Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions build.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ func (b *Builder) updateOCIConfigForOutput(sf *types.Stackerfile, s types.Storag
return err
}

// add user-defined annotations
for k, v := range l.Annotations {
annotations[k] = v
}

// compute the git version for the directory that the stacker file is
// in. we don't care if it's not a git directory, because in that case
// we'll fall back to putting the whole stacker file contents in the
Expand Down
2 changes: 1 addition & 1 deletion cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,5 @@ func TestCacheEntryChanged(t *testing.T) {
// This test works because the type information is included in the
// hashstructure hash above, so using a zero valued CacheEntry is
// enough to capture changes in types.
assert.Equal(uint64(0x99dd94c023d7ccc6), h)
assert.Equal(uint64(0x98ab47c70ff0b70), h)
}
13 changes: 13 additions & 0 deletions doc/stacker_yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,16 @@ In this particular case the parent folder of the current folder, let's call it
When `stacker build -f parent/folder1/stacker.yaml` is invoked, stacker would search
for the other two stacker.yaml files and build them first, before building
the stacker.yaml specified in the command line.

##### `annotations`

`annotations` is a user-specified key value map that will be included in the final OCI image.

annotations:
a.b.c.key: abc_val
p.q.r.key: pqr_val

While `config` section supports a similar `labels`, it is more pertitent to the
image runtime. On the other hand, `annotations` is intended to be
image-specific metadata aligned with the
[annotations in the image spec](https://github.com/opencontainers/image-spec/blob/main/annotations.md).
31 changes: 31 additions & 0 deletions test/annotations.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
load helpers

function setup() {
stacker_setup
}

function teardown() {
cleanup
}

@test "annotations work" {
cat > stacker.yaml <<EOF
thing:
from:
type: oci
url: $CENTOS_OCI
run: ls
annotations:
a.b.c.key: val
EOF
stacker build
[ "$status" -eq 0 ]
manifest=$(cat oci/index.json | jq -r .manifests[0].digest | cut -f2 -d:)
cat oci/blobs/sha256/$manifest | jq .
key=$(cat oci/blobs/sha256/$manifest | jq -r .annotations | cut -f1 -d:)
echo $key
val=$(cat oci/blobs/sha256/$manifest | jq -r .annotations | cut -f2 -d:)
echo $val
[[ "$key" == *"a.b.c.key"* ]]
[[ "$val" == *"val"* ]]
}
1 change: 1 addition & 0 deletions types/layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ type Layer struct {
BuildOnly bool `yaml:"build_only"`
Binds Binds `yaml:"binds"`
RuntimeUser string `yaml:"runtime_user"`
Annotations map[string]string `yaml:"annotations"`
}

func parseLayers(referenceDirectory string, lms yaml.MapSlice, requireHash bool) (map[string]Layer, error) {
Expand Down