remove decoder interface since it is only used inside k8sdeps

This commit is contained in:
Jingfang Liu
2018-10-10 11:08:23 -07:00
parent cf4a1ba083
commit 96091dfcf5
22 changed files with 35 additions and 92 deletions

View File

@@ -65,7 +65,7 @@ func NewCmdBuild(
out io.Writer, fs fs.FileSystem,
kf ifc.KunstructuredFactory,
ptf patch.TransformerFactory,
decoder ifc.Decoder, hash ifc.Hash) *cobra.Command {
hash ifc.Hash) *cobra.Command {
var o buildOptions
var p string
@@ -79,7 +79,7 @@ func NewCmdBuild(
if err != nil {
return err
}
return o.RunBuild(out, fs, kf, ptf, decoder, hash)
return o.RunBuild(out, fs, kf, ptf, hash)
},
}
cmd.Flags().StringVarP(
@@ -126,7 +126,7 @@ func (o *buildOptions) RunBuild(
out io.Writer, fSys fs.FileSystem,
kf ifc.KunstructuredFactory,
ptf patch.TransformerFactory,
decoder ifc.Decoder, hash ifc.Hash) error {
hash ifc.Hash) error {
rootLoader, err := loader.NewLoader(o.kustomizationPath, "", fSys)
if err != nil {
return err
@@ -137,7 +137,7 @@ func (o *buildOptions) RunBuild(
resmap.NewFactory(resource.NewFactory(kf)),
ptf,
makeTransformerconfig(fSys, o.transformerconfigPaths),
decoder, hash)
hash)
if err != nil {
return err
}

View File

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

View File

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

View File

@@ -23,14 +23,6 @@ import (
"sigs.k8s.io/kustomize/pkg/types"
)
// Decoder unmarshalls byte input into an object.
type Decoder interface {
// SetInput accepts new input.
SetInput([]byte)
// Decode yields the next object from the input, else io.EOF
Decode(interface{}) error
}
// Validator provides functions to validate annotations and labels
type Validator interface {
MakeAnnotationValidator() func(map[string]string) error

View File

@@ -32,7 +32,7 @@ import (
)
var rf = resource.NewFactory(
k8sdeps.NewKunstructuredFactoryImpl(k8sdeps.NewKustDecoder()))
k8sdeps.NewKunstructuredFactoryImpl())
func TestNewPatchJson6902FactoryNoTarget(t *testing.T) {
p := patch.Json6902{}

View File

@@ -32,7 +32,7 @@ var deploy = gvk.Gvk{Group: "apps", Version: "v1", Kind: "Deployment"}
func TestJsonPatchJSONTransformer_Transform(t *testing.T) {
rf := resource.NewFactory(
k8sdeps.NewKunstructuredFactoryImpl(k8sdeps.NewKustDecoder()))
k8sdeps.NewKunstructuredFactoryImpl())
id := resid.NewResId(deploy, "deploy1")
base := resmap.ResMap{
id: rf.FromMap(

View File

@@ -30,7 +30,7 @@ import (
var deploy = gvk.Gvk{Group: "apps", Version: "v1", Kind: "Deployment"}
var statefulset = gvk.Gvk{Group: "apps", Version: "v1", Kind: "StatefulSet"}
var rf = resource.NewFactory(
k8sdeps.NewKunstructuredFactoryImpl(k8sdeps.NewKustDecoder()))
k8sdeps.NewKunstructuredFactoryImpl())
var rmF = NewFactory(rf)
func TestEncodeAsYaml(t *testing.T) {

View File

@@ -23,7 +23,7 @@ import (
)
var factory = NewFactory(
k8sdeps.NewKunstructuredFactoryImpl(k8sdeps.NewKustDecoder()))
k8sdeps.NewKunstructuredFactoryImpl())
var testConfigMap = factory.FromMap(
map[string]interface{}{

View File

@@ -43,7 +43,6 @@ import (
// KustTarget encapsulates the entirety of a kustomization build.
type KustTarget struct {
kustomization *types.Kustomization
decoder ifc.Decoder
hash ifc.Hash
ldr ifc.Loader
fSys fs.FileSystem
@@ -58,7 +57,7 @@ func NewKustTarget(
rf *resmap.Factory,
ptf patch.TransformerFactory,
tcfg *transformerconfig.TransformerConfig,
d ifc.Decoder, h ifc.Hash) (*KustTarget, error) {
h ifc.Hash) (*KustTarget, error) {
content, err := ldr.Load(constants.KustomizationFileName)
if err != nil {
return nil, err
@@ -76,7 +75,6 @@ func NewKustTarget(
fSys: fSys,
rf: rf,
tcfg: tcfg,
decoder: d,
hash: h,
ptf: ptf,
}, nil
@@ -227,7 +225,7 @@ func (kt *KustTarget) loadCustomizedBases() (resmap.ResMap, *interror.Kustomizat
continue
}
target, err := NewKustTarget(
ldr, kt.fSys, kt.rf, kt.ptf, kt.tcfg, kt.decoder, kt.hash)
ldr, kt.fSys, kt.rf, kt.ptf, kt.tcfg, kt.hash)
if err != nil {
errs.Append(errors.Wrap(err, "couldn't make target for "+path))
continue
@@ -257,7 +255,7 @@ func (kt *KustTarget) loadBasesAsFlatList() ([]*KustTarget, error) {
continue
}
target, err := NewKustTarget(
ldr, kt.fSys, kt.rf, kt.ptf, kt.tcfg, kt.decoder, kt.hash)
ldr, kt.fSys, kt.rf, kt.ptf, kt.tcfg, kt.hash)
if err != nil {
errs.Append(err)
continue

View File

@@ -89,7 +89,7 @@ metadata:
)
var rf = resmap.NewFactory(resource.NewFactory(
k8sdeps.NewKunstructuredFactoryImpl(k8sdeps.NewKustDecoder())))
k8sdeps.NewKunstructuredFactoryImpl()))
func makeLoader1(t *testing.T) ifc.Loader {
ldr := loadertest.NewFakeLoader("/testpath")
@@ -212,7 +212,7 @@ func TestResources1(t *testing.T) {
kt, err := NewKustTarget(
l, fakeFs, rf, patch.NewPatchTransformerFactory(),
transformerconfig.MakeDefaultTransformerConfig(),
k8sdeps.NewKustDecoder(), k8sdeps.NewKustHash())
k8sdeps.NewKustHash())
if err != nil {
t.Fatalf("unexpected construction error %v", err)
}
@@ -238,7 +238,7 @@ func TestResourceNotFound(t *testing.T) {
kt, err := NewKustTarget(
l, fakeFs, rf, patch.NewPatchTransformerFactory(),
transformerconfig.MakeDefaultTransformerConfig(),
k8sdeps.NewKustDecoder(), k8sdeps.NewKustHash())
k8sdeps.NewKustHash())
if err != nil {
t.Fatalf("Unexpected construction error %v", err)
}
@@ -262,7 +262,7 @@ func TestSecretTimeout(t *testing.T) {
kt, err := NewKustTarget(
l, fakeFs, rf, patch.NewPatchTransformerFactory(),
transformerconfig.MakeDefaultTransformerConfig(),
k8sdeps.NewKustDecoder(), k8sdeps.NewKustHash())
k8sdeps.NewKustHash())
if err != nil {
t.Fatalf("Unexpected construction error %v", err)
}

View File

@@ -30,7 +30,7 @@ import (
func TestImageTagTransformer(t *testing.T) {
var rf = resource.NewFactory(
k8sdeps.NewKunstructuredFactoryImpl(k8sdeps.NewKustDecoder()))
k8sdeps.NewKunstructuredFactoryImpl())
m := resmap.ResMap{
resid.NewResId(deploy, "deploy1"): rf.FromMap(

View File

@@ -42,7 +42,7 @@ var crb = gvk.Gvk{Group: "rbac.authorization.k8s.io", Version: "v1", Kind: "Clus
var sa = gvk.Gvk{Version: "v1", Kind: "ServiceAccount"}
var ingress = gvk.Gvk{Kind: "Ingress"}
var rf = resource.NewFactory(
k8sdeps.NewKunstructuredFactoryImpl(k8sdeps.NewKustDecoder()))
k8sdeps.NewKunstructuredFactoryImpl())
func TestLabelsRun(t *testing.T) {
m := resmap.ResMap{

View File

@@ -29,7 +29,7 @@ import (
func TestNameHashTransformer(t *testing.T) {
rf := resource.NewFactory(
k8sdeps.NewKunstructuredFactoryImpl(k8sdeps.NewKustDecoder()))
k8sdeps.NewKunstructuredFactoryImpl())
objs := resmap.ResMap{
resid.NewResId(cmap, "cm1"): rf.FromMap(
map[string]interface{}{

View File

@@ -29,7 +29,7 @@ import (
func TestNameReferenceRun(t *testing.T) {
rf := resource.NewFactory(
k8sdeps.NewKunstructuredFactoryImpl(k8sdeps.NewKustDecoder()))
k8sdeps.NewKunstructuredFactoryImpl())
m := resmap.ResMap{
resid.NewResId(cmap, "cm1"): rf.FromMap(
map[string]interface{}{

View File

@@ -29,7 +29,7 @@ import (
func TestNamespaceRun(t *testing.T) {
rf := resource.NewFactory(
k8sdeps.NewKunstructuredFactoryImpl(k8sdeps.NewKustDecoder()))
k8sdeps.NewKunstructuredFactoryImpl())
m := resmap.ResMap{
resid.NewResId(cmap, "cm1"): rf.FromMap(
map[string]interface{}{

View File

@@ -29,7 +29,7 @@ import (
func TestPrefixNameRun(t *testing.T) {
rf := resource.NewFactory(
k8sdeps.NewKunstructuredFactoryImpl(k8sdeps.NewKustDecoder()))
k8sdeps.NewKunstructuredFactoryImpl())
m := resmap.ResMap{
resid.NewResId(cmap, "cm1"): rf.FromMap(
map[string]interface{}{