Skip to content

Commit c10e4fc

Browse files
authored
Merge pull request #2724 from dgageot/fix-2683
Fix 'skaffold diagnose' for custom builder without dependencies
2 parents 5cdff57 + a36142a commit c10e4fc

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

integration/diagnose_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ func TestDiagnose(t *testing.T) {
3333
tests := []struct {
3434
name string
3535
dir string
36-
args []string
3736
}{
3837
{name: "kaniko builder", dir: "examples/kaniko"},
3938
{name: "docker builder", dir: "examples/nodejs"},
4039
{name: "jib maven builder", dir: "testdata/jib"},
40+
{name: "jib gradle builder", dir: "testdata/jib-gradle"},
4141
{name: "bazel builder", dir: "examples/bazel"},
42-
// todo add test cases for "jib gradle builder" and "custom builder"
42+
{name: "custom builder", dir: "testdata/custom"},
4343
}
4444
for _, test := range tests {
4545
t.Run(test.name, func(t *testing.T) {
46-
skaffold.Diagnose(test.args...).InDir(test.dir).RunOrFailOutput(t)
46+
skaffold.Diagnose().InDir(test.dir).RunOrFailOutput(t)
4747
})
4848
}
4949
}

pkg/skaffold/schema/defaults/defaults.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package defaults
1919
import (
2020
"fmt"
2121

22-
"github.com/mitchellh/go-homedir"
22+
homedir "github.com/mitchellh/go-homedir"
2323
"github.com/pkg/errors"
2424
"github.com/sirupsen/logrus"
2525

@@ -68,6 +68,7 @@ func Set(c *latest.SkaffoldConfig) error {
6868
setDefaultWorkspace(a)
6969
defaultToDockerArtifact(a)
7070
setDefaultDockerfile(a)
71+
setDefaultCustomDependencies(a)
7172
}
7273

7374
for _, pf := range c.PortForward {
@@ -154,6 +155,14 @@ func setDefaultDockerfile(a *latest.Artifact) {
154155
}
155156
}
156157

158+
func setDefaultCustomDependencies(a *latest.Artifact) {
159+
if a.CustomArtifact != nil {
160+
if a.CustomArtifact.Dependencies == nil {
161+
a.CustomArtifact.Dependencies = &latest.CustomDependencies{}
162+
}
163+
}
164+
}
165+
157166
// SetDefaultDockerArtifact sets defaults on docker artifacts
158167
func SetDefaultDockerArtifact(a *latest.DockerArtifact) {
159168
a.DockerfilePath = valueOrDefault(a.DockerfilePath, constants.DefaultDockerfilePath)

pkg/skaffold/schema/defaults/defaults_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ func TestSetDefaults(t *testing.T) {
4242
},
4343
},
4444
},
45+
{
46+
ImageName: "third",
47+
ArtifactType: latest.ArtifactType{
48+
CustomArtifact: &latest.CustomArtifact{},
49+
},
50+
},
4551
},
4652
},
4753
},
@@ -58,6 +64,10 @@ func TestSetDefaults(t *testing.T) {
5864
testutil.CheckDeepEqual(t, "second", cfg.Build.Artifacts[1].ImageName)
5965
testutil.CheckDeepEqual(t, "folder", cfg.Build.Artifacts[1].Workspace)
6066
testutil.CheckDeepEqual(t, "Dockerfile.second", cfg.Build.Artifacts[1].DockerArtifact.DockerfilePath)
67+
68+
testutil.CheckDeepEqual(t, "third", cfg.Build.Artifacts[2].ImageName)
69+
testutil.CheckDeepEqual(t, []string(nil), cfg.Build.Artifacts[2].CustomArtifact.Dependencies.Paths)
70+
testutil.CheckDeepEqual(t, []string(nil), cfg.Build.Artifacts[2].CustomArtifact.Dependencies.Ignore)
6171
}
6272

6373
func TestSetDefaultsOnCluster(t *testing.T) {

0 commit comments

Comments
 (0)