Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: setting default deployer definition #5861

Merged
merged 1 commit into from
May 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: setting default deployer definition
gsquared94 committed May 18, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit fc0e9d442f9b64cc875995bbea54f4446f4d9dee
2 changes: 1 addition & 1 deletion pkg/skaffold/schema/defaults/defaults.go
Original file line number Diff line number Diff line change
@@ -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
}
}
69 changes: 69 additions & 0 deletions pkg/skaffold/schema/defaults/defaults_test.go
Original file line number Diff line number Diff line change
@@ -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