Merge pull request #1071 from cloudskiff/add_deep_mode_flags
Add deep mode flag on resource schemamain
commit
49d48b350b
|
@ -85,6 +85,11 @@ func (a Analyzer) Analyze(remoteResources, resourcesFromState []*resource.Resour
|
|||
continue
|
||||
}
|
||||
|
||||
// Stop if the resource is not compatible with deep mode
|
||||
if stateRes.Schema() != nil && !stateRes.Schema().Flags.HasFlag(resource.FlagDeepMode) {
|
||||
continue
|
||||
}
|
||||
|
||||
var delta diff.Changelog
|
||||
delta, _ = diff.Diff(stateRes.Attributes(), remoteRes.Attributes())
|
||||
|
||||
|
|
|
@ -11,4 +11,5 @@ func initAwsAmiMetaData(resourceSchemaRepository resource.SchemaRepositoryInterf
|
|||
val := res.Attrs
|
||||
val.SafeDelete([]string{"timeouts"})
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsAmiResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -22,4 +22,5 @@ func initAwsCloudformationStackMetaData(resourceSchemaRepository resource.Schema
|
|||
val := res.Attrs
|
||||
val.SafeDelete([]string{"timeouts"})
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsCloudformationStackResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -15,4 +15,5 @@ func initAwsCloudfrontDistributionMetaData(resourceSchemaRepository resource.Sch
|
|||
val.SafeDelete([]string{"status"})
|
||||
val.SafeDelete([]string{"wait_for_deployment"})
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsCloudfrontDistributionResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -20,4 +20,5 @@ func initAwsDbInstanceMetaData(resourceSchemaRepository resource.SchemaRepositor
|
|||
val.SafeDelete([]string{"apply_immediately"})
|
||||
val.DeleteIfDefault("CharacterSetName")
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsDbInstanceResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -11,4 +11,5 @@ func initAwsDbSubnetGroupMetaData(resourceSchemaRepository resource.SchemaReposi
|
|||
val := res.Attrs
|
||||
val.SafeDelete([]string{"name_prefix"})
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsDbSubnetGroupResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -10,4 +10,5 @@ func initAwsDefaultRouteTableMetadata(resourceSchemaRepository resource.SchemaRe
|
|||
"vpc_id": *res.Attributes().GetString("vpc_id"),
|
||||
}
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsDefaultRouteTableResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -13,4 +13,5 @@ func initAwsDefaultSecurityGroupMetaData(resourceSchemaRepository resource.Schem
|
|||
val.SafeDelete([]string{"ingress"})
|
||||
val.SafeDelete([]string{"egress"})
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsDefaultSecurityGroupResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -11,4 +11,5 @@ func initAwsDefaultSubnetMetaData(resourceSchemaRepository resource.SchemaReposi
|
|||
val := res.Attrs
|
||||
val.SafeDelete([]string{"timeouts"})
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsDefaultSubnetResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
package aws
|
||||
|
||||
import "github.com/cloudskiff/driftctl/pkg/resource"
|
||||
|
||||
const AwsDefaultVpcResourceType = "aws_default_vpc"
|
||||
|
||||
func initAwsDefaultVpcMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
||||
resourceSchemaRepository.SetFlags(AwsDefaultVpcResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -16,4 +16,6 @@ func initAwsDynamodbTableMetaData(resourceSchemaRepository resource.SchemaReposi
|
|||
val := res.Attrs
|
||||
val.SafeDelete([]string{"timeouts"})
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsDynamodbTableResourceType, resource.FlagDeepMode)
|
||||
|
||||
}
|
||||
|
|
|
@ -11,4 +11,5 @@ func initAwsEbsSnapshotMetaData(resourceSchemaRepository resource.SchemaReposito
|
|||
val := res.Attrs
|
||||
val.SafeDelete([]string{"timeouts"})
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsEbsSnapshotResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -14,4 +14,5 @@ func initAwsEbsVolumeMetaData(resourceSchemaRepository resource.SchemaRepository
|
|||
val.SafeDelete([]string{"snapshot_id"})
|
||||
val.DeleteIfDefault("throughput")
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsEbsVolumeResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -9,4 +9,5 @@ func initAwsEcrRepositoryMetaData(resourceSchemaRepository resource.SchemaReposi
|
|||
val := res.Attrs
|
||||
val.SafeDelete([]string{"timeouts"})
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsEcrRepositoryResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -11,4 +11,5 @@ func initAwsEipMetaData(resourceSchemaRepository resource.SchemaRepositoryInterf
|
|||
val := res.Attrs
|
||||
val.SafeDelete([]string{"timeouts"})
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsEipResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
package aws
|
||||
|
||||
import "github.com/cloudskiff/driftctl/pkg/resource"
|
||||
|
||||
const AwsEipAssociationResourceType = "aws_eip_association"
|
||||
|
||||
func initAwsEipAssociationMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
||||
resourceSchemaRepository.SetFlags(AwsEipAssociationResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -34,4 +34,5 @@ func initAwsIAMAccessKeyMetaData(resourceSchemaRepository resource.SchemaReposit
|
|||
}
|
||||
return attrs
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsIamAccessKeyResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -22,4 +22,5 @@ func initAwsIAMPolicyMetaData(resourceSchemaRepository resource.SchemaRepository
|
|||
|
||||
val.SafeDelete([]string{"name_prefix"})
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsIamPolicyResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -11,4 +11,5 @@ func initAwsIAMPolicyAttachmentMetaData(resourceSchemaRepository resource.Schema
|
|||
val := res.Attrs
|
||||
val.SafeDelete([]string{"name"})
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsIamPolicyAttachmentResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -16,4 +16,5 @@ func initAwsIAMRoleMetaData(resourceSchemaRepository resource.SchemaRepositoryIn
|
|||
val := res.Attrs
|
||||
val.SafeDelete([]string{"force_detach_policies"})
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsIamRoleResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -12,4 +12,5 @@ func initAwsIAMRolePolicyMetaData(resourceSchemaRepository resource.SchemaReposi
|
|||
attributeSchema.JsonString = true
|
||||
},
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsIamRolePolicyResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -11,4 +11,5 @@ func initAwsIamRolePolicyAttachmentMetaData(resourceSchemaRepository resource.Sc
|
|||
"policy_arn": *res.Attributes().GetString("policy_arn"),
|
||||
}
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsIamRolePolicyAttachmentResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -15,4 +15,5 @@ func initAwsIAMUserMetaData(resourceSchemaRepository resource.SchemaRepositoryIn
|
|||
}
|
||||
val.SafeDelete([]string{"force_destroy"})
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsIamUserResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -12,4 +12,5 @@ func initAwsIAMUserPolicyMetaData(resourceSchemaRepository resource.SchemaReposi
|
|||
attributeSchema.JsonString = true
|
||||
},
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsIamUserPolicyResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -11,4 +11,5 @@ func initAwsIamUserPolicyAttachmentMetaData(resourceSchemaRepository resource.Sc
|
|||
"policy_arn": *res.Attributes().GetString("policy_arn"),
|
||||
}
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsIamUserPolicyAttachmentResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -26,4 +26,5 @@ func initAwsInstanceMetaData(resourceSchemaRepository resource.SchemaRepositoryI
|
|||
}
|
||||
return attrs
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsInstanceResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
)
|
||||
|
||||
const AwsInternetGatewayResourceType = "aws_internet_gateway"
|
||||
|
||||
func initAwsInternetGatewayMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
||||
resourceSchemaRepository.SetFlags(AwsInternetGatewayResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -12,4 +12,5 @@ func initAwsKeyPairMetaData(resourceSchemaRepository resource.SchemaRepositoryIn
|
|||
val.SafeDelete([]string{"key_name_prefix"})
|
||||
val.SafeDelete([]string{"public_key"})
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsKeyPairResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -12,4 +12,5 @@ func initAwsKmsAliasMetaData(resourceSchemaRepository resource.SchemaRepositoryI
|
|||
val.SafeDelete([]string{"name"})
|
||||
val.SafeDelete([]string{"name_prefix"})
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsKmsAliasResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -22,4 +22,5 @@ func initAwsKmsKeyMetaData(resourceSchemaRepository resource.SchemaRepositoryInt
|
|||
}
|
||||
_ = val.SafeSet([]string{"policy"}, jsonString)
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsKmsKeyResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -27,4 +27,5 @@ func initAwsLambdaEventSourceMappingMetaData(resourceSchemaRepository resource.S
|
|||
}
|
||||
return attrs
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsLambdaEventSourceMappingResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -27,4 +27,5 @@ func initAwsLambdaFunctionMetaData(resourceSchemaRepository resource.SchemaRepos
|
|||
val.DeleteIfDefault("signing_profile_version_arn")
|
||||
val.SafeDelete([]string{"source_code_size"})
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsLambdaFunctionResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
package aws
|
||||
|
||||
import "github.com/cloudskiff/driftctl/pkg/resource"
|
||||
|
||||
const AwsNatGatewayResourceType = "aws_nat_gateway"
|
||||
|
||||
func initNatGatewayMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
||||
resourceSchemaRepository.SetFlags(AwsNatGatewayResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -19,4 +19,5 @@ func initAwsRDSClusterMetaData(resourceSchemaRepository resource.SchemaRepositor
|
|||
val.SafeDelete([]string{"cluster_members"})
|
||||
val.SafeDelete([]string{"skip_final_snapshot"})
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsRDSClusterResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ func initAwsRouteMetaData(resourceSchemaRepository resource.SchemaRepositoryInte
|
|||
}
|
||||
return attrs
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsRouteResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
||||
func CalculateRouteID(tableId, CidrBlock, Ipv6CidrBlock, PrefixListId *string) string {
|
||||
|
|
|
@ -39,4 +39,5 @@ func initAwsRoute53HealthCheckMetaData(resourceSchemaRepository resource.SchemaR
|
|||
}
|
||||
return attrs
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsRoute53HealthCheckResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -29,4 +29,5 @@ func initAwsRoute53RecordMetaData(resourceSchemaRepository resource.SchemaReposi
|
|||
}
|
||||
return attrs
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsRoute53RecordResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -19,4 +19,5 @@ func initAwsRoute53ZoneMetaData(resourceSchemaRepository resource.SchemaReposito
|
|||
}
|
||||
return attrs
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsRoute53ZoneResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
package aws
|
||||
|
||||
import "github.com/cloudskiff/driftctl/pkg/resource"
|
||||
|
||||
const AwsRouteTableResourceType = "aws_route_table"
|
||||
|
||||
func initAwsRouteTableMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
||||
resourceSchemaRepository.SetFlags(AwsRouteTableResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -26,4 +26,5 @@ func initAwsRouteTableAssociationMetaData(resourceSchemaRepository resource.Sche
|
|||
}
|
||||
return attrs
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsRouteTableAssociationResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -22,4 +22,5 @@ func initAwsS3BucketMetaData(resourceSchemaRepository resource.SchemaRepositoryI
|
|||
val.SafeDelete([]string{"force_destroy"})
|
||||
val.SafeDelete([]string{"bucket_prefix"})
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsS3BucketResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -10,4 +10,5 @@ func initAwsS3BucketInventoryMetadata(resourceSchemaRepository resource.SchemaRe
|
|||
"alias": *res.Attributes().GetString("region"),
|
||||
}
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsS3BucketInventoryResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -10,4 +10,5 @@ func initAwsS3BucketMetricMetadata(resourceSchemaRepository resource.SchemaRepos
|
|||
"alias": *res.Attributes().GetString("region"),
|
||||
}
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsS3BucketMetricResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -10,4 +10,5 @@ func initAwsS3BucketNotificationMetadata(resourceSchemaRepository resource.Schem
|
|||
"alias": *res.Attributes().GetString("region"),
|
||||
}
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsS3BucketNotificationResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -26,4 +26,5 @@ func initAwsS3BucketPolicyMetaData(resourceSchemaRepository resource.SchemaRepos
|
|||
}
|
||||
_ = val.SafeSet([]string{"policy"}, jsonString)
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsS3BucketPolicyResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -14,4 +14,5 @@ func initAwsSecurityGroupMetaData(resourceSchemaRepository resource.SchemaReposi
|
|||
val.SafeDelete([]string{"ingress"})
|
||||
val.SafeDelete([]string{"egress"})
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsSecurityGroupResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -161,4 +161,5 @@ func initAwsSecurityGroupRuleMetaData(resourceSchemaRepository resource.SchemaRe
|
|||
}
|
||||
return attrs
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsSecurityGroupRuleResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -40,4 +40,5 @@ func initSnsTopicMetaData(resourceSchemaRepository resource.SchemaRepositoryInte
|
|||
}
|
||||
return attrs
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsSnsTopicResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -29,4 +29,5 @@ func initSnsTopicPolicyMetaData(resourceSchemaRepository resource.SchemaReposito
|
|||
}
|
||||
_ = val.SafeSet([]string{"policy"}, jsonString)
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsSnsTopicPolicyResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -42,4 +42,5 @@ func initSnsTopicSubscriptionMetaData(resourceSchemaRepository resource.SchemaRe
|
|||
val.SafeDelete([]string{"confirmation_timeout_in_minutes"})
|
||||
}
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsSnsTopicSubscriptionResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
)
|
||||
|
||||
const AwsSqsQueueResourceType = "aws_sqs_queue"
|
||||
|
||||
func initSqsQueueMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
||||
resourceSchemaRepository.SetFlags(AwsSqsQueueResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -21,4 +21,5 @@ func initAwsSQSQueuePolicyMetaData(resourceSchemaRepository resource.SchemaRepos
|
|||
}
|
||||
_ = val.SafeSet([]string{"policy"}, jsonString)
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsSqsQueuePolicyResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -11,4 +11,5 @@ func initAwsSubnetMetaData(resourceSchemaRepository resource.SchemaRepositoryInt
|
|||
val := res.Attrs
|
||||
val.SafeDelete([]string{"timeouts"})
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsSubnetResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
package aws
|
||||
|
||||
import "github.com/cloudskiff/driftctl/pkg/resource"
|
||||
|
||||
const AwsVpcResourceType = "aws_vpc"
|
||||
|
||||
func initAwsVpcMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) {
|
||||
resourceSchemaRepository.SetFlags(AwsVpcResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -9,12 +9,15 @@ func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInt
|
|||
initAwsDbSubnetGroupMetaData(resourceSchemaRepository)
|
||||
initAwsDefaultSecurityGroupMetaData(resourceSchemaRepository)
|
||||
initAwsDefaultSubnetMetaData(resourceSchemaRepository)
|
||||
initAwsDefaultVpcMetaData(resourceSchemaRepository)
|
||||
initAwsDefaultRouteTableMetadata(resourceSchemaRepository)
|
||||
initAwsDynamodbTableMetaData(resourceSchemaRepository)
|
||||
initAwsEbsSnapshotMetaData(resourceSchemaRepository)
|
||||
initAwsInstanceMetaData(resourceSchemaRepository)
|
||||
initAwsInternetGatewayMetaData(resourceSchemaRepository)
|
||||
initAwsEbsVolumeMetaData(resourceSchemaRepository)
|
||||
initAwsEipMetaData(resourceSchemaRepository)
|
||||
initAwsEipAssociationMetaData(resourceSchemaRepository)
|
||||
initAwsS3BucketMetaData(resourceSchemaRepository)
|
||||
initAwsS3BucketPolicyMetaData(resourceSchemaRepository)
|
||||
initAwsS3BucketInventoryMetadata(resourceSchemaRepository)
|
||||
|
@ -27,9 +30,11 @@ func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInt
|
|||
initAwsRoute53RecordMetaData(resourceSchemaRepository)
|
||||
initAwsRoute53ZoneMetaData(resourceSchemaRepository)
|
||||
initAwsRoute53HealthCheckMetaData(resourceSchemaRepository)
|
||||
initAwsRouteTableMetaData(resourceSchemaRepository)
|
||||
initSnsTopicSubscriptionMetaData(resourceSchemaRepository)
|
||||
initSnsTopicPolicyMetaData(resourceSchemaRepository)
|
||||
initSnsTopicMetaData(resourceSchemaRepository)
|
||||
initSqsQueueMetaData(resourceSchemaRepository)
|
||||
initAwsIAMAccessKeyMetaData(resourceSchemaRepository)
|
||||
initAwsIAMPolicyMetaData(resourceSchemaRepository)
|
||||
initAwsIAMPolicyAttachmentMetaData(resourceSchemaRepository)
|
||||
|
@ -44,10 +49,12 @@ func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInt
|
|||
initAwsKmsAliasMetaData(resourceSchemaRepository)
|
||||
initAwsLambdaFunctionMetaData(resourceSchemaRepository)
|
||||
initAwsLambdaEventSourceMappingMetaData(resourceSchemaRepository)
|
||||
initNatGatewayMetaData(resourceSchemaRepository)
|
||||
initAwsSubnetMetaData(resourceSchemaRepository)
|
||||
initAwsSQSQueuePolicyMetaData(resourceSchemaRepository)
|
||||
initAwsSecurityGroupRuleMetaData(resourceSchemaRepository)
|
||||
initAwsSecurityGroupMetaData(resourceSchemaRepository)
|
||||
initAwsRDSClusterMetaData(resourceSchemaRepository)
|
||||
initAwsCloudformationStackMetaData(resourceSchemaRepository)
|
||||
initAwsVpcMetaData(resourceSchemaRepository)
|
||||
}
|
||||
|
|
|
@ -39,4 +39,5 @@ func initGithubBranchProtectionMetaData(resourceSchemaRepository resource.Schema
|
|||
attrs["Id"] = res.ResourceId()
|
||||
return attrs
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(GithubBranchProtectionResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -10,4 +10,5 @@ func initGithubMembershipMetaData(resourceSchemaRepository resource.SchemaReposi
|
|||
val := res.Attrs
|
||||
val.SafeDelete([]string{"etag"})
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(GithubMembershipResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -10,4 +10,5 @@ func initGithubRepositoryMetaData(resourceSchemaRepository resource.SchemaReposi
|
|||
val.SafeDelete([]string{"auto_init"})
|
||||
val.SafeDelete([]string{"etag"})
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(GithubRepositoryResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -22,4 +22,5 @@ func initGithubTeamMetaData(resourceSchemaRepository resource.SchemaRepositoryIn
|
|||
}
|
||||
return attrs
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(GithubTeamResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -10,4 +10,5 @@ func initGithubTeamMembershipMetaData(resourceSchemaRepository resource.SchemaRe
|
|||
val := res.Attrs
|
||||
val.SafeDelete([]string{"etag"})
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(GithubTeamMembershipResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -14,4 +14,5 @@ func initGoogleComputeFirewallMetadata(resourceSchemaRepository resource.SchemaR
|
|||
resourceSchemaRepository.SetNormalizeFunc(GoogleComputeFirewallResourceType, func(res *resource.Resource) {
|
||||
res.Attrs.SafeDelete([]string{"timeouts"})
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(GoogleComputeFirewallResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -13,4 +13,5 @@ func initGoogleStorageBucketMetadata(resourceSchemaRepository resource.SchemaRep
|
|||
"name": res.ResourceId(),
|
||||
}
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(GoogleStorageBucketResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
|
@ -14,8 +14,23 @@ type AttributeSchema struct {
|
|||
JsonString bool
|
||||
}
|
||||
|
||||
type Flags uint32
|
||||
|
||||
const (
|
||||
FlagDeepMode Flags = 1 << iota
|
||||
)
|
||||
|
||||
func (f Flags) HasFlag(flag Flags) bool {
|
||||
return f&flag != 0
|
||||
}
|
||||
|
||||
func (f *Flags) AddFlag(flag Flags) {
|
||||
*f |= flag
|
||||
}
|
||||
|
||||
type Schema struct {
|
||||
ProviderVersion *version.Version
|
||||
Flags Flags
|
||||
SchemaVersion int64
|
||||
Attributes map[string]AttributeSchema
|
||||
NormalizeFunc func(res *Resource)
|
||||
|
@ -41,6 +56,7 @@ func (s *Schema) IsJsonStringField(path []string) bool {
|
|||
|
||||
type SchemaRepositoryInterface interface {
|
||||
GetSchema(resourceType string) (*Schema, bool)
|
||||
SetFlags(typ string, flags ...Flags)
|
||||
UpdateSchema(typ string, schemasMutators map[string]func(attributeSchema *AttributeSchema))
|
||||
SetNormalizeFunc(typ string, normalizeFunc func(res *Resource))
|
||||
SetHumanReadableAttributesFunc(typ string, humanReadableAttributesFunc func(res *Resource) map[string]string)
|
||||
|
@ -106,6 +122,17 @@ func (r *SchemaRepository) Init(providerName, providerVersion string, schema map
|
|||
return nil
|
||||
}
|
||||
|
||||
func (r SchemaRepository) SetFlags(typ string, flags ...Flags) {
|
||||
metadata, exist := r.GetSchema(typ)
|
||||
if !exist {
|
||||
logrus.WithFields(logrus.Fields{"type": typ}).Warning("Unable to set flags, no schema found")
|
||||
return
|
||||
}
|
||||
for _, flag := range flags {
|
||||
metadata.Flags.AddFlag(flag)
|
||||
}
|
||||
}
|
||||
|
||||
func (r *SchemaRepository) UpdateSchema(typ string, schemasMutators map[string]func(attributeSchema *AttributeSchema)) {
|
||||
for s, f := range schemasMutators {
|
||||
metadata, exist := r.GetSchema(typ)
|
||||
|
|
Loading…
Reference in New Issue