Skip to content

Commit

Permalink
Drop error return for mutate.Annotations (#1058)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjohnsonjr committed Jun 22, 2021
1 parent 92e9e85 commit acad0ed
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
6 changes: 1 addition & 5 deletions cmd/crane/cmd/mutate.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,7 @@ func NewCmdMutate(options *[]crane.Option) *cobra.Command {
log.Fatalf("mutating config: %v", err)
}

// Mutate and write image.
img, err = mutate.Annotations(img, annotations)
if err != nil {
log.Fatalf("mutating annotations: %v", err)
}
img = mutate.Annotations(img, annotations)

// If the new ref isn't provided, write over the original image.
// If that ref was provided by digest (e.g., output from
Expand Down
6 changes: 2 additions & 4 deletions pkg/v1/mutate/mutate.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,11 @@ func Config(base v1.Image, cfg v1.Config) (v1.Image, error) {
}

// Annotations mutates the provided v1.Image to have the provided annotations
func Annotations(base v1.Image, annotations map[string]string) (v1.Image, error) {
image := &image{
func Annotations(base v1.Image, annotations map[string]string) v1.Image {
return &image{
base: base,
annotations: annotations,
}

return image, nil
}

// ConfigFile mutates the provided v1.Image to have the provided v1.ConfigFile
Expand Down
5 changes: 1 addition & 4 deletions pkg/v1/mutate/mutate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,7 @@ func TestAnnotations(t *testing.T) {
"im.the.first.annotation": "hello world",
}

result, err := mutate.Annotations(source, newAnnotations)
if err != nil {
t.Fatalf("failed to mutate annotations: %v", err)
}
result := mutate.Annotations(source, newAnnotations)

if configDigestsAreEqual(t, source, result) {
t.Errorf("mutating the manifest annotations MUST mutate the config digest")
Expand Down

0 comments on commit acad0ed

Please sign in to comment.