Skip to content

Commit

Permalink
remove option init
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-chenzz committed Jan 15, 2024
1 parent 1fb4bdf commit 9825a6f
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions kustomize/commands/edit/add/addreplacement.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@ type addReplacementOptions struct {

func newCmdAddReplacement(fSys filesys.FileSystem) *cobra.Command {
var o addReplacementOptions
o.Replacement.Source = &types.SourceSelector{}
o.Replacement.Targets = append(o.Replacement.Targets, &types.TargetSelector{})
cmd := &cobra.Command{
Use: "replacement",
Short: "add an item to replacement field",
Long: `this command will add an item to replacement field in the kustomization file.
the item will be:
- be either a file, or an inline string
The item must be either a file, or an inline string.
`,
Example: `
# Adds a replacement file to the kustomization file
Expand Down Expand Up @@ -66,13 +63,6 @@ func (o *addReplacementOptions) RunAddReplacement(fSys filesys.FileSystem) error
return fmt.Errorf("failed to read kustomization file: %w", err)
}

if o.Replacement.Targets != nil {
o.Replacement.Targets = nil
}
if o.Replacement.Source != nil {
o.Replacement.Source = nil
}

for _, r := range m.Replacements {
if len(r.Path) > 0 && r.Path == o.Replacement.Path {
return fmt.Errorf("replacement for path %q already in %s file", r.Path, konfig.DefaultKustomizationFileName())
Expand Down

0 comments on commit 9825a6f

Please sign in to comment.