Fix utility function uses the wrong flag text to get value (#1368)

The utility function GetMetadata uses wrong flag text to get the resource namespace and could cause the wrong results returned from the API server. This PR changes the function signature that allows users to pass in the flag text in order to get the correct value.
This commit is contained in:
Ta-Ching Chen
2019-11-01 00:59:50 +08:00
committed by GitHub
parent fe02bb1678
commit 2b616ec4e2
6 changed files with 16 additions and 16 deletions
+1 -1
View File
@@ -65,7 +65,7 @@ func (opts *CreateSubCommand) complete(flags cli.Input) error {
// run write the resource to a spec file or create a fission CRD with remote fission server.
// It also prints warning/error if necessary.
func (opts *CreateSubCommand) run(flags cli.Input) error {
m, err := cmd.GetMetadata(flags)
m, err := cmd.GetMetadata(cmd.RESOURCE_NAME, cmd.ENVIRONMENT_NAMESPACE, flags)
if err != nil {
return err
}
+3 -3
View File
@@ -21,7 +21,7 @@ import (
"github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
cmdutils "github.com/fission/fission/pkg/fission-cli/cmd"
"github.com/fission/fission/pkg/fission-cli/cmd"
"github.com/fission/fission/pkg/fission-cli/util"
)
@@ -31,13 +31,13 @@ type DeleteSubCommand struct {
func Delete(flags cli.Input) error {
opts := DeleteSubCommand{
client: cmdutils.GetServer(flags),
client: cmd.GetServer(flags),
}
return opts.do(flags)
}
func (opts *DeleteSubCommand) do(flags cli.Input) error {
m, err := cmdutils.GetMetadata(flags)
m, err := cmd.GetMetadata(cmd.RESOURCE_NAME, cmd.ENVIRONMENT_NAMESPACE, flags)
if err != nil {
return err
}
+3 -3
View File
@@ -23,7 +23,7 @@ import (
"github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
cmdutils "github.com/fission/fission/pkg/fission-cli/cmd"
"github.com/fission/fission/pkg/fission-cli/cmd"
"github.com/fission/fission/pkg/fission-cli/util"
)
@@ -33,13 +33,13 @@ type GetSubCommand struct {
func Get(flags cli.Input) error {
opts := GetSubCommand{
client: cmdutils.GetServer(flags),
client: cmd.GetServer(flags),
}
return opts.do(flags)
}
func (opts *GetSubCommand) do(flags cli.Input) error {
m, err := cmdutils.GetMetadata(flags)
m, err := cmd.GetMetadata(cmd.RESOURCE_NAME, cmd.ENVIRONMENT_NAMESPACE, flags)
if err != nil {
return err
}
+3 -3
View File
@@ -23,7 +23,7 @@ import (
"github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
cmdutils "github.com/fission/fission/pkg/fission-cli/cmd"
"github.com/fission/fission/pkg/fission-cli/cmd"
"github.com/fission/fission/pkg/fission-cli/util"
)
@@ -33,13 +33,13 @@ type ListSubCommand struct {
func List(flags cli.Input) error {
opts := ListSubCommand{
client: cmdutils.GetServer(flags),
client: cmd.GetServer(flags),
}
return opts.do(flags)
}
func (opts *ListSubCommand) do(flags cli.Input) error {
envNamespace := flags.String(cmdutils.ENVIRONMENT_NAMESPACE)
envNamespace := flags.String(cmd.ENVIRONMENT_NAMESPACE)
envs, err := opts.client.EnvironmentList(envNamespace)
util.CheckErr(err, "list environments")
+1 -1
View File
@@ -50,7 +50,7 @@ func (opts *UpdateSubCommand) do(flags cli.Input) error {
}
func (opts *UpdateSubCommand) complete(flags cli.Input) error {
m, err := cmd.GetMetadata(flags)
m, err := cmd.GetMetadata(cmd.RESOURCE_NAME, cmd.ENVIRONMENT_NAMESPACE, flags)
if err != nil {
return err
}