Merge pull request #822 from cloudskiff/change_Sqs_to_SQS

Change Sqs to SQS typo (except resourceType)
main
William BEUIL 2021-07-08 17:25:11 +02:00 committed by GitHub
commit 97af9a43b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 28 additions and 28 deletions

View File

@ -95,8 +95,8 @@ func (d DriftCTL) Run() (*analyser.Analysis, error) {
middlewares.NewAwsDefaultRoute(),
middlewares.NewAwsNatGatewayEipAssoc(),
middlewares.NewAwsBucketPolicyExpander(d.resourceFactory),
middlewares.NewAwsSqsQueuePolicyExpander(d.resourceFactory, d.resourceSchemaRepository),
middlewares.NewAwsDefaultSqsQueuePolicy(),
middlewares.NewAwsSQSQueuePolicyExpander(d.resourceFactory, d.resourceSchemaRepository),
middlewares.NewAwsDefaultSQSQueuePolicy(),
middlewares.NewAwsSNSTopicPolicyExpander(d.resourceFactory, d.resourceSchemaRepository),
middlewares.NewAwsRoleManagedPolicyExpander(d.resourceFactory),
middlewares.NewTagsAllManager(),

View File

@ -12,13 +12,13 @@ import (
// the SDK return an empty policy (e.g. policy = "").
// We need to ignore those policy from unmanaged resources if they are not managed
// by IaC.
type AwsDefaultSqsQueuePolicy struct{}
type AwsDefaultSQSQueuePolicy struct{}
func NewAwsDefaultSqsQueuePolicy() AwsDefaultSqsQueuePolicy {
return AwsDefaultSqsQueuePolicy{}
func NewAwsDefaultSQSQueuePolicy() AwsDefaultSQSQueuePolicy {
return AwsDefaultSQSQueuePolicy{}
}
func (m AwsDefaultSqsQueuePolicy) Execute(remoteResources, resourcesFromState *[]resource.Resource) error {
func (m AwsDefaultSQSQueuePolicy) Execute(remoteResources, resourcesFromState *[]resource.Resource) error {
newRemoteResources := make([]resource.Resource, 0)
for _, res := range *remoteResources {
// Ignore all resources other than sqs_queue_policy

View File

@ -11,7 +11,7 @@ import (
"github.com/cloudskiff/driftctl/pkg/resource/aws"
)
func TestAwsDefaultSqsQueuePolicy_Execute(t *testing.T) {
func TestAwsDefaultSQSQueuePolicy_Execute(t *testing.T) {
tests := []struct {
name string
remoteResources []resource.Resource
@ -129,7 +129,7 @@ func TestAwsDefaultSqsQueuePolicy_Execute(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
m := NewAwsDefaultSqsQueuePolicy()
m := NewAwsDefaultSQSQueuePolicy()
err := m.Execute(&tt.remoteResources, &tt.resourcesFromState)
if err != nil {
t.Fatal(err)

View File

@ -8,19 +8,19 @@ import (
)
// Explodes policy found in aws_sqs_queue.policy from state resources to dedicated resources
type AwsSqsQueuePolicyExpander struct {
type AwsSQSQueuePolicyExpander struct {
resourceFactory resource.ResourceFactory
resourceSchemaRepository resource.SchemaRepositoryInterface
}
func NewAwsSqsQueuePolicyExpander(resourceFactory resource.ResourceFactory, resourceSchemaRepository resource.SchemaRepositoryInterface) AwsSqsQueuePolicyExpander {
return AwsSqsQueuePolicyExpander{
func NewAwsSQSQueuePolicyExpander(resourceFactory resource.ResourceFactory, resourceSchemaRepository resource.SchemaRepositoryInterface) AwsSQSQueuePolicyExpander {
return AwsSQSQueuePolicyExpander{
resourceFactory,
resourceSchemaRepository,
}
}
func (m AwsSqsQueuePolicyExpander) Execute(remoteResources, resourcesFromState *[]resource.Resource) error {
func (m AwsSQSQueuePolicyExpander) Execute(remoteResources, resourcesFromState *[]resource.Resource) error {
for _, res := range *remoteResources {
if res.TerraformType() != aws.AwsSqsQueueResourceType {
continue
@ -59,7 +59,7 @@ func (m AwsSqsQueuePolicyExpander) Execute(remoteResources, resourcesFromState *
return nil
}
func (m *AwsSqsQueuePolicyExpander) handlePolicy(queue *resource.AbstractResource, results *[]resource.Resource) error {
func (m *AwsSQSQueuePolicyExpander) handlePolicy(queue *resource.AbstractResource, results *[]resource.Resource) error {
policy, exists := queue.Attrs.Get("policy")
if !exists || policy.(string) == "" {
queue.Attrs.SafeDelete([]string{"policy"})
@ -86,7 +86,7 @@ func (m *AwsSqsQueuePolicyExpander) handlePolicy(queue *resource.AbstractResourc
// It is mandatory since it's possible to have a aws_sqs_queue with an inline policy
// AND a aws_sqs_queue_policy resource at the same time. At the end, on the AWS console,
// the aws_sqs_queue_policy will be used.
func (m *AwsSqsQueuePolicyExpander) hasPolicyAttached(queue *resource.AbstractResource, resourcesFromState *[]resource.Resource) bool {
func (m *AwsSQSQueuePolicyExpander) hasPolicyAttached(queue *resource.AbstractResource, resourcesFromState *[]resource.Resource) bool {
for _, res := range *resourcesFromState {
if res.TerraformType() == aws.AwsSqsQueuePolicyResourceType &&
res.TerraformId() == queue.Id {

View File

@ -15,7 +15,7 @@ import (
"github.com/r3labs/diff/v2"
)
func TestAwsSqsQueuePolicyExpander_Execute(t *testing.T) {
func TestAwsSQSQueuePolicyExpander_Execute(t *testing.T) {
tests := []struct {
name string
resourcesFromState []resource.Resource
@ -224,7 +224,7 @@ func TestAwsSqsQueuePolicyExpander_Execute(t *testing.T) {
repo := testresource.InitFakeSchemaRepository("aws", "3.19.0")
aws.InitResourcesMetadata(repo)
m := NewAwsSqsQueuePolicyExpander(factory, repo)
m := NewAwsSQSQueuePolicyExpander(factory, repo)
err := m.Execute(&[]resource.Resource{}, &tt.resourcesFromState)
if err != nil {
t.Fatal(err)

View File

@ -119,7 +119,7 @@ func Init(version string, alerter *alerter.Alerter,
remoteLibrary.AddEnumerator(NewCloudfrontDistributionEnumerator(cloudfrontRepository, factory))
remoteLibrary.AddDetailsFetcher(aws.AwsCloudfrontDistributionResourceType, common.NewGenericDetailsFetcher(aws.AwsCloudfrontDistributionResourceType, provider, deserializer))
remoteLibrary.AddEnumerator(NewSqsQueueEnumerator(sqsRepository, factory))
remoteLibrary.AddEnumerator(NewSQSQueueEnumerator(sqsRepository, factory))
remoteLibrary.AddDetailsFetcher(aws.AwsSqsQueueResourceType, common.NewGenericDetailsFetcher(aws.AwsSqsQueueResourceType, provider, deserializer))
remoteLibrary.AddEnumerator(NewSQSQueuePolicyEnumerator(sqsRepository, factory))
remoteLibrary.AddDetailsFetcher(aws.AwsSqsQueuePolicyResourceType, common.NewGenericDetailsFetcher(aws.AwsSqsQueuePolicyResourceType, provider, deserializer))

View File

@ -9,23 +9,23 @@ import (
awssdk "github.com/aws/aws-sdk-go/aws"
)
type SqsQueueEnumerator struct {
type SQSQueueEnumerator struct {
repository repository.SQSRepository
factory resource.ResourceFactory
}
func NewSqsQueueEnumerator(repo repository.SQSRepository, factory resource.ResourceFactory) *SqsQueueEnumerator {
return &SqsQueueEnumerator{
func NewSQSQueueEnumerator(repo repository.SQSRepository, factory resource.ResourceFactory) *SQSQueueEnumerator {
return &SQSQueueEnumerator{
repository: repo,
factory: factory,
}
}
func (e *SqsQueueEnumerator) SupportedType() resource.ResourceType {
func (e *SQSQueueEnumerator) SupportedType() resource.ResourceType {
return aws.AwsSqsQueueResourceType
}
func (e *SqsQueueEnumerator) Enumerate() ([]resource.Resource, error) {
func (e *SQSQueueEnumerator) Enumerate() ([]resource.Resource, error) {
queues, err := e.repository.ListAllQueues()
if err != nil {
return nil, remoteerror.NewResourceEnumerationError(err, string(e.SupportedType()))

View File

@ -22,7 +22,7 @@ import (
"github.com/stretchr/testify/mock"
)
func TestSqsQueue(t *testing.T) {
func TestSQSQueue(t *testing.T) {
cases := []struct {
test string
dirName string
@ -99,7 +99,7 @@ func TestSqsQueue(t *testing.T) {
repo = repository.NewSQSRepository(sess, cache.New(0))
}
remoteLibrary.AddEnumerator(aws.NewSqsQueueEnumerator(repo, factory))
remoteLibrary.AddEnumerator(aws.NewSQSQueueEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsSqsQueueResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSqsQueueResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)

View File

@ -7,7 +7,7 @@ import (
const AwsSqsQueuePolicyResourceType = "aws_sqs_queue_policy"
func initAwsSqsQueuePolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
func initAwsSQSQueuePolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
resourceSchemaRepository.UpdateSchema(AwsSqsQueuePolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){
"policy": func(attributeSchema *resource.AttributeSchema) {
attributeSchema.JsonString = true

View File

@ -12,7 +12,7 @@ import (
"github.com/cloudskiff/driftctl/test/acceptance"
)
func TestAcc_AwsSqsQueuePolicy(t *testing.T) {
func TestAcc_AwsSQSQueuePolicy(t *testing.T) {
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.14.9",
Paths: []string{"./testdata/acc/aws_sqs_queue_policy"},

View File

@ -19,7 +19,7 @@ import (
"github.com/cloudskiff/driftctl/test/acceptance/awsutils"
)
func TestAcc_AwsSqsQueue(t *testing.T) {
func TestAcc_AwsSQSQueue(t *testing.T) {
var mutatedQueue string
acceptance.Run(t, acceptance.AccTestCase{
TerraformVersion: "0.14.9",

View File

@ -38,7 +38,7 @@ func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInt
initAwsLambdaFunctionMetaData(resourceSchemaRepository)
initAwsLambdaEventSourceMappingMetaData(resourceSchemaRepository)
initAwsSubnetMetaData(resourceSchemaRepository)
initAwsSqsQueuePolicyMetaData(resourceSchemaRepository)
initAwsSQSQueuePolicyMetaData(resourceSchemaRepository)
initAwsSecurityGroupRuleMetaData(resourceSchemaRepository)
initAwsSecurityGroupMetaData(resourceSchemaRepository)
}