Merge pull request #42948 from CaoShuFeng/fromLiteralStrings

Automatic merge from submit-queue (batch tested with PRs 42998, 42902, 42959, 43020, 42948)

[cli] fix Generator's error messages

Invalid variables are used when format error messages. This change
fixes them.

**Release note**:

```NONE
```
This commit is contained in:
Kubernetes Submit Queue 2017-03-25 17:17:28 -07:00 committed by GitHub
commit 6a529f700a
4 changed files with 20 additions and 20 deletions

View File

@ -52,29 +52,29 @@ func (s ClusterRoleBindingGeneratorV1) Generate(genericParams map[string]interfa
return nil, err return nil, err
} }
delegate := &ClusterRoleBindingGeneratorV1{} delegate := &ClusterRoleBindingGeneratorV1{}
fromFileStrings, found := genericParams["user"] userStrings, found := genericParams["user"]
if found { if found {
fromFileArray, isArray := fromFileStrings.([]string) fromFileArray, isArray := userStrings.([]string)
if !isArray { if !isArray {
return nil, fmt.Errorf("expected []string, found :%v", fromFileStrings) return nil, fmt.Errorf("expected []string, found :%v", userStrings)
} }
delegate.Users = fromFileArray delegate.Users = fromFileArray
delete(genericParams, "user") delete(genericParams, "user")
} }
fromLiteralStrings, found := genericParams["group"] groupStrings, found := genericParams["group"]
if found { if found {
fromLiteralArray, isArray := fromLiteralStrings.([]string) fromLiteralArray, isArray := groupStrings.([]string)
if !isArray { if !isArray {
return nil, fmt.Errorf("expected []string, found :%v", fromFileStrings) return nil, fmt.Errorf("expected []string, found :%v", groupStrings)
} }
delegate.Groups = fromLiteralArray delegate.Groups = fromLiteralArray
delete(genericParams, "group") delete(genericParams, "group")
} }
fromSAStrings, found := genericParams["serviceaccount"] saStrings, found := genericParams["serviceaccount"]
if found { if found {
fromLiteralArray, isArray := fromSAStrings.([]string) fromLiteralArray, isArray := saStrings.([]string)
if !isArray { if !isArray {
return nil, fmt.Errorf("expected []string, found :%v", fromFileStrings) return nil, fmt.Errorf("expected []string, found :%v", saStrings)
} }
delegate.ServiceAccounts = fromLiteralArray delegate.ServiceAccounts = fromLiteralArray
delete(genericParams, "serviceaccount") delete(genericParams, "serviceaccount")

View File

@ -68,7 +68,7 @@ func (s ConfigMapGeneratorV1) Generate(genericParams map[string]interface{}) (ru
if found { if found {
fromLiteralArray, isArray := fromLiteralStrings.([]string) fromLiteralArray, isArray := fromLiteralStrings.([]string)
if !isArray { if !isArray {
return nil, fmt.Errorf("expected []string, found :%v", fromFileStrings) return nil, fmt.Errorf("expected []string, found :%v", fromLiteralStrings)
} }
delegate.LiteralSources = fromLiteralArray delegate.LiteralSources = fromLiteralArray
delete(genericParams, "from-literal") delete(genericParams, "from-literal")

View File

@ -54,29 +54,29 @@ func (s RoleBindingGeneratorV1) Generate(genericParams map[string]interface{}) (
return nil, err return nil, err
} }
delegate := &RoleBindingGeneratorV1{} delegate := &RoleBindingGeneratorV1{}
fromFileStrings, found := genericParams["user"] userStrings, found := genericParams["user"]
if found { if found {
fromFileArray, isArray := fromFileStrings.([]string) fromFileArray, isArray := userStrings.([]string)
if !isArray { if !isArray {
return nil, fmt.Errorf("expected []string, found :%v", fromFileStrings) return nil, fmt.Errorf("expected []string, found :%v", userStrings)
} }
delegate.Users = fromFileArray delegate.Users = fromFileArray
delete(genericParams, "user") delete(genericParams, "user")
} }
fromLiteralStrings, found := genericParams["group"] groupStrings, found := genericParams["group"]
if found { if found {
fromLiteralArray, isArray := fromLiteralStrings.([]string) fromLiteralArray, isArray := groupStrings.([]string)
if !isArray { if !isArray {
return nil, fmt.Errorf("expected []string, found :%v", fromFileStrings) return nil, fmt.Errorf("expected []string, found :%v", groupStrings)
} }
delegate.Groups = fromLiteralArray delegate.Groups = fromLiteralArray
delete(genericParams, "group") delete(genericParams, "group")
} }
fromSAStrings, found := genericParams["serviceaccount"] saStrings, found := genericParams["serviceaccount"]
if found { if found {
fromLiteralArray, isArray := fromSAStrings.([]string) fromLiteralArray, isArray := saStrings.([]string)
if !isArray { if !isArray {
return nil, fmt.Errorf("expected []string, found :%v", fromFileStrings) return nil, fmt.Errorf("expected []string, found :%v", saStrings)
} }
delegate.ServiceAccounts = fromLiteralArray delegate.ServiceAccounts = fromLiteralArray
delete(genericParams, "serviceaccount") delete(genericParams, "serviceaccount")

View File

@ -68,7 +68,7 @@ func (s SecretGeneratorV1) Generate(genericParams map[string]interface{}) (runti
if found { if found {
fromLiteralArray, isArray := fromLiteralStrings.([]string) fromLiteralArray, isArray := fromLiteralStrings.([]string)
if !isArray { if !isArray {
return nil, fmt.Errorf("expected []string, found :%v", fromFileStrings) return nil, fmt.Errorf("expected []string, found :%v", fromLiteralStrings)
} }
delegate.LiteralSources = fromLiteralArray delegate.LiteralSources = fromLiteralArray
delete(genericParams, "from-literal") delete(genericParams, "from-literal")