diff --git a/integration/examples/annotated-skaffold.yaml b/integration/examples/annotated-skaffold.yaml index ac9399483eb..942255cd33c 100644 --- a/integration/examples/annotated-skaffold.yaml +++ b/integration/examples/annotated-skaffold.yaml @@ -133,7 +133,7 @@ deploy: # - namespace:deployment/web-app2 # kustomize: - # kustomizePath: "kustomization.yaml" + # path: . # kustomize deploys manifests with kubectl. # kubectl can be passed additional option flags either on every command (Global), # on creations (Apply) or deletions (Delete). diff --git a/pkg/skaffold/config/transform/transforms.go b/pkg/skaffold/config/transform/transforms.go index e292195497a..1f97708340a 100644 --- a/pkg/skaffold/config/transform/transforms.go +++ b/pkg/skaffold/config/transform/transforms.go @@ -132,6 +132,7 @@ func ToV1Alpha3(vc util.VersionedConfig) (util.VersionedConfig, error) { if err := convert(oldConfig.Deploy, &newDeploy); err != nil { return nil, errors.Wrap(err, "converting deploy config") } + // if the helm deploy config was set, then convert ValueFilePath to ValuesFiles if oldHelmDeploy := oldConfig.Deploy.DeployType.HelmDeploy; oldHelmDeploy != nil { for i, oldHelmRelease := range oldHelmDeploy.Releases { @@ -141,6 +142,12 @@ func ToV1Alpha3(vc util.VersionedConfig) (util.VersionedConfig, error) { } } + // the kustomize path parameter was renamed + kustomize := oldConfig.Deploy.KustomizeDeploy + if kustomize != nil { + newDeploy.KustomizeDeploy.Path = kustomize.KustomizePath + } + // convert v1alpha2.Profiles to v1alpha3.Profiles (should be the same) var newProfiles []v1alpha3.Profile if oldConfig.Profiles != nil { diff --git a/pkg/skaffold/deploy/kustomize.go b/pkg/skaffold/deploy/kustomize.go index 7dd3c5a3088..96271433e3f 100644 --- a/pkg/skaffold/deploy/kustomize.go +++ b/pkg/skaffold/deploy/kustomize.go @@ -164,11 +164,11 @@ func joinPaths(root string, paths []string) []string { // Dependencies lists all the files that can change what needs to be deployed. func (k *KustomizeDeployer) Dependencies() ([]string, error) { - return dependenciesForKustomization(k.KustomizePath) + return dependenciesForKustomization(k.Path) } func (k *KustomizeDeployer) readManifests(ctx context.Context) (kubectl.ManifestList, error) { - cmd := exec.CommandContext(ctx, "kustomize", "build", k.KustomizePath) + cmd := exec.CommandContext(ctx, "kustomize", "build", k.Path) out, err := util.RunCmdOut(cmd) if err != nil { return nil, errors.Wrap(err, "kustomize build") diff --git a/pkg/skaffold/schema/v1alpha3/config.go b/pkg/skaffold/schema/v1alpha3/config.go index 665861826b6..a861a4c116b 100644 --- a/pkg/skaffold/schema/v1alpha3/config.go +++ b/pkg/skaffold/schema/v1alpha3/config.go @@ -144,9 +144,10 @@ type HelmDeploy struct { Releases []HelmRelease `yaml:"releases,omitempty"` } +// KustomizeDeploy contains the configuration needed for deploying with kustomize. type KustomizeDeploy struct { - KustomizePath string `yaml:"kustomizePath,omitempty"` - Flags KubectlFlags `yaml:"flags,omitempty"` + Path string `yaml:"path,omitempty"` + Flags KubectlFlags `yaml:"flags,omitempty"` } type HelmRelease struct { diff --git a/pkg/skaffold/schema/v1alpha3/defaults.go b/pkg/skaffold/schema/v1alpha3/defaults.go index 965f6abf0b8..36e1c1a0a88 100644 --- a/pkg/skaffold/schema/v1alpha3/defaults.go +++ b/pkg/skaffold/schema/v1alpha3/defaults.go @@ -95,8 +95,13 @@ func (c *SkaffoldConfig) setDefaultTagger() { } func (c *SkaffoldConfig) setDefaultKustomizePath() { - if c.Deploy.KustomizeDeploy != nil && c.Deploy.KustomizeDeploy.KustomizePath == "" { - c.Deploy.KustomizeDeploy.KustomizePath = constants.DefaultKustomizationPath + kustomize := c.Deploy.KustomizeDeploy + if kustomize == nil { + return + } + + if kustomize.Path == "" { + kustomize.Path = constants.DefaultKustomizationPath } }