From 8aea623e32a4145f29ad566fb0a03066103e72e8 Mon Sep 17 00:00:00 2001 From: Preslav Date: Fri, 29 Sep 2023 11:56:17 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20Apply=20root-level=20asset=20lab?= =?UTF-8?q?els=20to=20inventory=20assets.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- providers/assets.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/providers/assets.go b/providers/assets.go index 4312e121c5..081ff2974a 100644 --- a/providers/assets.go +++ b/providers/assets.go @@ -19,7 +19,17 @@ func ProcessAssetCandidates(runtime *Runtime, connectRes *pp.ConnectRes, upstrea return []*inventory.Asset{connectRes.Asset}, nil } else { logger.DebugDumpJSON("inventory-resolved", connectRes.Inventory) - assetCandidates = connectRes.Inventory.Spec.Assets + // We want to apply all root asset labels to the inventory assets. We could also do this + // per provider, but we'd have to apply the same logic in all providers. + for _, a := range connectRes.Inventory.Spec.Assets { + for k, v := range connectRes.Asset.Labels { + if a.Labels == nil { + a.Labels = map[string]string{} + } + a.Labels[k] = v + } + assetCandidates = append(assetCandidates, a) + } } log.Debug().Msgf("resolved %d assets", len(assetCandidates))