Skip to content

Commit be770b4

Browse files
Merge pull request shipwright-io#58 from shipwright-io/sascha-prevent-empty-dockerfile
Make sure Dockerfile is not set to empty string
2 parents c91c9b7 + 640e2ac commit be770b4

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

pkg/shp/flags/build.go

+3
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,7 @@ func SanitizeBuildSpec(b *buildv1alpha1.BuildSpec) {
6565
if b.Timeout != nil && b.Timeout.Duration == 0 {
6666
b.Timeout = nil
6767
}
68+
if b.Dockerfile != nil && *b.Dockerfile == "" {
69+
b.Dockerfile = nil
70+
}
6871
}

pkg/shp/flags/build_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ func TestSanitizeBuildSpec(t *testing.T) {
127127
},
128128
}
129129

130+
emptyString := ""
131+
130132
testCases := []struct {
131133
name string
132134
in buildv1alpha1.BuildSpec
@@ -161,6 +163,10 @@ func TestSanitizeBuildSpec(t *testing.T) {
161163
Duration: time.Duration(0),
162164
}},
163165
out: buildv1alpha1.BuildSpec{Timeout: nil},
166+
}, {
167+
name: "should clean-up an empty Dockerfile",
168+
in: buildv1alpha1.BuildSpec{Dockerfile: &emptyString},
169+
out: buildv1alpha1.BuildSpec{Dockerfile: nil},
164170
}}
165171

166172
for _, tt := range testCases {

0 commit comments

Comments
 (0)