diff --git a/gcp/compute/firewalls.go b/gcp/compute/firewalls.go index 6ec16ba5..f427d3ef 100644 --- a/gcp/compute/firewalls.go +++ b/gcp/compute/firewalls.go @@ -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 } diff --git a/gcp/compute/firewalls_test.go b/gcp/compute/firewalls_test.go index fcdedc8a..d55e6e60 100644 --- a/gcp/compute/firewalls_test.go +++ b/gcp/compute/firewalls_test.go @@ -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