Add hash interface

This commit is contained in:
Jingfang Liu
2018-10-05 13:29:06 -07:00
parent 489f6e2e67
commit 5036a12a65
11 changed files with 45 additions and 27 deletions

View File

@@ -60,7 +60,7 @@ Use different transformer configurations by passing files to kustomize
// NewCmdBuild creates a new build command.
func NewCmdBuild(
out io.Writer, fs fs.FileSystem,
decoder ifc.Decoder) *cobra.Command {
decoder ifc.Decoder, hash ifc.Hash) *cobra.Command {
var o buildOptions
var p string
@@ -74,7 +74,7 @@ func NewCmdBuild(
if err != nil {
return err
}
return o.RunBuild(out, fs, decoder)
return o.RunBuild(out, fs, decoder, hash)
},
}
cmd.Flags().StringVarP(
@@ -119,7 +119,7 @@ func (o *buildOptions) Validate(args []string, p string, fs fs.FileSystem) error
// RunBuild runs build command.
func (o *buildOptions) RunBuild(
out io.Writer, fSys fs.FileSystem,
decoder ifc.Decoder) error {
decoder ifc.Decoder, hash ifc.Hash) error {
rootLoader, err := loader.NewLoader(o.kustomizationPath, "", fSys)
if err != nil {
return err
@@ -128,7 +128,7 @@ func (o *buildOptions) RunBuild(
kt, err := target.NewKustTarget(
rootLoader, fSys,
makeTransformerconfig(fSys, o.transformerconfigPaths),
decoder)
decoder, hash)
if err != nil {
return err
}

View File

@@ -125,7 +125,7 @@ func runBuildTestCase(t *testing.T, testcaseName string, updateKustomizeExpected
kustomizationPath: testcase.Filename,
}
buf := bytes.NewBuffer([]byte{})
err = ops.RunBuild(buf, fSys, k8sdeps.NewKustDecoder())
err = ops.RunBuild(buf, fSys, k8sdeps.NewKustDecoder(), k8sdeps.NewKustHash())
switch {
case err != nil && len(testcase.ExpectedError) == 0:
t.Errorf("unexpected error: %v", err)

View File

@@ -31,7 +31,7 @@ import (
// NewDefaultCommand returns the default (aka root) command for kustomize command.
func NewDefaultCommand(
decoder ifc.Decoder, validator ifc.Validator) *cobra.Command {
decoder ifc.Decoder, validator ifc.Validator, hash ifc.Hash) *cobra.Command {
fsys := fs.MakeRealFS()
stdOut := os.Stdout
@@ -47,7 +47,7 @@ See https://sigs.k8s.io/kustomize
c.AddCommand(
// TODO: Make consistent API for newCmd* functions.
build.NewCmdBuild(stdOut, fsys, decoder),
build.NewCmdBuild(stdOut, fsys, decoder, hash),
edit.NewCmdEdit(fsys, validator),
misc.NewCmdConfig(fsys),
misc.NewCmdVersion(stdOut),