@@ -2,16 +2,16 @@ package helm
22
33import (
44 "fmt"
5- "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/ocicontainer"
6- artutils "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
7- "strings"
8-
95 "github.com/jfrog/build-info-go/entities"
106 ioutils "github.com/jfrog/gofrog/io"
7+ "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/ocicontainer"
8+ artutils "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
119 "github.com/jfrog/jfrog-client-go/artifactory"
1210 "github.com/jfrog/jfrog-client-go/artifactory/services"
1311 servicesUtils "github.com/jfrog/jfrog-client-go/artifactory/services/utils"
12+ "github.com/jfrog/jfrog-client-go/utils/io/content"
1413 "github.com/jfrog/jfrog-client-go/utils/log"
14+ "strings"
1515)
1616
1717type manifest struct {
@@ -76,7 +76,7 @@ func addOCILayersForDependency(dep entities.Dependency, serviceManager artifacto
7676 return
7777 }
7878 searchPattern := fmt .Sprintf ("%s/%s/*" , repoName , versionPath )
79- resultMap , err := searchDependencyOCIFilesByPath (serviceManager , searchPattern )
79+ resultMap , err := searchDependencyOCIFilesByPath (serviceManager , searchPattern , "" )
8080 if err != nil {
8181 log .Debug ("Failed to search OCI artifacts for dependency " , dep .Id , " : " , err )
8282 return
@@ -108,7 +108,6 @@ func addOCILayersForDependency(dep entities.Dependency, serviceManager artifacto
108108 for _ , depLayer := range dependencyLayers {
109109 * processedDependencies = append (* processedDependencies , entities.Dependency {
110110 Id : depLayer .Name ,
111- Type : depLayer .Type ,
112111 Repository : depLayer .Repo ,
113112 Checksum : entities.Checksum {
114113 Sha1 : depLayer .Actual_Sha1 ,
@@ -184,7 +183,7 @@ func searchClassicHelmChart(serviceManager artifactory.ArtifactoryServicesManage
184183}
185184
186185// searchDependencyOCIFilesByPath searches for OCI artifacts using a search pattern
187- func searchDependencyOCIFilesByPath (serviceManager artifactory.ArtifactoryServicesManager , searchPattern string ) (map [string ]* servicesUtils.ResultItem , error ) {
186+ func searchDependencyOCIFilesByPath (serviceManager artifactory.ArtifactoryServicesManager , searchPattern string , buildProperties string ) (map [string ]* servicesUtils.ResultItem , error ) {
188187 log .Debug ("Searching for OCI artifacts with pattern: " , searchPattern )
189188 searchParams := services .NewSearchParams ()
190189 searchParams .Pattern = searchPattern
@@ -193,6 +192,9 @@ func searchDependencyOCIFilesByPath(serviceManager artifactory.ArtifactoryServic
193192 if err != nil {
194193 return nil , fmt .Errorf ("failed to search for OCI artifacts: %w" , err )
195194 }
195+ if buildProperties != "" {
196+ addBuildPropertiesOnArtifacts (serviceManager , reader , buildProperties , searchPattern )
197+ }
196198 var closeErr error
197199 defer func () {
198200 if closeErr != nil {
@@ -223,8 +225,30 @@ func getManifest(resultMap map[string]*servicesUtils.ResultItem, serviceManager
223225 return
224226}
225227
228+ func getManifestSha256 (resultMap map [string ]* servicesUtils.ResultItem ) (string , error ) {
229+ if len (resultMap ) == 0 {
230+ return "" , fmt .Errorf ("no manifest found" )
231+ }
232+ manifestResult , ok := resultMap ["manifest.json" ]
233+ if ! ok || manifestResult == nil {
234+ return "" , fmt .Errorf ("no manifest found" )
235+ }
236+ return manifestResult .Sha256 , nil
237+ }
238+
226239// Download the content of layer search result.
227240func downloadLayer (searchResult servicesUtils.ResultItem , result interface {}, serviceManager artifactory.ArtifactoryServicesManager , repo string ) error {
228241 searchResult .Repo = repo
229242 return artutils .RemoteUnmarshal (serviceManager , searchResult .GetItemRelativePath (), result )
230243}
244+
245+ func addBuildPropertiesOnArtifacts (serviceManager artifactory.ArtifactoryServicesManager , reader * content.ContentReader , buildProps , searchPattern string ) {
246+ propsParams := services.PropsParams {
247+ Reader : reader ,
248+ Props : buildProps ,
249+ }
250+ _ , err := serviceManager .SetProps (propsParams )
251+ if err != nil {
252+ log .Warn (fmt .Sprintf ("Failed to set properties on %s: %s" , searchPattern , err ))
253+ }
254+ }
0 commit comments