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

Add resource filters to config #74

Merged
merged 4 commits into from
Feb 9, 2018
Merged

Add resource filters to config #74

merged 4 commits into from
Feb 9, 2018

Conversation

svenwltr
Copy link
Member

Closes #54

Unlike proposed in #54, I let the flag named --target. I think my confusion about union and intersection came from the flag name. By naming the flag target it should be more clear how it behaves.

Also I updated the command line flag descriptions.

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

@svenwltr svenwltr self-assigned this Jan 26, 2018
README.md Outdated

If a exclude is defined in any place, then if will be ignored in any case.

**Hint:** You can see all available resources types with this command:
Copy link
Contributor

Choose a reason for hiding this comment

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

resource types

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

README.md Outdated
a resource type must be specified in all places. In other words each
configuration limits the previous ones.

If a exclude is defined in any place, then if will be ignored in any case.
Copy link
Contributor

Choose a reason for hiding this comment

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

an exclude
it will be ignored

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@svenwltr
Copy link
Member Author

bump

bjoernhaeuser
bjoernhaeuser previously approved these changes Jan 30, 2018
README.md Outdated
release. Eventually, every resources should get deleted. You might to restrict
which resources to delete. There are multiple ways to configure this.

One way are filter, which already got mentioned. This requires to know the
Copy link
Member

Choose a reason for hiding this comment

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

filters

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@@ -0,0 +1,39 @@
package types

type Set []string
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you considered using map[string]bool as the underlying data structure? Iterating over it would be less intuitive, but it would give a uniqueness guarantee. Possibly use a custom iterator function?

For initialization you could create a constructor which accepts []string. That would allow making sure that the resulting set will not have duplicate entries.

Copy link
Member Author

Choose a reason for hiding this comment

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

Using a map also has these two downsides:

  • We need a constructor, which currently isn't required (which I like).
  • Since our lovely golang map gets shuffled all the time, we get non-deterministic results (ie resources get nuked in a different order every time).

Copy link
Contributor

Choose a reason for hiding this comment

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

Valid points. It feels rather odd though to have a data structure called "set", which does not adhere to the properties of a set.
If I am not mistaken, Set{"foo", "foo"}.Remove(Set{"foo"}) would return Set{"foo"}

Copy link
Member Author

Choose a reason for hiding this comment

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

With the current implementation it would remove both.

I am not eager to implement something just to match a name. We can rename it, if you suggest a better name.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh yeah, you are totally right, it would remove both. Sorry about that.

Hmm..., naming things is hard ... how about LazySet. What do you think? It would imply it is not quite a super strict set but it certainly is a set. Feel free to stick with Set if you prefer.

Copy link
Member Author

Choose a reason for hiding this comment

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

"lazy" always makes me think of lazy loading. What about Collection to remove any implication from the name?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good idea! I like it.

Copy link
Member Author

Choose a reason for hiding this comment

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

renamed

}

func (s Set) Union(o Set) Set {
return Set(append(s, o...))
Copy link
Contributor

Choose a reason for hiding this comment

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

This would create duplicate entries in the set. Do you actually need it?

Copy link
Member Author

Choose a reason for hiding this comment

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

feixd

@@ -0,0 +1,39 @@
package types
Copy link
Contributor

Choose a reason for hiding this comment

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

I would probably call it set.go

Copy link
Member Author

Choose a reason for hiding this comment

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

fiexd

@@ -4,8 +4,18 @@ regions:
account-blacklist:
- 1234567890

resource-types:
target:
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider having two examples, one with a blacklist and another one with a whitelist.

Copy link
Member Author

Choose a reason for hiding this comment

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

fxeid

cmd/config.go Outdated
"gopkg.in/yaml.v2"
)

type ResourceConfig struct {
Targets types.Set `yaml:"targets"`
Excludes types.Set `yaml:"excludes"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be yaml:"target" and yaml:"exclude" ?

Copy link
Member Author

Choose a reason for hiding this comment

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

IMO not, since you specify a list.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

fexid

README.md Outdated
a resource type must be specified in all places. In other words each
configuration limits the previous ones.

If an exclude is defined in any place, then it will be ignored in any case.
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider being more explicit, along the lines of:

If an exclude is used, then all its resource types will not be deleted.

Copy link
Member Author

Choose a reason for hiding this comment

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

fxied

@svenwltr
Copy link
Member Author

svenwltr commented Feb 1, 2018

bump

README.md Outdated
### Specifying Resource Types to Delete

*aws-nuke* deletes a lot of resources and there might be added more at any
release. Eventually, every resources should get deleted. You might to restrict
Copy link
Contributor

Choose a reason for hiding this comment

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

"you might want to restrict" ?

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@svenwltr svenwltr merged commit 44434a3 into master Feb 9, 2018
@svenwltr svenwltr deleted the improve-filters branch February 9, 2018 16:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants