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

Commit

Permalink
Add formatting check to GitHub Actions (#1063)
Browse files Browse the repository at this point in the history
* Add formatting check to GitHub Actions

* Fix pre-existing formatting issues
  • Loading branch information
der-eismann authored Aug 2, 2023
1 parent 34899fb commit 47fc6c7
Show file tree
Hide file tree
Showing 23 changed files with 114 additions and 109 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ jobs:
go install golang.org/x/lint/golint@latest
- name: Checkout code
uses: actions/checkout@v3
- name: Check Formatting
run: |
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
echo "### Go formatting is off, please execute 'gofmt -w -s .' - see following diff: ###"
gofmt -s -d .
exit 1
fi
- name: Test Project
run: |
make test
Expand Down
2 changes: 1 addition & 1 deletion resources/batch-computeenvironments.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func ListBatchComputeEnvironments(sess *session.Session) ([]Resource, error) {

for _, computeEnvironment := range output.ComputeEnvironments {
resources = append(resources, &BatchComputeEnvironment{
svc: svc,
svc: svc,
computeEnvironmentName: computeEnvironment.ComputeEnvironmentName,
})
}
Expand Down
4 changes: 2 additions & 2 deletions resources/batch-computeenvironmentstates.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ func ListBatchComputeEnvironmentStates(sess *session.Session) ([]Resource, error

for _, computeEnvironment := range output.ComputeEnvironments {
resources = append(resources, &BatchComputeEnvironmentState{
svc: svc,
svc: svc,
computeEnvironmentName: computeEnvironment.ComputeEnvironmentName,
state: computeEnvironment.State,
state: computeEnvironment.State,
})
}

Expand Down
10 changes: 5 additions & 5 deletions resources/billing-costandusagereports.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ func ListBillingCostandUsageReports(sess *session.Session) ([]Resource, error) {
resources := []Resource{}
for _, report := range reports {
resources = append(resources, &BillingCostandUsageReport{
svc: svc,
reportName: report.ReportName,
s3Bucket: report.S3Bucket,
s3Prefix: report.S3Prefix,
s3Region: report.S3Region,
svc: svc,
reportName: report.ReportName,
s3Bucket: report.S3Bucket,
s3Prefix: report.S3Prefix,
s3Region: report.S3Region,
})
}

Expand Down
76 changes: 38 additions & 38 deletions resources/cloudfront-origin-access-identities.go
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
package resources

import (
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/cloudfront"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/cloudfront"
"github.com/rebuy-de/aws-nuke/v2/pkg/types"
)

type CloudFrontOriginAccessIdentity struct {
svc *cloudfront.CloudFront
ID *string
svc *cloudfront.CloudFront
ID *string
}

func init() {
register("CloudFrontOriginAccessIdentity", ListCloudFrontOriginAccessIdentities)
register("CloudFrontOriginAccessIdentity", ListCloudFrontOriginAccessIdentities)
}

func ListCloudFrontOriginAccessIdentities(sess *session.Session) ([]Resource, error) {
svc := cloudfront.New(sess)
resources := []Resource{}

for {
resp, err := svc.ListCloudFrontOriginAccessIdentities(nil)
if err != nil {
return nil, err
}

for _, item := range resp.CloudFrontOriginAccessIdentityList.Items {
resources = append(resources,&CloudFrontOriginAccessIdentity{
svc: svc,
ID: item.Id,
})
}
return resources, nil
}
svc := cloudfront.New(sess)
resources := []Resource{}

for {
resp, err := svc.ListCloudFrontOriginAccessIdentities(nil)
if err != nil {
return nil, err
}

for _, item := range resp.CloudFrontOriginAccessIdentityList.Items {
resources = append(resources, &CloudFrontOriginAccessIdentity{
svc: svc,
ID: item.Id,
})
}
return resources, nil
}
}

func (f *CloudFrontOriginAccessIdentity) Remove() error {
resp, err := f.svc.GetCloudFrontOriginAccessIdentity(&cloudfront.GetCloudFrontOriginAccessIdentityInput{
Id: f.ID,
})
if err != nil {
return err
}

_, err = f.svc.DeleteCloudFrontOriginAccessIdentity(&cloudfront.DeleteCloudFrontOriginAccessIdentityInput{
Id: f.ID,
IfMatch: resp.ETag,
})

return err
resp, err := f.svc.GetCloudFrontOriginAccessIdentity(&cloudfront.GetCloudFrontOriginAccessIdentityInput{
Id: f.ID,
})
if err != nil {
return err
}

_, err = f.svc.DeleteCloudFrontOriginAccessIdentity(&cloudfront.DeleteCloudFrontOriginAccessIdentityInput{
Id: f.ID,
IfMatch: resp.ETag,
})

return err
}

func (f *CloudFrontOriginAccessIdentity) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("ID", f.ID)
return properties
properties := types.NewProperties()
properties.Set("ID", f.ID)
return properties
}
17 changes: 8 additions & 9 deletions resources/codestar-connections.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
)

type CodeStarConnection struct {
svc *codestarconnections.CodeStarConnections
connectionARN *string
connectionName *string
providerType *string
svc *codestarconnections.CodeStarConnections
connectionARN *string
connectionName *string
providerType *string
}

func init() {
Expand All @@ -34,10 +34,10 @@ func ListCodeStarConnections(sess *session.Session) ([]Resource, error) {

for _, connection := range output.Connections {
resources = append(resources, &CodeStarConnection{
svc: svc,
connectionARN: connection.ConnectionArn,
connectionName: connection.ConnectionName,
providerType: connection.ProviderType,
svc: svc,
connectionARN: connection.ConnectionArn,
connectionName: connection.ConnectionName,
providerType: connection.ProviderType,
})
}

Expand Down Expand Up @@ -68,7 +68,6 @@ func (f *CodeStarConnection) Properties() types.Properties {
return properties
}


func (f *CodeStarConnection) String() string {
return *f.connectionName
}
2 changes: 1 addition & 1 deletion resources/configservice-configurationrecorders.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func ListConfigServiceConfigurationRecorders(sess *session.Session) ([]Resource,
resources := make([]Resource, 0)
for _, configurationRecorder := range resp.ConfigurationRecorders {
resources = append(resources, &ConfigServiceConfigurationRecorder{
svc: svc,
svc: svc,
configurationRecorderName: configurationRecorder.Name,
})
}
Expand Down
2 changes: 1 addition & 1 deletion resources/dax-subnetgroups.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package resources

import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/dax"
"fmt"
)

type DAXSubnetGroup struct {
Expand Down
19 changes: 9 additions & 10 deletions resources/dynamodb-tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ func ListDynamoDBTables(sess *session.Session) ([]Resource, error) {
}

resources = append(resources, &DynamoDBTable{
svc: svc,
id: *tableName,
svc: svc,
id: *tableName,
tags: tags,
})
}
Expand Down Expand Up @@ -65,7 +65,7 @@ func GetTableTags(svc *dynamodb.DynamoDB, tableName *string) ([]*dynamodb.Tag, e
return make([]*dynamodb.Tag, 0), err
}

tags, err := svc.ListTagsOfResource(&dynamodb.ListTagsOfResourceInput{
tags, err := svc.ListTagsOfResource(&dynamodb.ListTagsOfResourceInput{
ResourceArn: result.Table.TableArn,
})

Expand All @@ -77,17 +77,16 @@ func GetTableTags(svc *dynamodb.DynamoDB, tableName *string) ([]*dynamodb.Tag, e
}

func (i *DynamoDBTable) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("Identifier", i.id)
properties := types.NewProperties()
properties.Set("Identifier", i.id)

for _, tag := range i.tags {
properties.SetTag(tag.Key, tag.Value)
}
for _, tag := range i.tags {
properties.SetTag(tag.Key, tag.Value)
}

return properties
return properties
}


func (i *DynamoDBTable) String() string {
return i.id
}
8 changes: 4 additions & 4 deletions resources/ec2-vpn-connections.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
)

type EC2VPNConnection struct {
svc *ec2.EC2
conn *ec2.VpnConnection
svc *ec2.EC2
conn *ec2.VpnConnection
}

func init() {
Expand All @@ -29,8 +29,8 @@ func ListEC2VPNConnections(sess *session.Session) ([]Resource, error) {
resources := make([]Resource, 0)
for _, out := range resp.VpnConnections {
resources = append(resources, &EC2VPNConnection{
svc: svc,
conn: out,
svc: svc,
conn: out,
})
}

Expand Down
2 changes: 1 addition & 1 deletion resources/iam-policies.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package resources

import (
"github.com/sirupsen/logrus"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/iam"
"github.com/rebuy-de/aws-nuke/v2/pkg/types"
"github.com/sirupsen/logrus"
)

type IAMPolicy struct {
Expand Down
24 changes: 12 additions & 12 deletions resources/rds-clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ func ListRDSClusters(sess *session.Session) ([]Resource, error) {
resources := make([]Resource, 0)
for _, instance := range resp.DBClusters {
tags, err := svc.ListTagsForResource(&rds.ListTagsForResourceInput{
ResourceName: instance.DBClusterArn,
})
ResourceName: instance.DBClusterArn,
})

if err != nil {
continue
}
if err != nil {
continue
}

resources = append(resources, &RDSDBCluster{
svc: svc,
Expand All @@ -49,7 +49,7 @@ func ListRDSClusters(sess *session.Session) ([]Resource, error) {
}

func (i *RDSDBCluster) Remove() error {
if (i.deletionProtection) {
if i.deletionProtection {
modifyParams := &rds.ModifyDBClusterInput{
DBClusterIdentifier: &i.id,
DeletionProtection: aws.Bool(false),
Expand Down Expand Up @@ -78,13 +78,13 @@ func (i *RDSDBCluster) String() string {
}

func (i *RDSDBCluster) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("Identifier", i.id)
properties := types.NewProperties()
properties.Set("Identifier", i.id)
properties.Set("Deletion Protection", i.deletionProtection)

for _, tag := range i.tags {
properties.SetTag(tag.Key, tag.Value)
}
for _, tag := range i.tags {
properties.SetTag(tag.Key, tag.Value)
}

return properties
return properties
}
10 changes: 5 additions & 5 deletions resources/rds-dbclusterparametergroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ func ListRDSClusterParameterGroups(sess *session.Session) ([]Resource, error) {
var resources []Resource
for _, parametergroup := range resp.DBClusterParameterGroups {
tags, err := svc.ListTagsForResource(&rds.ListTagsForResourceInput{
ResourceName: parametergroup.DBClusterParameterGroupArn,
})
ResourceName: parametergroup.DBClusterParameterGroupArn,
})

if err != nil {
continue
}
if err != nil {
continue
}

resources = append(resources, &RDSDBClusterParameterGroup{
svc: svc,
Expand Down
22 changes: 11 additions & 11 deletions resources/rds-subnets.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ func ListRDSSubnetGroups(sess *session.Session) ([]Resource, error) {
var resources []Resource
for _, subnetGroup := range resp.DBSubnetGroups {
tags, err := svc.ListTagsForResource(&rds.ListTagsForResourceInput{
ResourceName: subnetGroup.DBSubnetGroupArn,
})
ResourceName: subnetGroup.DBSubnetGroupArn,
})

if err != nil {
continue
}
if err != nil {
continue
}

resources = append(resources, &RDSDBSubnetGroup{
svc: svc,
Expand Down Expand Up @@ -64,12 +64,12 @@ func (i *RDSDBSubnetGroup) String() string {
}

func (i *RDSDBSubnetGroup) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("Name", i.name)
properties := types.NewProperties()
properties.Set("Name", i.name)

for _, tag := range i.tags {
properties.SetTag(tag.Key, tag.Value)
}
for _, tag := range i.tags {
properties.SetTag(tag.Key, tag.Value)
}

return properties
return properties
}
2 changes: 1 addition & 1 deletion resources/redshift-subnetgroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func ListRedshiftSubnetGroups(sess *session.Session) ([]Resource, error) {

for _, subnetGroup := range output.ClusterSubnetGroups {
resources = append(resources, &RedshiftSubnetGroup{
svc: svc,
svc: svc,
clusterSubnetGroupName: subnetGroup.ClusterSubnetGroupName,
})
}
Expand Down
Loading

0 comments on commit 47fc6c7

Please sign in to comment.