mirror of
https://github.com/siderolabs/talos.git
synced 2026-05-05 12:26:21 +02:00
chore: tag aws snapshots created via ci with the image name
This is to make them more easily identifiable for clean up if required. Signed-off-by: Andrew Longwill <andrew.longwill@siderolabs.com>
This commit is contained in:
parent
06ef7108a6
commit
bfc57fb863
@ -259,6 +259,24 @@ func (au *AWSUploader) registerAMI(ctx context.Context, region string, svc *ec2.
|
||||
return g.Wait()
|
||||
}
|
||||
|
||||
//nolint:gocyclo
|
||||
func (au *AWSUploader) tagSnapshot(ctx context.Context, svc *ec2.Client, snapshotID, imageName string) {
|
||||
if snapshotID == "" {
|
||||
return
|
||||
}
|
||||
|
||||
_, tagErr := svc.CreateTags(ctx, &ec2.CreateTagsInput{
|
||||
Resources: []string{snapshotID},
|
||||
Tags: []types.Tag{{
|
||||
Key: pointer.To("Name"),
|
||||
Value: pointer.To(imageName),
|
||||
}},
|
||||
})
|
||||
if tagErr != nil {
|
||||
log.Printf("WARNING: failed to tag snapshot %s: %v", snapshotID, tagErr)
|
||||
}
|
||||
}
|
||||
|
||||
//nolint:gocyclo
|
||||
func (au *AWSUploader) registerAMIArch(ctx context.Context, region string, svc *ec2.Client, arch, bucketName string, uploader *manager.Uploader) error {
|
||||
err := retry.Constant(30*time.Minute, retry.WithUnits(time.Second), retry.WithErrorLogging(true)).RetryWithContext(ctx, func(ctx context.Context) error {
|
||||
@ -359,6 +377,8 @@ func (au *AWSUploader) registerAMIArch(ctx context.Context, region string, svc *
|
||||
imageName = fmt.Sprintf("%s-%s-%s-%s", au.Options.NamePrefix, au.Options.Tag, region, arch)
|
||||
}
|
||||
|
||||
au.tagSnapshot(ctx, svc, snapshotID, imageName)
|
||||
|
||||
imageResp, err := svc.DescribeImages(ctx, &ec2.DescribeImagesInput{
|
||||
Filters: []types.Filter{
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user