mirror of
https://github.com/kubevela/kubevela.git
synced 2026-02-14 18:10:21 +00:00
allow vela CLI to specify NS
This commit is contained in:
@@ -45,10 +45,12 @@ type DryRunCmdOptions struct {
|
||||
cmdutil.IOStreams
|
||||
ApplicationFile string
|
||||
DefinitionFile string
|
||||
NameSpace string
|
||||
}
|
||||
|
||||
// NewDryRunCommand creates `dry-run` command
|
||||
func NewDryRunCommand(c common.Args, ioStreams cmdutil.IOStreams) *cobra.Command {
|
||||
var namespace string
|
||||
o := &DryRunCmdOptions{IOStreams: ioStreams}
|
||||
cmd := &cobra.Command{
|
||||
Use: "dry-run",
|
||||
@@ -60,11 +62,7 @@ func NewDryRunCommand(c common.Args, ioStreams cmdutil.IOStreams) *cobra.Command
|
||||
return c.SetConfig()
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
velaEnv, err := GetEnv(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
buff, err := DryRunApplication(o, c, velaEnv.Namespace)
|
||||
buff, err := DryRunApplication(o, c, namespace)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -75,6 +73,7 @@ func NewDryRunCommand(c common.Args, ioStreams cmdutil.IOStreams) *cobra.Command
|
||||
|
||||
cmd.Flags().StringVarP(&o.ApplicationFile, "file", "f", "./app.yaml", "application file name")
|
||||
cmd.Flags().StringVarP(&o.DefinitionFile, "definition", "d", "", "specify a definition file or directory, it will only be used in dry-run rather than applied to K8s cluster")
|
||||
cmd.Flags().StringVarP(&namespace, "namespace", "n", "default", "specify namespace of the definition file, by default is default namespace")
|
||||
cmd.SetOut(ioStreams.Out)
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ type LiveDiffCmdOptions struct {
|
||||
|
||||
// NewLiveDiffCommand creates `live-diff` command
|
||||
func NewLiveDiffCommand(c common.Args, ioStreams cmdutil.IOStreams) *cobra.Command {
|
||||
var namespace string
|
||||
o := &LiveDiffCmdOptions{
|
||||
DryRunCmdOptions: DryRunCmdOptions{
|
||||
IOStreams: ioStreams,
|
||||
@@ -56,11 +57,7 @@ func NewLiveDiffCommand(c common.Args, ioStreams cmdutil.IOStreams) *cobra.Comma
|
||||
return c.SetConfig()
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
velaEnv, err := GetEnv(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
buff, err := LiveDiffApplication(o, c, velaEnv.Namespace)
|
||||
buff, err := LiveDiffApplication(o, c, namespace)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -73,6 +70,7 @@ func NewLiveDiffCommand(c common.Args, ioStreams cmdutil.IOStreams) *cobra.Comma
|
||||
cmd.Flags().StringVarP(&o.DefinitionFile, "definition", "d", "", "specify a file or directory containing capability definitions, they will only be used in dry-run rather than applied to K8s cluster")
|
||||
cmd.Flags().StringVarP(&o.Revision, "Revision", "r", "", "specify an application Revision name, by default, it will compare with the latest Revision")
|
||||
cmd.Flags().IntVarP(&o.Context, "context", "c", -1, "output number lines of context around changes, by default show all unchanged lines")
|
||||
cmd.Flags().StringVarP(&namespace, "namespace", "n", "default", "specify namespace of the application to be compared, by default is default namespace")
|
||||
cmd.SetOut(ioStreams.Out)
|
||||
return cmd
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user