address comments

This commit is contained in:
Jingfang Liu
2019-04-08 11:10:05 -07:00
parent 826affb8dd
commit e9a3f9f5f6
5 changed files with 15 additions and 15 deletions

View File

@@ -42,13 +42,13 @@ var _ transformers.Transformer = &pruneTransformer{}
// NewPruneTransformer makes a pruneTransformer. // NewPruneTransformer makes a pruneTransformer.
func NewPruneTransformer(p *types.Prune, namespace string, append bool) transformers.Transformer { func NewPruneTransformer(p *types.Prune, namespace string, append bool) transformers.Transformer {
if p == nil || p.Type != "alphaConfigMap" || p.AlphaConfigMap.Namespace != namespace { if p == nil || p.Type != "ConfigMap" || p.ConfigMap.Namespace != namespace {
return transformers.NewNoOpTransformer() return transformers.NewNoOpTransformer()
} }
return &pruneTransformer{ return &pruneTransformer{
append: append, append: append,
cmName: p.AlphaConfigMap.Name, cmName: p.ConfigMap.Name,
cmNamespace: p.AlphaConfigMap.Namespace, cmNamespace: p.ConfigMap.Namespace,
} }
} }

View File

@@ -140,8 +140,8 @@ func TestPruneTransformer(t *testing.T) {
} }
p := &types.Prune{ p := &types.Prune{
Type: "alphaConfigMap", Type: "ConfigMap",
AlphaConfigMap: types.NameArgs{ ConfigMap: types.NameArgs{
Name: "pruneCM", Name: "pruneCM",
Namespace: "default", Namespace: "default",
}, },

View File

@@ -85,7 +85,7 @@ func NewCmdBuild(
"output", "o", "", "output", "o", "",
"If specified, write the build output to this path.") "If specified, write the build output to this path.")
cmd.AddCommand(NewCmdBuildPrune(out, fs, rf, ptf, b)) cmd.AddCommand(NewCmdBuildPrune(out, fs, rf, ptf, pc))
return cmd return cmd
} }
@@ -136,13 +136,13 @@ func (o *Options) RunBuild(
func (o *Options) RunBuildPrune( func (o *Options) RunBuildPrune(
out io.Writer, fSys fs.FileSystem, out io.Writer, fSys fs.FileSystem,
rf *resmap.Factory, ptf transformer.Factory, rf *resmap.Factory, ptf transformer.Factory,
b bool) error { pc *types.PluginConfig) error {
ldr, err := loader.NewLoader(o.kustomizationPath, fSys) ldr, err := loader.NewLoader(o.kustomizationPath, fSys)
if err != nil { if err != nil {
return err return err
} }
defer ldr.Cleanup() defer ldr.Cleanup()
kt, err := target.NewKustTarget(ldr, rf, ptf, b) kt, err := target.NewKustTarget(ldr, rf, ptf, pc)
if err != nil { if err != nil {
return err return err
} }
@@ -166,11 +166,11 @@ func NewCmdBuildPrune(
out io.Writer, fs fs.FileSystem, out io.Writer, fs fs.FileSystem,
rf *resmap.Factory, rf *resmap.Factory,
ptf transformer.Factory, ptf transformer.Factory,
b bool) *cobra.Command { pc *types.PluginConfig) *cobra.Command {
var o Options var o Options
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "prune [path]", Use: "alpha-prune [path]",
Short: "Print configmap to prune previous applied objects", Short: "Print configmap to prune previous applied objects",
Example: examples, Example: examples,
SilenceUsage: true, SilenceUsage: true,
@@ -179,7 +179,7 @@ func NewCmdBuildPrune(
if err != nil { if err != nil {
return err return err
} }
return o.RunBuildPrune(out, fs, rf, ptf, b) return o.RunBuildPrune(out, fs, rf, ptf, pc)
}, },
} }
return cmd return cmd

View File

@@ -29,8 +29,8 @@ resources:
- secret.yaml - secret.yaml
prune: prune:
type: alphaConfigMap type: ConfigMap
alphaConfigMap: configMap:
name: haha name: haha
namespace: default namespace: default

View File

@@ -295,7 +295,7 @@ type KVSource struct {
type Prune struct { type Prune struct {
Type string `json:"type,omitempty" yaml:"type,omitempty"` Type string `json:"type,omitempty" yaml:"type,omitempty"`
AlphaConfigMap NameArgs `json:"alphaConfigMap,omitempty" yaml:"alphaConfigMap,omitempty"` ConfigMap NameArgs `json:"configMap,omitempty" yaml:"configMap,omitempty"`
} }
type NameArgs struct { type NameArgs struct {