From c0b53e2f25099f77f42869da777c24f3293f5c56 Mon Sep 17 00:00:00 2001 From: Enzo Date: Mon, 10 May 2021 13:30:21 +0200 Subject: [PATCH] fix: tagging vpc --- charts/pleco/Chart.yaml | 4 ++-- charts/pleco/values.yaml | 2 +- cmd/version.go | 2 +- providers/aws/vpc/vpc.go | 38 ++++++++++++++------------------------ utils/utils.go | 2 +- 5 files changed, 19 insertions(+), 29 deletions(-) diff --git a/charts/pleco/Chart.yaml b/charts/pleco/Chart.yaml index cda80bd..bd43940 100644 --- a/charts/pleco/Chart.yaml +++ b/charts/pleco/Chart.yaml @@ -3,6 +3,6 @@ name: pleco description: Automatically removes Cloud managed services and Kubernetes resources based on tags with TTL type: application home: https://github.com/Qovery/pleco -version: 0.7.11 -appVersion: 0.7.11 +version: 0.7.12 +appVersion: 0.7.12 icon: https://github.com/Qovery/pleco/raw/main/assets/pleco_logo.png diff --git a/charts/pleco/values.yaml b/charts/pleco/values.yaml index 271cd3e..9a20ac8 100644 --- a/charts/pleco/values.yaml +++ b/charts/pleco/values.yaml @@ -3,7 +3,7 @@ replicaCount: 1 image: repository: qoveryrd/pleco pullPolicy: IfNotPresent - plecoImageTag: "0.7.11" + plecoImageTag: "0.7.12" environmentVariables: LOG_LEVEL: "info" diff --git a/cmd/version.go b/cmd/version.go index 9851c2e..449f6a1 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -19,5 +19,5 @@ func init() { } func GetCurrentVersion() string { - return "0.7.11" // ci-version-check + return "0.7.12" // ci-version-check } diff --git a/providers/aws/vpc/vpc.go b/providers/aws/vpc/vpc.go index a4dd641..1b7ff5b 100644 --- a/providers/aws/vpc/vpc.go +++ b/providers/aws/vpc/vpc.go @@ -129,30 +129,20 @@ func deleteVPC(ec2Session ec2.EC2, VpcList []VpcInfo, dryRun bool) error { region := *ec2Session.Config.Region for _, vpc := range VpcList { - DeleteSecurityGroupsByIds(ec2Session,vpc.SecurityGroups) - DeleteInternetGatewaysByIds(ec2Session, vpc.InternetGateways) - DeleteSubnetsByIds(ec2Session, vpc.Subnets) - DeleteRouteTablesByIds(ec2Session, vpc.RouteTables) - - _, err := ec2Session.DeleteVpc( - &ec2.DeleteVpcInput{ - VpcId: aws.String(*vpc.VpcId), - }, - ) - if err != nil { - // ignore errors, certainly due to dependencies that are not yet removed - log.Warnf("Can't delete VPC %s in %s yet: %s", *vpc.VpcId, region, err.Error()) - } - } - - _, err := ec2Session.DeleteVpc( - &ec2.DeleteVpcInput{ - VpcId: aws.String(*VpcList[0].VpcId), - }, - ) - if err != nil { - // ignore errors, certainly due to dependencies that are not yet removed - log.Warnf("Can't delete VPC %s in %s yet: %s", *VpcList[1].VpcId, region, err.Error()) + DeleteSecurityGroupsByIds(ec2Session,vpc.SecurityGroups) + DeleteInternetGatewaysByIds(ec2Session, vpc.InternetGateways) + DeleteSubnetsByIds(ec2Session, vpc.Subnets) + DeleteRouteTablesByIds(ec2Session, vpc.RouteTables) + + _, err := ec2Session.DeleteVpc( + &ec2.DeleteVpcInput{ + VpcId: aws.String(*vpc.VpcId), + }, + ) + if err != nil { + // ignore errors, certainly due to dependencies that are not yet removed + log.Warnf("Can't delete VPC %s in %s yet: %s", *vpc.VpcId, region, err.Error()) + } } return nil diff --git a/utils/utils.go b/utils/utils.go index d5540d4..b4f1b86 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -98,7 +98,7 @@ func GetEssentialTags(tagsInput interface{}, tagName string) (time.Time, int64, func CheckIfExpired(creationTime time.Time, ttl int64) bool { expirationTime := creationTime.Add(time.Duration(ttl) * time.Second) - if ttl == 0 || creationTime == time.Date(1970, 01, 01, 00, 00, 00, 0000, time.UTC) || creationTime == time.Date(0001, 01, 01, 00, 00, 00, 0000, time.UTC){ + if ttl == 0 || creationTime == time.Date(1970, 01, 01, 01, 00, 00, 0000, time.UTC) || creationTime == time.Date(0001, 01, 01, 00, 00, 00, 0000, time.UTC){ return false } return time.Now().After(expirationTime)