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.
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 &pruneTransformer{
append: append,
cmName: p.AlphaConfigMap.Name,
cmNamespace: p.AlphaConfigMap.Namespace,
cmName: p.ConfigMap.Name,
cmNamespace: p.ConfigMap.Namespace,
}
}

View File

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

View File

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

View File

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

View File

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