Skip to content

Commit

Permalink
Merge pull request #63 from OpsHelmInc/update-ebs-snapshopts
Browse files Browse the repository at this point in the history
update ebs snapshot fetching to use paginator
  • Loading branch information
kylemcc authored Dec 16, 2023
2 parents fc6846f + deea8ad commit 0984ecd
Show file tree
Hide file tree
Showing 354 changed files with 515 additions and 502 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.51.2
version: v1.55.2
args: --timeout=5m
10 changes: 9 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ run:
- all

linters-settings:
gofmt:
rewrite-rules:
- pattern: 'interface{}'
replacement: 'any'
errcheck:
check-blank: false
ignore: fmt:.*,[rR]ead|[wW]rite|[cC]lose,io:Copy
Expand Down Expand Up @@ -64,12 +68,15 @@ linters-settings:
disabled: true
- name: nested-structs
disabled: true
- name: unchecked-type-assertion
disabled: true
- name: import-alias-naming
disabled: true

linters:
enable:
- asciicheck
- bodyclose
- depguard
- dupl
- errcheck
- gocritic
Expand All @@ -94,6 +101,7 @@ issues:
linters:
- dupl
- gocritic
- revive
# Exclude some linters from running on resource files.
- path: resources(\\|\/).*\.go
linters:
Expand Down
2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ func filterDisabledRegions(regions []string, enabledRegions []types.Region) []st
return filteredRegions
}

func (a AwsLogger) Logf(classification logging.Classification, format string, v ...interface{}) {
func (a AwsLogger) Logf(classification logging.Classification, format string, v ...any) {
if classification == logging.Warn {
a.l.Warn().Msg(fmt.Sprintf(format, v...))
} else {
Expand Down
10 changes: 5 additions & 5 deletions client/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
type AWSService string

type AwsService struct {
Regions map[string]*map[string]interface{} `json:"regions"`
Regions map[string]*map[string]any `json:"regions"`
}

type AwsPartition struct {
Expand All @@ -34,10 +34,10 @@ type SupportedServiceRegionsData struct {
}

// ListResolver is responsible for iterating through entire list of resources that should be grabbed (if API is paginated). It should send list of items via the `resultsChan` so that the DetailResolver can grab the details of each item. All errors should be sent to the error channel.
type ListResolverFunc func(ctx context.Context, meta schema.ClientMeta, detailChan chan<- interface{}) error
type ListResolverFunc func(ctx context.Context, meta schema.ClientMeta, detailChan chan<- any) error

// DetailResolveFunc is responsible for grabbing any and all metadata for a resource. All errors should be sent to the error channel.
type DetailResolverFunc func(ctx context.Context, meta schema.ClientMeta, resultsChan chan<- interface{}, errorChan chan<- error, summary interface{})
type DetailResolverFunc func(ctx context.Context, meta schema.ClientMeta, resultsChan chan<- any, errorChan chan<- error, summary any)

const (
ApigatewayService AWSService = "apigateway"
Expand Down Expand Up @@ -342,7 +342,7 @@ func IsAWSError(err error, code ...string) bool {
}

// TagsIntoMap expects []T (usually "[]Tag") where T has "Key" and "Value" fields (of type string or *string) and writes them into the given map
func TagsIntoMap(tagSlice interface{}, dst map[string]string) {
func TagsIntoMap(tagSlice any, dst map[string]string) {
stringify := func(v reflect.Value) string {
vt := v.Type()
if vt.Kind() == reflect.String {
Expand Down Expand Up @@ -386,7 +386,7 @@ func TagsIntoMap(tagSlice interface{}, dst map[string]string) {
}

// TagsToMap expects []T (usually "[]Tag") where T has "Key" and "Value" fields (of type string or *string) and returns a map
func TagsToMap(tagSlice interface{}) map[string]string {
func TagsToMap(tagSlice any) map[string]string {
if k := reflect.TypeOf(tagSlice).Kind(); k != reflect.Slice {
panic("invalid usage: Only slices are supported as input: " + k.String())
}
Expand Down
4 changes: 2 additions & 2 deletions client/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestResolveARN(t *testing.T) {
service AWSService
resourceID func(resource *schema.Resource) ([]string, error)
resource *schema.Resource
want interface{}
want any
wantErr bool
}{
{
Expand Down Expand Up @@ -83,7 +83,7 @@ func TestTagsToMap(t *testing.T) {
}

tests := []struct {
Input interface{}
Input any
Expected map[string]string
}{
{
Expand Down
2 changes: 1 addition & 1 deletion client/resolvers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

func TestResolveTags(t *testing.T) {
cases := []struct {
InputItem interface{}
InputItem any
ExpectedTags map[string]string
}{
{
Expand Down
6 changes: 3 additions & 3 deletions resources/services/accessanalyzer/analyzers_fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/cloudquery/plugin-sdk/schema"
)

func fetchAccessanalyzerAnalyzers(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
func fetchAccessanalyzerAnalyzers(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
config := accessanalyzer.ListAnalyzersInput{}
c := meta.(*client.Client)
svc := c.Services().Accessanalyzer
Expand Down Expand Up @@ -44,7 +44,7 @@ func fetchAccessanalyzerAnalyzers(ctx context.Context, meta schema.ClientMeta, p
return nil
}

func fetchAccessanalyzerAnalyzerFindings(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
func fetchAccessanalyzerAnalyzerFindings(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
analyzer := parent.Item.(types.AnalyzerSummary)
c := meta.(*client.Client)
svc := c.Services().Accessanalyzer
Expand All @@ -66,7 +66,7 @@ func fetchAccessanalyzerAnalyzerFindings(ctx context.Context, meta schema.Client
return nil
}

func fetchAccessanalyzerAnalyzerArchiveRules(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
func fetchAccessanalyzerAnalyzerArchiveRules(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
analyzer := parent.Item.(types.AnalyzerSummary)
c := meta.(*client.Client)
svc := c.Services().Accessanalyzer
Expand Down
2 changes: 1 addition & 1 deletion resources/services/account/alternate_contacts_fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/cloudquery/plugin-sdk/schema"
)

func fetchAccountAlternateContacts(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
func fetchAccountAlternateContacts(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
cl := meta.(*client.Client)
svc := cl.Services().Account
var contactTypes types.AlternateContactType
Expand Down
2 changes: 1 addition & 1 deletion resources/services/account/contacts_fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/cloudquery/plugin-sdk/schema"
)

func fetchAccountContacts(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
func fetchAccountContacts(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
cl := meta.(*client.Client)
svc := cl.Services().Account
var input account.GetContactInformationInput
Expand Down
2 changes: 1 addition & 1 deletion resources/services/acm/certificates_fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/cloudquery/plugin-sdk/schema"
)

func fetchAcmCertificates(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
func fetchAcmCertificates(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
cl := meta.(*client.Client)
svc := cl.Services().Acm
var input acm.ListCertificatesInput
Expand Down
2 changes: 1 addition & 1 deletion resources/services/apigateway/api_keys_fetch.go
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/cloudquery/plugin-sdk/schema"
)

func fetchApigatewayApiKeys(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
func fetchApigatewayApiKeys(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
config := apigateway.GetApiKeysInput{
IncludeValues: aws.Bool(true),
}
Expand Down
2 changes: 1 addition & 1 deletion resources/services/apigateway/client_certificates_fetch.go
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/cloudquery/plugin-sdk/schema"
)

func fetchApigatewayClientCertificates(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
func fetchApigatewayClientCertificates(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
var config apigateway.GetClientCertificatesInput
c := meta.(*client.Client)
svc := c.Services().Apigateway
Expand Down
4 changes: 2 additions & 2 deletions resources/services/apigateway/domain_names_fetch.go
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/cloudquery/plugin-sdk/schema"
)

func fetchApigatewayDomainNames(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
func fetchApigatewayDomainNames(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
var config apigateway.GetDomainNamesInput
c := meta.(*client.Client)
svc := c.Services().Apigateway
Expand All @@ -36,7 +36,7 @@ func resolveApigatewayDomainNameArn(ctx context.Context, meta schema.ClientMeta,
Resource: fmt.Sprintf("/domainnames/%s", aws.ToString(domain.DomainName)),
}.String())
}
func fetchApigatewayDomainNameBasePathMappings(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
func fetchApigatewayDomainNameBasePathMappings(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
r := parent.Item.(types.DomainName)
c := meta.(*client.Client)
svc := c.Services().Apigateway
Expand Down
20 changes: 10 additions & 10 deletions resources/services/apigateway/rest_apis_fetch.go
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/cloudquery/plugin-sdk/schema"
)

func fetchApigatewayRestApis(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
func fetchApigatewayRestApis(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
var config apigateway.GetRestApisInput
c := meta.(*client.Client)
svc := c.Services().Apigateway
Expand All @@ -36,7 +36,7 @@ func resolveApigatewayRestAPIArn(ctx context.Context, meta schema.ClientMeta, re
Resource: fmt.Sprintf("/restapis/%s", aws.ToString(rapi.Id)),
}.String())
}
func fetchApigatewayRestApiAuthorizers(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
func fetchApigatewayRestApiAuthorizers(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
r := parent.Item.(types.RestApi)
c := meta.(*client.Client)
svc := c.Services().Apigateway
Expand Down Expand Up @@ -69,7 +69,7 @@ func resolveApigatewayRestAPIAuthorizerArn(ctx context.Context, meta schema.Clie
Resource: fmt.Sprintf("/restapis/%s/authorizers/%s", aws.ToString(rapi.Id), aws.ToString(auth.Id)),
}.String())
}
func fetchApigatewayRestApiDeployments(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
func fetchApigatewayRestApiDeployments(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
r := parent.Item.(types.RestApi)
c := meta.(*client.Client)
svc := c.Services().Apigateway
Expand Down Expand Up @@ -98,7 +98,7 @@ func resolveApigatewayRestAPIDeploymentArn(ctx context.Context, meta schema.Clie
Resource: fmt.Sprintf("/restapis/%s/deployments/%s", aws.ToString(rapi.Id), aws.ToString(d.Id)),
}.String())
}
func fetchApigatewayRestApiDocumentationParts(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
func fetchApigatewayRestApiDocumentationParts(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
r := parent.Item.(types.RestApi)
c := meta.(*client.Client)
svc := c.Services().Apigateway
Expand Down Expand Up @@ -131,7 +131,7 @@ func resolveApigatewayRestAPIDocumentationPartArn(ctx context.Context, meta sche
Resource: fmt.Sprintf("/restapis/%s/documentation/parts/%s", aws.ToString(rapi.Id), aws.ToString(d.Id)),
}.String())
}
func fetchApigatewayRestApiDocumentationVersions(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
func fetchApigatewayRestApiDocumentationVersions(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
r := parent.Item.(types.RestApi)
c := meta.(*client.Client)
svc := c.Services().Apigateway
Expand Down Expand Up @@ -164,7 +164,7 @@ func resolveApigatewayRestAPIDocumentationVersionArn(ctx context.Context, meta s
Resource: fmt.Sprintf("/restapis/%s/documentation/versions/%s", aws.ToString(rapi.Id), aws.ToString(v.Version)),
}.String())
}
func fetchApigatewayRestApiGatewayResponses(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
func fetchApigatewayRestApiGatewayResponses(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
r := parent.Item.(types.RestApi)
c := meta.(*client.Client)
svc := c.Services().Apigateway
Expand Down Expand Up @@ -197,7 +197,7 @@ func resolveApigatewayRestAPIGatewayResponseArn(ctx context.Context, meta schema
Resource: fmt.Sprintf("/restapis/%s/gatewayresponses/%s", aws.ToString(rapi.Id), string(r.ResponseType)),
}.String())
}
func fetchApigatewayRestApiModels(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
func fetchApigatewayRestApiModels(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
r := parent.Item.(types.RestApi)
c := meta.(*client.Client)
svc := c.Services().Apigateway
Expand Down Expand Up @@ -257,7 +257,7 @@ func resolveApigatewayRestAPIModelModelTemplate(ctx context.Context, meta schema
}
return resource.Set(c.Name, response.Value)
}
func fetchApigatewayRestApiRequestValidators(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
func fetchApigatewayRestApiRequestValidators(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
r := parent.Item.(types.RestApi)
c := meta.(*client.Client)
svc := c.Services().Apigateway
Expand Down Expand Up @@ -290,7 +290,7 @@ func resolveApigatewayRestAPIRequestValidatorArn(ctx context.Context, meta schem
Resource: fmt.Sprintf("/restapis/%s/requestvalidators/%s", aws.ToString(rapi.Id), aws.ToString(r.Id)),
}.String())
}
func fetchApigatewayRestApiResources(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
func fetchApigatewayRestApiResources(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
r := parent.Item.(types.RestApi)
c := meta.(*client.Client)
svc := c.Services().Apigateway
Expand Down Expand Up @@ -319,7 +319,7 @@ func resolveApigatewayRestAPIResourceArn(ctx context.Context, meta schema.Client
Resource: fmt.Sprintf("/restapis/%s/resources/%s", aws.ToString(rapi.Id), aws.ToString(r.Id)),
}.String())
}
func fetchApigatewayRestApiStages(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
func fetchApigatewayRestApiStages(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
r := parent.Item.(types.RestApi)
c := meta.(*client.Client)
svc := c.Services().Apigateway
Expand Down
4 changes: 2 additions & 2 deletions resources/services/apigateway/usage_plans_fetch.go
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/cloudquery/plugin-sdk/schema"
)

func fetchApigatewayUsagePlans(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
func fetchApigatewayUsagePlans(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
var config apigateway.GetUsagePlansInput
c := meta.(*client.Client)
svc := c.Services().Apigateway
Expand All @@ -36,7 +36,7 @@ func resolveApigatewayUsagePlanArn(ctx context.Context, meta schema.ClientMeta,
Resource: fmt.Sprintf("/usageplans/%s", aws.ToString(up.Id)),
}.String())
}
func fetchApigatewayUsagePlanKeys(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
func fetchApigatewayUsagePlanKeys(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
r := parent.Item.(types.UsagePlan)
c := meta.(*client.Client)
svc := c.Services().Apigateway
Expand Down
2 changes: 1 addition & 1 deletion resources/services/apigateway/vpc_links_fetch.go
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/cloudquery/plugin-sdk/schema"
)

func fetchApigatewayVpcLinks(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
func fetchApigatewayVpcLinks(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- any) error {
var config apigateway.GetVpcLinksInput
c := meta.(*client.Client)
svc := c.Services().Apigateway
Expand Down
Loading

0 comments on commit 0984ecd

Please sign in to comment.