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

Commit

Permalink
fixes #658 (#659)
Browse files Browse the repository at this point in the history
enable Unmarshalling of "Images" in duffle.json
  • Loading branch information
Swapnil Bawaskar authored and radu-matei committed Mar 14, 2019
1 parent 178fe2d commit adcaa3a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ type ImagePlatform struct {

// Image describes a container image in the bundle
type Image struct {
BaseImage
BaseImage `mapstructure:",squash"`
Description string `json:"description" mapstructure:"description"` //TODO: change? see where it's being used? change to description?
Refs []LocationRef `json:"refs" mapstructure:"refs"`
}

// InvocationImage contains the image type and location for the installation of a bundle
type InvocationImage struct {
BaseImage
BaseImage `mapstructure:",squash"`
}

// Location provides the location where a value should be written in
Expand Down
9 changes: 9 additions & 0 deletions pkg/duffle/manifest/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ func TestLoad(t *testing.T) {
t.Errorf("expected a component named cnab but got %v", m.InvocationImages)
}

if len(m.Images) != 1 {
t.Errorf("exp 1 but was \"%v\"", len(m.Images))
}

img := m.Images["istio"]
if !strings.EqualFold(img.ImageType, "docker") {
t.Errorf("exp docker but was \"%v\"", img.ImageType)
}

if len(m.Parameters) != 1 {
t.Fatalf("expected 1 parameter but got %d", len(m.Parameters))
}
Expand Down
8 changes: 8 additions & 0 deletions pkg/duffle/manifest/testdata/duffle.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
}
}
},
"images": {
"istio": {
"description": "istio images",
"imageType": "docker",
"image": "docker.io/istio/citadel:1.0.2",
"digest": "sha256:ca4050c9fed3a2ddcaef32140686613c4110ed728f53262d0a23a7e17da73111"
}
},
"parameters": {
"foo": {
"type": "string"
Expand Down
6 changes: 6 additions & 0 deletions pkg/duffle/manifest/testdata/duffle.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ name = "testbundle"
name = "cnab"
builder = "docker"
configuration = { registry = "microsoft" }
[images]
[images.istio]
description = "istio images"
imageType = "docker"
image = "docker.io/istio/citadel:1.0.2"
digest = "sha256:ca4050c9fed3a2ddcaef32140686613c4110ed728f53262d0a23a7e17da73111"
[parameters.foo]
type = "string"

Expand Down
6 changes: 6 additions & 0 deletions pkg/duffle/manifest/testdata/duffle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ invocationImages:
builder: docker
configuration:
registry: microsoft
images:
istio:
description: "istio images"
imageType: "docker"
image: "docker.io/istio/citadel:1.0.2"
digest: "sha256:ca4050c9fed3a2ddcaef32140686613c4110ed728f53262d0a23a7e17da73111"
parameters:
foo:
type: string
Expand Down

0 comments on commit adcaa3a

Please sign in to comment.