Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: fix check annotation format #2267

Merged
merged 1 commit into from
Sep 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apis/opts/spec_annotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func ParseAnnotation(annotations []string) (map[string]string, error) {
specAnnotation := make(map[string]string)

for _, annotation := range annotations {
splits := strings.Split(annotation, "=")
splits := strings.SplitN(annotation, "=", 2)
if len(splits) != 2 || splits[0] == "" || splits[1] == "" {
return nil, fmt.Errorf("invalid format for spec annotation: %s, correct format should be key=value, neither should be nil", annotation)
}
Expand Down
3 changes: 2 additions & 1 deletion apis/opts/spec_annotation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ func TestParseAnnotation(t *testing.T) {
{name: "test1", args: args{annotations: []string{""}}, want: nil, wantErr: true},
{name: "test2", args: args{annotations: []string{"=foo"}}, want: nil, wantErr: true},
{name: "test3", args: args{annotations: []string{"key="}}, want: nil, wantErr: true},
{name: "test4", args: args{annotations: []string{"key=foo=bar"}}, want: nil, wantErr: true},
{name: "test4", args: args{annotations: []string{"key=foo=bar"}}, want: map[string]string{"key": "foo=bar"}, wantErr: false},
{name: "test5", args: args{annotations: []string{"foo=bar"}}, want: map[string]string{"foo": "bar"}, wantErr: false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down