Merge pull request #63417 from smarterclayton/map_string

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

FlagMaps may be nil (prior to being initialized)

Do not panic if they haven't been set yet.

Fixes: #64090
This commit is contained in:
Kubernetes Submit Queue 2018-05-24 20:32:26 -07:00 committed by GitHub
commit 4c227ab821
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -39,6 +39,9 @@ func NewMapStringBool(m *map[string]bool) *MapStringBool {
// String implements github.com/spf13/pflag.Value
func (m *MapStringBool) String() string {
if m == nil || m.Map == nil {
return ""
}
pairs := []string{}
for k, v := range *m.Map {
pairs = append(pairs, fmt.Sprintf("%s=%t", k, v))

View File

@ -50,6 +50,9 @@ func NewMapStringStringNoSplit(m *map[string]string) *MapStringString {
// String implements github.com/spf13/pflag.Value
func (m *MapStringString) String() string {
if m == nil || m.Map == nil {
return ""
}
pairs := []string{}
for k, v := range *m.Map {
pairs = append(pairs, fmt.Sprintf("%s=%s", k, v))