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 skaffold debug for helm charts with skaffold config file other than default skaffold.yaml #5138

Merged
merged 1 commit into from
Dec 11, 2020
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions pkg/skaffold/deploy/helm/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ type Deployer struct {
kubeContext string
kubeConfig string
namespace string
configFile string

// packaging temporary directory, used for predictable test output
pkgTmpDir string
Expand Down Expand Up @@ -106,6 +107,7 @@ func NewDeployer(cfg kubectl.Config, labels map[string]string) (*Deployer, error
kubeConfig: cfg.GetKubeConfig(),
namespace: cfg.GetKubeNamespace(),
forceDeploy: cfg.ForceDeploy(),
configFile: cfg.ConfigurationFile(),
labels: labels,
bV: hv,
enableDebug: cfg.Mode() == config.RunModes.Debug,
Expand Down Expand Up @@ -346,6 +348,7 @@ func (h *Deployer) deployRelease(ctx context.Context, out io.Writer, r latest.He
// need to include current environment, specifically for HOME to lookup ~/.kube/config
env := util.EnvSliceToMap(util.OSEnviron(), "=")
env["SKAFFOLD_CMDLINE"] = shell.Join(cmdLine...)
env["SKAFFOLD_FILENAME"] = h.configFile
installEnv = util.EnvMapToSlice(env, "=")
}

Expand Down
20 changes: 12 additions & 8 deletions pkg/skaffold/deploy/helm/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,8 @@ func TestHelmDeploy(t *testing.T) {
CmdRunWithOutput("helm version --client", version31).
AndRun("helm --kube-context kubecontext get all skaffold-helm --kubeconfig kubeconfig").
AndRun("helm --kube-context kubecontext dep build examples/test --kubeconfig kubeconfig").
AndRun("helm --kube-context kubecontext upgrade skaffold-helm --post-renderer SKAFFOLD-BINARY examples/test -f skaffold-overrides.yaml --set-string image=docker.io:5000/skaffold-helm:3605e7bc17cf46e53f4d81c4cbc24e5b4c495184 --set some.key=somevalue --kubeconfig kubeconfig").
AndRunEnv("helm --kube-context kubecontext upgrade skaffold-helm --post-renderer SKAFFOLD-BINARY examples/test -f skaffold-overrides.yaml --set-string image=docker.io:5000/skaffold-helm:3605e7bc17cf46e53f4d81c4cbc24e5b4c495184 --set some.key=somevalue --kubeconfig kubeconfig",
[]string{"SKAFFOLD_FILENAME=test.yaml"}).
AndRun("helm --kube-context kubecontext get all skaffold-helm --kubeconfig kubeconfig"),
helm: testDeployConfig,
builds: testBuilds,
Expand Down Expand Up @@ -938,9 +939,10 @@ func TestHelmDeploy(t *testing.T) {
t.Override(&osExecutable, func() (string, error) { return "SKAFFOLD-BINARY", nil })

deployer, err := NewDeployer(&helmConfig{
helm: test.helm,
namespace: test.namespace,
force: test.force,
helm: test.helm,
namespace: test.namespace,
force: test.force,
configFile: "test.yaml",
}, nil)
t.RequireNoError(err)

Expand Down Expand Up @@ -1413,12 +1415,14 @@ type helmConfig struct {
namespace string
force bool
helm latest.HelmDeploy
configFile string
}

func (c *helmConfig) ForceDeploy() bool { return c.force }
func (c *helmConfig) GetKubeConfig() string { return kubectl.TestKubeConfig }
func (c *helmConfig) GetKubeContext() string { return kubectl.TestKubeContext }
func (c *helmConfig) GetKubeNamespace() string { return c.namespace }
func (c *helmConfig) ForceDeploy() bool { return c.force }
func (c *helmConfig) GetKubeConfig() string { return kubectl.TestKubeConfig }
func (c *helmConfig) GetKubeContext() string { return kubectl.TestKubeContext }
func (c *helmConfig) GetKubeNamespace() string { return c.namespace }
func (c *helmConfig) ConfigurationFile() string { return c.configFile }
func (c *helmConfig) Pipeline() latest.Pipeline {
var pipeline latest.Pipeline
pipeline.Deploy.DeployType.HelmDeploy = &c.helm
Expand Down
1 change: 1 addition & 0 deletions pkg/skaffold/deploy/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type Config interface {
Pipeline() latest.Pipeline
GetWorkingDir() string
GlobalConfig() string
ConfigurationFile() string
DefaultRepo() *string
SkipRender() bool
}
Expand Down