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
+5 -5
View File
@@ -125,14 +125,14 @@ func GetSpecDir(flags cli.Input) string {
return specDir
}
// GetMetadata returns a pointer to ObjectMeta which initialized with command line input.
func GetMetadata(flags cli.Input) (*metav1.ObjectMeta, error) {
name := flags.String(RESOURCE_NAME)
// GetMetadata returns a pointer to ObjectMeta that is populated with resource name and namespace given by the user.
func GetMetadata(nameFlagText string, namespaceFlagText string, flags cli.Input) (*metav1.ObjectMeta, error) {
name := flags.String(nameFlagText)
if len(name) == 0 {
return nil, errors.New("Need a resource name, use --name.")
return nil, errors.New("need a resource name, use --name")
}
ns := flags.String(ENVIRONMENT_NAMESPACE)
ns := flags.String(namespaceFlagText)
m := &metav1.ObjectMeta{
Name: name,