Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

fix schemaVersion and Version export #790

Merged
merged 1 commit into from Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/duffle/create_test.go
Expand Up @@ -45,7 +45,7 @@ func TestCreateCmd(t *testing.T) {
}

// This is the Canonical JSON representation. http://wiki.laptop.org/go/Canonical_JSON
expected := `{"description":"A short description of your bundle","invocationImages":{"cnab":{"builder":"docker","configuration":{"registry":"deislabs"},"name":"cnab"}},"keywords":["test-bundle","cnab","tutorial"],"maintainers":[{"email":"john.doe@example.com","name":"John Doe","url":"https://example.com"},{"email":"jane.doe@example.com","name":"Jane Doe","url":"https://example.com"}],"name":"test-bundle","version":"0.1.0"}`
expected := `{"description":"A short description of your bundle","invocationImages":{"cnab":{"builder":"docker","configuration":{"registry":"deislabs"},"name":"cnab"}},"keywords":["test-bundle","cnab","tutorial"],"maintainers":[{"email":"john.doe@example.com","name":"John Doe","url":"https://example.com"},{"email":"jane.doe@example.com","name":"Jane Doe","url":"https://example.com"}],"name":"test-bundle","schemaVersion":"v1.0.0-WD","version":"0.1.0"}`

if string(mbytes) != expected {
t.Errorf("Expected duffle.json output to look like this:\n\n%s\n\nGot:\n\n%s", expected, string(mbytes))
Expand Down
18 changes: 10 additions & 8 deletions pkg/builder/builder.go
Expand Up @@ -67,14 +67,16 @@ func (b *Builder) PrepareBuild(bldr *Builder, mfst *manifest.Manifest, appDir st
}

bf := &bundle.Bundle{
Name: ctx.Manifest.Name,
Description: ctx.Manifest.Description,
Images: ctx.Manifest.Images,
Keywords: ctx.Manifest.Keywords,
Maintainers: ctx.Manifest.Maintainers,
Actions: ctx.Manifest.Actions,
Parameters: ctx.Manifest.Parameters,
Credentials: ctx.Manifest.Credentials,
Name: ctx.Manifest.Name,
Description: ctx.Manifest.Description,
Images: ctx.Manifest.Images,
Keywords: ctx.Manifest.Keywords,
Maintainers: ctx.Manifest.Maintainers,
Actions: ctx.Manifest.Actions,
Parameters: ctx.Manifest.Parameters,
Credentials: ctx.Manifest.Credentials,
Version: ctx.Manifest.Version,
SchemaVersion: ctx.Manifest.SchemaVersion,
}

for _, imb := range imageBuilders {
Expand Down
15 changes: 11 additions & 4 deletions pkg/builder/builder_test.go
Expand Up @@ -52,10 +52,11 @@ func (tc testImage) Build(ctx context.Context, log io.WriteCloser) error {

func TestPrepareBuild(t *testing.T) {
mfst := &manifest.Manifest{
Name: "foo",
Version: "0.1.0",
Description: "description",
Keywords: []string{"test"},
Name: "foo",
Version: "0.1.0",
SchemaVersion: "v1.0.0",
Description: "description",
Keywords: []string{"test"},
InvocationImages: map[string]*manifest.InvocationImage{
"cnab": {
Name: "cnab",
Expand Down Expand Up @@ -90,6 +91,12 @@ func TestPrepareBuild(t *testing.T) {
t.Fatalf("expected there to be 1 image, got %d. Full output: %v", len(b.Images), b)
}

if b.Version != mfst.Version {
t.Errorf("expected version %v, got %v", mfst.Version, b.Version)
}
if b.SchemaVersion != mfst.SchemaVersion {
t.Errorf("expected schemaVersion %v, got %v", mfst.SchemaVersion, b.SchemaVersion)
}
expected := bundle.InvocationImage{}
expected.Image = "cnab:0.1.0"
expected.ImageType = "docker"
Expand Down
11 changes: 7 additions & 4 deletions pkg/duffle/manifest/create.go
Expand Up @@ -31,15 +31,18 @@ COPY app /cnab/app
CMD ["/cnab/app/run"]
`

const schemaVersion = "v1.0.0-WD"

// Scaffold takes a path and creates a minimal duffle manifest (duffle.json)
// and scaffolds the components in that manifest
func Scaffold(path string) error {
name := filepath.Base(path)
m := &Manifest{
Name: name,
Version: "0.1.0",
Description: "A short description of your bundle",
Keywords: []string{name, "cnab", "tutorial"},
Name: name,
Version: "0.1.0",
SchemaVersion: schemaVersion,
Description: "A short description of your bundle",
Keywords: []string{name, "cnab", "tutorial"},
Maintainers: []bundle.Maintainer{
{
Name: "John Doe",
Expand Down
1 change: 1 addition & 0 deletions pkg/duffle/manifest/manifest.go
Expand Up @@ -14,6 +14,7 @@ import (
type Manifest struct {
Name string `json:"name" mapstructure:"name"`
Version string `json:"version" mapstructure:"version"`
SchemaVersion string `json:"schemaVersion" mapstructure:"schemaVersion"`
Description string `json:"description,omitempty" mapstructure:"description"`
Keywords []string `json:"keywords,omitempty" mapstructure:"keywords"`
Maintainers []bundle.Maintainer `json:"maintainers,omitempty" mapstructure:"maintainers"`
Expand Down