Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add repo field to docker build-info artifacts #1211

Merged
merged 7 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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),
OriginalRepo: 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),
OriginalRepo: 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
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ require (
gopkg.in/warnings.v0 v0.1.2 // indirect
)

// replace github.com/jfrog/jfrog-client-go => github.com/eyalbe4/jfrog-client-go v1.28.1-0.20240723132744-93aab0ffffb1
replace github.com/jfrog/jfrog-client-go => github.com/sverdlov93/jfrog-client-go v1.0.2-0.20240724085647-94b9df5a8185

// 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/RobiNino/build-info-go v1.0.1-0.20240723103322-50a393657f06

// replace github.com/jfrog/gofrog => github.com/jfrog/gofrog v1.3.3-0.20231223133729-ef57bd08cedc
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78=
github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0=
github.com/RobiNino/build-info-go v1.0.1-0.20240723103322-50a393657f06 h1:6ISlVsUZw8Mfqh353/O1gew1yPil0SWxR0u3xozxGN0=
github.com/RobiNino/build-info-go v1.0.1-0.20240723103322-50a393657f06/go.mod h1:EruGjHPKelWgQzTPyWzF+xuoo2iWzAPNzk5l+Pa50Ho=
github.com/VividCortex/ewma v1.2.0 h1:f58SaIzcDXrSy3kWaHNvuJgJ3Nmz59Zji6XoJR/q1ow=
github.com/VividCortex/ewma v1.2.0/go.mod h1:nz4BbCtbLyFDeC9SUHbtcT5644juEuWfUAUnGx7j5l4=
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8=
Expand Down Expand Up @@ -92,12 +94,8 @@ 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.43.0 h1:0A4zT8ZIpAwtEUICNhKPx1bwM1LocJN9C38IGycS7UY=
github.com/jfrog/jfrog-client-go v1.43.0/go.mod h1:1RklAq1rNS3HmIsJ+BM3tEn9XHZuTAs37JtVUpefUk4=
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 @@ -198,6 +196,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/sverdlov93/jfrog-client-go v1.0.2-0.20240724085647-94b9df5a8185 h1:u6VIZQQRGC0liku02VBYOVEAdkmrUFNkJAu2HBQWwsY=
github.com/sverdlov93/jfrog-client-go v1.0.2-0.20240724085647-94b9df5a8185/go.mod h1:Ac2Ynr/680lhEZEq1wJP4bP+RvrKIblgryZzgLuZjKo=
github.com/terminalstatic/go-xsd-validate v0.1.5 h1:RqpJnf6HGE2CB/lZB1A8BYguk8uRtcvYAPLCF15qguo=
github.com/terminalstatic/go-xsd-validate v0.1.5/go.mod h1:18lsvYFofBflqCrvo1umpABZ99+GneNTw2kEEc8UPJw=
github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
Expand Down
Loading