Skip to content

Commit

Permalink
Add new function to get only external repos urls
Browse files Browse the repository at this point in the history
  • Loading branch information
ncaak committed Aug 3, 2023
1 parent 5c08ac5 commit 4af787f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/gatherers/workloads/gather_workloads_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const (
// None
//
// ### Changes
// None
// - Image repository is now collected if it comes from outside the Red Hat domain
func (g *Gatherer) GatherWorkloadInfo(ctx context.Context) ([]record.Record, []error) {
gatherKubeClient, err := kubernetes.NewForConfig(g.gatherProtoKubeConfig)
if err != nil {
Expand Down Expand Up @@ -509,8 +509,11 @@ func calculateWorkloadInfo(h hash.Hash, image *imagev1.Image) workloadImage {
for _, layer := range image.DockerImageLayers {
layers = append(layers, layer.Name)
}

info := workloadImage{
LayerIDs: layers,
//RepoURL: "quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:5710554c08735126986b7c553cdb9a31bf97071c7adceda20f7aa116f35e867f",
Repository: getExternalImageRepo(image.DockerImageReference),
}

if err := imageutil.ImageWithMetadata(image); err != nil {
Expand Down Expand Up @@ -587,3 +590,11 @@ func workloadImageAdd(imageID string, image workloadImage) {
defer workloadSizeLock.Unlock()
workloadImageLRU.Add(imageID, image)
}

// getExternalImageRepo returns image URLs if they are not from Red Hat domain
func getExternalImageRepo(s string) (repo string) {
if !strings.Contains(s, "redhat") {
repo = s
}
return
}

0 comments on commit 4af787f

Please sign in to comment.