File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed
Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -2855,7 +2855,7 @@ func validateCreateScanFlags(cmd *cobra.Command) error {
28552855}
28562856
28572857func validateContainerImageFormat (containerImage string ) error {
2858- pattern := regexp .MustCompile (`^(?:[a-zA-Z0-9.-]+(?::[0-9]+)?/)?(?:[a-z0-9]+(?:[._-][a-z0-9]+)*/)*[a-z0-9]+(?:[._-][a-z0-9]+)*(?:: [\w][\w.-]{0,127})? $` )
2858+ pattern := regexp .MustCompile (`^(?:[a-zA-Z0-9.-]+(?::[0-9]+)?/)?(?:[a-z0-9]+(?:[._-][a-z0-9]+)*/)*[a-z0-9]+(?:[._-][a-z0-9]+)*: [\w][\w.-]{0,127}$` )
28592859
28602860 matched := pattern .MatchString (containerImage )
28612861
Original file line number Diff line number Diff line change @@ -1598,6 +1598,11 @@ func TestValidateContainerImageFormat(t *testing.T) {
15981598 containerImage : "service.test.whatever.image:8443/service/registries:custom-value" ,
15991599 expectedError : nil ,
16001600 },
1601+ {
1602+ name : "Valid container image format" ,
1603+ containerImage : "nginx" ,
1604+ expectedError : errors .Errorf ("Invalid value for --container-images flag. The value must be in the format <image-name>:<image-tag>" ),
1605+ },
16011606 {
16021607 name : "Missing image name" ,
16031608 containerImage : ":latest" ,
You can’t perform that action at this time.
0 commit comments