Skip to content

Commit 06d986a

Browse files
authored
Merge branch 'dev' into dockerscan_panic
2 parents 77efcf8 + 9917078 commit 06d986a

File tree

6 files changed

+56
-10
lines changed

6 files changed

+56
-10
lines changed

artifactory/utils/commandsummary/buildinfosummary.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
77
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils/container"
88
"github.com/jfrog/jfrog-client-go/utils/log"
9+
"net/url"
910
"path"
1011
"strings"
1112
)
@@ -249,16 +250,16 @@ func isSupportedModule(module *buildInfo.Module) bool {
249250
}
250251

251252
func createDockerMultiArchTitle(module *buildInfo.Module) string {
252-
parentImageName := strings.Split(module.Parent, ":")[0]
253-
var sha256 string
254-
for _, artifact := range module.Artifacts {
255-
if artifact.Name == container.ManifestJsonFile {
256-
sha256 = artifact.Sha256
257-
break
258-
}
259-
}
260253
if StaticMarkdownConfig.IsExtendedSummary() {
261-
dockerModuleLink := fmt.Sprintf(artifactoryDockerPackagesUiFormat, strings.TrimSuffix(StaticMarkdownConfig.GetPlatformUrl(), "/"), "%2F%2F"+parentImageName, sha256)
254+
parentImageName := strings.Split(module.Parent, ":")[0]
255+
var sha256 string
256+
for _, artifact := range module.Artifacts {
257+
if artifact.Name == container.ManifestJsonFile {
258+
sha256 = artifact.Sha256
259+
break
260+
}
261+
}
262+
dockerModuleLink := fmt.Sprintf(artifactoryDockerPackagesUiFormat, strings.TrimSuffix(StaticMarkdownConfig.GetPlatformUrl(), "/"), "%2F%2F"+url.PathEscape(parentImageName), sha256)
262263
return fmt.Sprintf("%s <a href=%s>(🐸 View)</a>", module.Id, dockerModuleLink)
263264
}
264265
return module.Id

artifactory/utils/container/buildinfo.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,10 @@ func (builder *buildInfoBuilder) createMultiPlatformBuildInfo(fatManifest *FatMa
362362
Properties: imageProperties,
363363
Artifacts: []buildinfo.Artifact{getFatManifestArtifact(searchResultFatManifest)},
364364
}}}
365+
imageLongNameWithoutRepo, err := builder.image.GetImageLongNameWithoutRepoWithTag()
366+
if err != nil {
367+
return nil, err
368+
}
365369
// Create all image arch modules
366370
for _, manifest := range fatManifest.Manifests {
367371
image := candidateImages[manifest.Digest]
@@ -378,7 +382,7 @@ func (builder *buildInfoBuilder) createMultiPlatformBuildInfo(fatManifest *FatMa
378382
Id: getModuleIdByManifest(manifest, baseModuleId),
379383
Type: buildinfo.Docker,
380384
Artifacts: artifacts,
381-
Parent: baseModuleId,
385+
Parent: imageLongNameWithoutRepo,
382386
})
383387
}
384388
return buildInfo, setBuildProperties(builder.buildName, builder.buildNumber, builder.project, builder.imageLayers, builder.serviceManager)

artifactory/utils/container/image.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,21 @@ func (image *Image) GetImageShortNameWithTag() (string, error) {
8686
return imageName, nil
8787
}
8888

89+
// GetImageLongNameWithoutRepoWithTag removes the registry hostname and repository name, returning the organization and image name with the tag.
90+
// e.g., "docker-local/myorg/hello-world:latest" -> "myorg/hello-world:latest"
91+
// e.g., "docker-local/hello-world:latest" -> "hello-world:latest"
92+
func (image *Image) GetImageLongNameWithoutRepoWithTag() (string, error) {
93+
longName, err := image.GetImageLongNameWithTag()
94+
if err != nil {
95+
return "", err
96+
}
97+
parts := strings.Split(longName, "/")
98+
if len(parts) > 1 {
99+
return strings.Join(parts[1:], "/"), nil
100+
}
101+
return longName, nil
102+
}
103+
89104
// Get image tag name of an image.
90105
// e.g.: https://my-registry/docker-local/hello-world:latest. -> latest
91106
func (image *Image) GetImageTag() (string, error) {

artifactory/utils/container/image_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,28 @@ func TestGetImageLongNameWithTag(t *testing.T) {
8282
_, err := NewImage("domain").GetImageLongNameWithTag()
8383
assert.Error(t, err)
8484
}
85+
86+
func TestGetImageLongNameWithoutRepoWithTag(t *testing.T) {
87+
var imageTags = []struct {
88+
in string
89+
expected string
90+
}{
91+
{"domain:8080/repo-name/hello-world:latest", "hello-world:latest"},
92+
{"domain/repo-name/hello-world:latest", "hello-world:latest"},
93+
{"domain/repo-name/org-name/hello-world:latest", "org-name/hello-world:latest"},
94+
{"domain/repo-name/org-name/hello-world", "org-name/hello-world:latest"},
95+
}
96+
97+
for _, v := range imageTags {
98+
result, err := NewImage(v.in).GetImageLongNameWithoutRepoWithTag()
99+
assert.NoError(t, err)
100+
assert.Equal(t, v.expected, result)
101+
}
102+
// Validate failure upon missing image name
103+
_, err := NewImage("domain").GetImageLongNameWithoutRepoWithTag()
104+
assert.Error(t, err)
105+
}
106+
85107
func TestGetImageShortNameWithTag(t *testing.T) {
86108
var imageTags = []struct {
87109
in string

common/commands/configfile.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ func handleInteractiveConfigCreation(configFile *ConfigFile, confType project.Pr
171171
return configFile.configGradle()
172172
case project.Terraform:
173173
return configFile.setDeployer(false)
174+
case project.Cocoapods:
175+
return configFile.setDeployerResolver()
174176
}
175177
return
176178
}

common/project/projectconfig.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const (
3939
Dotnet
4040
Build
4141
Terraform
42+
Cocoapods
4243
)
4344

4445
type ConfigType string
@@ -62,6 +63,7 @@ var ProjectTypes = []string{
6263
"dotnet",
6364
"build",
6465
"terraform",
66+
"cocoapods",
6567
}
6668

6769
func (projectType ProjectType) String() string {

0 commit comments

Comments
 (0)