Skip to content

Commit

Permalink
release: v1.2.0 (#39)
Browse files Browse the repository at this point in the history
* release: v1.2.0

* release: v1.2.0

* update mod

* remove codecov, don't over cloudinary limit
  • Loading branch information
hwbrzzl authored Jun 9, 2024
1 parent 792ebde commit 7fef5ed
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 230 deletions.
27 changes: 0 additions & 27 deletions .github/workflows/codecov.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
test:
strategy:
matrix:
go: [ '1.20' ]
go: [ '1.21' ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ A cloudinary driver for `facades.Storage()` of Goravel.

## Version

| goravel/cloudinary | cloudinary | goravel/framework |
|--------------------|------------|-------------------|
| v1.1.* | v2.4.0 | v1.13.* |
| goravel/cloudinary | goravel/framework |
|--------------------|-------------------|
| v1.2.* | v1.14.* |
| v1.1.* | v1.13.* |

## Install

Expand All @@ -29,6 +30,7 @@ import "github.com/goravel/cloudinary"
```

3. Add cloudinary disk to `config/filesystems.go` file

```go
// config/filesystems.go
...
Expand Down
11 changes: 10 additions & 1 deletion cloudinary.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,22 @@ func (r *Cloudinary) Files(path string) ([]string, error) {

// Get returns the contents of a file.
func (r *Cloudinary) Get(file string) (string, error) {
rawContent, err := GetRawContent(r.Url(file))
rawContent, err := r.GetBytes(file)
if err != nil {
return "", err
}
return string(rawContent), nil
}

// GetBytes returns the byte of a file.
func (r *Cloudinary) GetBytes(file string) ([]byte, error) {
rawContent, err := GetRawContent(r.Url(file))
if err != nil {
return nil, err
}
return rawContent, nil
}

// LastModified returns the last modified time of a file.
func (r *Cloudinary) LastModified(file string) (time.Time, error) {
resource, err := r.getAsset(file)
Expand Down
26 changes: 20 additions & 6 deletions cloudinary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"time"

"github.com/gookit/color"
configmocks "github.com/goravel/framework/contracts/config/mocks"
contractsfilesystem "github.com/goravel/framework/contracts/filesystem"
filesystemcontract "github.com/goravel/framework/contracts/filesystem"
configmock "github.com/goravel/framework/mocks/config"
"github.com/goravel/framework/support/carbon"
"github.com/stretchr/testify/assert"
)
Expand All @@ -27,12 +27,12 @@ func TestStorage(t *testing.T) {

assert.Nil(t, os.WriteFile("test.txt", []byte("Goravel"), 0644))

mockConfig := &configmocks.Config{}
mockConfig := &configmock.Config{}
mockConfig.On("GetString", "filesystems.disks.cloudinary.key").Return(os.Getenv("CLOUDINARY_ACCESS_KEY_ID"))
mockConfig.On("GetString", "filesystems.disks.cloudinary.secret").Return(os.Getenv("CLOUDINARY_ACCESS_KEY_SECRET"))
mockConfig.On("GetString", "filesystems.disks.cloudinary.cloud").Return(os.Getenv("CLOUDINARY_CLOUD"))

var driver contractsfilesystem.Driver
var driver filesystemcontract.Driver
randNum, err := rand.Int(rand.Reader, big.NewInt(1000))
rootFolder := randNum.String() + "/"
assert.Nil(t, err)
Expand Down Expand Up @@ -200,6 +200,20 @@ func TestStorage(t *testing.T) {
assert.Nil(t, driver.DeleteDirectory(rootFolder+"Get"))
},
},
{
name: "GetBytes",
setup: func() {
assert.Nil(t, driver.Put("GetBytes/1.txt", "Goravel"))
assert.True(t, driver.Exists("GetBytes/1.txt"))
data, err := driver.GetBytes("GetBytes/1.txt")
assert.Nil(t, err)
assert.Equal(t, []byte("Goravel"), data)
length, err := driver.Size("GetBytes/1.txt")
assert.Nil(t, err)
assert.Equal(t, int64(7), length)
assert.Nil(t, driver.DeleteDirectory("GetBytes"))
},
},
{
name: "LastModified",
setup: func() {
Expand All @@ -211,7 +225,7 @@ func TestStorage(t *testing.T) {

l, err := time.LoadLocation("UTC")
assert.Nil(t, err)
assert.Equal(t, carbon.Now().ToStdTime().In(l).Format("2006-01-02 15"), date.Format("2006-01-02 15"))
assert.Equal(t, carbon.Now().StdTime().In(l).Format("2006-01-02 15"), date.Format("2006-01-02 15"))
assert.Nil(t, driver.DeleteDirectory(rootFolder+"LastModified"))
},
},
Expand Down Expand Up @@ -383,7 +397,7 @@ type File struct {
path string
}

func (f *File) Disk(disk string) contractsfilesystem.File {
func (f *File) Disk(disk string) filesystemcontract.File {
return &File{}
}

Expand Down
45 changes: 9 additions & 36 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,56 +1,29 @@
module github.com/goravel/cloudinary

go 1.20
go 1.21

require (
github.com/cloudinary/cloudinary-go/v2 v2.7.0
github.com/gookit/color v1.5.4
github.com/goravel/framework v1.13.1
github.com/goravel/framework v1.14.0
github.com/stretchr/testify v1.9.0
golang.org/x/net v0.26.0
)

require (
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
github.com/containerd/continuity v0.3.0 // indirect
github.com/creasty/defaults v1.5.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/cli v20.10.22+incompatible // indirect
github.com/docker/docker v20.10.24+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-module/carbon/v2 v2.2.6 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/golang-module/carbon/v2 v2.3.12 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/schema v1.2.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/opencontainers/runc v1.1.5 // indirect
github.com/ory/dockertest/v3 v3.10.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
google.golang.org/grpc v1.58.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect
google.golang.org/grpc v1.64.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 7fef5ed

Please sign in to comment.