Skip to content

Commit

Permalink
fix: managed images annotation whitespace handling (#186) (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomsozolins authored Sep 15, 2023
1 parent 1ec21d1 commit 8e132d5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
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

0 comments on commit 8e132d5

Please sign in to comment.