adding some support for annotations at the manifest level

Signed-off-by: Mike Brown <brownwm@us.ibm.com>
This commit is contained in:
Mike Brown 2017-07-31 18:34:11 -05:00
parent ec2aa05cdf
commit f186e1da1c
3 changed files with 28 additions and 10 deletions

View file

@ -10,7 +10,6 @@ import (
"github.com/opencontainers/image-spec/specs-go/v1"
)
// TODO (mikebrow): add annotations to the test
var expectedManifestSerialization = []byte(`{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.manifest.v1+json",
@ -31,7 +30,10 @@ var expectedManifestSerialization = []byte(`{
"lettuce": "wrap"
}
}
]
],
"annotations": {
"hot": "potato"
}
}`)
func TestManifest(t *testing.T) {
@ -51,6 +53,7 @@ func TestManifest(t *testing.T) {
Annotations: map[string]string{"lettuce": "wrap"},
},
},
Annotations: map[string]string{"hot": "potato"},
}
deserialized, err := FromStruct(manifest)
@ -87,6 +90,9 @@ func TestManifest(t *testing.T) {
if !reflect.DeepEqual(&unmarshalled, deserialized) {
t.Fatalf("manifests are different after unmarshaling: %v != %v", unmarshalled, *deserialized)
}
if deserialized.Annotations["hot"] != "potato" {
t.Fatalf("unexpected annotation in manifest: %s", deserialized.Annotations["hot"])
}
target := deserialized.Target()
if target.Digest != "sha256:1a9ec845ee94c202b2d5da74a24f0ed2058318bfa9879fa541efaecba272e86b" {