Skip to content

Commit

Permalink
Skip default firewalls on gcp.
Browse files Browse the repository at this point in the history
  • Loading branch information
Genevieve LEsperance committed Apr 14, 2018
1 parent 72705ca commit 3271914
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
6 changes: 5 additions & 1 deletion gcp/compute/firewalls.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ func (f Firewalls) List(filter string) ([]common.Deletable, error) {
for _, firewall := range firewalls.Items {
resource := NewFirewall(f.client, firewall.Name)

if !strings.Contains(firewall.Name, filter) {
if strings.Contains(resource.Name(), "default") {
continue
}

if !strings.Contains(resource.Name(), filter) {
continue
}

Expand Down
18 changes: 18 additions & 0 deletions gcp/compute/firewalls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,24 @@ var _ = Describe("Firewalls", func() {
})
})

Context("when the firewall name contains default", func() {
BeforeEach(func() {
client.ListFirewallsCall.Returns.Output = &gcpcompute.FirewallList{
Items: []*gcpcompute.Firewall{{
Name: "default-allow-banana",
}},
}
})

It("does not add it to the list", func() {
list, err := firewalls.List("banana")
Expect(err).NotTo(HaveOccurred())

Expect(logger.PromptWithDetailsCall.CallCount).To(Equal(0))
Expect(list).To(HaveLen(0))
})
})

Context("when the user says no to the prompt", func() {
BeforeEach(func() {
logger.PromptWithDetailsCall.Returns.Proceed = false
Expand Down

0 comments on commit 3271914

Please sign in to comment.