diff --git a/Gopkg.lock b/Gopkg.lock index bb951427..5503f336 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -200,12 +200,13 @@ version = "v1.1.1" [[projects]] - digest = "1:e6b1ef832f13f503f6496d923b9f918d5475b004424ca589558afae541dc0a17" + digest = "1:e86556f6f91e6c175ac44965165c1edbf75a978dd85442cef7415059f86a4bc3" name = "github.com/deislabs/cnab-go" packages = [ "action", "bundle", "bundle/definition", + "bundle/loader", "claim", "credentials", "driver", @@ -215,8 +216,8 @@ "utils/crud", ] pruneopts = "NUT" - revision = "c992a169ba13fb2f36857dbddfb45e6790400758" - version = "v0.3.0-beta1" + revision = "1ef7d96a46de6e4205de8eedd80e3cf387fef72b" + version = "v0.3.1-beta1" [[projects]] digest = "1:7a6852b35eb5bbc184561443762d225116ae630c26a7c4d90546619f1e7d2ad2" @@ -1244,6 +1245,7 @@ "github.com/deislabs/cnab-go/action", "github.com/deislabs/cnab-go/bundle", "github.com/deislabs/cnab-go/bundle/definition", + "github.com/deislabs/cnab-go/bundle/loader", "github.com/deislabs/cnab-go/claim", "github.com/deislabs/cnab-go/credentials", "github.com/deislabs/cnab-go/driver", diff --git a/Gopkg.toml b/Gopkg.toml index 3e077884..44597cfa 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -57,7 +57,7 @@ [[constraint]] name = "github.com/deislabs/cnab-go" - version = "v0.3.0-beta1" + version = "v0.3.1-beta1" [[override]] name = "github.com/google/go-containerregistry" diff --git a/cmd/duffle/export.go b/cmd/duffle/export.go index 6e677253..6c9a9ec5 100644 --- a/cmd/duffle/export.go +++ b/cmd/duffle/export.go @@ -4,12 +4,12 @@ import ( "fmt" "io" + "github.com/deislabs/cnab-go/bundle/loader" + "github.com/spf13/cobra" + "github.com/deislabs/duffle/pkg/duffle/home" "github.com/deislabs/duffle/pkg/imagestore/construction" - "github.com/deislabs/duffle/pkg/loader" "github.com/deislabs/duffle/pkg/packager" - - "github.com/spf13/cobra" ) const exportDesc = ` diff --git a/cmd/duffle/import.go b/cmd/duffle/import.go index d50060aa..dc7f8f78 100644 --- a/cmd/duffle/import.go +++ b/cmd/duffle/import.go @@ -5,10 +5,10 @@ import ( "io" "path/filepath" + "github.com/deislabs/cnab-go/bundle/loader" "github.com/spf13/cobra" "github.com/deislabs/duffle/pkg/duffle/home" - "github.com/deislabs/duffle/pkg/loader" "github.com/deislabs/duffle/pkg/packager" ) diff --git a/cmd/duffle/main.go b/cmd/duffle/main.go index 6f4a1344..1e12cd81 100644 --- a/cmd/duffle/main.go +++ b/cmd/duffle/main.go @@ -9,17 +9,17 @@ import ( "runtime" "strings" - duffleDriver "github.com/deislabs/duffle/pkg/driver" - "github.com/deislabs/duffle/pkg/duffle/home" - "github.com/deislabs/duffle/pkg/loader" - "github.com/deislabs/duffle/pkg/reference" - "github.com/deislabs/cnab-go/bundle" + "github.com/deislabs/cnab-go/bundle/loader" "github.com/deislabs/cnab-go/claim" "github.com/deislabs/cnab-go/credentials" "github.com/deislabs/cnab-go/driver" "github.com/deislabs/cnab-go/utils/crud" "github.com/spf13/cobra" + + duffleDriver "github.com/deislabs/duffle/pkg/driver" + "github.com/deislabs/duffle/pkg/duffle/home" + "github.com/deislabs/duffle/pkg/reference" ) var ( diff --git a/cmd/duffle/relocate.go b/cmd/duffle/relocate.go index b4dcea42..efc93ba4 100644 --- a/cmd/duffle/relocate.go +++ b/cmd/duffle/relocate.go @@ -10,21 +10,18 @@ import ( "strconv" "strings" - "github.com/deislabs/duffle/pkg/imagestore" - "github.com/deislabs/duffle/pkg/imagestore/construction" - "github.com/deislabs/duffle/pkg/loader" - "github.com/deislabs/duffle/pkg/packager" - "github.com/deislabs/duffle/pkg/relocator" - + "github.com/deislabs/cnab-go/bundle" + "github.com/deislabs/cnab-go/bundle/loader" "github.com/pivotal/image-relocation/pkg/image" "github.com/pivotal/image-relocation/pkg/pathmapping" - - "github.com/deislabs/cnab-go/bundle" - - "github.com/deislabs/duffle/pkg/duffle/home" - "github.com/spf13/cobra" "k8s.io/apimachinery/pkg/util/validation" + + "github.com/deislabs/duffle/pkg/duffle/home" + "github.com/deislabs/duffle/pkg/imagestore" + "github.com/deislabs/duffle/pkg/imagestore/construction" + "github.com/deislabs/duffle/pkg/packager" + "github.com/deislabs/duffle/pkg/relocator" ) const ( diff --git a/pkg/loader/loader_test.go b/pkg/loader/loader_test.go deleted file mode 100644 index 0a3225f9..00000000 --- a/pkg/loader/loader_test.go +++ /dev/null @@ -1,50 +0,0 @@ -package loader - -import ( - "bytes" - "io" - "io/ioutil" - "net/http" - "net/http/httptest" - "path/filepath" - "testing" - - "github.com/stretchr/testify/assert" -) - -var testFooJSON = filepath.Join("..", "..", "tests", "testdata", "bundles", "foo.json") - -func TestLoader(t *testing.T) { - is := assert.New(t) - - l := NewLoader() - bundle, err := l.Load(testFooJSON) - if err != nil { - t.Fatalf("cannot load bundle: %v", err) - } - - is.Equal("foo", bundle.Name) - is.Equal("1.0", bundle.Version) -} -func TestLoader_Remote(t *testing.T) { - - data, err := ioutil.ReadFile(testFooJSON) - if err != nil { - t.Fatalf("cannot read bundle file: %v", err) - } - - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - io.Copy(w, bytes.NewBuffer(data)) - })) - defer ts.Close() - - l := NewLoader() - bundle, err := l.Load(ts.URL) - if err != nil { - t.Fatal(err) - } - is := assert.New(t) - - is.Equal("foo", bundle.Name) - is.Equal("1.0", bundle.Version) -} diff --git a/pkg/packager/export.go b/pkg/packager/export.go index dc818aaf..66a19d60 100644 --- a/pkg/packager/export.go +++ b/pkg/packager/export.go @@ -8,12 +8,11 @@ import ( "path/filepath" "time" - "github.com/deislabs/duffle/pkg/imagestore" - "github.com/deislabs/cnab-go/bundle" + "github.com/deislabs/cnab-go/bundle/loader" "github.com/docker/docker/pkg/archive" - "github.com/deislabs/duffle/pkg/loader" + "github.com/deislabs/duffle/pkg/imagestore" ) type Exporter struct { diff --git a/pkg/packager/export_test.go b/pkg/packager/export_test.go index bd8f58bf..e242dd35 100644 --- a/pkg/packager/export_test.go +++ b/pkg/packager/export_test.go @@ -9,10 +9,10 @@ import ( "strings" "testing" + "github.com/deislabs/cnab-go/bundle/loader" + "github.com/deislabs/duffle/pkg/imagestore" "github.com/deislabs/duffle/pkg/imagestore/imagestoremocks" - - "github.com/deislabs/duffle/pkg/loader" ) func TestExport(t *testing.T) { diff --git a/pkg/packager/import.go b/pkg/packager/import.go index 05707b5c..624a8313 100644 --- a/pkg/packager/import.go +++ b/pkg/packager/import.go @@ -8,10 +8,8 @@ import ( "strings" "github.com/deislabs/cnab-go/bundle" - + "github.com/deislabs/cnab-go/bundle/loader" "github.com/docker/docker/pkg/archive" - - "github.com/deislabs/duffle/pkg/loader" ) var ( diff --git a/pkg/packager/import_test.go b/pkg/packager/import_test.go index 445584f5..3fd13b4e 100644 --- a/pkg/packager/import_test.go +++ b/pkg/packager/import_test.go @@ -6,9 +6,8 @@ import ( "path/filepath" "testing" + "github.com/deislabs/cnab-go/bundle/loader" "github.com/stretchr/testify/assert" - - "github.com/deislabs/duffle/pkg/loader" ) func TestImport(t *testing.T) { diff --git a/vendor/github.com/deislabs/cnab-go/bundle/bundle.go b/vendor/github.com/deislabs/cnab-go/bundle/bundle.go index 3c2568a7..efcf7bbc 100644 --- a/vendor/github.com/deislabs/cnab-go/bundle/bundle.go +++ b/vendor/github.com/deislabs/cnab-go/bundle/bundle.go @@ -81,7 +81,7 @@ type LocationRef struct { type BaseImage struct { ImageType string `json:"imageType" yaml:"imageType"` Image string `json:"image" yaml:"image"` - Digest string `json:"contentDigest,omitempty" yaml:"contentDigest"` + Digest string `json:"contentDigest,omitempty" yaml:"contentDigest,omitempty"` Size uint64 `json:"size,omitempty" yaml:"size,omitempty"` Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` MediaType string `json:"mediaType,omitempty" yaml:"mediaType,omitempty"` diff --git a/pkg/loader/loader.go b/vendor/github.com/deislabs/cnab-go/bundle/loader/loader.go similarity index 97% rename from pkg/loader/loader.go rename to vendor/github.com/deislabs/cnab-go/bundle/loader/loader.go index 3d07ec24..058b6235 100644 --- a/pkg/loader/loader.go +++ b/vendor/github.com/deislabs/cnab-go/bundle/loader/loader.go @@ -10,7 +10,7 @@ import ( "github.com/deislabs/cnab-go/bundle" ) -// Loader provides an interface for loading a bundle +// BundleLoader provides an interface for loading a bundle type BundleLoader interface { // Load a bundle from a local file Load(source string) (*bundle.Bundle, error)