Skip to content

Commit

Permalink
Merge pull request #30 from Qovery/fix/vpc_tagging
Browse files Browse the repository at this point in the history
fix: tagging vpc
  • Loading branch information
MacLikorne authored May 10, 2021
2 parents 20c5146 + c0b53e2 commit 2bf3dcd
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 29 deletions.
4 changes: 2 additions & 2 deletions charts/pleco/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion charts/pleco/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ replicaCount: 1
image:
repository: qoveryrd/pleco
pullPolicy: IfNotPresent
plecoImageTag: "0.7.11"
plecoImageTag: "0.7.12"

environmentVariables:
LOG_LEVEL: "info"
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ func init() {
}

func GetCurrentVersion() string {
return "0.7.11" // ci-version-check
return "0.7.12" // ci-version-check
}
38 changes: 14 additions & 24 deletions providers/aws/vpc/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2bf3dcd

Please sign in to comment.