diff --git a/pkg/skaffold/deploy/deploy.go b/pkg/skaffold/deploy/deploy.go index 47d7d93d8bd..c873127d476 100644 --- a/pkg/skaffold/deploy/deploy.go +++ b/pkg/skaffold/deploy/deploy.go @@ -38,6 +38,10 @@ type Deployer interface { // Cleanup deletes what was deployed by calling Deploy. Cleanup(context.Context, io.Writer) error + + // Render generates the Kubernetes manifests replacing the build results and + // writes them to the given file path + Render(context.Context, io.Writer, []build.Artifact, string) error } type Result struct { diff --git a/pkg/skaffold/deploy/helm.go b/pkg/skaffold/deploy/helm.go index f5a5a2380c2..d4af34236a5 100644 --- a/pkg/skaffold/deploy/helm.go +++ b/pkg/skaffold/deploy/helm.go @@ -461,6 +461,10 @@ func (h *HelmDeployer) joinTagsToBuildResult(builds []build.Artifact, params map return paramToBuildResult, nil } +func (h *HelmDeployer) Render(context.Context, io.Writer, []build.Artifact, string) error { + return errors.New("not yet implemented") +} + func evaluateReleaseName(nameTemplate string) (string, error) { tmpl, err := util.ParseEnvTemplate(nameTemplate) if err != nil { diff --git a/pkg/skaffold/deploy/helm_test.go b/pkg/skaffold/deploy/helm_test.go index 8f6f2aacf82..752edc16307 100644 --- a/pkg/skaffold/deploy/helm_test.go +++ b/pkg/skaffold/deploy/helm_test.go @@ -714,6 +714,25 @@ func TestExpandPaths(t *testing.T) { } } +func TestHelmRender(t *testing.T) { + tests := []struct { + description string + shouldErr bool + }{ + { + description: "calling render returns error", + shouldErr: true, + }, + } + for _, test := range tests { + testutil.Run(t, test.description, func(t *testutil.T) { + deployer := NewHelmDeployer(&runcontext.RunContext{}) + actual := deployer.Render(context.Background(), ioutil.Discard, []build.Artifact{}, "tmp/dir") + t.CheckError(test.shouldErr, actual) + }) + } +} + func makeRunContext(deploy latest.HelmDeploy, force bool) *runcontext.RunContext { pipeline := latest.Pipeline{} pipeline.Deploy.DeployType.HelmDeploy = &deploy diff --git a/pkg/skaffold/deploy/kubectl.go b/pkg/skaffold/deploy/kubectl.go index 46458c818aa..577af7362d7 100644 --- a/pkg/skaffold/deploy/kubectl.go +++ b/pkg/skaffold/deploy/kubectl.go @@ -251,3 +251,7 @@ func (k *KubectlDeployer) readRemoteManifest(ctx context.Context, name string) ( return manifest.Bytes(), nil } + +func (k *KubectlDeployer) Render(context.Context, io.Writer, []build.Artifact, string) error { + return errors.New("not yet implemented") +} diff --git a/pkg/skaffold/deploy/kubectl_test.go b/pkg/skaffold/deploy/kubectl_test.go index 6609c00e538..707b6556c95 100644 --- a/pkg/skaffold/deploy/kubectl_test.go +++ b/pkg/skaffold/deploy/kubectl_test.go @@ -457,3 +457,32 @@ func TestDependencies(t *testing.T) { }) } } + +func TestKubectlRender(t *testing.T) { + tests := []struct { + description string + shouldErr bool + }{ + { + description: "calling render returns error", + shouldErr: true, + }, + } + for _, test := range tests { + testutil.Run(t, test.description, func(t *testutil.T) { + deployer := NewKubectlDeployer(&runcontext.RunContext{ + Cfg: latest.Pipeline{ + Deploy: latest.DeployConfig{ + DeployType: latest.DeployType{ + KubectlDeploy: &latest.KubectlDeploy{ + Manifests: []string{}, + }, + }, + }, + }, + }) + actual := deployer.Render(context.Background(), ioutil.Discard, []build.Artifact{}, "tmp/dir") + t.CheckError(test.shouldErr, actual) + }) + } +} diff --git a/pkg/skaffold/deploy/kustomize.go b/pkg/skaffold/deploy/kustomize.go index 494b520cff4..4f0abb267b3 100644 --- a/pkg/skaffold/deploy/kustomize.go +++ b/pkg/skaffold/deploy/kustomize.go @@ -167,6 +167,10 @@ func (k *KustomizeDeployer) Dependencies() ([]string, error) { return dependenciesForKustomization(k.KustomizePath) } +func (k *KustomizeDeployer) Render(context.Context, io.Writer, []build.Artifact, string) error { + return errors.New("not yet implemented") +} + func dependenciesForKustomization(dir string) ([]string, error) { var deps []string diff --git a/pkg/skaffold/deploy/kustomize_test.go b/pkg/skaffold/deploy/kustomize_test.go index 013d62d7511..499bc2c4c00 100644 --- a/pkg/skaffold/deploy/kustomize_test.go +++ b/pkg/skaffold/deploy/kustomize_test.go @@ -393,3 +393,30 @@ func TestKustomizeBuildCommandArgs(t *testing.T) { }) } } + +func TestKustomizeRender(t *testing.T) { + tests := []struct { + description string + shouldErr bool + }{ + { + description: "calling render returns error", + shouldErr: true, + }, + } + for _, test := range tests { + testutil.Run(t, test.description, func(t *testutil.T) { + deployer := NewKustomizeDeployer(&runcontext.RunContext{ + Cfg: latest.Pipeline{ + Deploy: latest.DeployConfig{ + DeployType: latest.DeployType{ + KustomizeDeploy: &latest.KustomizeDeploy{}, + }, + }, + }, + }) + actual := deployer.Render(context.Background(), ioutil.Discard, []build.Artifact{}, "tmp/dir") + t.CheckError(test.shouldErr, actual) + }) + } +} diff --git a/pkg/skaffold/runner/runner_test.go b/pkg/skaffold/runner/runner_test.go index c6679700ecf..27a443041e8 100644 --- a/pkg/skaffold/runner/runner_test.go +++ b/pkg/skaffold/runner/runner_test.go @@ -18,6 +18,7 @@ package runner import ( "context" + "errors" "fmt" "io" "io/ioutil" @@ -170,6 +171,10 @@ func (t *TestBench) Deploy(_ context.Context, _ io.Writer, artifacts []build.Art return deploy.NewDeploySuccessResult(t.namespaces) } +func (t *TestBench) Render(_ context.Context, _ io.Writer, artifacts []build.Artifact, _ string) error { + return errors.New("not yet implemented") +} + func (t *TestBench) Actions() []Actions { return append(t.actions, t.currentActions) }