Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Initial version of tag-based filterring #237

Merged
merged 3 commits into from
Aug 2, 2018

Conversation

nisabek
Copy link
Contributor

@nisabek nisabek commented Aug 1, 2018

@svenwltr - this is what I had in mind. Not sure we need an extra Map for tags...
let me know what you think. @leflamm interesting for you too :)

Copy link
Member

@svenwltr svenwltr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/cc @rebuy-de/prp-aws-nuke

.gitignore Outdated
@@ -2,3 +2,5 @@
/aws-nuke
/aws-nuke-*
.glide
.idea
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not want to add any IDE specific ignores here. Every developer should use any IDE or text editor they want and requiring to update our .gitignore to reflect the use of all the quirky files some IDEs produce would be a cumbersome tasks.

You rather should configure a global gitignore.

@@ -3,7 +3,8 @@ package resources
import (
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/cloudformation"
)
"github.com/rebuy-de/aws-nuke/pkg/types"
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation is wrong. Are you using gofmt?

})
return err
}

func (cfs *CloudFormationStack) Properties() types.Properties {
properties := types.NewProperties()
properties.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting looks also wrong here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove the newline here.

properties.
Set("Name", cfs.stack.StackName)
for _, tagValue := range cfs.stack.Tags {
properties.Set("tag:"+*tagValue.Key, tagValue.Value);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would create a new function in properties for this. Something like properties.SetTag(tagValue.Key, tagValue.Value). This function can then add the tag: prefix.

  1. We can do proper nil checks in SetTag. If Key is nil for some reason the scan will terminate for this resource.
  2. We avoid typos for the prefix.
  3. We get a proper types interface in properties. With this we are able to do more sophisticated stuff inside of Properties without changing every resource. Otherwise we would have to do a prefix check for every property to implement the global include filter.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs say it is *string and not string. If it is nil the dereference *tagValue.Key would cause a panic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it! :)

@nisabek
Copy link
Contributor Author

nisabek commented Aug 1, 2018

@svenwltr thanks for feedback, see update.

Copy link
Member

@svenwltr svenwltr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rebuy-de/prp-aws-nuke Please review.

})
return err
}

func (cfs *CloudFormationStack) Properties() types.Properties {
properties := types.NewProperties()
properties.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove the newline here.

@svenwltr svenwltr merged commit 057edc5 into rebuy-de:master Aug 2, 2018
@svenwltr
Copy link
Member

svenwltr commented Aug 2, 2018

@nisabek Thank you very much for your contribution.

We can now start to add this to other resources and once we have a good coverage we can start to think about the global include feature.

@svenwltr svenwltr added the kind/enhancement New core feature or improvement of existing ones. label Aug 10, 2018
@svenwltr svenwltr mentioned this pull request Sep 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/enhancement New core feature or improvement of existing ones.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants