Skip to content

Commit

Permalink
Merge pull request #58 from shipwright-io/sascha-prevent-empty-docker…
Browse files Browse the repository at this point in the history
…file

Make sure Dockerfile is not set to empty string
  • Loading branch information
openshift-merge-robot authored Oct 18, 2021
2 parents c91c9b7 + 640e2ac commit be770b4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/shp/flags/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,7 @@ func SanitizeBuildSpec(b *buildv1alpha1.BuildSpec) {
if b.Timeout != nil && b.Timeout.Duration == 0 {
b.Timeout = nil
}
if b.Dockerfile != nil && *b.Dockerfile == "" {
b.Dockerfile = nil
}
}
6 changes: 6 additions & 0 deletions pkg/shp/flags/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ func TestSanitizeBuildSpec(t *testing.T) {
},
}

emptyString := ""

testCases := []struct {
name string
in buildv1alpha1.BuildSpec
Expand Down Expand Up @@ -161,6 +163,10 @@ func TestSanitizeBuildSpec(t *testing.T) {
Duration: time.Duration(0),
}},
out: buildv1alpha1.BuildSpec{Timeout: nil},
}, {
name: "should clean-up an empty Dockerfile",
in: buildv1alpha1.BuildSpec{Dockerfile: &emptyString},
out: buildv1alpha1.BuildSpec{Dockerfile: nil},
}}

for _, tt := range testCases {
Expand Down

0 comments on commit be770b4

Please sign in to comment.