Skip to content

Commit 93d0e87

Browse files
tommytroenybelMekksindrerh2
committed
refactor: use environmentmapper for vuln summary
Co-authored-by: ybelmekk <[email protected]> Co-authored-by: sindrerh2 <[email protected]>
1 parent 43c6308 commit 93d0e87

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

internal/vulnerability/queries.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/nais/api/internal/activitylog"
1010
"github.com/nais/api/internal/auth/authz"
11+
"github.com/nais/api/internal/environmentmapper"
1112
"github.com/nais/api/internal/graph/apierror"
1213
"github.com/nais/api/internal/graph/ident"
1314
"github.com/nais/api/internal/graph/model"
@@ -347,7 +348,8 @@ func getFilteredVulnerabilitySummaries(ctx context.Context, s slug.Slug, filter
347348
it := iterator.New(ctx, 100, func(limit, offset int32) (*vulnerabilities.ListVulnerabilitySummariesResponse, error) {
348349
opts := make([]vulnerabilities.Option, 0)
349350
if filter != nil && len(filter.Environments) == 1 {
350-
opts = append(opts, vulnerabilities.ClusterFilter(filter.Environments[0]))
351+
cluster := environmentmapper.ClusterName(filter.Environments[0])
352+
opts = append(opts, vulnerabilities.ClusterFilter(cluster))
351353
}
352354
opts = append(opts, vulnerabilities.NamespaceFilter(s.String()))
353355
opts = append(opts, vulnerabilities.Offset(offset))
@@ -362,15 +364,16 @@ func getFilteredVulnerabilitySummaries(ctx context.Context, s slug.Slug, filter
362364
}
363365

364366
wSum := it.Value()
367+
env := environmentmapper.EnvironmentName(wSum.Workload.Cluster)
365368
if wSum.Workload.Type == "app" {
366-
_, err := application.Get(ctx, s, wSum.Workload.Cluster, wSum.Workload.Name)
369+
_, err := application.Get(ctx, s, env, wSum.Workload.Name)
367370
if err != nil {
368371
continue
369372
}
370373
ret = append(ret, toWorkloadVulnerabilitySummary(wSum))
371374
}
372375
if wSum.Workload.Type == "job" {
373-
_, err := job.Get(ctx, s, wSum.Workload.Cluster, wSum.Workload.Name)
376+
_, err := job.Get(ctx, s, env, wSum.Workload.Name)
374377
if err != nil {
375378
continue
376379
}

0 commit comments

Comments
 (0)