From c0464dbbcc7788f62e4c22558f2930675330e2f9 Mon Sep 17 00:00:00 2001 From: Mike Tonks Date: Tue, 3 Dec 2024 09:40:56 +0000 Subject: [PATCH] chore: Add tags to help debugging --- pkg/selector/aws/selector.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/selector/aws/selector.go b/pkg/selector/aws/selector.go index 3c66e62e1f..5a033666f0 100644 --- a/pkg/selector/aws/selector.go +++ b/pkg/selector/aws/selector.go @@ -53,6 +53,9 @@ type Instance struct { SecretName *string EbsVolume *string DeviceName *string + // Tags is only used for debug information + // It is saved to the selector and logged in the id column + Tags map[string]string } func (instance *Instance) Id() string { @@ -96,6 +99,7 @@ func (impl *SelectImpl) Select(ctx context.Context, awsSelector *v1alpha1.AWSSel SecretName: awsSelector.SecretName, EbsVolume: awsSelector.EbsVolume, DeviceName: awsSelector.DeviceName, + Tags: readTags(r.Instances[0].Tags), }) } mode := awsSelector.Mode @@ -109,6 +113,16 @@ func (impl *SelectImpl) Select(ctx context.Context, awsSelector *v1alpha1.AWSSel return filteredInstances, nil } +func readTags(sourceTags []ec2types.Tag) map[string]string { + tags := map[string]string{} + for _, tag := range sourceTags { + if tag.Key != nil && tag.Value != nil { + tags[*tag.Key] = *tag.Value + } + } + return tags +} + type Params struct { fx.In