Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
shahriar committed May 22, 2017
1 parent a26023f commit d5dd50d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
5 changes: 3 additions & 2 deletions docs/kubedb/edit.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ $ kubedb edit --help
Edit a resource from the default editor.

The edit command allows you to directly edit any API resource you can retrieve via the command line tools. It will open
the editor defined by your KUBEDB _EDITOR, or EDITOR environment variables, or fall back to 'vi' for Linux. You can edit
multiple objects, although changes are applied one at a time.
the editor defined by your KUBEDB _EDITOR, or EDITOR environment variables, or fall back to 'nano'

Examples:
# Edit the elastic named 'elasticsearch-demo':
Expand All @@ -21,7 +20,9 @@ Examples:
KUBEDB_EDITOR="nano" kubedb edit es/elasticsearch-demo

Options:
--all=false: [-all] to select all the specified resources.
-o, --output='yaml': Output format. One of: yaml|json.
-l, --selector='': Selector (label query) to filter on.

Usage:
kubedb edit (RESOURCE/NAME) [flags] [options]
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func RunDelete(f cmdutil.Factory, cmd *cobra.Command, out io.Writer, args []stri
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, options).
SelectorParam(cmdutil.GetFlagString(cmd, "selector")).
ResourceTypeOrNameArgs(true, args...).RequireObject(true).
ResourceTypeOrNameArgs(false, args...).RequireObject(true).
Flatten().
Do()
err = r.Err()
Expand Down
6 changes: 4 additions & 2 deletions pkg/cmd/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func runEdit(f cmdutil.Factory, out, errOut io.Writer, cmd *cobra.Command, args
}
args[0] = strings.Join(resources, ",")

mapper, resourceMapper, r, _, err := getMapperAndResult(f, args)
mapper, resourceMapper, r, _, err := getMapperAndResult(f, cmd, args)
if err != nil {
return err
}
Expand Down Expand Up @@ -274,7 +274,7 @@ func visitToPatch(extClient clientset.ExtensionInterface, originalObj runtime.Ob
return err
}

func getMapperAndResult(f cmdutil.Factory, args []string) (meta.RESTMapper, *resource.Mapper, *resource.Result, string, error) {
func getMapperAndResult(f cmdutil.Factory, cmd *cobra.Command, args []string) (meta.RESTMapper, *resource.Mapper, *resource.Result, string, error) {
cmdNamespace, _, err := f.DefaultNamespace()
if err != nil {
return nil, nil, nil, "", err
Expand All @@ -294,6 +294,8 @@ func getMapperAndResult(f cmdutil.Factory, args []string) (meta.RESTMapper, *res
}

b := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.UnstructuredClientForMapping), runtime.UnstructuredJSONScheme).
SelectorParam(cmdutil.GetFlagString(cmd, "selector")).
SelectAllParam(cmdutil.GetFlagBool(cmd, "all")).
ResourceTypeOrNameArgs(false, args...).
RequireObject(true).
Latest()
Expand Down
2 changes: 2 additions & 0 deletions pkg/cmd/util/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ func AddDescribeFlags(cmd *cobra.Command) {
}

func AddEditFlags(cmd *cobra.Command) {
cmd.Flags().Bool("all", false, "[-all] to select all the specified resources.")
cmd.Flags().StringP("selector", "l", "", "Selector (label query) to filter on.")
cmd.Flags().StringP("output", "o", "yaml", "Output format. One of: yaml|json.")
}

Expand Down

0 comments on commit d5dd50d

Please sign in to comment.