Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Golang capitalization #55

Merged
merged 5 commits into from
Dec 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Do you really want to nuke the account with the ID 000000000000 and the alias 'a
Do you want to continue? Enter account alias to continue.
> aws-nuke-example

eu-west-1 - EC2DhcpOption - 'dopt-bf2ec3d8' - would remove
eu-west-1 - EC2DHCPOption - 'dopt-bf2ec3d8' - would remove
eu-west-1 - EC2Instance - 'i-01b489457a60298dd' - would remove
eu-west-1 - EC2KeyPair - 'test' - would remove
eu-west-1 - EC2NetworkACL - 'acl-6482a303' - cannot delete default VPC
Expand All @@ -91,7 +91,7 @@ eu-west-1 - EC2SecurityGroup - 'sg-220e945a' - cannot delete group 'default'
eu-west-1 - EC2SecurityGroup - 'sg-f20f958a' - would remove
eu-west-1 - EC2Subnet - 'subnet-154d844e' - would remove
eu-west-1 - EC2Volume - 'vol-0ddfb15461a00c3e2' - would remove
eu-west-1 - EC2Vpc - 'vpc-c6159fa1' - would remove
eu-west-1 - EC2VPC - 'vpc-c6159fa1' - would remove
eu-west-1 - IAMUserAccessKey - 'my-user -> ABCDEFGHIJKLMNOPQRST' - would remove
eu-west-1 - IAMUserPolicyAttachment - 'my-user -> AdministratorAccess' - would remove
eu-west-1 - IAMUser - 'my-user' - would remove
Expand Down Expand Up @@ -132,7 +132,7 @@ Do you really want to nuke the account with the ID 000000000000 and the alias 'a
Do you want to continue? Enter account alias to continue.
> aws-nuke-example

eu-west-1 - EC2DhcpOption - 'dopt-bf2ec3d8' - would remove
eu-west-1 - EC2DHCPOption - 'dopt-bf2ec3d8' - would remove
eu-west-1 - EC2Instance - 'i-01b489457a60298dd' - would remove
eu-west-1 - EC2KeyPair - 'test' - would remove
eu-west-1 - EC2NetworkACL - 'acl-6482a303' - cannot delete default VPC
Expand All @@ -141,7 +141,7 @@ eu-west-1 - EC2SecurityGroup - 'sg-220e945a' - cannot delete group 'default'
eu-west-1 - EC2SecurityGroup - 'sg-f20f958a' - would remove
eu-west-1 - EC2Subnet - 'subnet-154d844e' - would remove
eu-west-1 - EC2Volume - 'vol-0ddfb15461a00c3e2' - would remove
eu-west-1 - EC2Vpc - 'vpc-c6159fa1' - would remove
eu-west-1 - EC2VPC - 'vpc-c6159fa1' - would remove
eu-west-1 - IAMUserAccessKey - 'my-user -> ABCDEFGHIJKLMNOPQRST' - filtered by config
eu-west-1 - IAMUserPolicyAttachment - 'my-user -> AdministratorAccess' - filtered by config
eu-west-1 - IAMUser - 'my-user' - filtered by config
Expand All @@ -151,7 +151,7 @@ Do you really want to nuke these resources on the account with the ID 0000000000
Do you want to continue? Enter account alias to continue.
> aws-nuke-example

eu-west-1 - EC2DhcpOption - 'dopt-bf2ec3d8' - DependencyViolation: The dhcpOptions 'dopt-bf2ec3d8' has dependencies and cannot be deleted.
eu-west-1 - EC2DHCPOption - 'dopt-bf2ec3d8' - DependencyViolation: The dhcpOptions 'dopt-bf2ec3d8' has dependencies and cannot be deleted.
status code: 400, request id: 9665c066-6bb1-4643-9071-f03481f80d4e
eu-west-1 - EC2Instance - 'i-01b489457a60298dd' - triggered remove
eu-west-1 - EC2KeyPair - 'test' - triggered remove
Expand All @@ -163,12 +163,12 @@ eu-west-1 - EC2Subnet - 'subnet-154d844e' - DependencyViolation: The subnet 'sub
status code: 400, request id: 237186aa-b035-4f64-a6e3-518bed64e240
eu-west-1 - EC2Volume - 'vol-0ddfb15461a00c3e2' - VolumeInUse: Volume vol-0ddfb15461a00c3e2 is currently attached to i-01b489457a60298dd
status code: 400, request id: f88ff792-a17f-4fdd-9219-78a937a8d058
eu-west-1 - EC2Vpc - 'vpc-c6159fa1' - DependencyViolation: The vpc 'vpc-c6159fa1' has dependencies and cannot be deleted.
eu-west-1 - EC2VPC - 'vpc-c6159fa1' - DependencyViolation: The vpc 'vpc-c6159fa1' has dependencies and cannot be deleted.
eu-west-1 - S3Object - 's3://rebuy-terraform-state-138758637120/run-terraform.lock' - triggered remove

Removal requested: 2 waiting, 6 failed, 5 skipped, 0 finished

eu-west-1 - EC2DhcpOption - 'dopt-bf2ec3d8' - DependencyViolation: The dhcpOptions 'dopt-bf2ec3d8' has dependencies and cannot be deleted.
eu-west-1 - EC2DHCPOption - 'dopt-bf2ec3d8' - DependencyViolation: The dhcpOptions 'dopt-bf2ec3d8' has dependencies and cannot be deleted.
status code: 400, request id: d85d26e8-9f6f-42f0-811a-3b05471b0254
eu-west-1 - EC2Instance - 'i-01b489457a60298dd' - waiting
eu-west-1 - EC2KeyPair - 'test' - removed
Expand All @@ -180,7 +180,7 @@ eu-west-1 - EC2Subnet - 'subnet-154d844e' - DependencyViolation: The subnet 'sub
status code: 400, request id: ba0649ba-3be8-41ee-ae0f-6b74a1f0a873
eu-west-1 - EC2Volume - 'vol-0ddfb15461a00c3e2' - VolumeInUse: Volume vol-0ddfb15461a00c3e2 is currently attached to i-01b489457a60298dd
status code: 400, request id: 9ac3eac5-f1ef-4337-a780-228295a7ebc7
eu-west-1 - EC2Vpc - 'vpc-c6159fa1' - DependencyViolation: The vpc 'vpc-c6159fa1' has dependencies and cannot be deleted.
eu-west-1 - EC2VPC - 'vpc-c6159fa1' - DependencyViolation: The vpc 'vpc-c6159fa1' has dependencies and cannot be deleted.
status code: 400, request id: 89f870e9-1ffa-42be-9f73-76c29f088e1a

Removal requested: 1 waiting, 6 failed, 5 skipped, 1 finished
Expand Down
4 changes: 2 additions & 2 deletions cmd/nuke.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (n *Nuke) ValidateAccount() error {
if !n.Config.HasBlacklist() {
return fmt.Errorf("The config file contains an empty blacklist. " +
"For safety reasons you need to specify at least one account ID. " +
"This should be you production account.")
"This should be your production account.")
}

if n.Config.InBlacklist(accountID) {
Expand All @@ -189,7 +189,7 @@ func (n *Nuke) ValidateAccount() error {

for _, alias := range aliases {
if strings.Contains(strings.ToLower(*alias), "prod") {
return fmt.Errorf("You are trying to nuke a account with the alias '%s', "+
return fmt.Errorf("You are trying to nuke an account with the alias '%s', "+
"but it has the substring 'prod' in it. Aborting.", *aliases[0])
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func NewRootCommand() *cobra.Command {
"limit nuking to certain resource types (eg IAMServerCertificate)")
command.PersistentFlags().BoolVar(
&params.NoDryRun, "no-dry-run", false,
"actualy delete found resources")
"actually delete found resources")
command.PersistentFlags().BoolVar(
&params.Force, "force", false,
"don't ask for confirmation")
Expand Down
10 changes: 5 additions & 5 deletions resources/ec2-dhcp-options.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package resources

import "github.com/aws/aws-sdk-go/service/ec2"

type EC2DhcpOption struct {
type EC2DHCPOption struct {
svc *ec2.EC2
id *string
}

func (n *EC2Nuke) ListDhcpOptions() ([]Resource, error) {
func (n *EC2Nuke) ListDHCPOptions() ([]Resource, error) {
resp, err := n.Service.DescribeDhcpOptions(nil)
if err != nil {
return nil, err
Expand All @@ -16,7 +16,7 @@ func (n *EC2Nuke) ListDhcpOptions() ([]Resource, error) {
resources := make([]Resource, 0)
for _, out := range resp.DhcpOptions {

resources = append(resources, &EC2DhcpOption{
resources = append(resources, &EC2DHCPOption{
svc: n.Service,
id: out.DhcpOptionsId,
})
Expand All @@ -25,7 +25,7 @@ func (n *EC2Nuke) ListDhcpOptions() ([]Resource, error) {
return resources, nil
}

func (e *EC2DhcpOption) Remove() error {
func (e *EC2DHCPOption) Remove() error {
params := &ec2.DeleteDhcpOptionsInput{
DhcpOptionsId: e.id,
}
Expand All @@ -38,6 +38,6 @@ func (e *EC2DhcpOption) Remove() error {
return nil
}

func (e *EC2DhcpOption) String() string {
func (e *EC2DHCPOption) String() string {
return *e.id
}
12 changes: 6 additions & 6 deletions resources/ec2-nat-gateways.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import (
"github.com/aws/aws-sdk-go/service/ec2"
)

type EC2NatGateway struct {
type EC2NATGateway struct {
svc *ec2.EC2
id string
state string
}

func (n *EC2Nuke) ListNatGateways() ([]Resource, error) {
func (n *EC2Nuke) ListNATGateways() ([]Resource, error) {
params := &ec2.DescribeNatGatewaysInput{}
resp, err := n.Service.DescribeNatGateways(params)
if err != nil {
Expand All @@ -21,7 +21,7 @@ func (n *EC2Nuke) ListNatGateways() ([]Resource, error) {

resources := make([]Resource, 0)
for _, out := range resp.NatGateways {
resources = append(resources, &EC2NatGateway{
resources = append(resources, &EC2NATGateway{
svc: n.Service,
id: *out.NatGatewayId,
state: *out.State,
Expand All @@ -31,14 +31,14 @@ func (n *EC2Nuke) ListNatGateways() ([]Resource, error) {
return resources, nil
}

func (n *EC2NatGateway) Filter() error {
func (n *EC2NATGateway) Filter() error {
if n.state == "deleted" {
return fmt.Errorf("already deleted")
}
return nil
}

func (n *EC2NatGateway) Remove() error {
func (n *EC2NATGateway) Remove() error {
params := &ec2.DeleteNatGatewayInput{
NatGatewayId: &n.id,
}
Expand All @@ -51,6 +51,6 @@ func (n *EC2NatGateway) Remove() error {
return nil
}

func (n *EC2NatGateway) String() string {
func (n *EC2NATGateway) String() string {
return n.id
}
10 changes: 5 additions & 5 deletions resources/ec2-vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ package resources

import "github.com/aws/aws-sdk-go/service/ec2"

type EC2Vpc struct {
type EC2VPC struct {
svc *ec2.EC2
id *string
}

func (n *EC2Nuke) ListVpcs() ([]Resource, error) {
func (n *EC2Nuke) ListVPCs() ([]Resource, error) {
resp, err := n.Service.DescribeVpcs(nil)
if err != nil {
return nil, err
}

resources := make([]Resource, 0)
for _, vpc := range resp.Vpcs {
resources = append(resources, &EC2Vpc{
resources = append(resources, &EC2VPC{
svc: n.Service,
id: vpc.VpcId,
})
Expand All @@ -24,7 +24,7 @@ func (n *EC2Nuke) ListVpcs() ([]Resource, error) {
return resources, nil
}

func (e *EC2Vpc) Remove() error {
func (e *EC2VPC) Remove() error {
params := &ec2.DeleteVpcInput{
VpcId: e.id,
}
Expand All @@ -37,6 +37,6 @@ func (e *EC2Vpc) Remove() error {
return nil
}

func (e *EC2Vpc) String() string {
func (e *EC2VPC) String() string {
return *e.id
}
10 changes: 5 additions & 5 deletions resources/ec2-vpcEndpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ package resources

import "github.com/aws/aws-sdk-go/service/ec2"

type EC2VpcEndpoint struct {
type EC2VPCEndpoint struct {
svc *ec2.EC2
id *string
}

func (n *EC2Nuke) ListVpcEndpoints() ([]Resource, error) {
func (n *EC2Nuke) ListVPCEndpoints() ([]Resource, error) {
resp, err := n.Service.DescribeVpcEndpoints(nil)
if err != nil {
return nil, err
}

resources := make([]Resource, 0)
for _, vpcEndpoint := range resp.VpcEndpoints {
resources = append(resources, &EC2VpcEndpoint{
resources = append(resources, &EC2VPCEndpoint{
svc: n.Service,
id: vpcEndpoint.VpcEndpointId,
})
Expand All @@ -24,7 +24,7 @@ func (n *EC2Nuke) ListVpcEndpoints() ([]Resource, error) {
return resources, nil
}

func (endpoint *EC2VpcEndpoint) Remove() error {
func (endpoint *EC2VPCEndpoint) Remove() error {
params := &ec2.DeleteVpcEndpointsInput{
VpcEndpointIds: []*string{endpoint.id},
}
Expand All @@ -37,6 +37,6 @@ func (endpoint *EC2VpcEndpoint) Remove() error {
return nil
}

func (endpoint *EC2VpcEndpoint) String() string {
func (endpoint *EC2VPCEndpoint) String() string {
return *endpoint.id
}
12 changes: 6 additions & 6 deletions resources/ec2-vpn-connections.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import (
"github.com/aws/aws-sdk-go/service/ec2"
)

type EC2VpnConnection struct {
type EC2VPNConnection struct {
svc *ec2.EC2
id string
state string
}

func (n *EC2Nuke) ListVpnConnections() ([]Resource, error) {
func (n *EC2Nuke) ListVPNConnections() ([]Resource, error) {
params := &ec2.DescribeVpnConnectionsInput{}
resp, err := n.Service.DescribeVpnConnections(params)
if err != nil {
Expand All @@ -21,7 +21,7 @@ func (n *EC2Nuke) ListVpnConnections() ([]Resource, error) {

resources := make([]Resource, 0)
for _, out := range resp.VpnConnections {
resources = append(resources, &EC2VpnConnection{
resources = append(resources, &EC2VPNConnection{
svc: n.Service,
id: *out.VpnConnectionId,
state: *out.State,
Expand All @@ -31,14 +31,14 @@ func (n *EC2Nuke) ListVpnConnections() ([]Resource, error) {
return resources, nil
}

func (v *EC2VpnConnection) Filter() error {
func (v *EC2VPNConnection) Filter() error {
if v.state == "deleted" {
return fmt.Errorf("already deleted")
}
return nil
}

func (v *EC2VpnConnection) Remove() error {
func (v *EC2VPNConnection) Remove() error {
params := &ec2.DeleteVpnConnectionInput{
VpnConnectionId: &v.id,
}
Expand All @@ -51,6 +51,6 @@ func (v *EC2VpnConnection) Remove() error {
return nil
}

func (v *EC2VpnConnection) String() string {
func (v *EC2VPNConnection) String() string {
return v.id
}
12 changes: 6 additions & 6 deletions resources/ec2-vpn-gateway-attachments.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import (
"github.com/aws/aws-sdk-go/service/ec2"
)

type EC2VpnGatewayAttachment struct {
type EC2VPNGatewayAttachment struct {
svc *ec2.EC2
vpcId string
vpnId string
state string
}

func (n *EC2Nuke) ListVpnGatewayAttachments() ([]Resource, error) {
func (n *EC2Nuke) ListVPNGatewayAttachments() ([]Resource, error) {

resp, err := n.Service.DescribeVpnGateways(nil)
if err != nil {
Expand All @@ -24,7 +24,7 @@ func (n *EC2Nuke) ListVpnGatewayAttachments() ([]Resource, error) {

for _, vgw := range resp.VpnGateways {
for _, att := range vgw.VpcAttachments {
resources = append(resources, &EC2VpnGatewayAttachment{
resources = append(resources, &EC2VPNGatewayAttachment{
svc: n.Service,
vpcId: *att.VpcId,
vpnId: *vgw.VpnGatewayId,
Expand All @@ -36,14 +36,14 @@ func (n *EC2Nuke) ListVpnGatewayAttachments() ([]Resource, error) {
return resources, nil
}

func (v *EC2VpnGatewayAttachment) Filter() error {
func (v *EC2VPNGatewayAttachment) Filter() error {
if v.state == "detached" {
return fmt.Errorf("already detached")
}
return nil
}

func (v *EC2VpnGatewayAttachment) Remove() error {
func (v *EC2VPNGatewayAttachment) Remove() error {
params := &ec2.DetachVpnGatewayInput{
VpcId: &v.vpcId,
VpnGatewayId: &v.vpnId,
Expand All @@ -57,6 +57,6 @@ func (v *EC2VpnGatewayAttachment) Remove() error {
return nil
}

func (v *EC2VpnGatewayAttachment) String() string {
func (v *EC2VPNGatewayAttachment) String() string {
return fmt.Sprintf("%s -> %s", v.vpnId, v.vpcId)
}
Loading