Skip to content

Commit

Permalink
Add public image labels (#2425)
Browse files Browse the repository at this point in the history
  • Loading branch information
KarnVadaliya authored Jan 9, 2025
1 parent fa94ed0 commit d2adb0b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cli_tools/gce_image_publish/publish/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ type Image struct {
ShieldedInstanceInitialState *computeAlpha.InitialStateConfig `json:",omitempty"`
// RolloutPolicy entry for the image rollout policy.
RolloutPolicy *computeAlpha.RolloutPolicy `json:",omitempty"`
// Optional labels to add to the image.
Labels map[string]string `json:",omitempty"`
}

var (
Expand Down Expand Up @@ -298,6 +300,7 @@ func publishImage(p *Publish, img *Image, pubImgs []*computeAlpha.Image, skipDup
Deprecated: ds,
ShieldedInstanceInitialState: img.ShieldedInstanceInitialState,
RolloutOverride: img.RolloutPolicy,
Labels: img.Labels,
},
ImageBase: daisy.ImageBase{
Resource: daisy.Resource{
Expand Down
4 changes: 3 additions & 1 deletion cli_tools/gce_image_publish/publish/publish_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func TestPublishImage(t *testing.T) {
RolloutPolicy: &computeAlpha.RolloutPolicy{
DefaultRolloutTime: now.Format(time.RFC3339),
},
Labels: map[string]string{"foo": "bar"},
},
pubImgs: []*computeAlpha.Image{
{Name: "bar-2", Family: "bar-family"},
Expand Down Expand Up @@ -106,6 +107,7 @@ func TestPublishImage(t *testing.T) {
State: "ACTIVE",
Obsolete: now.Format(time.RFC3339),
},
Labels: map[string]string{"foo": "bar"},
},
GuestOsFeatures: []string{"foo-feature", "bar-feature"},
},
Expand Down Expand Up @@ -766,7 +768,7 @@ func TestCreatePublishWithFile(t *testing.T) {
wantErr bool
}{
{"no valid path", "", true},
{"pass with valid path", "../../../daisy_workflows/build-publish/debian/debian_10.publish.json", false},
{"pass with valid path", "../../../daisy_workflows/build-publish/debian/debian_11.publish.json", false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit d2adb0b

Please sign in to comment.