Skip to content

Commit

Permalink
fix: setting default deployer definition (#5861)
Browse files Browse the repository at this point in the history
  • Loading branch information
gsquared94 authored May 19, 2021
1 parent c44d98a commit 7a2ba77
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/skaffold/schema/defaults/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func setDefaultKustomizePath(c *latestV1.SkaffoldConfig) {
}

func setDefaultKubectlManifests(c *latestV1.SkaffoldConfig) {
if c.Deploy.KubectlDeploy != nil && len(c.Deploy.KubectlDeploy.Manifests) == 0 {
if c.Deploy.KubectlDeploy != nil && len(c.Deploy.KubectlDeploy.Manifests) == 0 && len(c.Deploy.KubectlDeploy.RemoteManifests) == 0 {
c.Deploy.KubectlDeploy.Manifests = constants.DefaultKubectlManifests
}
}
Expand Down
69 changes: 69 additions & 0 deletions pkg/skaffold/schema/defaults/defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,75 @@ func TestSetDefaultPortForwardAddress(t *testing.T) {
testutil.CheckDeepEqual(t, constants.DefaultPortForwardAddress, cfg.PortForward[1].Address)
}

func TestSetDefaultDeployer(t *testing.T) {
tests := []struct {
description string
cfg *latestV1.SkaffoldConfig
expected latestV1.DeployConfig
}{
{
description: "no deployer definition",
cfg: &latestV1.SkaffoldConfig{},
expected: latestV1.DeployConfig{
DeployType: latestV1.DeployType{
KubectlDeploy: &latestV1.KubectlDeploy{Manifests: []string{"k8s/*.yaml"}},
},
},
},
{
description: "existing kubectl definition with local manifests",
cfg: &latestV1.SkaffoldConfig{
Pipeline: latestV1.Pipeline{
Deploy: latestV1.DeployConfig{DeployType: latestV1.DeployType{
KubectlDeploy: &latestV1.KubectlDeploy{Manifests: []string{"foo.yaml"}},
}},
},
},
expected: latestV1.DeployConfig{
DeployType: latestV1.DeployType{
KubectlDeploy: &latestV1.KubectlDeploy{Manifests: []string{"foo.yaml"}},
},
},
},
{
description: "existing kubectl definition with remote manifests",
cfg: &latestV1.SkaffoldConfig{
Pipeline: latestV1.Pipeline{
Deploy: latestV1.DeployConfig{DeployType: latestV1.DeployType{
KubectlDeploy: &latestV1.KubectlDeploy{RemoteManifests: []string{"foo:bar"}},
}},
},
},
expected: latestV1.DeployConfig{
DeployType: latestV1.DeployType{
KubectlDeploy: &latestV1.KubectlDeploy{RemoteManifests: []string{"foo:bar"}},
},
},
},
{
description: "existing helm definition",
cfg: &latestV1.SkaffoldConfig{
Pipeline: latestV1.Pipeline{
Deploy: latestV1.DeployConfig{DeployType: latestV1.DeployType{
HelmDeploy: &latestV1.HelmDeploy{Releases: []latestV1.HelmRelease{{ChartPath: "foo"}}},
}},
},
},
expected: latestV1.DeployConfig{
DeployType: latestV1.DeployType{
HelmDeploy: &latestV1.HelmDeploy{Releases: []latestV1.HelmRelease{{ChartPath: "foo"}}},
},
},
},
}
for _, test := range tests {
testutil.Run(t, test.description, func(t *testutil.T) {
SetDefaultDeployer(test.cfg)
t.CheckDeepEqual(test.expected, test.cfg.Deploy)
})
}
}

func TestSetLogsConfig(t *testing.T) {
tests := []struct {
description string
Expand Down

0 comments on commit 7a2ba77

Please sign in to comment.