Skip to content

Commit

Permalink
Add repo field to docker build-info artifacts (#1211)
Browse files Browse the repository at this point in the history
  • Loading branch information
sverdlov93 authored Jul 29, 2024
1 parent 2b249c4 commit 9c1dae3
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 25 deletions.
2 changes: 1 addition & 1 deletion artifactory/commands/generic/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func getDownloadParams(f *spec.File, configuration *utils.DownloadConfiguration)
return
}
downParams.Symlink = configuration.Symlink
downParams.MinSplitSizeKb = configuration.MinSplitSizeKb
downParams.MinSplitSize = configuration.MinSplitSize
downParams.SplitCount = configuration.SplitCount
downParams.SkipChecksum = configuration.SkipChecksum

Expand Down
30 changes: 23 additions & 7 deletions artifactory/utils/container/buildinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,33 @@ func writeLayersToFile(layers []utils.ResultItem) (filePath string, err error) {

// Return - manifest artifacts as buildinfo.Artifact struct.
func getManifestArtifact(manifest *utils.ResultItem) (artifact buildinfo.Artifact) {
return buildinfo.Artifact{Name: "manifest.json", Type: "json", Checksum: buildinfo.Checksum{Sha1: manifest.Actual_Sha1, Md5: manifest.Actual_Md5}, Path: path.Join(manifest.Path, manifest.Name)}
return buildinfo.Artifact{
Name: "manifest.json",
Type: "json",
Checksum: buildinfo.Checksum{Sha1: manifest.Actual_Sha1, Md5: manifest.Actual_Md5},
Path: path.Join(manifest.Path, manifest.Name),
OriginalDeploymentRepo: manifest.Repo,
}
}

// Return - fat manifest artifacts as buildinfo.Artifact struct.
func getFatManifestArtifact(fatManifest *utils.ResultItem) (artifact buildinfo.Artifact) {
return buildinfo.Artifact{Name: "list.manifest.json", Type: "json", Checksum: buildinfo.Checksum{Sha1: fatManifest.Actual_Sha1, Md5: fatManifest.Actual_Md5}, Path: path.Join(fatManifest.Path, fatManifest.Name)}
return buildinfo.Artifact{
Name: "list.manifest.json",
Type: "json",
Checksum: buildinfo.Checksum{Sha1: fatManifest.Actual_Sha1, Md5: fatManifest.Actual_Md5},
Path: path.Join(fatManifest.Path, fatManifest.Name),
OriginalDeploymentRepo: fatManifest.Repo,
}
}

// Return - manifest dependency as buildinfo.Dependency struct.
func getManifestDependency(searchResults *utils.ResultItem) (dependency buildinfo.Dependency) {
return buildinfo.Dependency{Id: "manifest.json", Type: "json", Checksum: buildinfo.Checksum{Sha1: searchResults.Actual_Sha1, Md5: searchResults.Actual_Md5}}
return buildinfo.Dependency{
Id: "manifest.json",
Type: "json",
Checksum: buildinfo.Checksum{Sha1: searchResults.Actual_Sha1, Md5: searchResults.Actual_Md5},
}
}

// Read the file which contains the following format: 'IMAGE-TAG-IN-ARTIFACTORY'@sha256'SHA256-OF-THE-IMAGE-MANIFEST'.
Expand Down Expand Up @@ -321,7 +337,7 @@ func (builder *buildInfoBuilder) createBuildInfo(commandType CommandType, manife
}

// Create the image's build info from list.manifest.json.
func (builder *buildInfoBuilder) createMultiPlatformBuildInfo(fatManifest *FatManifest, searchRultFatManifest *utils.ResultItem, candidateimages map[string][]*utils.ResultItem, module string) (*buildinfo.BuildInfo, error) {
func (builder *buildInfoBuilder) createMultiPlatformBuildInfo(fatManifest *FatManifest, searchResultFatManifest *utils.ResultItem, candidateImages map[string][]*utils.ResultItem, module string) (*buildinfo.BuildInfo, error) {
imageProperties := map[string]string{
"docker.image.tag": builder.image.Name(),
}
Expand All @@ -333,17 +349,17 @@ func (builder *buildInfoBuilder) createMultiPlatformBuildInfo(fatManifest *FatMa
module = imageName
}
// Add layers.
builder.imageLayers = append(builder.imageLayers, *searchRultFatManifest)
builder.imageLayers = append(builder.imageLayers, *searchResultFatManifest)
// Create fat-manifest module
buildInfo := &buildinfo.BuildInfo{Modules: []buildinfo.Module{{
Id: module,
Type: buildinfo.Docker,
Properties: imageProperties,
Artifacts: []buildinfo.Artifact{getFatManifestArtifact(searchRultFatManifest)},
Artifacts: []buildinfo.Artifact{getFatManifestArtifact(searchResultFatManifest)},
}}}
// Create all image arch modules
for _, manifest := range fatManifest.Manifests {
image := candidateimages[manifest.Digest]
image := candidateImages[manifest.Digest]
var artifacts []buildinfo.Artifact
for _, layer := range image {
builder.imageLayers = append(builder.imageLayers, *layer)
Expand Down
7 changes: 4 additions & 3 deletions artifactory/utils/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ func CreateDownloadServiceManager(artDetails *config.ServerDetails, threads, htt
}

type DownloadConfiguration struct {
Threads int
SplitCount int
MinSplitSizeKb int64
Threads int
SplitCount int
// Min split size in Kilobytes
MinSplitSize int64
Symlink bool
ValidateSymlink bool
SkipChecksum bool
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/gookit/color v1.5.4
github.com/jedib0t/go-pretty/v6 v6.5.9
github.com/jfrog/build-info-go v1.9.30
github.com/jfrog/gofrog v1.7.4
github.com/jfrog/gofrog v1.7.5
github.com/jfrog/jfrog-client-go v1.43.0
github.com/magiconair/properties v1.8.7
github.com/manifoldco/promptui v0.9.0
Expand All @@ -22,7 +22,7 @@ require (
github.com/stretchr/testify v1.9.0
github.com/urfave/cli v1.22.15
github.com/vbauerster/mpb/v8 v8.7.4
golang.org/x/exp v0.0.0-20240707233637-46b078467d37
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
golang.org/x/mod v0.19.0
golang.org/x/sync v0.7.0
golang.org/x/term v0.22.0
Expand Down Expand Up @@ -96,8 +96,8 @@ require (
gopkg.in/warnings.v0 v0.1.2 // indirect
)

replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20240725183511-4d539d3a7a99
replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20240729103741-f6c521eb9a40

// replace github.com/jfrog/build-info-go => github.com/eyalbe4/build-info-go v1.8.9-0.20240723132035-980d2c84b738
replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20240729055355-5b51bf71e756

// replace github.com/jfrog/gofrog => github.com/jfrog/gofrog v1.3.3-0.20231223133729-ef57bd08cedc
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ github.com/jedib0t/go-pretty/v6 v6.5.9 h1:ACteMBRrrmm1gMsXe9PSTOClQ63IXDUt03H5U+
github.com/jedib0t/go-pretty/v6 v6.5.9/go.mod h1:zbn98qrYlh95FIhwwsbIip0LYpwSG8SUOScs+v9/t0E=
github.com/jfrog/archiver/v3 v3.6.1 h1:LOxnkw9pOn45DzCbZNFV6K0+6dCsQ0L8mR3ZcujO5eI=
github.com/jfrog/archiver/v3 v3.6.1/go.mod h1:VgR+3WZS4N+i9FaDwLZbq+jeU4B4zctXL+gL4EMzfLw=
github.com/jfrog/build-info-go v1.9.30 h1:RmK3NuDGUoyCjCNJJBlHaCm4vWzO8BLjkuAkMzj6PGE=
github.com/jfrog/build-info-go v1.9.30/go.mod h1:fxSfpp+kQ8qln/0y7pgV3tg2exWe5OM1np5FF2LlSDg=
github.com/jfrog/gofrog v1.7.4 h1:on4AeWef5LJUhGCigSjTS4Ez3n9l8+NiZlXH6UYp05c=
github.com/jfrog/gofrog v1.7.4/go.mod h1:jyGiCgiqSSR7k86hcUSu67XVvmvkkgWTmPsH25wI298=
github.com/jfrog/jfrog-client-go v1.28.1-0.20240725183511-4d539d3a7a99 h1:jCfJV5FXOIclSGhRbrTNNFteF27CSb+etW246mewVAk=
github.com/jfrog/jfrog-client-go v1.28.1-0.20240725183511-4d539d3a7a99/go.mod h1:1RklAq1rNS3HmIsJ+BM3tEn9XHZuTAs37JtVUpefUk4=
github.com/jfrog/build-info-go v1.8.9-0.20240729055355-5b51bf71e756 h1:xyZEZDZvg/sLS5PH5b8zFnj6b2XBW4aYHXey0sv+F9I=
github.com/jfrog/build-info-go v1.8.9-0.20240729055355-5b51bf71e756/go.mod h1:fxSfpp+kQ8qln/0y7pgV3tg2exWe5OM1np5FF2LlSDg=
github.com/jfrog/gofrog v1.7.5 h1:dFgtEDefJdlq9cqTRoe09RLxS5Bxbe1Ev5+E6SmZHcg=
github.com/jfrog/gofrog v1.7.5/go.mod h1:jyGiCgiqSSR7k86hcUSu67XVvmvkkgWTmPsH25wI298=
github.com/jfrog/jfrog-client-go v1.28.1-0.20240729103741-f6c521eb9a40 h1:zmh1NwYtbS3GE7jCPWtQpGsTakMo5DHl73BRkZTn6Ag=
github.com/jfrog/jfrog-client-go v1.28.1-0.20240729103741-f6c521eb9a40/go.mod h1:BJqDxNVbs34kuCx9ct6ge3/M39Pf/m5L5IYgZ9p8ap4=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
Expand Down Expand Up @@ -231,8 +231,8 @@ golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2Uz
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
golang.org/x/exp v0.0.0-20240707233637-46b078467d37 h1:uLDX+AfeFCct3a2C7uIWBKMJIR3CJMhcgfrUAqjRK6w=
golang.org/x/exp v0.0.0-20240707233637-46b078467d37/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8=
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8=
Expand Down
4 changes: 2 additions & 2 deletions lifecycle/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ func (rbe *ReleaseBundleExportCommand) downloadReleaseBundle(exportResponse serv
Pattern: strings.TrimPrefix(exportResponse.RelativeUrl, "/"),
Target: rbe.targetPath,
},
MinSplitSizeKb: downloadConfiguration.MinSplitSizeKb,
SplitCount: downloadConfiguration.SplitCount,
MinSplitSize: downloadConfiguration.MinSplitSize,
SplitCount: downloadConfiguration.SplitCount,
}
artifactoryServiceManager, err := createArtifactoryServiceManager(rbe.serverDetails)
if err != nil {
Expand Down

0 comments on commit 9c1dae3

Please sign in to comment.