Skip to content

Commit

Permalink
Merge pull request #1386 from dgageot/fix-1370
Browse files Browse the repository at this point in the history
Don’t panic if image field is not of type string
  • Loading branch information
r2d4 authored Dec 12, 2018
2 parents dd8ffa4 + a902e9d commit 5ad5717
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/skaffold/deploy/kubectl/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ func (r *imageReplacer) Matches(key string) bool {
}

func (r *imageReplacer) NewValue(old interface{}) (bool, interface{}) {
image := old.(string)
image, ok := old.(string)
if !ok {
return false, nil
}

found, tag := r.parseAndReplace(image)
if !found {
subbedImage := r.substituteRepoIntoImage(image)
Expand Down
13 changes: 13 additions & 0 deletions pkg/skaffold/deploy/kubectl/images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,16 @@ func TestReplaceInvalidManifest(t *testing.T) {

testutil.CheckError(t, true, err)
}

func TestReplaceNonStringImageField(t *testing.T) {
manifests := ManifestList{[]byte(`
apiVersion: v1
image:
- value1
- value2
`)}

output, err := manifests.ReplaceImages(nil, "")

testutil.CheckErrorAndDeepEqual(t, false, err, manifests.String(), output.String())
}

0 comments on commit 5ad5717

Please sign in to comment.