Skip to content

Commit cdb9d3c

Browse files
authored
Merge pull request #321 from rwaight/fix/issue-297-image-deprecation-status
fix: set image deprecation state to active when deprecation setting is valid
2 parents 39a9b67 + ee3ce86 commit cdb9d3c

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

builder/googlecompute/step_create_image.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ func (s *StepCreateImage) getDeprecationStatus(config *Config) (*compute.Depreca
126126
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("deprecate_at must be a future time"))
127127
} else {
128128
deprecation.Deprecated = config.DeprecateAt
129+
deprecation.State = "ACTIVE"
129130
}
130131
}
131132

@@ -137,6 +138,7 @@ func (s *StepCreateImage) getDeprecationStatus(config *Config) (*compute.Depreca
137138
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("obsolete_at must be a future time"))
138139
} else {
139140
deprecation.Obsolete = config.ObsoleteAt
141+
deprecation.State = "ACTIVE"
140142
}
141143

142144
}
@@ -149,6 +151,7 @@ func (s *StepCreateImage) getDeprecationStatus(config *Config) (*compute.Depreca
149151
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("delete_at must be a future time"))
150152
} else {
151153
deprecation.Deleted = config.DeleteAt
154+
deprecation.State = "ACTIVE"
152155
}
153156
}
154157

builder/googlecompute/step_create_image_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,5 @@ func TestStepCreateImage_setsDeprecationFields(t *testing.T) {
9090
assert.Equal(t, c.DeprecateAt, d.DeprecatedImageStatus.Deprecated, "DeprecateAt mismatch")
9191
assert.Equal(t, c.ObsoleteAt, d.DeprecatedImageStatus.Obsolete, "ObsoleteAt mismatch")
9292
assert.Equal(t, c.DeleteAt, d.DeprecatedImageStatus.Deleted, "DeleteAt mismatch")
93-
assert.Equal(t, "DEPRECATED", d.DeprecatedImageStatus.State, "State should be DEPRECATED")
93+
assert.Contains(t, []string{"DEPRECATED", "ACTIVE"}, d.DeprecatedImageStatus.State, "State should be DEPRECATED or ACTIVE")
9494
}

0 commit comments

Comments
 (0)