Skip to content

Commit a814b8d

Browse files
committed
Simplify Docker curation code
1 parent a7b6843 commit a814b8d

File tree

4 files changed

+0
-60
lines changed

4 files changed

+0
-60
lines changed

commands/curation/curationaudit.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,6 @@ func (ca *CurationAuditCommand) checkDockerSupport() (bool, error) {
137137
if dockerImageName == "" {
138138
return false, nil
139139
}
140-
if !strings.Contains(dockerImageName, "/") {
141-
return false, errorutils.CheckErrorf("invalid docker image format: '%s'. Expected format: 'repo/image:tag' or 'repo/path/image:tag'", dockerImageName)
142-
}
143140
return true, nil
144141
}
145142

commands/curation/curationaudit_test.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,36 +1281,6 @@ func Test_getDockerNameScopeAndVersion(t *testing.T) {
12811281
wantScope: "",
12821282
wantVersion: "latest",
12831283
},
1284-
{
1285-
name: "Empty id returns empty values",
1286-
id: "",
1287-
artiUrl: "http://test.jfrog.io/artifactory",
1288-
repo: "docker-remote",
1289-
wantDownloadUrls: nil,
1290-
wantName: "",
1291-
wantScope: "",
1292-
wantVersion: "",
1293-
},
1294-
{
1295-
name: "Without artiUrl and repo, no download URL",
1296-
id: "docker://nginx:1.21.0",
1297-
artiUrl: "",
1298-
repo: "",
1299-
wantDownloadUrls: nil,
1300-
wantName: "nginx",
1301-
wantScope: "",
1302-
wantVersion: "1.21.0",
1303-
},
1304-
{
1305-
name: "Artifactory URL with trailing slash",
1306-
id: "docker://nginx:1.21.0",
1307-
artiUrl: "http://test.jfrog.io/artifactory/",
1308-
repo: "docker-remote",
1309-
wantDownloadUrls: []string{"http://test.jfrog.io/artifactory/api/docker/docker-remote/v2/nginx/manifests/1.21.0"},
1310-
wantName: "nginx",
1311-
wantScope: "",
1312-
wantVersion: "1.21.0",
1313-
},
13141284
}
13151285
for _, tt := range tests {
13161286
t.Run(tt.name, func(t *testing.T) {

sca/bom/buildinfo/technologies/docker/docker.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,7 @@ var (
3030

3131
func ParseDockerImage(imageName string) (*DockerImageInfo, error) {
3232
imageName = strings.TrimSpace(imageName)
33-
if imageName == "" {
34-
return nil, fmt.Errorf("docker image name is required")
35-
}
36-
if idx := strings.Index(imageName, ","); idx > 0 {
37-
imageName = strings.TrimSpace(imageName[:idx])
38-
}
39-
imageName = strings.TrimSuffix(imageName, "/")
40-
4133
info := &DockerImageInfo{Tag: "latest"}
42-
4334
if idx := strings.LastIndex(imageName, ":"); idx > 0 {
4435
afterColon := imageName[idx+1:]
4536
if !strings.Contains(afterColon, "/") {
@@ -56,13 +47,6 @@ func ParseDockerImage(imageName string) (*DockerImageInfo, error) {
5647
info.Registry = parts[0]
5748
info.Repo, info.Image = parseRegistryAndExtract(info.Registry, parts[1:])
5849

59-
if info.Image == "" {
60-
return nil, fmt.Errorf("invalid docker image format: '%s'", imageName)
61-
}
62-
if info.Repo == "" {
63-
return nil, fmt.Errorf("could not determine repository from: '%s'", imageName)
64-
}
65-
6650
log.Debug(fmt.Sprintf("Parsed Docker image - Registry: %s, Repo: %s, Image: %s, Tag: %s",
6751
info.Registry, info.Repo, info.Image, info.Tag))
6852

sca/bom/buildinfo/technologies/docker/docker_test.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,6 @@ func TestParseDockerImage(t *testing.T) {
109109
expectedImg: "nginx",
110110
expectedTag: "latest",
111111
},
112-
// Error cases
113-
{
114-
name: "Empty image name",
115-
imageName: "",
116-
expectError: true,
117-
},
118-
{
119-
name: "No registry",
120-
imageName: "nginx:latest",
121-
expectError: true,
122-
},
123112
}
124113

125114
for _, tt := range tests {

0 commit comments

Comments
 (0)