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

add render interface to deployers which is not implemented #2834

Merged
merged 3 commits into from
Sep 16, 2019
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
4 changes: 4 additions & 0 deletions pkg/skaffold/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions pkg/skaffold/deploy/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
19 changes: 19 additions & 0 deletions pkg/skaffold/deploy/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions pkg/skaffold/deploy/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
29 changes: 29 additions & 0 deletions pkg/skaffold/deploy/kubectl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
}
4 changes: 4 additions & 0 deletions pkg/skaffold/deploy/kustomize.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
27 changes: 27 additions & 0 deletions pkg/skaffold/deploy/kustomize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
}
5 changes: 5 additions & 0 deletions pkg/skaffold/runner/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package runner

import (
"context"
"errors"
"fmt"
"io"
"io/ioutil"
Expand Down Expand Up @@ -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)
}
Expand Down