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

fix: managed images annotation whitespace handling (#186) #188

Merged
merged 1 commit into from
Sep 15, 2023
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 internal/models/argo.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func extractManagedImages(annotations map[string]string) (map[string]string, err
if !strings.Contains(image, "=") {
return nil, fmt.Errorf("invalid format for %s annotation", managedImagesAnnotation)
}
managedImage := strings.Split(image, "=")
managedImage := strings.Split(strings.TrimSpace(image), "=")
managedImages[managedImage[0]] = managedImage[1]
}
}
Expand Down
30 changes: 30 additions & 0 deletions internal/models/argo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,36 @@ func TestExtractManagedImages(t *testing.T) {
"alias2": "image2",
},
},
{
name: "Extracts multiple managed images with whitespace in alias",
annotation: map[string]string{
managedImagesAnnotation: "alias1=image1, alias2=image2",
},
expected: map[string]string{
"alias1": "image1",
"alias2": "image2",
},
},
{
name: "Extracts multiple managed images with whitespace in image",
annotation: map[string]string{
managedImagesAnnotation: "alias1=image1 ,alias2=image2",
},
expected: map[string]string{
"alias1": "image1",
"alias2": "image2",
},
},
{
name: "Extracts multiple managed images with whitespace in alias and image",
annotation: map[string]string{
managedImagesAnnotation: "alias1=image1 , alias2=image2",
},
expected: map[string]string{
"alias1": "image1",
"alias2": "image2",
},
},
{
name: "Extracts single managed image",
annotation: map[string]string{
Expand Down
Loading