diff --git a/sources/apigateway/resource.go b/sources/apigateway/resource.go index 734f7bd8..394db4d0 100644 --- a/sources/apigateway/resource.go +++ b/sources/apigateway/resource.go @@ -38,19 +38,19 @@ func resourceOutputMapper(query, scope string, awsItem *types.Resource) (*sdp.It } } - attributes, err := sources.ToAttributesCase(awsItem, "tags") + attributes, err := sources.ToAttributesWithExclude(awsItem, "tags") if err != nil { return nil, err } - err = attributes.Set("uniqueName", fmt.Sprintf("%s/%s", restApiID, *awsItem.Id)) + err = attributes.Set("UniqueName", fmt.Sprintf("%s/%s", restApiID, *awsItem.Id)) if err != nil { return nil, err } item := sdp.Item{ Type: "apigateway-resource", - UniqueAttribute: "uniqueName", + UniqueAttribute: "UniqueName", Attributes: attributes, Scope: scope, } diff --git a/sources/apigateway/rest-api.go b/sources/apigateway/rest-api.go index 9905f933..2549daf7 100644 --- a/sources/apigateway/rest-api.go +++ b/sources/apigateway/rest-api.go @@ -49,7 +49,7 @@ func restApiListFunc(ctx context.Context, client *apigateway.Client, _ string) ( } func restApiOutputMapper(scope string, awsItem *types.RestApi) (*sdp.Item, error) { - attributes, err := sources.ToAttributesCase(awsItem, "tags") + attributes, err := sources.ToAttributesWithExclude(awsItem, "tags") if err != nil { return nil, err } @@ -75,7 +75,7 @@ func restApiOutputMapper(scope string, awsItem *types.RestApi) (*sdp.Item, error return nil, nil //nolint:nilerr } - attributes, err = sources.ToAttributesCase(restApi, "tags") + attributes, err = sources.ToAttributesWithExclude(restApi, "tags") if err != nil { return nil, err } @@ -83,7 +83,7 @@ func restApiOutputMapper(scope string, awsItem *types.RestApi) (*sdp.Item, error item := sdp.Item{ Type: "apigateway-rest-api", - UniqueAttribute: "id", + UniqueAttribute: "Id", Attributes: attributes, Scope: scope, Tags: awsItem.Tags, diff --git a/sources/autoscaling/auto_scaling_group.go b/sources/autoscaling/auto_scaling_group.go index 6bdf524e..4c6e7a18 100644 --- a/sources/autoscaling/auto_scaling_group.go +++ b/sources/autoscaling/auto_scaling_group.go @@ -16,7 +16,7 @@ func autoScalingGroupOutputMapper(_ context.Context, _ *autoscaling.Client, scop var err error for _, asg := range output.AutoScalingGroups { - attributes, err = sources.ToAttributesCase(asg) + attributes, err = sources.ToAttributesWithExclude(asg) if err != nil { return nil, err @@ -24,7 +24,7 @@ func autoScalingGroupOutputMapper(_ context.Context, _ *autoscaling.Client, scop item = sdp.Item{ Type: "autoscaling-auto-scaling-group", - UniqueAttribute: "autoScalingGroupName", + UniqueAttribute: "AutoScalingGroupName", Scope: scope, Attributes: attributes, } diff --git a/sources/case.go b/sources/case.go deleted file mode 100644 index eb0d52e6..00000000 --- a/sources/case.go +++ /dev/null @@ -1,188 +0,0 @@ -package sources - -import ( - "encoding/json" - "errors" - "reflect" - - "github.com/iancoleman/strcase" - "github.com/overmindtech/sdp-go" -) - -var Acronyms = []string{ - "ACL", - "ADFS", - "AES", - "AI", - "AMI", - "API", - "ARN", - "ASG", - "AWS", - "AZ", - "CDN", - "CIDR", - "CLI", - "CORS", - "DaaS", - "DDoS", - "DMS", - "DNS", - "DoS", - "EBS", - "EC2", - "ECS", - "EFS", - "EIP", - "ELB", - "EMR", - "ENI", - "FaaS", - "FIFO", - "HPC", - "HTTP", - "HTTPS", - "HVM", - "IaaS", - "IAM", - "ICMP", - "IGW", - "IOPS", - "IOT", - "IP", - "IPSec", - "iSCSI", - "JSON", - "KMS", - "LB", - "MFA", - "MITM", - "MPLS", - "MPP", - "MSTSC", - "NAT", - "NFS", - "NS", - "OLAP", - "OLTP", - "PaaS", - "PCI DSS", - "PV", - "RAID", - "RAM", - "RDS", - "RRS", - "S3 IA", - "S3", - "SaaS", - "SaaS", - "SAML", - "SDK", - "SES", - "SLA", - "SMS", - "SNS", - "SOA", - "SOAP", - "SQS", - "SSE", - "SSH", - "SSL", - "SSO", - "STS", - "SWF", - "TCP", - "TLS", - "TPM", - "TPM", - "TPS", - "TTL", - "VDI", - "VLAN", - "VM", - "VPC", - "VPG", - "VPN", - "VTL", - "WAF", -} - -func init() { - for _, acronym := range Acronyms { - // Load acronyms so tha they won't be wrecked by camelCase - strcase.ConfigureAcronym(acronym, acronym) - } -} - -// ToAttributesCase Converts any interface to SDP attributes and also fixes case -// to be the correct `camelCase`. Excluded fields can also be provided, the -// field names should be provided in the final camelCase format. Arrays are also -// sorted to ensure consistency. -func ToAttributesCase(i interface{}, exclusions ...string) (*sdp.ItemAttributes, error) { - var m map[string]interface{} - - // Convert via JSON - b, err := json.Marshal(i) - - if err != nil { - return &sdp.ItemAttributes{}, err - } - - err = json.Unmarshal(b, &m) - - if err != nil { - return &sdp.ItemAttributes{}, err - } - - camel := CamelCase(m) - - if camelMap, ok := camel.(map[string]interface{}); ok { - for _, exclusion := range exclusions { - // Exclude some things - delete(camelMap, exclusion) - } - return sdp.ToAttributesSorted(camelMap) - } else { - return &sdp.ItemAttributes{}, errors.New("could not convert camel cased data to map[string]interface{}") - } -} - -// CamelCase converts all keys in an object to camel case recursively, this -// includes ignoring known acronyms -func CamelCase(i interface{}) interface{} { - if i == nil { - return nil - } - - v := reflect.ValueOf(i) - - switch v.Kind() { // nolint:exhaustive // handled by default case - case reflect.Map: - newMap := make(map[string]interface{}) - - iter := v.MapRange() - for iter.Next() { - k := iter.Key() - v := iter.Value() - vi := v.Interface() - - if vi != nil { - keyCamel := strcase.ToLowerCamel(k.String()) - - newMap[keyCamel] = CamelCase(vi) - } - } - - return newMap - case reflect.Array, reflect.Slice: - newSlice := make([]interface{}, 0, v.Len()) - - for index := 0; index < v.Len(); index++ { - newSlice = append(newSlice, CamelCase(v.Index(index).Interface())) - } - - return newSlice - default: - return i - } -} diff --git a/sources/case_test.go b/sources/case_test.go deleted file mode 100644 index 237a3239..00000000 --- a/sources/case_test.go +++ /dev/null @@ -1,68 +0,0 @@ -package sources - -import ( - "encoding/json" - "testing" -) - -func TestCamelCase(t *testing.T) { - exampleMap := make(map[string]interface{}) - - exampleMap["Name"] = "Dylan" - exampleMap["Nested"] = map[string]interface{}{ - "NestedKeyName": "Value", - "NestedAWSAcronym": "Wow", - "NestedArray": []map[string]string{ - { - "FooBar": "Baz", - }, - }, - } - - i := interface{}(exampleMap) - - camel := CamelCase(i) - - b, err := json.Marshal(camel) - if err != nil { - t.Fatalf("error marshalling: %v", err) - } - - expected := `{"name":"Dylan","nested":{"nestedAWSAcronym":"Wow","nestedArray":[{"fooBar":"Baz"}],"nestedKeyName":"Value"}}` - - if string(b) != expected { - t.Fatalf("expected %v got %v", expected, string(b)) - } -} - -func TestToAttributesCase(t *testing.T) { - exampleMap := make(map[string]interface{}) - - exampleMap["Name"] = "Dylan" - exampleMap["Removed"] = "goodbye" - exampleMap["Nested"] = map[string]string{ - "NestedKeyName": "Value", - "NestedAWSAcronym": "Wow", - } - exampleMap["Nil"] = nil - - i := interface{}(exampleMap) - - attrs, err := ToAttributesCase(i, "removed") - - if err != nil { - t.Fatal(err) - } - - if _, err := attrs.Get("nested"); err != nil { - t.Error("could not find key nested") - } - - if _, err := attrs.Get("nil"); err == nil { - t.Error("expected nil attributes to be removed") - } - - if _, err := attrs.Get("removed"); err == nil { - t.Error("expected 'removed' to have been removed") - } -} diff --git a/sources/cloudfront/cache_policy.go b/sources/cloudfront/cache_policy.go index 407b1cb8..3889799d 100644 --- a/sources/cloudfront/cache_policy.go +++ b/sources/cloudfront/cache_policy.go @@ -65,7 +65,7 @@ func NewCachePolicySource(client CloudFrontClient, accountID string) *sources.Ge }, ListFunc: cachePolicyListFunc, ItemMapper: func(_, scope string, awsItem *types.CachePolicy) (*sdp.Item, error) { - attributes, err := sources.ToAttributesCase(awsItem) + attributes, err := sources.ToAttributesWithExclude(awsItem) if err != nil { return nil, err @@ -73,7 +73,7 @@ func NewCachePolicySource(client CloudFrontClient, accountID string) *sources.Ge item := sdp.Item{ Type: "cloudfront-cache-policy", - UniqueAttribute: "id", + UniqueAttribute: "Id", Attributes: attributes, Scope: scope, } diff --git a/sources/cloudfront/continuous_deployment_policy.go b/sources/cloudfront/continuous_deployment_policy.go index f01706ed..f2ee5da2 100644 --- a/sources/cloudfront/continuous_deployment_policy.go +++ b/sources/cloudfront/continuous_deployment_policy.go @@ -10,7 +10,7 @@ import ( ) func continuousDeploymentPolicyItemMapper(_, scope string, awsItem *types.ContinuousDeploymentPolicy) (*sdp.Item, error) { - attributes, err := sources.ToAttributesCase(awsItem) + attributes, err := sources.ToAttributesWithExclude(awsItem) if err != nil { return nil, err @@ -18,7 +18,7 @@ func continuousDeploymentPolicyItemMapper(_, scope string, awsItem *types.Contin item := sdp.Item{ Type: "cloudfront-continuous-deployment-policy", - UniqueAttribute: "id", + UniqueAttribute: "Id", Attributes: attributes, Scope: scope, } diff --git a/sources/cloudfront/distribution.go b/sources/cloudfront/distribution.go index eab213ac..19c65c96 100644 --- a/sources/cloudfront/distribution.go +++ b/sources/cloudfront/distribution.go @@ -40,7 +40,7 @@ func distributionGetFunc(ctx context.Context, client CloudFrontClient, scope str tags = sources.HandleTagsError(ctx, err) } - attributes, err := sources.ToAttributesCase(d) + attributes, err := sources.ToAttributesWithExclude(d) if err != nil { return nil, err @@ -48,7 +48,7 @@ func distributionGetFunc(ctx context.Context, client CloudFrontClient, scope str item := sdp.Item{ Type: "cloudfront-distribution", - UniqueAttribute: "id", + UniqueAttribute: "Id", Attributes: attributes, Scope: scope, Tags: tags, diff --git a/sources/cloudfront/function.go b/sources/cloudfront/function.go index 9ea0d510..504fa8cb 100644 --- a/sources/cloudfront/function.go +++ b/sources/cloudfront/function.go @@ -10,7 +10,7 @@ import ( ) func functionItemMapper(_, scope string, awsItem *types.FunctionSummary) (*sdp.Item, error) { - attributes, err := sources.ToAttributesCase(awsItem) + attributes, err := sources.ToAttributesWithExclude(awsItem) if err != nil { return nil, err @@ -18,7 +18,7 @@ func functionItemMapper(_, scope string, awsItem *types.FunctionSummary) (*sdp.I item := sdp.Item{ Type: "cloudfront-function", - UniqueAttribute: "name", + UniqueAttribute: "Name", Attributes: attributes, Scope: scope, } diff --git a/sources/cloudfront/key_group.go b/sources/cloudfront/key_group.go index 1494c64e..3858de27 100644 --- a/sources/cloudfront/key_group.go +++ b/sources/cloudfront/key_group.go @@ -10,7 +10,7 @@ import ( ) func KeyGroupItemMapper(_, scope string, awsItem *types.KeyGroup) (*sdp.Item, error) { - attributes, err := sources.ToAttributesCase(awsItem) + attributes, err := sources.ToAttributesWithExclude(awsItem) if err != nil { return nil, err @@ -18,7 +18,7 @@ func KeyGroupItemMapper(_, scope string, awsItem *types.KeyGroup) (*sdp.Item, er item := sdp.Item{ Type: "cloudfront-key-group", - UniqueAttribute: "id", + UniqueAttribute: "Id", Attributes: attributes, Scope: scope, } diff --git a/sources/cloudfront/origin_access_control.go b/sources/cloudfront/origin_access_control.go index 6e1966a8..ab9bd022 100644 --- a/sources/cloudfront/origin_access_control.go +++ b/sources/cloudfront/origin_access_control.go @@ -38,7 +38,7 @@ func originAccessControlListFunc(ctx context.Context, client *cloudfront.Client, } func originAccessControlItemMapper(_, scope string, awsItem *types.OriginAccessControl) (*sdp.Item, error) { - attributes, err := sources.ToAttributesCase(awsItem) + attributes, err := sources.ToAttributesWithExclude(awsItem) if err != nil { return nil, err @@ -46,7 +46,7 @@ func originAccessControlItemMapper(_, scope string, awsItem *types.OriginAccessC item := sdp.Item{ Type: "cloudfront-origin-access-control", - UniqueAttribute: "id", + UniqueAttribute: "Id", Attributes: attributes, Scope: scope, } diff --git a/sources/cloudfront/origin_request_policy.go b/sources/cloudfront/origin_request_policy.go index 98f5f0ae..7073ca4c 100644 --- a/sources/cloudfront/origin_request_policy.go +++ b/sources/cloudfront/origin_request_policy.go @@ -10,7 +10,7 @@ import ( ) func originRequestPolicyItemMapper(_, scope string, awsItem *types.OriginRequestPolicy) (*sdp.Item, error) { - attributes, err := sources.ToAttributesCase(awsItem) + attributes, err := sources.ToAttributesWithExclude(awsItem) if err != nil { return nil, err @@ -18,7 +18,7 @@ func originRequestPolicyItemMapper(_, scope string, awsItem *types.OriginRequest item := sdp.Item{ Type: "cloudfront-origin-request-policy", - UniqueAttribute: "id", + UniqueAttribute: "Id", Attributes: attributes, Scope: scope, } diff --git a/sources/cloudfront/realtime_log_configs.go b/sources/cloudfront/realtime_log_configs.go index 262a74bc..a208f6e6 100644 --- a/sources/cloudfront/realtime_log_configs.go +++ b/sources/cloudfront/realtime_log_configs.go @@ -10,7 +10,7 @@ import ( ) func realtimeLogConfigsItemMapper(_, scope string, awsItem *types.RealtimeLogConfig) (*sdp.Item, error) { - attributes, err := sources.ToAttributesCase(awsItem) + attributes, err := sources.ToAttributesWithExclude(awsItem) if err != nil { return nil, err @@ -18,7 +18,7 @@ func realtimeLogConfigsItemMapper(_, scope string, awsItem *types.RealtimeLogCon item := sdp.Item{ Type: "cloudfront-realtime-log-config", - UniqueAttribute: "name", + UniqueAttribute: "Name", Attributes: attributes, Scope: scope, } diff --git a/sources/cloudfront/response_headers_policy.go b/sources/cloudfront/response_headers_policy.go index 2c7d0136..623fd95b 100644 --- a/sources/cloudfront/response_headers_policy.go +++ b/sources/cloudfront/response_headers_policy.go @@ -10,7 +10,7 @@ import ( ) func ResponseHeadersPolicyItemMapper(_, scope string, awsItem *types.ResponseHeadersPolicy) (*sdp.Item, error) { - attributes, err := sources.ToAttributesCase(awsItem) + attributes, err := sources.ToAttributesWithExclude(awsItem) if err != nil { return nil, err @@ -18,7 +18,7 @@ func ResponseHeadersPolicyItemMapper(_, scope string, awsItem *types.ResponseHea item := sdp.Item{ Type: "cloudfront-response-headers-policy", - UniqueAttribute: "id", + UniqueAttribute: "Id", Attributes: attributes, Scope: scope, } diff --git a/sources/cloudfront/streaming_distribution.go b/sources/cloudfront/streaming_distribution.go index a6d19362..a8fd015c 100644 --- a/sources/cloudfront/streaming_distribution.go +++ b/sources/cloudfront/streaming_distribution.go @@ -42,7 +42,7 @@ func streamingDistributionGetFunc(ctx context.Context, client CloudFrontClient, return nil, fmt.Errorf("failed to get tags for streaming distribution %v: %w", *d.Id, err) } - attributes, err := sources.ToAttributesCase(d) + attributes, err := sources.ToAttributesWithExclude(d) if err != nil { return nil, err @@ -50,7 +50,7 @@ func streamingDistributionGetFunc(ctx context.Context, client CloudFrontClient, item := sdp.Item{ Type: "cloudfront-streaming-distribution", - UniqueAttribute: "id", + UniqueAttribute: "Id", Attributes: attributes, Scope: scope, Tags: tags, diff --git a/sources/cloudwatch/alarm.go b/sources/cloudwatch/alarm.go index facaa55d..b85fa855 100644 --- a/sources/cloudwatch/alarm.go +++ b/sources/cloudwatch/alarm.go @@ -73,11 +73,11 @@ func alarmOutputMapper(ctx context.Context, client CloudwatchClient, scope strin var arn *string if alarm.Metric != nil { - attrs, err = sources.ToAttributesCase(alarm.Metric) + attrs, err = sources.ToAttributesWithExclude(alarm.Metric) arn = alarm.Metric.AlarmArn } if alarm.Composite != nil { - attrs, err = sources.ToAttributesCase(alarm.Composite) + attrs, err = sources.ToAttributesWithExclude(alarm.Composite) arn = alarm.Composite.AlarmArn } @@ -104,7 +104,7 @@ func alarmOutputMapper(ctx context.Context, client CloudwatchClient, scope strin item := sdp.Item{ Type: "cloudwatch-alarm", - UniqueAttribute: "alarmName", + UniqueAttribute: "AlarmName", Scope: scope, Attributes: attrs, Tags: tags, diff --git a/sources/directconnect/connection.go b/sources/directconnect/connection.go index 6a0c586d..8344bfc4 100644 --- a/sources/directconnect/connection.go +++ b/sources/directconnect/connection.go @@ -12,14 +12,14 @@ func connectionOutputMapper(_ context.Context, _ *directconnect.Client, scope st items := make([]*sdp.Item, 0) for _, connection := range output.Connections { - attributes, err := sources.ToAttributesCase(connection, "tags") + attributes, err := sources.ToAttributesWithExclude(connection, "tags") if err != nil { return nil, err } item := sdp.Item{ Type: "directconnect-connection", - UniqueAttribute: "connectionId", + UniqueAttribute: "ConnectionId", Attributes: attributes, Scope: scope, Tags: tagsToMap(connection.Tags), diff --git a/sources/directconnect/customer-metadata.go b/sources/directconnect/customer-metadata.go index c6d7bd5b..ca2d2318 100644 --- a/sources/directconnect/customer-metadata.go +++ b/sources/directconnect/customer-metadata.go @@ -12,14 +12,14 @@ func customerMetadataOutputMapper(_ context.Context, _ *directconnect.Client, sc items := make([]*sdp.Item, 0) for _, agreement := range output.Agreements { - attributes, err := sources.ToAttributesCase(agreement, "tags") + attributes, err := sources.ToAttributesWithExclude(agreement, "tags") if err != nil { return nil, err } item := sdp.Item{ Type: "directconnect-customer-metadata", - UniqueAttribute: "agreementName", + UniqueAttribute: "AgreementName", Attributes: attributes, Scope: scope, } diff --git a/sources/directconnect/direct-connect-gateway-association-proposal.go b/sources/directconnect/direct-connect-gateway-association-proposal.go index 7885d421..efc8e029 100644 --- a/sources/directconnect/direct-connect-gateway-association-proposal.go +++ b/sources/directconnect/direct-connect-gateway-association-proposal.go @@ -13,14 +13,14 @@ func directConnectGatewayAssociationProposalOutputMapper(_ context.Context, _ *d items := make([]*sdp.Item, 0) for _, associationProposal := range output.DirectConnectGatewayAssociationProposals { - attributes, err := sources.ToAttributesCase(associationProposal, "tags") + attributes, err := sources.ToAttributesWithExclude(associationProposal, "tags") if err != nil { return nil, err } item := sdp.Item{ Type: "directconnect-direct-connect-gateway-association-proposal", - UniqueAttribute: "proposalId", + UniqueAttribute: "ProposalId", Attributes: attributes, Scope: scope, } diff --git a/sources/directconnect/direct-connect-gateway-association.go b/sources/directconnect/direct-connect-gateway-association.go index caeee2b2..5c092315 100644 --- a/sources/directconnect/direct-connect-gateway-association.go +++ b/sources/directconnect/direct-connect-gateway-association.go @@ -19,14 +19,14 @@ func directConnectGatewayAssociationOutputMapper(_ context.Context, _ *directcon items := make([]*sdp.Item, 0) for _, association := range output.DirectConnectGatewayAssociations { - attributes, err := sources.ToAttributesCase(association, "tags") + attributes, err := sources.ToAttributesWithExclude(association, "tags") if err != nil { return nil, err } item := sdp.Item{ Type: "directconnect-direct-connect-gateway-association", - UniqueAttribute: "associationId", + UniqueAttribute: "AssociationId", Attributes: attributes, Scope: scope, } diff --git a/sources/directconnect/direct-connect-gateway-attachment.go b/sources/directconnect/direct-connect-gateway-attachment.go index 11c384d6..583a855a 100644 --- a/sources/directconnect/direct-connect-gateway-attachment.go +++ b/sources/directconnect/direct-connect-gateway-attachment.go @@ -14,7 +14,7 @@ func directConnectGatewayAttachmentOutputMapper(_ context.Context, _ *directconn items := make([]*sdp.Item, 0) for _, attachment := range output.DirectConnectGatewayAttachments { - attributes, err := sources.ToAttributesCase(attachment, "tags") + attributes, err := sources.ToAttributesWithExclude(attachment, "tags") if err != nil { return nil, err } @@ -22,14 +22,14 @@ func directConnectGatewayAttachmentOutputMapper(_ context.Context, _ *directconn // The uniqueAttributeValue for this is a custom field: // {gatewayId}/{virtualInterfaceId} // i.e., "cf68415c-f4ae-48f2-87a7-3b52cexample/dxvif-ffhhk74f" - err = attributes.Set("uniqueName", fmt.Sprintf("%s/%s", *attachment.DirectConnectGatewayId, *attachment.VirtualInterfaceId)) + err = attributes.Set("UniqueName", fmt.Sprintf("%s/%s", *attachment.DirectConnectGatewayId, *attachment.VirtualInterfaceId)) if err != nil { return nil, err } item := sdp.Item{ Type: "directconnect-direct-connect-gateway-attachment", - UniqueAttribute: "uniqueName", + UniqueAttribute: "UniqueName", Attributes: attributes, Scope: scope, } diff --git a/sources/directconnect/direct-connect-gateway.go b/sources/directconnect/direct-connect-gateway.go index 2c8d89c8..3a870f61 100644 --- a/sources/directconnect/direct-connect-gateway.go +++ b/sources/directconnect/direct-connect-gateway.go @@ -37,7 +37,7 @@ func directConnectGatewayOutputMapper(ctx context.Context, cli *directconnect.Cl items := make([]*sdp.Item, 0) for _, directConnectGateway := range output.DirectConnectGateways { - attributes, err := sources.ToAttributesCase(directConnectGateway, "tags") + attributes, err := sources.ToAttributesWithExclude(directConnectGateway, "tags") if err != nil { return nil, err } @@ -46,7 +46,7 @@ func directConnectGatewayOutputMapper(ctx context.Context, cli *directconnect.Cl item := sdp.Item{ Type: "directconnect-direct-connect-gateway", - UniqueAttribute: "directConnectGatewayId", + UniqueAttribute: "DirectConnectGatewayId", Attributes: attributes, Scope: scope, Tags: tagsToMap(relevantTags), diff --git a/sources/directconnect/hosted-connection.go b/sources/directconnect/hosted-connection.go index 86a6c0ca..2272b34d 100644 --- a/sources/directconnect/hosted-connection.go +++ b/sources/directconnect/hosted-connection.go @@ -12,14 +12,14 @@ func hostedConnectionOutputMapper(_ context.Context, _ *directconnect.Client, sc items := make([]*sdp.Item, 0) for _, connection := range output.Connections { - attributes, err := sources.ToAttributesCase(connection, "tags") + attributes, err := sources.ToAttributesWithExclude(connection, "tags") if err != nil { return nil, err } item := sdp.Item{ Type: "directconnect-hosted-connection", - UniqueAttribute: "connectionId", + UniqueAttribute: "ConnectionId", Attributes: attributes, Scope: scope, Tags: tagsToMap(connection.Tags), diff --git a/sources/directconnect/interconnect.go b/sources/directconnect/interconnect.go index af58e687..2a228129 100644 --- a/sources/directconnect/interconnect.go +++ b/sources/directconnect/interconnect.go @@ -14,14 +14,14 @@ func interconnectOutputMapper(_ context.Context, _ *directconnect.Client, scope items := make([]*sdp.Item, 0) for _, interconnect := range output.Interconnects { - attributes, err := sources.ToAttributesCase(interconnect, "tags") + attributes, err := sources.ToAttributesWithExclude(interconnect, "tags") if err != nil { return nil, err } item := sdp.Item{ Type: "directconnect-interconnect", - UniqueAttribute: "interconnectId", + UniqueAttribute: "InterconnectId", Attributes: attributes, Scope: scope, Tags: tagsToMap(interconnect.Tags), diff --git a/sources/directconnect/lag.go b/sources/directconnect/lag.go index 945dfabb..e61ce8cb 100644 --- a/sources/directconnect/lag.go +++ b/sources/directconnect/lag.go @@ -14,14 +14,14 @@ func lagOutputMapper(_ context.Context, _ *directconnect.Client, scope string, _ items := make([]*sdp.Item, 0) for _, lag := range output.Lags { - attributes, err := sources.ToAttributesCase(lag, "tags") + attributes, err := sources.ToAttributesWithExclude(lag, "tags") if err != nil { return nil, err } item := sdp.Item{ Type: "directconnect-lag", - UniqueAttribute: "lagId", + UniqueAttribute: "LagId", Attributes: attributes, Scope: scope, Tags: tagsToMap(lag.Tags), diff --git a/sources/directconnect/location.go b/sources/directconnect/location.go index 86ddcbbe..da5c04bf 100644 --- a/sources/directconnect/location.go +++ b/sources/directconnect/location.go @@ -12,14 +12,14 @@ func locationOutputMapper(_ context.Context, _ *directconnect.Client, scope stri items := make([]*sdp.Item, 0) for _, location := range output.Locations { - attributes, err := sources.ToAttributesCase(location, "tags") + attributes, err := sources.ToAttributesWithExclude(location, "tags") if err != nil { return nil, err } item := sdp.Item{ Type: "directconnect-location", - UniqueAttribute: "locationCode", + UniqueAttribute: "LocationCode", Attributes: attributes, Scope: scope, } diff --git a/sources/directconnect/router-configuration.go b/sources/directconnect/router-configuration.go index db0eaa83..ecefe558 100644 --- a/sources/directconnect/router-configuration.go +++ b/sources/directconnect/router-configuration.go @@ -13,14 +13,14 @@ func routerConfigurationOutputMapper(_ context.Context, _ *directconnect.Client, return nil, nil } - attributes, err := sources.ToAttributesCase(output, "tags") + attributes, err := sources.ToAttributesWithExclude(output, "tags") if err != nil { return nil, err } item := sdp.Item{ Type: "directconnect-router-configuration", - UniqueAttribute: "virtualInterfaceId", + UniqueAttribute: "VirtualInterfaceId", Attributes: attributes, Scope: scope, } diff --git a/sources/directconnect/virtual-gateway.go b/sources/directconnect/virtual-gateway.go index aa76a925..8171ade8 100644 --- a/sources/directconnect/virtual-gateway.go +++ b/sources/directconnect/virtual-gateway.go @@ -12,14 +12,14 @@ func virtualGatewayOutputMapper(_ context.Context, _ *directconnect.Client, scop items := make([]*sdp.Item, 0) for _, virtualGateway := range output.VirtualGateways { - attributes, err := sources.ToAttributesCase(virtualGateway, "tags") + attributes, err := sources.ToAttributesWithExclude(virtualGateway, "tags") if err != nil { return nil, err } item := sdp.Item{ Type: "directconnect-virtual-gateway", - UniqueAttribute: "virtualGatewayId", + UniqueAttribute: "VirtualGatewayId", Attributes: attributes, Scope: scope, } diff --git a/sources/directconnect/virtual-interface.go b/sources/directconnect/virtual-interface.go index 4e64745e..45db715b 100644 --- a/sources/directconnect/virtual-interface.go +++ b/sources/directconnect/virtual-interface.go @@ -15,14 +15,14 @@ func virtualInterfaceOutputMapper(_ context.Context, _ *directconnect.Client, sc items := make([]*sdp.Item, 0) for _, virtualInterface := range output.VirtualInterfaces { - attributes, err := sources.ToAttributesCase(virtualInterface, "tags") + attributes, err := sources.ToAttributesWithExclude(virtualInterface, "tags") if err != nil { return nil, err } item := sdp.Item{ Type: "directconnect-virtual-interface", - UniqueAttribute: "virtualInterfaceId", + UniqueAttribute: "VirtualInterfaceId", Attributes: attributes, Scope: scope, Tags: tagsToMap(virtualInterface.Tags), diff --git a/sources/dynamodb/backup.go b/sources/dynamodb/backup.go index dd1d5b01..c8dc3ceb 100644 --- a/sources/dynamodb/backup.go +++ b/sources/dynamodb/backup.go @@ -32,7 +32,7 @@ func backupGetFunc(ctx context.Context, client Client, scope string, input *dyna details := out.BackupDescription.BackupDetails - attributes, err := sources.ToAttributesCase(details) + attributes, err := sources.ToAttributesWithExclude(details) if err != nil { return nil, err @@ -40,7 +40,7 @@ func backupGetFunc(ctx context.Context, client Client, scope string, input *dyna item := sdp.Item{ Type: "dynamodb-backup", - UniqueAttribute: "backupName", + UniqueAttribute: "BackupName", Attributes: attributes, Scope: scope, } diff --git a/sources/dynamodb/table.go b/sources/dynamodb/table.go index 55fb9970..471a2dce 100644 --- a/sources/dynamodb/table.go +++ b/sources/dynamodb/table.go @@ -51,7 +51,7 @@ func tableGetFunc(ctx context.Context, client Client, scope string, input *dynam } } - attributes, err := sources.ToAttributesCase(table) + attributes, err := sources.ToAttributesWithExclude(table) if err != nil { return nil, err @@ -59,7 +59,7 @@ func tableGetFunc(ctx context.Context, client Client, scope string, input *dynam item := sdp.Item{ Type: "dynamodb-table", - UniqueAttribute: "tableName", + UniqueAttribute: "TableName", Scope: scope, Attributes: attributes, Tags: tagsMap, diff --git a/sources/ec2/address.go b/sources/ec2/address.go index aaa16373..ed0f42fd 100644 --- a/sources/ec2/address.go +++ b/sources/ec2/address.go @@ -42,7 +42,7 @@ func addressOutputMapper(_ context.Context, _ *ec2.Client, scope string, _ *ec2. } for _, address := range output.Addresses { - attrs, err = sources.ToAttributesCase(address, "tags") + attrs, err = sources.ToAttributesWithExclude(address, "tags") if err != nil { return nil, err @@ -50,7 +50,7 @@ func addressOutputMapper(_ context.Context, _ *ec2.Client, scope string, _ *ec2. item := sdp.Item{ Type: "ec2-address", - UniqueAttribute: "publicIp", + UniqueAttribute: "PublicIp", Scope: scope, Attributes: attrs, LinkedItemQueries: []*sdp.LinkedItemQuery{ diff --git a/sources/ec2/capacity_reservation.go b/sources/ec2/capacity_reservation.go index d7923f35..c85d295b 100644 --- a/sources/ec2/capacity_reservation.go +++ b/sources/ec2/capacity_reservation.go @@ -12,7 +12,7 @@ func capacityReservationOutputMapper(_ context.Context, _ *ec2.Client, scope str items := make([]*sdp.Item, 0) for _, cr := range output.CapacityReservations { - attributes, err := sources.ToAttributesCase(cr, "tags") + attributes, err := sources.ToAttributesWithExclude(cr, "tags") if err != nil { return nil, err @@ -20,7 +20,7 @@ func capacityReservationOutputMapper(_ context.Context, _ *ec2.Client, scope str item := sdp.Item{ Type: "ec2-capacity-reservation", - UniqueAttribute: "capacityReservationId", + UniqueAttribute: "CapacityReservationId", Attributes: attributes, Scope: scope, Tags: tagsToMap(cr.Tags), diff --git a/sources/ec2/capacity_reservation_fleet.go b/sources/ec2/capacity_reservation_fleet.go index 3068abf8..fb290fd7 100644 --- a/sources/ec2/capacity_reservation_fleet.go +++ b/sources/ec2/capacity_reservation_fleet.go @@ -13,7 +13,7 @@ func capacityReservationFleetOutputMapper(_ context.Context, _ *ec2.Client, scop items := make([]*sdp.Item, 0) for _, cr := range output.CapacityReservationFleets { - attributes, err := sources.ToAttributesCase(cr, "tags") + attributes, err := sources.ToAttributesWithExclude(cr, "tags") if err != nil { return nil, err @@ -21,7 +21,7 @@ func capacityReservationFleetOutputMapper(_ context.Context, _ *ec2.Client, scop item := sdp.Item{ Type: "ec2-capacity-reservation-fleet", - UniqueAttribute: "capacityReservationFleetId", + UniqueAttribute: "CapacityReservationFleetId", Attributes: attributes, Scope: scope, Tags: tagsToMap(cr.Tags), diff --git a/sources/ec2/egress_internet_gateway.go b/sources/ec2/egress_internet_gateway.go index 5b8b42cc..a8c71bf4 100644 --- a/sources/ec2/egress_internet_gateway.go +++ b/sources/ec2/egress_internet_gateway.go @@ -26,7 +26,7 @@ func egressOnlyInternetGatewayOutputMapper(_ context.Context, _ *ec2.Client, sco for _, gw := range output.EgressOnlyInternetGateways { var err error var attrs *sdp.ItemAttributes - attrs, err = sources.ToAttributesCase(gw, "tags") + attrs, err = sources.ToAttributesWithExclude(gw, "tags") if err != nil { return nil, &sdp.QueryError{ @@ -38,7 +38,7 @@ func egressOnlyInternetGatewayOutputMapper(_ context.Context, _ *ec2.Client, sco item := sdp.Item{ Type: "ec2-egress-only-internet-gateway", - UniqueAttribute: "egressOnlyInternetGatewayId", + UniqueAttribute: "EgressOnlyInternetGatewayId", Scope: scope, Attributes: attrs, Tags: tagsToMap(gw.Tags), diff --git a/sources/ec2/iam_instance_profile_association.go b/sources/ec2/iam_instance_profile_association.go index 9b6366c8..3f825951 100644 --- a/sources/ec2/iam_instance_profile_association.go +++ b/sources/ec2/iam_instance_profile_association.go @@ -12,7 +12,7 @@ func iamInstanceProfileAssociationOutputMapper(_ context.Context, _ *ec2.Client, items := make([]*sdp.Item, 0) for _, assoc := range output.IamInstanceProfileAssociations { - attributes, err := sources.ToAttributesCase(assoc) + attributes, err := sources.ToAttributesWithExclude(assoc) if err != nil { return nil, err @@ -20,7 +20,7 @@ func iamInstanceProfileAssociationOutputMapper(_ context.Context, _ *ec2.Client, item := sdp.Item{ Type: "ec2-iam-instance-profile-association", - UniqueAttribute: "associationId", + UniqueAttribute: "AssociationId", Attributes: attributes, Scope: scope, } diff --git a/sources/ec2/image.go b/sources/ec2/image.go index 4a74e936..e9d020df 100644 --- a/sources/ec2/image.go +++ b/sources/ec2/image.go @@ -37,7 +37,7 @@ func imageOutputMapper(_ context.Context, _ *ec2.Client, scope string, _ *ec2.De for _, image := range output.Images { var err error var attrs *sdp.ItemAttributes - attrs, err = sources.ToAttributesCase(image, "tags") + attrs, err = sources.ToAttributesWithExclude(image, "tags") if err != nil { return nil, &sdp.QueryError{ @@ -49,7 +49,7 @@ func imageOutputMapper(_ context.Context, _ *ec2.Client, scope string, _ *ec2.De item := sdp.Item{ Type: "ec2-image", - UniqueAttribute: "imageId", + UniqueAttribute: "ImageId", Scope: scope, Attributes: attrs, Tags: tagsToMap(image.Tags), diff --git a/sources/ec2/instance.go b/sources/ec2/instance.go index d372fb04..a061de3f 100644 --- a/sources/ec2/instance.go +++ b/sources/ec2/instance.go @@ -36,7 +36,7 @@ func instanceOutputMapper(_ context.Context, _ *ec2.Client, scope string, _ *ec2 for _, reservation := range output.Reservations { for _, instance := range reservation.Instances { - attrs, err := sources.ToAttributesCase(instance, "tags") + attrs, err := sources.ToAttributesWithExclude(instance, "tags") if err != nil { return nil, &sdp.QueryError{ @@ -48,7 +48,7 @@ func instanceOutputMapper(_ context.Context, _ *ec2.Client, scope string, _ *ec2 item := sdp.Item{ Type: "ec2-instance", - UniqueAttribute: "instanceId", + UniqueAttribute: "InstanceId", Scope: scope, Attributes: attrs, Tags: tagsToMap(instance.Tags), diff --git a/sources/ec2/instance_event_window.go b/sources/ec2/instance_event_window.go index 689a94c4..31321337 100644 --- a/sources/ec2/instance_event_window.go +++ b/sources/ec2/instance_event_window.go @@ -24,7 +24,7 @@ func instanceEventWindowOutputMapper(_ context.Context, _ *ec2.Client, scope str items := make([]*sdp.Item, 0) for _, ew := range output.InstanceEventWindows { - attrs, err := sources.ToAttributesCase(ew, "tags") + attrs, err := sources.ToAttributesWithExclude(ew, "tags") if err != nil { return nil, &sdp.QueryError{ @@ -36,7 +36,7 @@ func instanceEventWindowOutputMapper(_ context.Context, _ *ec2.Client, scope str item := sdp.Item{ Type: "ec2-instance-event-window", - UniqueAttribute: "instanceEventWindowId", + UniqueAttribute: "InstanceEventWindowId", Scope: scope, Attributes: attrs, Tags: tagsToMap(ew.Tags), diff --git a/sources/ec2/instance_status.go b/sources/ec2/instance_status.go index dda82d02..c39926fc 100644 --- a/sources/ec2/instance_status.go +++ b/sources/ec2/instance_status.go @@ -25,7 +25,7 @@ func instanceStatusOutputMapper(_ context.Context, _ *ec2.Client, scope string, items := make([]*sdp.Item, 0) for _, instanceStatus := range output.InstanceStatuses { - attrs, err := sources.ToAttributesCase(instanceStatus) + attrs, err := sources.ToAttributesWithExclude(instanceStatus) if err != nil { return nil, &sdp.QueryError{ @@ -37,7 +37,7 @@ func instanceStatusOutputMapper(_ context.Context, _ *ec2.Client, scope string, item := sdp.Item{ Type: "ec2-instance-status", - UniqueAttribute: "instanceId", + UniqueAttribute: "InstanceId", Scope: scope, Attributes: attrs, LinkedItemQueries: []*sdp.LinkedItemQuery{ diff --git a/sources/ec2/internet_gateway.go b/sources/ec2/internet_gateway.go index 50d5847f..2a2634dd 100644 --- a/sources/ec2/internet_gateway.go +++ b/sources/ec2/internet_gateway.go @@ -26,7 +26,7 @@ func internetGatewayOutputMapper(_ context.Context, _ *ec2.Client, scope string, for _, gw := range output.InternetGateways { var err error var attrs *sdp.ItemAttributes - attrs, err = sources.ToAttributesCase(gw, "tags") + attrs, err = sources.ToAttributesWithExclude(gw, "tags") if err != nil { return nil, &sdp.QueryError{ @@ -38,7 +38,7 @@ func internetGatewayOutputMapper(_ context.Context, _ *ec2.Client, scope string, item := sdp.Item{ Type: "ec2-internet-gateway", - UniqueAttribute: "internetGatewayId", + UniqueAttribute: "InternetGatewayId", Scope: scope, Attributes: attrs, Tags: tagsToMap(gw.Tags), diff --git a/sources/ec2/key_pair.go b/sources/ec2/key_pair.go index efdc445b..d3b28770 100644 --- a/sources/ec2/key_pair.go +++ b/sources/ec2/key_pair.go @@ -26,7 +26,7 @@ func keyPairOutputMapper(_ context.Context, _ *ec2.Client, scope string, _ *ec2. for _, gw := range output.KeyPairs { var err error var attrs *sdp.ItemAttributes - attrs, err = sources.ToAttributesCase(gw, "tags") + attrs, err = sources.ToAttributesWithExclude(gw, "tags") if err != nil { return nil, &sdp.QueryError{ @@ -38,7 +38,7 @@ func keyPairOutputMapper(_ context.Context, _ *ec2.Client, scope string, _ *ec2. item := sdp.Item{ Type: "ec2-key-pair", - UniqueAttribute: "keyName", + UniqueAttribute: "KeyName", Scope: scope, Attributes: attrs, Tags: tagsToMap(gw.Tags), diff --git a/sources/ec2/launch_template.go b/sources/ec2/launch_template.go index 8f9542a5..67c6561b 100644 --- a/sources/ec2/launch_template.go +++ b/sources/ec2/launch_template.go @@ -26,7 +26,7 @@ func launchTemplateOutputMapper(_ context.Context, _ *ec2.Client, scope string, for _, LaunchTemplate := range output.LaunchTemplates { var err error var attrs *sdp.ItemAttributes - attrs, err = sources.ToAttributesCase(LaunchTemplate, "tags") + attrs, err = sources.ToAttributesWithExclude(LaunchTemplate, "tags") if err != nil { return nil, &sdp.QueryError{ @@ -38,7 +38,7 @@ func launchTemplateOutputMapper(_ context.Context, _ *ec2.Client, scope string, item := sdp.Item{ Type: "ec2-launch-template", - UniqueAttribute: "launchTemplateId", + UniqueAttribute: "LaunchTemplateId", Scope: scope, Attributes: attrs, Tags: tagsToMap(LaunchTemplate.Tags), diff --git a/sources/ec2/launch_template_version.go b/sources/ec2/launch_template_version.go index 5cf8a9ca..f77a58d6 100644 --- a/sources/ec2/launch_template_version.go +++ b/sources/ec2/launch_template_version.go @@ -42,7 +42,7 @@ func launchTemplateVersionOutputMapper(_ context.Context, _ *ec2.Client, scope s for _, ltv := range output.LaunchTemplateVersions { var err error var attrs *sdp.ItemAttributes - attrs, err = sources.ToAttributesCase(ltv) + attrs, err = sources.ToAttributesWithExclude(ltv) if err != nil { return nil, &sdp.QueryError{ @@ -55,14 +55,14 @@ func launchTemplateVersionOutputMapper(_ context.Context, _ *ec2.Client, scope s if ltv.LaunchTemplateId != nil && ltv.VersionNumber != nil { // Create a custom UAV here since there is no one unique attribute. // The new UAV will be {templateId}.{version} - attrs.Set("versionIdCombo", fmt.Sprintf("%v.%v", *ltv.LaunchTemplateId, *ltv.VersionNumber)) + attrs.Set("VersionIdCombo", fmt.Sprintf("%v.%v", *ltv.LaunchTemplateId, *ltv.VersionNumber)) } else { return nil, errors.New("ec2-launch-template-version must have LaunchTemplateId and VersionNumber populated") } item := sdp.Item{ Type: "ec2-launch-template-version", - UniqueAttribute: "versionIdCombo", + UniqueAttribute: "VersionIdCombo", Scope: scope, Attributes: attrs, } diff --git a/sources/ec2/nat_gateway.go b/sources/ec2/nat_gateway.go index 5edc4b34..03744c8a 100644 --- a/sources/ec2/nat_gateway.go +++ b/sources/ec2/nat_gateway.go @@ -26,7 +26,7 @@ func natGatewayOutputMapper(_ context.Context, _ *ec2.Client, scope string, _ *e for _, ng := range output.NatGateways { var err error var attrs *sdp.ItemAttributes - attrs, err = sources.ToAttributesCase(ng, "tags") + attrs, err = sources.ToAttributesWithExclude(ng, "tags") if err != nil { return nil, &sdp.QueryError{ @@ -38,7 +38,7 @@ func natGatewayOutputMapper(_ context.Context, _ *ec2.Client, scope string, _ *e item := sdp.Item{ Type: "ec2-nat-gateway", - UniqueAttribute: "natGatewayId", + UniqueAttribute: "NatGatewayId", Scope: scope, Attributes: attrs, Tags: tagsToMap(ng.Tags), diff --git a/sources/ec2/network_acl.go b/sources/ec2/network_acl.go index 7b3788f1..6357f773 100644 --- a/sources/ec2/network_acl.go +++ b/sources/ec2/network_acl.go @@ -26,7 +26,7 @@ func networkAclOutputMapper(_ context.Context, _ *ec2.Client, scope string, _ *e for _, networkAcl := range output.NetworkAcls { var err error var attrs *sdp.ItemAttributes - attrs, err = sources.ToAttributesCase(networkAcl, "tags") + attrs, err = sources.ToAttributesWithExclude(networkAcl, "tags") if err != nil { return nil, &sdp.QueryError{ @@ -38,7 +38,7 @@ func networkAclOutputMapper(_ context.Context, _ *ec2.Client, scope string, _ *e item := sdp.Item{ Type: "ec2-network-acl", - UniqueAttribute: "networkAclId", + UniqueAttribute: "NetworkAclId", Scope: scope, Attributes: attrs, Tags: tagsToMap(networkAcl.Tags), diff --git a/sources/ec2/network_interface.go b/sources/ec2/network_interface.go index 4504cab2..f88d92ea 100644 --- a/sources/ec2/network_interface.go +++ b/sources/ec2/network_interface.go @@ -26,7 +26,7 @@ func networkInterfaceOutputMapper(_ context.Context, _ *ec2.Client, scope string for _, ni := range output.NetworkInterfaces { var err error var attrs *sdp.ItemAttributes - attrs, err = sources.ToAttributesCase(ni, "tagSet") + attrs, err = sources.ToAttributesWithExclude(ni, "tagSet") if err != nil { return nil, &sdp.QueryError{ @@ -38,7 +38,7 @@ func networkInterfaceOutputMapper(_ context.Context, _ *ec2.Client, scope string item := sdp.Item{ Type: "ec2-network-interface", - UniqueAttribute: "networkInterfaceId", + UniqueAttribute: "NetworkInterfaceId", Scope: scope, Attributes: attrs, Tags: tagsToMap(ni.TagSet), diff --git a/sources/ec2/network_interface_permissions.go b/sources/ec2/network_interface_permissions.go index d319ece0..9880e56d 100644 --- a/sources/ec2/network_interface_permissions.go +++ b/sources/ec2/network_interface_permissions.go @@ -26,7 +26,7 @@ func networkInterfacePermissionOutputMapper(_ context.Context, _ *ec2.Client, sc for _, ni := range output.NetworkInterfacePermissions { var err error var attrs *sdp.ItemAttributes - attrs, err = sources.ToAttributesCase(ni) + attrs, err = sources.ToAttributesWithExclude(ni) if err != nil { return nil, &sdp.QueryError{ @@ -38,7 +38,7 @@ func networkInterfacePermissionOutputMapper(_ context.Context, _ *ec2.Client, sc item := sdp.Item{ Type: "ec2-network-interface-permission", - UniqueAttribute: "networkInterfacePermissionId", + UniqueAttribute: "NetworkInterfacePermissionId", Scope: scope, Attributes: attrs, } diff --git a/sources/ec2/placement_group.go b/sources/ec2/placement_group.go index 4dfcdcbb..410117a0 100644 --- a/sources/ec2/placement_group.go +++ b/sources/ec2/placement_group.go @@ -26,7 +26,7 @@ func placementGroupOutputMapper(_ context.Context, _ *ec2.Client, scope string, for _, ng := range output.PlacementGroups { var err error var attrs *sdp.ItemAttributes - attrs, err = sources.ToAttributesCase(ng, "tags") + attrs, err = sources.ToAttributesWithExclude(ng, "tags") if err != nil { return nil, &sdp.QueryError{ @@ -38,7 +38,7 @@ func placementGroupOutputMapper(_ context.Context, _ *ec2.Client, scope string, item := sdp.Item{ Type: "ec2-placement-group", - UniqueAttribute: "groupId", + UniqueAttribute: "GroupId", Scope: scope, Attributes: attrs, Tags: tagsToMap(ng.Tags), diff --git a/sources/ec2/reserved_instance.go b/sources/ec2/reserved_instance.go index 2793aa58..78447eca 100644 --- a/sources/ec2/reserved_instance.go +++ b/sources/ec2/reserved_instance.go @@ -24,7 +24,7 @@ func reservedInstanceOutputMapper(_ context.Context, _ *ec2.Client, scope string items := make([]*sdp.Item, 0) for _, reservation := range output.ReservedInstances { - attrs, err := sources.ToAttributesCase(reservation, "tags") + attrs, err := sources.ToAttributesWithExclude(reservation, "tags") if err != nil { return nil, &sdp.QueryError{ @@ -36,7 +36,7 @@ func reservedInstanceOutputMapper(_ context.Context, _ *ec2.Client, scope string item := sdp.Item{ Type: "ec2-reserved-instance", - UniqueAttribute: "reservedInstancesId", + UniqueAttribute: "ReservedInstancesId", Scope: scope, Attributes: attrs, Tags: tagsToMap(reservation.Tags), diff --git a/sources/ec2/route_table.go b/sources/ec2/route_table.go index fe7ece10..c3654679 100644 --- a/sources/ec2/route_table.go +++ b/sources/ec2/route_table.go @@ -27,7 +27,7 @@ func routeTableOutputMapper(_ context.Context, _ *ec2.Client, scope string, _ *e for _, rt := range output.RouteTables { var err error var attrs *sdp.ItemAttributes - attrs, err = sources.ToAttributesCase(rt, "tags") + attrs, err = sources.ToAttributesWithExclude(rt, "tags") if err != nil { return nil, &sdp.QueryError{ @@ -39,7 +39,7 @@ func routeTableOutputMapper(_ context.Context, _ *ec2.Client, scope string, _ *e item := sdp.Item{ Type: "ec2-route-table", - UniqueAttribute: "routeTableId", + UniqueAttribute: "RouteTableId", Scope: scope, Attributes: attrs, Tags: tagsToMap(rt.Tags), diff --git a/sources/ec2/sg.go b/sources/ec2/sg.go index ab794590..43b3ce11 100644 --- a/sources/ec2/sg.go +++ b/sources/ec2/sg.go @@ -27,7 +27,7 @@ func securityGroupOutputMapper(_ context.Context, _ *ec2.Client, scope string, _ for _, securityGroup := range output.SecurityGroups { var err error var attrs *sdp.ItemAttributes - attrs, err = sources.ToAttributesCase(securityGroup, "tags") + attrs, err = sources.ToAttributesWithExclude(securityGroup, "tags") if err != nil { return nil, &sdp.QueryError{ @@ -39,7 +39,7 @@ func securityGroupOutputMapper(_ context.Context, _ *ec2.Client, scope string, _ item := sdp.Item{ Type: "ec2-security-group", - UniqueAttribute: "groupId", + UniqueAttribute: "GroupId", Scope: scope, Attributes: attrs, Tags: tagsToMap(securityGroup.Tags), diff --git a/sources/ec2/sg_rule.go b/sources/ec2/sg_rule.go index 29dea6ae..5be9bb99 100644 --- a/sources/ec2/sg_rule.go +++ b/sources/ec2/sg_rule.go @@ -26,7 +26,7 @@ func securityGroupRuleOutputMapper(_ context.Context, _ *ec2.Client, scope strin for _, securityGroupRule := range output.SecurityGroupRules { var err error var attrs *sdp.ItemAttributes - attrs, err = sources.ToAttributesCase(securityGroupRule, "tags") + attrs, err = sources.ToAttributesWithExclude(securityGroupRule, "tags") if err != nil { return nil, &sdp.QueryError{ @@ -38,7 +38,7 @@ func securityGroupRuleOutputMapper(_ context.Context, _ *ec2.Client, scope strin item := sdp.Item{ Type: "ec2-security-group-rule", - UniqueAttribute: "securityGroupRuleId", + UniqueAttribute: "SecurityGroupRuleId", Scope: scope, Attributes: attrs, Tags: tagsToMap(securityGroupRule.Tags), diff --git a/sources/ec2/snapshot.go b/sources/ec2/snapshot.go index afb35f2c..5cad6644 100644 --- a/sources/ec2/snapshot.go +++ b/sources/ec2/snapshot.go @@ -32,7 +32,7 @@ func snapshotOutputMapper(_ context.Context, _ *ec2.Client, scope string, _ *ec2 for _, snapshot := range output.Snapshots { var err error var attrs *sdp.ItemAttributes - attrs, err = sources.ToAttributesCase(snapshot, "tags") + attrs, err = sources.ToAttributesWithExclude(snapshot, "tags") if err != nil { return nil, &sdp.QueryError{ @@ -44,7 +44,7 @@ func snapshotOutputMapper(_ context.Context, _ *ec2.Client, scope string, _ *ec2 item := sdp.Item{ Type: "ec2-snapshot", - UniqueAttribute: "snapshotId", + UniqueAttribute: "SnapshotId", Scope: scope, Attributes: attrs, Tags: tagsToMap(snapshot.Tags), diff --git a/sources/ec2/subnet.go b/sources/ec2/subnet.go index ed00831e..ee084063 100644 --- a/sources/ec2/subnet.go +++ b/sources/ec2/subnet.go @@ -26,7 +26,7 @@ func subnetOutputMapper(_ context.Context, _ *ec2.Client, scope string, _ *ec2.D for _, subnet := range output.Subnets { var err error var attrs *sdp.ItemAttributes - attrs, err = sources.ToAttributesCase(subnet, "tags") + attrs, err = sources.ToAttributesWithExclude(subnet, "tags") if err != nil { return nil, &sdp.QueryError{ @@ -38,7 +38,7 @@ func subnetOutputMapper(_ context.Context, _ *ec2.Client, scope string, _ *ec2.D item := sdp.Item{ Type: "ec2-subnet", - UniqueAttribute: "subnetId", + UniqueAttribute: "SubnetId", Scope: scope, Attributes: attrs, Tags: tagsToMap(subnet.Tags), diff --git a/sources/ec2/volume.go b/sources/ec2/volume.go index 5dedb417..94b673c6 100644 --- a/sources/ec2/volume.go +++ b/sources/ec2/volume.go @@ -26,7 +26,7 @@ func volumeOutputMapper(_ context.Context, _ *ec2.Client, scope string, _ *ec2.D for _, volume := range output.Volumes { var err error var attrs *sdp.ItemAttributes - attrs, err = sources.ToAttributesCase(volume, "tags") + attrs, err = sources.ToAttributesWithExclude(volume, "tags") if err != nil { return nil, &sdp.QueryError{ @@ -38,7 +38,7 @@ func volumeOutputMapper(_ context.Context, _ *ec2.Client, scope string, _ *ec2.D item := sdp.Item{ Type: "ec2-volume", - UniqueAttribute: "volumeId", + UniqueAttribute: "VolumeId", Scope: scope, Attributes: attrs, Tags: tagsToMap(volume.Tags), diff --git a/sources/ec2/volume_status.go b/sources/ec2/volume_status.go index a71c737c..e102857e 100644 --- a/sources/ec2/volume_status.go +++ b/sources/ec2/volume_status.go @@ -27,7 +27,7 @@ func volumeStatusOutputMapper(_ context.Context, _ *ec2.Client, scope string, _ for _, volume := range output.VolumeStatuses { var err error var attrs *sdp.ItemAttributes - attrs, err = sources.ToAttributesCase(volume) + attrs, err = sources.ToAttributesWithExclude(volume) if err != nil { return nil, &sdp.QueryError{ @@ -39,7 +39,7 @@ func volumeStatusOutputMapper(_ context.Context, _ *ec2.Client, scope string, _ item := sdp.Item{ Type: "ec2-volume-status", - UniqueAttribute: "volumeId", + UniqueAttribute: "VolumeId", Scope: scope, Attributes: attrs, LinkedItemQueries: []*sdp.LinkedItemQuery{ diff --git a/sources/ec2/vpc.go b/sources/ec2/vpc.go index 5cb02d29..44e821d5 100644 --- a/sources/ec2/vpc.go +++ b/sources/ec2/vpc.go @@ -26,7 +26,7 @@ func vpcOutputMapper(_ context.Context, _ *ec2.Client, scope string, _ *ec2.Desc for _, vpc := range output.Vpcs { var err error var attrs *sdp.ItemAttributes - attrs, err = sources.ToAttributesCase(vpc, "tags") + attrs, err = sources.ToAttributesWithExclude(vpc, "tags") if err != nil { return nil, &sdp.QueryError{ @@ -38,7 +38,7 @@ func vpcOutputMapper(_ context.Context, _ *ec2.Client, scope string, _ *ec2.Desc item := sdp.Item{ Type: "ec2-vpc", - UniqueAttribute: "vpcId", + UniqueAttribute: "VpcId", Scope: scope, Attributes: attrs, Tags: tagsToMap(vpc.Tags), diff --git a/sources/ec2/vpc_endpoint.go b/sources/ec2/vpc_endpoint.go index 8af11e08..3d7517f1 100644 --- a/sources/ec2/vpc_endpoint.go +++ b/sources/ec2/vpc_endpoint.go @@ -47,7 +47,7 @@ func vpcEndpointOutputMapper(_ context.Context, _ *ec2.Client, scope string, _ * endpointWithPolicy.PolicyDocument = parsedPolicy } - attrs, err = sources.ToAttributesCase(endpointWithPolicy, "tags") + attrs, err = sources.ToAttributesWithExclude(endpointWithPolicy, "tags") if err != nil { return nil, &sdp.QueryError{ @@ -59,7 +59,7 @@ func vpcEndpointOutputMapper(_ context.Context, _ *ec2.Client, scope string, _ * item := sdp.Item{ Type: "ec2-vpc-endpoint", - UniqueAttribute: "vpcEndpointId", + UniqueAttribute: "VpcEndpointId", Scope: scope, Attributes: attrs, Tags: tagsToMap(endpoint.Tags), diff --git a/sources/ec2/vpc_peering_connection.go b/sources/ec2/vpc_peering_connection.go index dcd7a7b0..5c64bf65 100644 --- a/sources/ec2/vpc_peering_connection.go +++ b/sources/ec2/vpc_peering_connection.go @@ -13,7 +13,7 @@ func vpcPeeringConnectionOutputMapper(_ context.Context, _ *ec2.Client, scope st items := make([]*sdp.Item, 0) for _, connection := range output.VpcPeeringConnections { - attributes, err := sources.ToAttributesCase(connection, "tags") + attributes, err := sources.ToAttributesWithExclude(connection, "tags") if err != nil { return nil, err @@ -21,7 +21,7 @@ func vpcPeeringConnectionOutputMapper(_ context.Context, _ *ec2.Client, scope st item := sdp.Item{ Type: "ec2-vpc-peering-connection", - UniqueAttribute: "vpcPeeringConnectionId", + UniqueAttribute: "VpcPeeringConnectionId", Scope: scope, Attributes: attributes, Tags: tagsToMap(connection.Tags), diff --git a/sources/ecs/capacity_provider.go b/sources/ecs/capacity_provider.go index 856ae4a0..1f522a82 100644 --- a/sources/ecs/capacity_provider.go +++ b/sources/ecs/capacity_provider.go @@ -18,7 +18,7 @@ func capacityProviderOutputMapper(_ context.Context, _ ECSClient, scope string, items := make([]*sdp.Item, 0) for _, provider := range output.CapacityProviders { - attributes, err := sources.ToAttributesCase(provider, "tags") + attributes, err := sources.ToAttributesWithExclude(provider, "tags") if err != nil { return nil, err @@ -26,7 +26,7 @@ func capacityProviderOutputMapper(_ context.Context, _ ECSClient, scope string, item := sdp.Item{ Type: "ecs-capacity-provider", - UniqueAttribute: "name", + UniqueAttribute: "Name", Attributes: attributes, Scope: scope, Tags: tagsToMap(provider.Tags), diff --git a/sources/ecs/cluster.go b/sources/ecs/cluster.go index fa3ab9c2..86400de8 100644 --- a/sources/ecs/cluster.go +++ b/sources/ecs/cluster.go @@ -53,7 +53,7 @@ func clusterGetFunc(ctx context.Context, client ECSClient, scope string, input * cluster := out.Clusters[0] - attributes, err := sources.ToAttributesCase(cluster, "tags") + attributes, err := sources.ToAttributesWithExclude(cluster, "tags") if err != nil { return nil, err @@ -61,7 +61,7 @@ func clusterGetFunc(ctx context.Context, client ECSClient, scope string, input * item := sdp.Item{ Type: "ecs-cluster", - UniqueAttribute: "clusterName", + UniqueAttribute: "ClusterName", Scope: scope, Attributes: attributes, Tags: tagsToMap(cluster.Tags), diff --git a/sources/ecs/container_instance.go b/sources/ecs/container_instance.go index 832b7636..1d2ec353 100644 --- a/sources/ecs/container_instance.go +++ b/sources/ecs/container_instance.go @@ -30,7 +30,7 @@ func containerInstanceGetFunc(ctx context.Context, client ECSClient, scope strin containerInstance := out.ContainerInstances[0] - attributes, err := sources.ToAttributesCase(containerInstance, "tags") + attributes, err := sources.ToAttributesWithExclude(containerInstance, "tags") if err != nil { return nil, err @@ -40,12 +40,12 @@ func containerInstanceGetFunc(ctx context.Context, client ECSClient, scope strin // identifies them. This is {clusterName}/{id} // ecs-template-ECSCluster-8nS0WOLbs3nZ/50e9bf71ed57450ca56293cc5a042886 if a, err := sources.ParseARN(*containerInstance.ContainerInstanceArn); err == nil { - attributes.Set("id", a.Resource) + attributes.Set("Id", a.Resource) } item := sdp.Item{ Type: "ecs-container-instance", - UniqueAttribute: "id", + UniqueAttribute: "Id", Scope: scope, Attributes: attributes, Tags: tagsToMap(containerInstance.Tags), diff --git a/sources/ecs/service.go b/sources/ecs/service.go index 26432fc5..85202dc2 100644 --- a/sources/ecs/service.go +++ b/sources/ecs/service.go @@ -48,7 +48,7 @@ func serviceGetFunc(ctx context.Context, client ECSClient, scope string, input * service.TaskSets = []types.TaskSet{} - attributes, err := sources.ToAttributesCase(service, "tags") + attributes, err := sources.ToAttributesWithExclude(service, "tags") if err != nil { return nil, err @@ -56,13 +56,13 @@ func serviceGetFunc(ctx context.Context, client ECSClient, scope string, input * if service.ServiceArn != nil { if a, err := sources.ParseARN(*service.ServiceArn); err == nil { - attributes.Set("serviceFullName", a.Resource) + attributes.Set("ServiceFullName", a.Resource) } } item := sdp.Item{ Type: "ecs-service", - UniqueAttribute: "serviceFullName", + UniqueAttribute: "ServiceFullName", Scope: scope, Attributes: attributes, Tags: tagsToMap(service.Tags), diff --git a/sources/ecs/task.go b/sources/ecs/task.go index 0c915fff..f463a068 100644 --- a/sources/ecs/task.go +++ b/sources/ecs/task.go @@ -30,7 +30,7 @@ func taskGetFunc(ctx context.Context, client ECSClient, scope string, input *ecs task := out.Tasks[0] - attributes, err := sources.ToAttributesCase(task, "tags") + attributes, err := sources.ToAttributesWithExclude(task, "tags") if err != nil { return nil, err @@ -48,11 +48,11 @@ func taskGetFunc(ctx context.Context, client ECSClient, scope string, input *ecs // Create unique attribute in the format {clusterName}/{id} // test-ECSCluster-Bt4SqcM3CURk/2ffd7ed376c841bcb0e6795ddb6e72e2 - attributes.Set("id", a.ResourceID()) + attributes.Set("Id", a.ResourceID()) item := sdp.Item{ Type: "ecs-task", - UniqueAttribute: "id", + UniqueAttribute: "Id", Attributes: attributes, Scope: scope, Tags: tagsToMap(task.Tags), diff --git a/sources/ecs/task_definition.go b/sources/ecs/task_definition.go index 9fd0f324..5a2d454c 100644 --- a/sources/ecs/task_definition.go +++ b/sources/ecs/task_definition.go @@ -28,7 +28,7 @@ func taskDefinitionGetFunc(ctx context.Context, client ECSClient, scope string, td := out.TaskDefinition - attributes, err := sources.ToAttributesCase(td) + attributes, err := sources.ToAttributesWithExclude(td) if err != nil { return nil, err @@ -42,7 +42,7 @@ func taskDefinitionGetFunc(ctx context.Context, client ECSClient, scope string, item := sdp.Item{ Type: "ecs-task-definition", - UniqueAttribute: "family", + UniqueAttribute: "Family", Attributes: attributes, Scope: scope, Tags: tagsToMap(out.Tags), diff --git a/sources/efs/access_point.go b/sources/efs/access_point.go index 96bd6f9b..e06f72e9 100644 --- a/sources/efs/access_point.go +++ b/sources/efs/access_point.go @@ -18,7 +18,7 @@ func AccessPointOutputMapper(_ context.Context, _ *efs.Client, scope string, inp items := make([]*sdp.Item, 0) for _, ap := range output.AccessPoints { - attrs, err := sources.ToAttributesCase(ap, "tags") + attrs, err := sources.ToAttributesWithExclude(ap, "tags") if err != nil { return nil, err @@ -26,7 +26,7 @@ func AccessPointOutputMapper(_ context.Context, _ *efs.Client, scope string, inp item := sdp.Item{ Type: "efs-access-point", - UniqueAttribute: "accessPointId", + UniqueAttribute: "AccessPointId", Scope: scope, Attributes: attrs, Health: lifeCycleStateToHealth(ap.LifeCycleState), diff --git a/sources/efs/backup_policy.go b/sources/efs/backup_policy.go index 49ab5f5e..2375508e 100644 --- a/sources/efs/backup_policy.go +++ b/sources/efs/backup_policy.go @@ -27,14 +27,14 @@ func BackupPolicyOutputMapper(_ context.Context, _ *efs.Client, scope string, in return nil, errors.New("nil filesystem ID on input") } - attrs, err := sources.ToAttributesCase(output) + attrs, err := sources.ToAttributesWithExclude(output) if err != nil { return nil, err } // Add the filesystem ID as an attribute - err = attrs.Set("fileSystemId", *input.FileSystemId) + err = attrs.Set("FileSystemId", *input.FileSystemId) if err != nil { return nil, err @@ -42,7 +42,7 @@ func BackupPolicyOutputMapper(_ context.Context, _ *efs.Client, scope string, in item := sdp.Item{ Type: "efs-backup-policy", - UniqueAttribute: "fileSystemId", + UniqueAttribute: "FileSystemId", Scope: scope, Attributes: attrs, } diff --git a/sources/efs/file_system.go b/sources/efs/file_system.go index 50fd3549..e438eda0 100644 --- a/sources/efs/file_system.go +++ b/sources/efs/file_system.go @@ -18,7 +18,7 @@ func FileSystemOutputMapper(_ context.Context, _ *efs.Client, scope string, inpu items := make([]*sdp.Item, 0) for _, fs := range output.FileSystems { - attrs, err := sources.ToAttributesCase(fs, "tags") + attrs, err := sources.ToAttributesWithExclude(fs, "tags") if err != nil { return nil, err @@ -30,7 +30,7 @@ func FileSystemOutputMapper(_ context.Context, _ *efs.Client, scope string, inpu item := sdp.Item{ Type: "efs-file-system", - UniqueAttribute: "fileSystemId", + UniqueAttribute: "FileSystemId", Scope: scope, Attributes: attrs, Health: lifeCycleStateToHealth(fs.LifeCycleState), diff --git a/sources/efs/mount_target.go b/sources/efs/mount_target.go index e9e45f4e..1a5f1407 100644 --- a/sources/efs/mount_target.go +++ b/sources/efs/mount_target.go @@ -18,7 +18,7 @@ func MountTargetOutputMapper(_ context.Context, _ *efs.Client, scope string, inp items := make([]*sdp.Item, 0) for _, mt := range output.MountTargets { - attrs, err := sources.ToAttributesCase(mt) + attrs, err := sources.ToAttributesWithExclude(mt) if err != nil { return nil, err @@ -34,7 +34,7 @@ func MountTargetOutputMapper(_ context.Context, _ *efs.Client, scope string, inp item := sdp.Item{ Type: "efs-mount-target", - UniqueAttribute: "mountTargetId", + UniqueAttribute: "MountTargetId", Scope: scope, Attributes: attrs, Health: lifeCycleStateToHealth(mt.LifeCycleState), diff --git a/sources/efs/replication_configuration.go b/sources/efs/replication_configuration.go index e80eda19..2b387324 100644 --- a/sources/efs/replication_configuration.go +++ b/sources/efs/replication_configuration.go @@ -19,7 +19,7 @@ func ReplicationConfigurationOutputMapper(_ context.Context, _ *efs.Client, scop items := make([]*sdp.Item, 0) for _, replication := range output.Replications { - attrs, err := sources.ToAttributesCase(replication) + attrs, err := sources.ToAttributesWithExclude(replication) if err != nil { return nil, err @@ -41,7 +41,7 @@ func ReplicationConfigurationOutputMapper(_ context.Context, _ *efs.Client, scop item := sdp.Item{ Type: "efs-replication-configuration", - UniqueAttribute: "sourceFileSystemId", + UniqueAttribute: "SourceFileSystemId", Scope: scope, Attributes: attrs, Health: sdp.Health_HEALTH_OK.Enum(), // Default to OK diff --git a/sources/eks/addon.go b/sources/eks/addon.go index 81f59d78..c3dc9910 100644 --- a/sources/eks/addon.go +++ b/sources/eks/addon.go @@ -23,7 +23,7 @@ func addonGetFunc(ctx context.Context, client EKSClient, scope string, input *ek } } - attributes, err := sources.ToAttributesCase(out.Addon) + attributes, err := sources.ToAttributesWithExclude(out.Addon) if err != nil { return nil, err @@ -31,11 +31,11 @@ func addonGetFunc(ctx context.Context, client EKSClient, scope string, input *ek // The uniqueAttributeValue for this is a custom field: // {clusterName}/{addonName} - attributes.Set("uniqueName", (*out.Addon.ClusterName + "/" + *out.Addon.AddonName)) + attributes.Set("UniqueName", (*out.Addon.ClusterName + "/" + *out.Addon.AddonName)) item := sdp.Item{ Type: "eks-addon", - UniqueAttribute: "uniqueName", + UniqueAttribute: "UniqueName", Attributes: attributes, Scope: scope, } diff --git a/sources/eks/cluster.go b/sources/eks/cluster.go index bd677bcc..51b52152 100644 --- a/sources/eks/cluster.go +++ b/sources/eks/cluster.go @@ -25,7 +25,7 @@ func clusterGetFunc(ctx context.Context, client EKSClient, scope string, input * cluster := output.Cluster - attributes, err := sources.ToAttributesCase(cluster, "clientRequestToken") + attributes, err := sources.ToAttributesWithExclude(cluster, "clientRequestToken") if err != nil { return nil, err @@ -33,7 +33,7 @@ func clusterGetFunc(ctx context.Context, client EKSClient, scope string, input * item := sdp.Item{ Type: "eks-cluster", - UniqueAttribute: "name", + UniqueAttribute: "Name", Attributes: attributes, Scope: scope, Tags: cluster.Tags, diff --git a/sources/eks/fargate_profile.go b/sources/eks/fargate_profile.go index 5001acc1..65aa3640 100644 --- a/sources/eks/fargate_profile.go +++ b/sources/eks/fargate_profile.go @@ -23,7 +23,7 @@ func fargateProfileGetFunc(ctx context.Context, client EKSClient, scope string, } } - attributes, err := sources.ToAttributesCase(out.FargateProfile) + attributes, err := sources.ToAttributesWithExclude(out.FargateProfile) if err != nil { return nil, err @@ -31,11 +31,11 @@ func fargateProfileGetFunc(ctx context.Context, client EKSClient, scope string, // The uniqueAttributeValue for this is a custom field: // {clusterName}/{FargateProfileName} - attributes.Set("uniqueName", (*out.FargateProfile.ClusterName + "/" + *out.FargateProfile.FargateProfileName)) + attributes.Set("UniqueName", (*out.FargateProfile.ClusterName + "/" + *out.FargateProfile.FargateProfileName)) item := sdp.Item{ Type: "eks-fargate-profile", - UniqueAttribute: "uniqueName", + UniqueAttribute: "UniqueName", Attributes: attributes, Scope: scope, Tags: out.FargateProfile.Tags, diff --git a/sources/eks/node_group.go b/sources/eks/node_group.go index 4f4a1356..868116be 100644 --- a/sources/eks/node_group.go +++ b/sources/eks/node_group.go @@ -23,7 +23,7 @@ func nodegroupGetFunc(ctx context.Context, client EKSClient, scope string, input } } - attributes, err := sources.ToAttributesCase(out.Nodegroup) + attributes, err := sources.ToAttributesWithExclude(out.Nodegroup) if err != nil { return nil, err @@ -33,11 +33,11 @@ func nodegroupGetFunc(ctx context.Context, client EKSClient, scope string, input // The uniqueAttributeValue for this is a custom field: // {clusterName}/{NodegroupName} - attributes.Set("uniqueName", (*out.Nodegroup.ClusterName + "/" + *out.Nodegroup.NodegroupName)) + attributes.Set("UniqueName", (*out.Nodegroup.ClusterName + "/" + *out.Nodegroup.NodegroupName)) item := sdp.Item{ Type: "eks-nodegroup", - UniqueAttribute: "uniqueName", + UniqueAttribute: "UniqueName", Attributes: attributes, Scope: scope, Tags: out.Nodegroup.Tags, diff --git a/sources/elb/elb.go b/sources/elb/elb.go index faa33911..be2758f8 100644 --- a/sources/elb/elb.go +++ b/sources/elb/elb.go @@ -54,7 +54,7 @@ func loadBalancerOutputMapper(ctx context.Context, client elbClient, scope strin } for _, desc := range output.LoadBalancerDescriptions { - attrs, err := sources.ToAttributesCase(desc) + attrs, err := sources.ToAttributesWithExclude(desc) if err != nil { return nil, err @@ -72,7 +72,7 @@ func loadBalancerOutputMapper(ctx context.Context, client elbClient, scope strin item := sdp.Item{ Type: "elb-load-balancer", - UniqueAttribute: "loadBalancerName", + UniqueAttribute: "LoadBalancerName", Attributes: attrs, Scope: scope, Tags: tags, diff --git a/sources/elb/instance_health.go b/sources/elb/instance_health.go index f2e9fd8c..ab86d60a 100644 --- a/sources/elb/instance_health.go +++ b/sources/elb/instance_health.go @@ -42,7 +42,7 @@ func instanceHealthOutputMapper(_ context.Context, _ *elb.Client, scope string, items := make([]*sdp.Item, 0) for _, is := range output.InstanceStates { - attrs, err := sources.ToAttributesCase(is) + attrs, err := sources.ToAttributesWithExclude(is) if err != nil { return nil, err @@ -50,7 +50,7 @@ func instanceHealthOutputMapper(_ context.Context, _ *elb.Client, scope string, item := sdp.Item{ Type: "elb-instance-health", - UniqueAttribute: "instanceId", + UniqueAttribute: "InstanceId", Attributes: attrs, Scope: scope, } diff --git a/sources/elbv2/elb.go b/sources/elbv2/elb.go index 5b9af25e..b6c09e11 100644 --- a/sources/elbv2/elb.go +++ b/sources/elbv2/elb.go @@ -24,7 +24,7 @@ func loadBalancerOutputMapper(ctx context.Context, client elbClient, scope strin tagsMap := getTagsMap(ctx, client, arns) for _, lb := range output.LoadBalancers { - attrs, err := sources.ToAttributesCase(lb) + attrs, err := sources.ToAttributesWithExclude(lb) if err != nil { return nil, err @@ -38,7 +38,7 @@ func loadBalancerOutputMapper(ctx context.Context, client elbClient, scope strin item := sdp.Item{ Type: "elbv2-load-balancer", - UniqueAttribute: "loadBalancerName", + UniqueAttribute: "LoadBalancerName", Attributes: attrs, Scope: scope, Tags: tags, diff --git a/sources/elbv2/listener.go b/sources/elbv2/listener.go index b9d7229e..35295bd0 100644 --- a/sources/elbv2/listener.go +++ b/sources/elbv2/listener.go @@ -45,7 +45,7 @@ func listenerOutputMapper(ctx context.Context, client elbClient, scope string, _ } } - attrs, err := sources.ToAttributesCase(listener) + attrs, err := sources.ToAttributesWithExclude(listener) if err != nil { return nil, err @@ -59,7 +59,7 @@ func listenerOutputMapper(ctx context.Context, client elbClient, scope string, _ item := sdp.Item{ Type: "elbv2-listener", - UniqueAttribute: "listenerArn", + UniqueAttribute: "ListenerArn", Attributes: attrs, Scope: scope, Tags: tags, diff --git a/sources/elbv2/rule.go b/sources/elbv2/rule.go index 34a15c02..826d0263 100644 --- a/sources/elbv2/rule.go +++ b/sources/elbv2/rule.go @@ -22,7 +22,7 @@ func ruleOutputMapper(ctx context.Context, client elbClient, scope string, _ *el tagsMap := getTagsMap(ctx, client, ruleArns) for _, rule := range output.Rules { - attrs, err := sources.ToAttributesCase(rule) + attrs, err := sources.ToAttributesWithExclude(rule) if err != nil { return nil, err @@ -36,7 +36,7 @@ func ruleOutputMapper(ctx context.Context, client elbClient, scope string, _ *el item := sdp.Item{ Type: "elbv2-rule", - UniqueAttribute: "ruleArn", + UniqueAttribute: "RuleArn", Attributes: attrs, Scope: scope, Tags: tags, diff --git a/sources/elbv2/rule_test.go b/sources/elbv2/rule_test.go index 78d2f73f..f4402714 100644 --- a/sources/elbv2/rule_test.go +++ b/sources/elbv2/rule_test.go @@ -110,7 +110,7 @@ func TestNewRuleSource(t *testing.T) { t.Skip("no load balancers found") } - lbARN, err := lbs[0].GetAttributes().Get("loadBalancerArn") + lbARN, err := lbs[0].GetAttributes().Get("LoadBalancerArn") if err != nil { t.Fatal(err) } @@ -124,7 +124,7 @@ func TestNewRuleSource(t *testing.T) { t.Skip("no listeners found") } - listenerARN, err := listeners[0].GetAttributes().Get("listenerArn") + listenerARN, err := listeners[0].GetAttributes().Get("ListenerArn") if err != nil { t.Fatal(err) } diff --git a/sources/elbv2/target_group.go b/sources/elbv2/target_group.go index 93430577..c618842e 100644 --- a/sources/elbv2/target_group.go +++ b/sources/elbv2/target_group.go @@ -23,7 +23,7 @@ func targetGroupOutputMapper(ctx context.Context, client elbClient, scope string tagsMap := getTagsMap(ctx, client, tgArns) for _, tg := range output.TargetGroups { - attrs, err := sources.ToAttributesCase(tg) + attrs, err := sources.ToAttributesWithExclude(tg) if err != nil { return nil, err @@ -37,7 +37,7 @@ func targetGroupOutputMapper(ctx context.Context, client elbClient, scope string item := sdp.Item{ Type: "elbv2-target-group", - UniqueAttribute: "targetGroupName", + UniqueAttribute: "TargetGroupName", Attributes: attrs, Scope: scope, Tags: tags, diff --git a/sources/elbv2/target_health.go b/sources/elbv2/target_health.go index 8fb91145..f9b00efb 100644 --- a/sources/elbv2/target_health.go +++ b/sources/elbv2/target_health.go @@ -79,7 +79,7 @@ func targetHealthOutputMapper(_ context.Context, _ *elbv2.Client, scope string, items := make([]*sdp.Item, 0) for _, desc := range output.TargetHealthDescriptions { - attrs, err := sources.ToAttributesCase(desc) + attrs, err := sources.ToAttributesWithExclude(desc) if err != nil { return nil, err @@ -87,7 +87,7 @@ func targetHealthOutputMapper(_ context.Context, _ *elbv2.Client, scope string, item := sdp.Item{ Type: "elbv2-target-health", - UniqueAttribute: "uniqueId", + UniqueAttribute: "UniqueId", Attributes: attrs, Scope: scope, } @@ -137,7 +137,7 @@ func targetHealthOutputMapper(_ context.Context, _ *elbv2.Client, scope string, Port: desc.Target.Port, } - item.GetAttributes().Set("uniqueId", id.String()) + item.GetAttributes().Set("UniqueId", id.String()) // See if the ID is an ARN a, err := sources.ParseARN(*desc.Target.Id) diff --git a/sources/iam/group.go b/sources/iam/group.go index 451f5752..f82f0ebb 100644 --- a/sources/iam/group.go +++ b/sources/iam/group.go @@ -40,7 +40,7 @@ func groupListFunc(ctx context.Context, client *iam.Client, _ string) ([]*types. } func groupItemMapper(_, scope string, awsItem *types.Group) (*sdp.Item, error) { - attributes, err := sources.ToAttributesCase(awsItem) + attributes, err := sources.ToAttributesWithExclude(awsItem) if err != nil { return nil, err @@ -48,7 +48,7 @@ func groupItemMapper(_, scope string, awsItem *types.Group) (*sdp.Item, error) { item := sdp.Item{ Type: "iam-group", - UniqueAttribute: "groupName", + UniqueAttribute: "GroupName", Attributes: attributes, Scope: scope, } diff --git a/sources/iam/instance_profile.go b/sources/iam/instance_profile.go index 7f1bc340..4ed56ea0 100644 --- a/sources/iam/instance_profile.go +++ b/sources/iam/instance_profile.go @@ -40,7 +40,7 @@ func instanceProfileListFunc(ctx context.Context, client *iam.Client, _ string) } func instanceProfileItemMapper(_, scope string, awsItem *types.InstanceProfile) (*sdp.Item, error) { - attributes, err := sources.ToAttributesCase(awsItem) + attributes, err := sources.ToAttributesWithExclude(awsItem) if err != nil { return nil, err @@ -48,7 +48,7 @@ func instanceProfileItemMapper(_, scope string, awsItem *types.InstanceProfile) item := sdp.Item{ Type: "iam-instance-profile", - UniqueAttribute: "instanceProfileName", + UniqueAttribute: "InstanceProfileName", Attributes: attributes, Scope: scope, } diff --git a/sources/iam/policy.go b/sources/iam/policy.go index 78601b57..c6c93f79 100644 --- a/sources/iam/policy.go +++ b/sources/iam/policy.go @@ -206,7 +206,7 @@ func policyItemMapper(_, scope string, awsItem *PolicyDetails) (*sdp.Item, error Policy: awsItem.Policy, Document: awsItem.Document, } - attributes, err := sources.ToAttributesCase(finalAttributes) + attributes, err := sources.ToAttributesWithExclude(finalAttributes) if err != nil { return nil, err @@ -224,11 +224,11 @@ func policyItemMapper(_, scope string, awsItem *PolicyDetails) (*sdp.Item, error // Create a new attribute which is a combination of `path` and `policyName`, // this can then be constructed into an ARN when a user calls GET - attributes.Set("policyFullName", policyFullName) + attributes.Set("PolicyFullName", policyFullName) item := sdp.Item{ Type: "iam-policy", - UniqueAttribute: "policyFullName", + UniqueAttribute: "PolicyFullName", Attributes: attributes, Scope: scope, } diff --git a/sources/iam/policy_test.go b/sources/iam/policy_test.go index 551dbad5..a1c2b6fc 100644 --- a/sources/iam/policy_test.go +++ b/sources/iam/policy_test.go @@ -379,7 +379,7 @@ func TestNewPolicySource(t *testing.T) { } for _, item := range items { - arnString, err := item.GetAttributes().Get("arn") + arnString, err := item.GetAttributes().Get("Arn") if err != nil { t.Errorf("expected item to have an arn attribute, got %v", err) @@ -402,7 +402,7 @@ func TestNewPolicySource(t *testing.T) { t.Parallel() - arn, _ := items[0].GetAttributes().Get("arn") + arn, _ := items[0].GetAttributes().Get("Arn") _, err := source.Search(ctx, sources.FormatScope(account, ""), arn.(string), false) @@ -417,7 +417,7 @@ func TestNewPolicySource(t *testing.T) { t.Parallel() - arn, _ := items[0].GetAttributes().Get("arn") + arn, _ := items[0].GetAttributes().Get("Arn") _, err := source.Search(ctx, "aws", arn.(string), false) @@ -441,7 +441,7 @@ func TestNewPolicySource(t *testing.T) { } for _, item := range items { - arnString, err := item.GetAttributes().Get("arn") + arnString, err := item.GetAttributes().Get("Arn") if err != nil { t.Errorf("expected item to have an arn attribute, got %v", err) @@ -464,7 +464,7 @@ func TestNewPolicySource(t *testing.T) { t.Parallel() - arn, _ := items[0].GetAttributes().Get("arn") + arn, _ := items[0].GetAttributes().Get("Arn") _, err := source.Search(ctx, sources.FormatScope(account, ""), arn.(string), false) @@ -479,7 +479,7 @@ func TestNewPolicySource(t *testing.T) { t.Parallel() - arn, _ := items[0].GetAttributes().Get("arn") + arn, _ := items[0].GetAttributes().Get("Arn") _, err := source.Search(ctx, "aws", arn.(string), false) diff --git a/sources/iam/role.go b/sources/iam/role.go index bf2cca6c..3c291825 100644 --- a/sources/iam/role.go +++ b/sources/iam/role.go @@ -220,7 +220,7 @@ func roleItemMapper(_, scope string, awsItem *RoleDetails) (*sdp.Item, error) { enrichedRole.AssumeRolePolicyDocument = policyDoc } - attributes, err := sources.ToAttributesCase(enrichedRole) + attributes, err := sources.ToAttributesWithExclude(enrichedRole) if err != nil { return nil, err @@ -228,7 +228,7 @@ func roleItemMapper(_, scope string, awsItem *RoleDetails) (*sdp.Item, error) { item := sdp.Item{ Type: "iam-role", - UniqueAttribute: "roleName", + UniqueAttribute: "RoleName", Attributes: attributes, Scope: scope, } diff --git a/sources/iam/user.go b/sources/iam/user.go index 676d0a3f..1e4fc6fa 100644 --- a/sources/iam/user.go +++ b/sources/iam/user.go @@ -113,7 +113,7 @@ func userListFunc(ctx context.Context, client IAMClient, _ string) ([]*UserDetai } func userItemMapper(_, scope string, awsItem *UserDetails) (*sdp.Item, error) { - attributes, err := sources.ToAttributesCase(awsItem.User) + attributes, err := sources.ToAttributesWithExclude(awsItem.User) if err != nil { return nil, err @@ -121,7 +121,7 @@ func userItemMapper(_, scope string, awsItem *UserDetails) (*sdp.Item, error) { item := sdp.Item{ Type: "iam-user", - UniqueAttribute: "userName", + UniqueAttribute: "UserName", Attributes: attributes, Scope: scope, } diff --git a/sources/integration/apigateway/apigateway_test.go b/sources/integration/apigateway/apigateway_test.go index a9c15138..5b891b4a 100644 --- a/sources/integration/apigateway/apigateway_test.go +++ b/sources/integration/apigateway/apigateway_test.go @@ -99,7 +99,7 @@ func APIGateway(t *testing.T) { restApiIDFromSearch, err := integration.GetUniqueAttributeValueBySignificantAttribute( restApiUniqueAttribute, - "name", + "Name", integration.ResourceName(integration.APIGateway, restAPISrc, integration.TestID()), restApisFromSearch, true, @@ -126,7 +126,7 @@ func APIGateway(t *testing.T) { resourceUniqueAttrFromSearch, err := integration.GetUniqueAttributeValueBySignificantAttribute( resourceUniqueAttribute, - "path", + "Path", "/test", resources, true, @@ -143,7 +143,7 @@ func APIGateway(t *testing.T) { resourceUniqueAttrFromGet, err := integration.GetUniqueAttributeValueBySignificantAttribute( resourceUniqueAttribute, - "path", + "Path", "/test", []*sdp.Item{resource}, true, diff --git a/sources/integration/networkmanager/networkmanager_test.go b/sources/integration/networkmanager/networkmanager_test.go index 93a5eb2a..f09d5c61 100644 --- a/sources/integration/networkmanager/networkmanager_test.go +++ b/sources/integration/networkmanager/networkmanager_test.go @@ -96,7 +96,7 @@ func NetworkManager(t *testing.T) { } // Search global network by ARN - globalNetworkARN, err := globalNetwork.GetAttributes().Get("globalNetworkArn") + globalNetworkARN, err := globalNetwork.GetAttributes().Get("GlobalNetworkArn") if err != nil { t.Fatalf("failed to get global network ARN: %v", err) } diff --git a/sources/kms/alias.go b/sources/kms/alias.go index e122e856..a3cc86ff 100644 --- a/sources/kms/alias.go +++ b/sources/kms/alias.go @@ -14,7 +14,7 @@ func aliasOutputMapper(_ context.Context, _ *kms.Client, scope string, _ *kms.Li items := make([]*sdp.Item, 0) for _, alias := range output.Aliases { - attributes, err := sources.ToAttributesCase(alias, "tags") + attributes, err := sources.ToAttributesWithExclude(alias, "tags") if err != nil { return nil, err } @@ -43,14 +43,14 @@ func aliasOutputMapper(_ context.Context, _ *kms.Client, scope string, _ *kms.Li // The uniqueAttributeValue for this is the combination of the keyID and aliasName // i.e., "cf68415c-f4ae-48f2-87a7-3b52ce/alias/test-key" - err = attributes.Set("uniqueName", fmt.Sprintf("%s/%s", *alias.TargetKeyId, *alias.AliasName)) + err = attributes.Set("UniqueName", fmt.Sprintf("%s/%s", *alias.TargetKeyId, *alias.AliasName)) if err != nil { return nil, err } item := sdp.Item{ Type: "kms-alias", - UniqueAttribute: "uniqueName", + UniqueAttribute: "UniqueName", Attributes: attributes, Scope: scope, } diff --git a/sources/kms/custom-key-store.go b/sources/kms/custom-key-store.go index 010b07ec..5d6a22c3 100644 --- a/sources/kms/custom-key-store.go +++ b/sources/kms/custom-key-store.go @@ -15,14 +15,14 @@ func customKeyStoreOutputMapper(_ context.Context, _ *kms.Client, scope string, items := make([]*sdp.Item, 0) for _, customKeyStore := range output.CustomKeyStores { - attributes, err := sources.ToAttributesCase(customKeyStore, "tags") + attributes, err := sources.ToAttributesWithExclude(customKeyStore, "tags") if err != nil { return nil, err } item := sdp.Item{ Type: "kms-custom-key-store", - UniqueAttribute: "customKeyStoreId", + UniqueAttribute: "CustomKeyStoreId", Attributes: attributes, Scope: scope, } diff --git a/sources/kms/grant.go b/sources/kms/grant.go index 8919841c..846634cb 100644 --- a/sources/kms/grant.go +++ b/sources/kms/grant.go @@ -16,7 +16,7 @@ func grantOutputMapper(ctx context.Context, _ *kms.Client, scope string, _ *kms. items := make([]*sdp.Item, 0) for _, grant := range output.Grants { - attributes, err := sources.ToAttributesCase(grant, "tags") + attributes, err := sources.ToAttributesWithExclude(grant, "tags") if err != nil { return nil, err } @@ -41,14 +41,14 @@ func grantOutputMapper(ctx context.Context, _ *kms.Client, scope string, _ *kms. // The uniqueAttributeValue for this is the combination of the keyID and grantId // i.e., "cf68415c-f4ae-48f2-87a7-3b52ce/grant-id" - err = attributes.Set("uniqueName", fmt.Sprintf("%s/%s", keyID, *grant.GrantId)) + err = attributes.Set("UniqueName", fmt.Sprintf("%s/%s", keyID, *grant.GrantId)) if err != nil { return nil, err } item := sdp.Item{ Type: "kms-grant", - UniqueAttribute: "uniqueName", + UniqueAttribute: "UniqueName", Attributes: attributes, Scope: scope, } diff --git a/sources/kms/key-policy.go b/sources/kms/key-policy.go index 0cb4ccc1..bff08e35 100644 --- a/sources/kms/key-policy.go +++ b/sources/kms/key-policy.go @@ -50,19 +50,19 @@ func getKeyPolicyFunc(ctx context.Context, client keyPolicyClient, scope string, return nil, nil //nolint:nilerr } - attributes, err := sources.ToAttributesCase(parsedPolicy) + attributes, err := sources.ToAttributesWithExclude(parsedPolicy) if err != nil { return nil, err } - err = attributes.Set("keyId", *input.KeyId) + err = attributes.Set("KeyId", *input.KeyId) if err != nil { return nil, err } item := &sdp.Item{ Type: "kms-key-policy", - UniqueAttribute: "keyId", + UniqueAttribute: "KeyId", Attributes: attributes, Scope: scope, } diff --git a/sources/kms/key.go b/sources/kms/key.go index 749b380e..34c7b6f9 100644 --- a/sources/kms/key.go +++ b/sources/kms/key.go @@ -29,7 +29,7 @@ func getFunc(ctx context.Context, client kmsClient, scope string, input *kms.Des } } - attributes, err := sources.ToAttributesCase(output.KeyMetadata) + attributes, err := sources.ToAttributesWithExclude(output.KeyMetadata) if err != nil { return nil, err } @@ -46,7 +46,7 @@ func getFunc(ctx context.Context, client kmsClient, scope string, input *kms.Des item := &sdp.Item{ Type: "kms-key", - UniqueAttribute: "keyId", + UniqueAttribute: "KeyId", Attributes: attributes, Scope: scope, Tags: resourceTags, diff --git a/sources/lambda/function.go b/sources/lambda/function.go index e09ae990..ba944357 100644 --- a/sources/lambda/function.go +++ b/sources/lambda/function.go @@ -100,13 +100,13 @@ func functionGetFunc(ctx context.Context, client LambdaClient, scope string, inp } } - attributes, err := sources.ToAttributesCase(function, "resultMetadata") + attributes, err := sources.ToAttributesWithExclude(function, "resultMetadata") if err != nil { return nil, err } - err = attributes.Set("name", *out.Configuration.FunctionName) + err = attributes.Set("Name", *out.Configuration.FunctionName) if err != nil { return nil, err @@ -114,7 +114,7 @@ func functionGetFunc(ctx context.Context, client LambdaClient, scope string, inp item := sdp.Item{ Type: "lambda-function", - UniqueAttribute: "name", + UniqueAttribute: "Name", Attributes: attributes, Scope: scope, Tags: out.Tags, diff --git a/sources/lambda/layer.go b/sources/lambda/layer.go index 9521653f..d7661f83 100644 --- a/sources/lambda/layer.go +++ b/sources/lambda/layer.go @@ -31,7 +31,7 @@ func layerListFunc(ctx context.Context, client *lambda.Client, scope string) ([] } func layerItemMapper(_, scope string, awsItem *types.LayersListItem) (*sdp.Item, error) { - attributes, err := sources.ToAttributesCase(awsItem) + attributes, err := sources.ToAttributesWithExclude(awsItem) if err != nil { return nil, err @@ -39,7 +39,7 @@ func layerItemMapper(_, scope string, awsItem *types.LayersListItem) (*sdp.Item, item := sdp.Item{ Type: "lambda-layer", - UniqueAttribute: "layerName", + UniqueAttribute: "LayerName", Attributes: attributes, Scope: scope, } diff --git a/sources/lambda/layer_version.go b/sources/lambda/layer_version.go index 7eab6ddc..cd97c833 100644 --- a/sources/lambda/layer_version.go +++ b/sources/lambda/layer_version.go @@ -46,13 +46,13 @@ func layerVersionGetFunc(ctx context.Context, client LambdaClient, scope string, return nil, err } - attributes, err := sources.ToAttributesCase(out, "resultMetadata") + attributes, err := sources.ToAttributesWithExclude(out, "resultMetadata") if err != nil { return nil, err } - err = attributes.Set("fullName", fmt.Sprintf("%v:%v", *input.LayerName, input.VersionNumber)) + err = attributes.Set("FullName", fmt.Sprintf("%v:%v", *input.LayerName, input.VersionNumber)) if err != nil { return nil, err @@ -60,7 +60,7 @@ func layerVersionGetFunc(ctx context.Context, client LambdaClient, scope string, item := sdp.Item{ Type: "lambda-layer-version", - UniqueAttribute: "fullName", + UniqueAttribute: "FullName", Attributes: attributes, Scope: scope, } diff --git a/sources/networkfirewall/firewall.go b/sources/networkfirewall/firewall.go index 2033d6cc..6a5df6c2 100644 --- a/sources/networkfirewall/firewall.go +++ b/sources/networkfirewall/firewall.go @@ -67,7 +67,7 @@ func firewallGetFunc(ctx context.Context, client networkFirewallClient, scope st wg.Wait() - attributes, err := sources.ToAttributesCase(uf) + attributes, err := sources.ToAttributesWithExclude(uf) if err != nil { return nil, err @@ -94,7 +94,7 @@ func firewallGetFunc(ctx context.Context, client networkFirewallClient, scope st item := sdp.Item{ Type: "network-firewall-firewall", - UniqueAttribute: "name", + UniqueAttribute: "Name", Scope: scope, Attributes: attributes, Health: health, diff --git a/sources/networkfirewall/firewall_policy.go b/sources/networkfirewall/firewall_policy.go index 01de6bf6..8106b79f 100644 --- a/sources/networkfirewall/firewall_policy.go +++ b/sources/networkfirewall/firewall_policy.go @@ -26,7 +26,7 @@ func firewallPolicyGetFunc(ctx context.Context, client networkFirewallClient, sc FirewallPolicy: resp.FirewallPolicy, } - attributes, err := sources.ToAttributesCase(ufp) + attributes, err := sources.ToAttributesWithExclude(ufp) if err != nil { return nil, err @@ -53,7 +53,7 @@ func firewallPolicyGetFunc(ctx context.Context, client networkFirewallClient, sc item := sdp.Item{ Type: "network-firewall-firewall-policy", - UniqueAttribute: "firewallPolicyName", + UniqueAttribute: "FirewallPolicyName", Attributes: attributes, Scope: scope, Tags: tags, diff --git a/sources/networkfirewall/rule_group.go b/sources/networkfirewall/rule_group.go index f492331e..f1775794 100644 --- a/sources/networkfirewall/rule_group.go +++ b/sources/networkfirewall/rule_group.go @@ -33,7 +33,7 @@ func ruleGroupGetFunc(ctx context.Context, client networkFirewallClient, scope s RuleGroup: resp.RuleGroup, } - attributes, err := sources.ToAttributesCase(urg) + attributes, err := sources.ToAttributesWithExclude(urg) if err != nil { return nil, err @@ -58,7 +58,7 @@ func ruleGroupGetFunc(ctx context.Context, client networkFirewallClient, scope s item := sdp.Item{ Type: "network-firewall-rule-group", - UniqueAttribute: "name", + UniqueAttribute: "Name", Attributes: attributes, Scope: scope, Tags: tags, diff --git a/sources/networkfirewall/tls_inspection_configuration.go b/sources/networkfirewall/tls_inspection_configuration.go index 38ed0592..14d5eafd 100644 --- a/sources/networkfirewall/tls_inspection_configuration.go +++ b/sources/networkfirewall/tls_inspection_configuration.go @@ -38,7 +38,7 @@ func tlsInspectionConfigurationGetFunc(ctx context.Context, client networkFirewa TLSInspectionConfiguration: resp.TLSInspectionConfiguration, } - attributes, err := sources.ToAttributesCase(utic) + attributes, err := sources.ToAttributesWithExclude(utic) if err != nil { return nil, err @@ -63,7 +63,7 @@ func tlsInspectionConfigurationGetFunc(ctx context.Context, client networkFirewa item := sdp.Item{ Type: "network-firewall-tls-inspection-configuration", - UniqueAttribute: "name", + UniqueAttribute: "Name", Attributes: attributes, Scope: scope, Tags: tags, diff --git a/sources/networkmanager/connect_attachment.go b/sources/networkmanager/connect_attachment.go index 9e9eee6d..47aec2dd 100644 --- a/sources/networkmanager/connect_attachment.go +++ b/sources/networkmanager/connect_attachment.go @@ -22,7 +22,7 @@ func connectAttachmentGetFunc(ctx context.Context, client *networkmanager.Client } func connectAttachmentItemMapper(_, scope string, ca *types.ConnectAttachment) (*sdp.Item, error) { - attributes, err := sources.ToAttributesCase(ca) + attributes, err := sources.ToAttributesWithExclude(ca) if err != nil { return nil, err @@ -33,11 +33,11 @@ func connectAttachmentItemMapper(_, scope string, ca *types.ConnectAttachment) ( } // The uniqueAttributeValue for this is a nested value of AttachmentId: - attributes.Set("attachmentId", *ca.Attachment.AttachmentId) + attributes.Set("AttachmentId", *ca.Attachment.AttachmentId) item := sdp.Item{ Type: "networkmanager-connect-attachment", - UniqueAttribute: "attachmentId", + UniqueAttribute: "AttachmentId", Attributes: attributes, Scope: scope, } diff --git a/sources/networkmanager/connect_peer.go b/sources/networkmanager/connect_peer.go index c6cd47ca..c29ee1b1 100644 --- a/sources/networkmanager/connect_peer.go +++ b/sources/networkmanager/connect_peer.go @@ -18,7 +18,7 @@ func connectPeerGetFunc(ctx context.Context, client NetworkManagerClient, scope cn := out.ConnectPeer - attributes, err := sources.ToAttributesCase(cn, "tags") + attributes, err := sources.ToAttributesWithExclude(cn, "tags") if err != nil { return nil, err @@ -26,7 +26,7 @@ func connectPeerGetFunc(ctx context.Context, client NetworkManagerClient, scope item := sdp.Item{ Type: "networkmanager-connect-peer", - UniqueAttribute: "connectPeerId", + UniqueAttribute: "ConnectPeerId", Attributes: attributes, Scope: scope, Tags: tagsToMap(cn.Tags), diff --git a/sources/networkmanager/connect_peer_association.go b/sources/networkmanager/connect_peer_association.go index 067258a0..c544b01d 100644 --- a/sources/networkmanager/connect_peer_association.go +++ b/sources/networkmanager/connect_peer_association.go @@ -17,7 +17,7 @@ func connectPeerAssociationsOutputMapper(_ context.Context, _ *networkmanager.Cl for _, a := range output.ConnectPeerAssociations { var err error var attrs *sdp.ItemAttributes - attrs, err = sources.ToAttributesCase(a) + attrs, err = sources.ToAttributesWithExclude(a) if err != nil { return nil, &sdp.QueryError{ @@ -31,11 +31,11 @@ func connectPeerAssociationsOutputMapper(_ context.Context, _ *networkmanager.Cl return nil, sdp.NewQueryError(errors.New("globalNetworkId or connectPeerId is nil for connect peer association")) } - attrs.Set("globalNetworkIdConnectPeerId", idWithGlobalNetwork(*a.GlobalNetworkId, *a.ConnectPeerId)) + attrs.Set("GlobalNetworkIdConnectPeerId", idWithGlobalNetwork(*a.GlobalNetworkId, *a.ConnectPeerId)) item := sdp.Item{ Type: "networkmanager-connect-peer-association", - UniqueAttribute: "globalNetworkIdConnectPeerId", + UniqueAttribute: "GlobalNetworkIdConnectPeerId", Scope: scope, Attributes: attrs, LinkedItemQueries: []*sdp.LinkedItemQuery{ diff --git a/sources/networkmanager/connection.go b/sources/networkmanager/connection.go index a991de4d..611bd5fb 100644 --- a/sources/networkmanager/connection.go +++ b/sources/networkmanager/connection.go @@ -17,7 +17,7 @@ func connectionOutputMapper(_ context.Context, _ *networkmanager.Client, scope s for _, s := range output.Connections { var err error var attrs *sdp.ItemAttributes - attrs, err = sources.ToAttributesCase(s, "tags") + attrs, err = sources.ToAttributesWithExclude(s, "tags") if err != nil { return nil, &sdp.QueryError{ @@ -31,11 +31,11 @@ func connectionOutputMapper(_ context.Context, _ *networkmanager.Client, scope s return nil, sdp.NewQueryError(errors.New("globalNetworkId or connectionId is nil for connection")) } - attrs.Set("globalNetworkIdConnectionId", idWithGlobalNetwork(*s.GlobalNetworkId, *s.ConnectionId)) + attrs.Set("GlobalNetworkIdConnectionId", idWithGlobalNetwork(*s.GlobalNetworkId, *s.ConnectionId)) item := sdp.Item{ Type: "networkmanager-connection", - UniqueAttribute: "globalNetworkIdConnectionId", + UniqueAttribute: "GlobalNetworkIdConnectionId", Scope: scope, Attributes: attrs, Tags: tagsToMap(s.Tags), diff --git a/sources/networkmanager/core_network.go b/sources/networkmanager/core_network.go index 35744a5a..ecfa644c 100644 --- a/sources/networkmanager/core_network.go +++ b/sources/networkmanager/core_network.go @@ -23,7 +23,7 @@ func coreNetworkGetFunc(ctx context.Context, client NetworkManagerClient, scope cn := out.CoreNetwork - attributes, err := sources.ToAttributesCase(cn) + attributes, err := sources.ToAttributesWithExclude(cn) if err != nil { return nil, err @@ -31,7 +31,7 @@ func coreNetworkGetFunc(ctx context.Context, client NetworkManagerClient, scope item := sdp.Item{ Type: "networkmanager-core-network", - UniqueAttribute: "coreNetworkId", + UniqueAttribute: "CoreNetworkId", Attributes: attributes, Scope: scope, Tags: tagsToMap(cn.Tags), diff --git a/sources/networkmanager/core_network_policy.go b/sources/networkmanager/core_network_policy.go index 0ae5e33c..ce5bf4f6 100644 --- a/sources/networkmanager/core_network_policy.go +++ b/sources/networkmanager/core_network_policy.go @@ -22,7 +22,7 @@ func coreNetworkPolicyGetFunc(ctx context.Context, client *networkmanager.Client } func coreNetworkPolicyItemMapper(_, scope string, cn *types.CoreNetworkPolicy) (*sdp.Item, error) { - attributes, err := sources.ToAttributesCase(cn) + attributes, err := sources.ToAttributesWithExclude(cn) if err != nil { return nil, err } @@ -33,7 +33,7 @@ func coreNetworkPolicyItemMapper(_, scope string, cn *types.CoreNetworkPolicy) ( item := sdp.Item{ Type: "networkmanager-core-network-policy", - UniqueAttribute: "coreNetworkId", + UniqueAttribute: "CoreNetworkId", Attributes: attributes, Scope: scope, LinkedItemQueries: []*sdp.LinkedItemQuery{ diff --git a/sources/networkmanager/device.go b/sources/networkmanager/device.go index 97d5ef9d..834fac4e 100644 --- a/sources/networkmanager/device.go +++ b/sources/networkmanager/device.go @@ -17,7 +17,7 @@ func deviceOutputMapper(_ context.Context, _ *networkmanager.Client, scope strin for _, s := range output.Devices { var err error var attrs *sdp.ItemAttributes - attrs, err = sources.ToAttributesCase(s, "tags") + attrs, err = sources.ToAttributesWithExclude(s, "tags") if err != nil { return nil, &sdp.QueryError{ @@ -31,11 +31,11 @@ func deviceOutputMapper(_ context.Context, _ *networkmanager.Client, scope strin return nil, sdp.NewQueryError(errors.New("globalNetworkId or deviceId is nil for device")) } - attrs.Set("globalNetworkIdDeviceId", idWithGlobalNetwork(*s.GlobalNetworkId, *s.DeviceId)) + attrs.Set("GlobalNetworkIdDeviceId", idWithGlobalNetwork(*s.GlobalNetworkId, *s.DeviceId)) item := sdp.Item{ Type: "networkmanager-device", - UniqueAttribute: "globalNetworkIdDeviceId", + UniqueAttribute: "GlobalNetworkIdDeviceId", Scope: scope, Attributes: attrs, Tags: tagsToMap(s.Tags), diff --git a/sources/networkmanager/global_network.go b/sources/networkmanager/global_network.go index 093733bc..209b94a3 100644 --- a/sources/networkmanager/global_network.go +++ b/sources/networkmanager/global_network.go @@ -16,7 +16,7 @@ func globalNetworkOutputMapper(_ context.Context, client *networkmanager.Client, for _, gn := range output.GlobalNetworks { var err error var attrs *sdp.ItemAttributes - attrs, err = sources.ToAttributesCase(gn, "tags") + attrs, err = sources.ToAttributesWithExclude(gn, "tags") if err != nil { return nil, &sdp.QueryError{ @@ -28,7 +28,7 @@ func globalNetworkOutputMapper(_ context.Context, client *networkmanager.Client, item := sdp.Item{ Type: "networkmanager-global-network", - UniqueAttribute: "globalNetworkId", + UniqueAttribute: "GlobalNetworkId", Scope: scope, Attributes: attrs, Tags: tagsToMap(gn.Tags), diff --git a/sources/networkmanager/link.go b/sources/networkmanager/link.go index 82542562..ede19b67 100644 --- a/sources/networkmanager/link.go +++ b/sources/networkmanager/link.go @@ -2,9 +2,10 @@ package networkmanager import ( "context" - "github.com/aws/aws-sdk-go-v2/service/networkmanager/types" "strings" + "github.com/aws/aws-sdk-go-v2/service/networkmanager/types" + "github.com/aws/aws-sdk-go-v2/service/networkmanager" "github.com/overmindtech/aws-source/sources" "github.com/overmindtech/sdp-go" @@ -16,7 +17,7 @@ func linkOutputMapper(_ context.Context, _ *networkmanager.Client, scope string, for _, s := range output.Links { var err error var attrs *sdp.ItemAttributes - attrs, err = sources.ToAttributesCase(s, "tags") + attrs, err = sources.ToAttributesWithExclude(s, "tags") if err != nil { return nil, &sdp.QueryError{ @@ -26,11 +27,11 @@ func linkOutputMapper(_ context.Context, _ *networkmanager.Client, scope string, } } - attrs.Set("globalNetworkIdLinkId", idWithGlobalNetwork(*s.GlobalNetworkId, *s.LinkId)) + attrs.Set("GlobalNetworkIdLinkId", idWithGlobalNetwork(*s.GlobalNetworkId, *s.LinkId)) item := sdp.Item{ Type: "networkmanager-link", - UniqueAttribute: "globalNetworkIdLinkId", + UniqueAttribute: "GlobalNetworkIdLinkId", Scope: scope, Attributes: attrs, Tags: tagsToMap(s.Tags), diff --git a/sources/networkmanager/link_association.go b/sources/networkmanager/link_association.go index 7221ca89..f507c063 100644 --- a/sources/networkmanager/link_association.go +++ b/sources/networkmanager/link_association.go @@ -4,9 +4,10 @@ import ( "context" "errors" "fmt" - "github.com/aws/aws-sdk-go-v2/service/networkmanager/types" "strings" + "github.com/aws/aws-sdk-go-v2/service/networkmanager/types" + "github.com/aws/aws-sdk-go-v2/service/networkmanager" "github.com/overmindtech/aws-source/sources" "github.com/overmindtech/sdp-go" @@ -18,7 +19,7 @@ func linkAssociationOutputMapper(_ context.Context, _ *networkmanager.Client, sc for _, s := range output.LinkAssociations { var err error var attrs *sdp.ItemAttributes - attrs, err = sources.ToAttributesCase(s, "tags") + attrs, err = sources.ToAttributesWithExclude(s, "tags") if err != nil { return nil, &sdp.QueryError{ @@ -32,11 +33,11 @@ func linkAssociationOutputMapper(_ context.Context, _ *networkmanager.Client, sc return nil, sdp.NewQueryError(errors.New("globalNetworkId, linkId or deviceId is nil for link association")) } - attrs.Set("globalNetworkIdLinkIdDeviceId", fmt.Sprintf("%s|%s|%s", *s.GlobalNetworkId, *s.LinkId, *s.DeviceId)) + attrs.Set("GlobalNetworkIdLinkIdDeviceId", fmt.Sprintf("%s|%s|%s", *s.GlobalNetworkId, *s.LinkId, *s.DeviceId)) item := sdp.Item{ Type: "networkmanager-link-association", - UniqueAttribute: "globalNetworkIdLinkIdDeviceId", + UniqueAttribute: "GlobalNetworkIdLinkIdDeviceId", Scope: scope, Attributes: attrs, LinkedItemQueries: []*sdp.LinkedItemQuery{ diff --git a/sources/networkmanager/network_resource_relationship.go b/sources/networkmanager/network_resource_relationship.go index 4d15c0e1..5424feee 100644 --- a/sources/networkmanager/network_resource_relationship.go +++ b/sources/networkmanager/network_resource_relationship.go @@ -45,9 +45,9 @@ func networkResourceRelationshipOutputMapper(_ context.Context, _ *networkmanage sha := base64.URLEncoding.EncodeToString(hasher.Sum(nil)) attrs, err := sdp.ToAttributes(map[string]interface{}{ - "hash": sha, - "from": fromArn.String(), - "to": toArn.String(), + "Hash": sha, + "From": fromArn.String(), + "To": toArn.String(), }) if err != nil { return nil, err @@ -55,7 +55,7 @@ func networkResourceRelationshipOutputMapper(_ context.Context, _ *networkmanage item := sdp.Item{ Type: "networkmanager-network-resource-relationship", - UniqueAttribute: "hash", + UniqueAttribute: "Hash", Scope: scope, Attributes: attrs, LinkedItemQueries: []*sdp.LinkedItemQuery{}, diff --git a/sources/networkmanager/site.go b/sources/networkmanager/site.go index bc4e6814..2b646555 100644 --- a/sources/networkmanager/site.go +++ b/sources/networkmanager/site.go @@ -17,7 +17,7 @@ func siteOutputMapper(_ context.Context, _ *networkmanager.Client, scope string, for _, s := range output.Sites { var err error var attrs *sdp.ItemAttributes - attrs, err = sources.ToAttributesCase(s, "tags") + attrs, err = sources.ToAttributesWithExclude(s, "tags") if err != nil { return nil, &sdp.QueryError{ @@ -31,11 +31,11 @@ func siteOutputMapper(_ context.Context, _ *networkmanager.Client, scope string, return nil, sdp.NewQueryError(errors.New("globalNetworkId or siteId is nil for site")) } - attrs.Set("globalNetworkIdSiteId", idWithGlobalNetwork(*s.GlobalNetworkId, *s.SiteId)) + attrs.Set("GlobalNetworkIdSiteId", idWithGlobalNetwork(*s.GlobalNetworkId, *s.SiteId)) item := sdp.Item{ Type: "networkmanager-site", - UniqueAttribute: "globalNetworkIdSiteId", + UniqueAttribute: "GlobalNetworkIdSiteId", Scope: scope, Attributes: attrs, Tags: tagsToMap(s.Tags), diff --git a/sources/networkmanager/site_to_site_vpn_attachment.go b/sources/networkmanager/site_to_site_vpn_attachment.go index 4e28df76..80af05dc 100644 --- a/sources/networkmanager/site_to_site_vpn_attachment.go +++ b/sources/networkmanager/site_to_site_vpn_attachment.go @@ -21,7 +21,7 @@ func getSiteToSiteVpnAttachmentGetFunc(ctx context.Context, client *networkmanag } func siteToSiteVpnAttachmentItemMapper(_, scope string, awsItem *types.SiteToSiteVpnAttachment) (*sdp.Item, error) { - attributes, err := sources.ToAttributesCase(awsItem) + attributes, err := sources.ToAttributesWithExclude(awsItem) if err != nil { return nil, err @@ -29,12 +29,12 @@ func siteToSiteVpnAttachmentItemMapper(_, scope string, awsItem *types.SiteToSit // The uniqueAttributeValue for this is a nested value of peeringId: if awsItem != nil && awsItem.Attachment != nil { - attributes.Set("attachmentId", *awsItem.Attachment.AttachmentId) + attributes.Set("AttachmentId", *awsItem.Attachment.AttachmentId) } item := sdp.Item{ Type: "networkmanager-site-to-site-vpn-attachment", - UniqueAttribute: "attachmentId", + UniqueAttribute: "AttachmentId", Attributes: attributes, Scope: scope, } diff --git a/sources/networkmanager/transit_gateway_connect_peer_associations.go b/sources/networkmanager/transit_gateway_connect_peer_associations.go index 1771c1bd..473dbd42 100644 --- a/sources/networkmanager/transit_gateway_connect_peer_associations.go +++ b/sources/networkmanager/transit_gateway_connect_peer_associations.go @@ -16,7 +16,7 @@ func transitGatewayConnectPeerAssociationsOutputMapper(_ context.Context, _ *net for _, a := range output.TransitGatewayConnectPeerAssociations { var err error var attrs *sdp.ItemAttributes - attrs, err = sources.ToAttributesCase(a, "tags") + attrs, err = sources.ToAttributesWithExclude(a, "tags") if err != nil { return nil, &sdp.QueryError{ @@ -26,11 +26,11 @@ func transitGatewayConnectPeerAssociationsOutputMapper(_ context.Context, _ *net } } - attrs.Set("globalNetworkIdWithTransitGatewayConnectPeerArn", idWithGlobalNetwork(*a.GlobalNetworkId, *a.TransitGatewayConnectPeerArn)) + attrs.Set("GlobalNetworkIdWithTransitGatewayConnectPeerArn", idWithGlobalNetwork(*a.GlobalNetworkId, *a.TransitGatewayConnectPeerArn)) item := sdp.Item{ Type: "networkmanager-transit-gateway-connect-peer-association", - UniqueAttribute: "globalNetworkIdWithTransitGatewayConnectPeerArn", + UniqueAttribute: "GlobalNetworkIdWithTransitGatewayConnectPeerArn", Scope: scope, Attributes: attrs, LinkedItemQueries: []*sdp.LinkedItemQuery{ diff --git a/sources/networkmanager/transit_gateway_peering.go b/sources/networkmanager/transit_gateway_peering.go index 11cc6284..360e2841 100644 --- a/sources/networkmanager/transit_gateway_peering.go +++ b/sources/networkmanager/transit_gateway_peering.go @@ -21,7 +21,7 @@ func getTransitGatewayPeeringGetFunc(ctx context.Context, client *networkmanager } func transitGatewayPeeringItemMapper(_, scope string, awsItem *types.TransitGatewayPeering) (*sdp.Item, error) { - attributes, err := sources.ToAttributesCase(awsItem) + attributes, err := sources.ToAttributesWithExclude(awsItem) if err != nil { return nil, err @@ -29,12 +29,12 @@ func transitGatewayPeeringItemMapper(_, scope string, awsItem *types.TransitGate // The uniqueAttributeValue for this is a nested value of peeringId: if awsItem != nil && awsItem.Peering != nil { - attributes.Set("peeringId", *awsItem.Peering.PeeringId) + attributes.Set("PeeringId", *awsItem.Peering.PeeringId) } item := sdp.Item{ Type: "networkmanager-transit-gateway-peering", - UniqueAttribute: "peeringId", + UniqueAttribute: "PeeringId", Attributes: attributes, Scope: scope, Tags: tagsToMap(awsItem.Peering.Tags), diff --git a/sources/networkmanager/transit_gateway_registration.go b/sources/networkmanager/transit_gateway_registration.go index 29533152..46d6d39c 100644 --- a/sources/networkmanager/transit_gateway_registration.go +++ b/sources/networkmanager/transit_gateway_registration.go @@ -16,7 +16,7 @@ func transitGatewayRegistrationOutputMapper(_ context.Context, _ *networkmanager for _, r := range output.TransitGatewayRegistrations { var err error var attrs *sdp.ItemAttributes - attrs, err = sources.ToAttributesCase(r) + attrs, err = sources.ToAttributesWithExclude(r) if err != nil { return nil, &sdp.QueryError{ @@ -30,11 +30,11 @@ func transitGatewayRegistrationOutputMapper(_ context.Context, _ *networkmanager return nil, sdp.NewQueryError(errors.New("globalNetworkId or transitGatewayArn is nil for transit gateway registration")) } - attrs.Set("globalNetworkIdWithTransitGatewayARN", idWithGlobalNetwork(*r.GlobalNetworkId, *r.TransitGatewayArn)) + attrs.Set("GlobalNetworkIdWithTransitGatewayARN", idWithGlobalNetwork(*r.GlobalNetworkId, *r.TransitGatewayArn)) item := sdp.Item{ Type: "networkmanager-transit-gateway-registration", - UniqueAttribute: "globalNetworkIdWithTransitGatewayARN", + UniqueAttribute: "GlobalNetworkIdWithTransitGatewayARN", Scope: scope, Attributes: attrs, LinkedItemQueries: []*sdp.LinkedItemQuery{ diff --git a/sources/networkmanager/transit_gateway_route_table_attachment.go b/sources/networkmanager/transit_gateway_route_table_attachment.go index 46c03f07..dd1e5e5a 100644 --- a/sources/networkmanager/transit_gateway_route_table_attachment.go +++ b/sources/networkmanager/transit_gateway_route_table_attachment.go @@ -21,7 +21,7 @@ func getTransitGatewayRouteTableAttachmentGetFunc(ctx context.Context, client *n } func transitGatewayRouteTableAttachmentItemMapper(_, scope string, awsItem *types.TransitGatewayRouteTableAttachment) (*sdp.Item, error) { - attributes, err := sources.ToAttributesCase(awsItem) + attributes, err := sources.ToAttributesWithExclude(awsItem) if err != nil { return nil, err @@ -29,12 +29,12 @@ func transitGatewayRouteTableAttachmentItemMapper(_, scope string, awsItem *type // The uniqueAttributeValue for this is a nested value of AttachmentId: if awsItem != nil && awsItem.Attachment != nil { - attributes.Set("attachmentId", *awsItem.Attachment.AttachmentId) + attributes.Set("AttachmentId", *awsItem.Attachment.AttachmentId) } item := sdp.Item{ Type: "networkmanager-transit-gateway-route-table-attachment", - UniqueAttribute: "attachmentId", + UniqueAttribute: "AttachmentId", Attributes: attributes, Scope: scope, Tags: tagsToMap(awsItem.Attachment.Tags), diff --git a/sources/networkmanager/vpc_attachment.go b/sources/networkmanager/vpc_attachment.go index 231fdb07..1b542341 100644 --- a/sources/networkmanager/vpc_attachment.go +++ b/sources/networkmanager/vpc_attachment.go @@ -21,7 +21,7 @@ func vpcAttachmentGetFunc(ctx context.Context, client *networkmanager.Client, _, } func vpcAttachmentItemMapper(_, scope string, awsItem *types.VpcAttachment) (*sdp.Item, error) { - attributes, err := sources.ToAttributesCase(awsItem) + attributes, err := sources.ToAttributesWithExclude(awsItem) if err != nil { return nil, err @@ -29,12 +29,12 @@ func vpcAttachmentItemMapper(_, scope string, awsItem *types.VpcAttachment) (*sd // The uniqueAttributeValue for this is a nested value of AttachmentId: if awsItem != nil && awsItem.Attachment != nil { - attributes.Set("attachmentId", *awsItem.Attachment.AttachmentId) + attributes.Set("AttachmentId", *awsItem.Attachment.AttachmentId) } item := sdp.Item{ Type: "networkmanager-vpc-attachment", - UniqueAttribute: "attachmentId", + UniqueAttribute: "AttachmentId", Attributes: attributes, Scope: scope, Tags: tagsToMap(awsItem.Attachment.Tags), diff --git a/sources/rds/db_cluster.go b/sources/rds/db_cluster.go index 4544e178..f720c905 100644 --- a/sources/rds/db_cluster.go +++ b/sources/rds/db_cluster.go @@ -25,7 +25,7 @@ func dBClusterOutputMapper(ctx context.Context, client rdsClient, scope string, tags = sources.HandleTagsError(ctx, err) } - attributes, err := sources.ToAttributesCase(cluster) + attributes, err := sources.ToAttributesWithExclude(cluster) if err != nil { return nil, err @@ -33,7 +33,7 @@ func dBClusterOutputMapper(ctx context.Context, client rdsClient, scope string, item := sdp.Item{ Type: "rds-db-cluster", - UniqueAttribute: "dBClusterIdentifier", + UniqueAttribute: "DBClusterIdentifier", Attributes: attributes, Scope: scope, Tags: tags, diff --git a/sources/rds/db_cluster_parameter_group.go b/sources/rds/db_cluster_parameter_group.go index 61a055c5..41f97c3d 100644 --- a/sources/rds/db_cluster_parameter_group.go +++ b/sources/rds/db_cluster_parameter_group.go @@ -17,7 +17,7 @@ type ClusterParameterGroup struct { } func dBClusterParameterGroupItemMapper(_, scope string, awsItem *ClusterParameterGroup) (*sdp.Item, error) { - attributes, err := sources.ToAttributesCase(awsItem) + attributes, err := sources.ToAttributesWithExclude(awsItem) if err != nil { return nil, err @@ -25,7 +25,7 @@ func dBClusterParameterGroupItemMapper(_, scope string, awsItem *ClusterParamete item := sdp.Item{ Type: "rds-db-cluster-parameter-group", - UniqueAttribute: "dBClusterParameterGroupName", + UniqueAttribute: "DBClusterParameterGroupName", Attributes: attributes, Scope: scope, } diff --git a/sources/rds/db_instance.go b/sources/rds/db_instance.go index 995f8f51..a98361c5 100644 --- a/sources/rds/db_instance.go +++ b/sources/rds/db_instance.go @@ -98,7 +98,7 @@ func dBInstanceOutputMapper(ctx context.Context, client rdsClient, scope string, instance.DBSubnetGroup = nil } - attributes, err := sources.ToAttributesCase(instance) + attributes, err := sources.ToAttributesWithExclude(instance) if err != nil { return nil, err @@ -106,7 +106,7 @@ func dBInstanceOutputMapper(ctx context.Context, client rdsClient, scope string, item := sdp.Item{ Type: "rds-db-instance", - UniqueAttribute: "dBInstanceIdentifier", + UniqueAttribute: "DBInstanceIdentifier", Attributes: attributes, Scope: scope, Tags: tags, diff --git a/sources/rds/db_parameter_group.go b/sources/rds/db_parameter_group.go index 0478a900..b30f448d 100644 --- a/sources/rds/db_parameter_group.go +++ b/sources/rds/db_parameter_group.go @@ -17,7 +17,7 @@ type ParameterGroup struct { } func dBParameterGroupItemMapper(_, scope string, awsItem *ParameterGroup) (*sdp.Item, error) { - attributes, err := sources.ToAttributesCase(awsItem) + attributes, err := sources.ToAttributesWithExclude(awsItem) if err != nil { return nil, err @@ -25,7 +25,7 @@ func dBParameterGroupItemMapper(_, scope string, awsItem *ParameterGroup) (*sdp. item := sdp.Item{ Type: "rds-db-parameter-group", - UniqueAttribute: "dBParameterGroupName", + UniqueAttribute: "DBParameterGroupName", Attributes: attributes, Scope: scope, } diff --git a/sources/rds/db_subnet_group.go b/sources/rds/db_subnet_group.go index b5eb19f5..dea0d24d 100644 --- a/sources/rds/db_subnet_group.go +++ b/sources/rds/db_subnet_group.go @@ -25,7 +25,7 @@ func dBSubnetGroupOutputMapper(ctx context.Context, client rdsClient, scope stri tags = sources.HandleTagsError(ctx, err) } - attributes, err := sources.ToAttributesCase(sg) + attributes, err := sources.ToAttributesWithExclude(sg) if err != nil { return nil, err @@ -33,7 +33,7 @@ func dBSubnetGroupOutputMapper(ctx context.Context, client rdsClient, scope stri item := sdp.Item{ Type: "rds-db-subnet-group", - UniqueAttribute: "dBSubnetGroupName", + UniqueAttribute: "DBSubnetGroupName", Attributes: attributes, Scope: scope, Tags: tags, diff --git a/sources/rds/option_group.go b/sources/rds/option_group.go index 4f353ed5..26424470 100644 --- a/sources/rds/option_group.go +++ b/sources/rds/option_group.go @@ -25,7 +25,7 @@ func optionGroupOutputMapper(ctx context.Context, client rdsClient, scope string tags = sources.HandleTagsError(ctx, err) } - attributes, err := sources.ToAttributesCase(group) + attributes, err := sources.ToAttributesWithExclude(group) if err != nil { return nil, err @@ -33,7 +33,7 @@ func optionGroupOutputMapper(ctx context.Context, client rdsClient, scope string item := sdp.Item{ Type: "rds-option-group", - UniqueAttribute: "optionGroupName", + UniqueAttribute: "OptionGroupName", Attributes: attributes, Scope: scope, Tags: tags, diff --git a/sources/route53/health_check.go b/sources/route53/health_check.go index a1c874eb..7ac55357 100644 --- a/sources/route53/health_check.go +++ b/sources/route53/health_check.go @@ -70,7 +70,7 @@ func healthCheckListFunc(ctx context.Context, client *route53.Client, scope stri } func healthCheckItemMapper(_, scope string, awsItem *HealthCheck) (*sdp.Item, error) { - attributes, err := sources.ToAttributesCase(awsItem) + attributes, err := sources.ToAttributesWithExclude(awsItem) if err != nil { return nil, err @@ -78,7 +78,7 @@ func healthCheckItemMapper(_, scope string, awsItem *HealthCheck) (*sdp.Item, er item := sdp.Item{ Type: "route53-health-check", - UniqueAttribute: "id", + UniqueAttribute: "Id", Attributes: attributes, Scope: scope, } diff --git a/sources/route53/hosted_zone.go b/sources/route53/hosted_zone.go index 3d5ac2e4..fb60f504 100644 --- a/sources/route53/hosted_zone.go +++ b/sources/route53/hosted_zone.go @@ -39,7 +39,7 @@ func hostedZoneListFunc(ctx context.Context, client *route53.Client, scope strin } func hostedZoneItemMapper(_, scope string, awsItem *types.HostedZone) (*sdp.Item, error) { - attributes, err := sources.ToAttributesCase(awsItem) + attributes, err := sources.ToAttributesWithExclude(awsItem) if err != nil { return nil, err @@ -47,7 +47,7 @@ func hostedZoneItemMapper(_, scope string, awsItem *types.HostedZone) (*sdp.Item item := sdp.Item{ Type: "route53-hosted-zone", - UniqueAttribute: "id", + UniqueAttribute: "Id", Attributes: attributes, Scope: scope, LinkedItemQueries: []*sdp.LinkedItemQuery{ diff --git a/sources/route53/resource_record_set.go b/sources/route53/resource_record_set.go index d29bdb4c..8b25dee8 100644 --- a/sources/route53/resource_record_set.go +++ b/sources/route53/resource_record_set.go @@ -52,7 +52,7 @@ func resourceRecordSetSearchFunc(ctx context.Context, client *route53.Client, sc } func resourceRecordSetItemMapper(_, scope string, awsItem *types.ResourceRecordSet) (*sdp.Item, error) { - attributes, err := sources.ToAttributesCase(awsItem) + attributes, err := sources.ToAttributesWithExclude(awsItem) if err != nil { return nil, err @@ -60,7 +60,7 @@ func resourceRecordSetItemMapper(_, scope string, awsItem *types.ResourceRecordS item := sdp.Item{ Type: "route53-resource-record-set", - UniqueAttribute: "name", + UniqueAttribute: "Name", Attributes: attributes, Scope: scope, } diff --git a/sources/route53/resource_record_set_test.go b/sources/route53/resource_record_set_test.go index 0a850d61..09d4b5c0 100644 --- a/sources/route53/resource_record_set_test.go +++ b/sources/route53/resource_record_set_test.go @@ -160,8 +160,8 @@ func TestNewResourceRecordSetSource(t *testing.T) { item := items[0] // Construct a terraform style ID - name, _ := item.GetAttributes().Get("name") - typ, _ := item.GetAttributes().Get("type") + name, _ := item.GetAttributes().Get("Name") + typ, _ := item.GetAttributes().Get("Type") search = fmt.Sprintf("%s_%s_%s", rawZone, name, typ) items, err := source.Search(context.Background(), zoneSource.Scopes()[0], search, true) diff --git a/sources/s3/s3.go b/sources/s3/s3.go index 7fd21b76..3466f2ae 100644 --- a/sources/s3/s3.go +++ b/sources/s3/s3.go @@ -378,7 +378,7 @@ func getImpl(ctx context.Context, cache *sdpcache.Cache, client S3Client, scope // Wait for all requests to complete wg.Wait() - attributes, err := sources.ToAttributesCase(bucket) + attributes, err := sources.ToAttributesWithExclude(bucket) if err != nil { err = &sdp.QueryError{ @@ -403,7 +403,7 @@ func getImpl(ctx context.Context, cache *sdpcache.Cache, client S3Client, scope item := sdp.Item{ Type: "s3-bucket", - UniqueAttribute: "name", + UniqueAttribute: "Name", Attributes: attributes, Scope: scope, Tags: tags, diff --git a/sources/sns/data_protection_policy.go b/sources/sns/data_protection_policy.go index b012d3bb..2ed43628 100644 --- a/sources/sns/data_protection_policy.go +++ b/sources/sns/data_protection_policy.go @@ -27,17 +27,17 @@ func getDataProtectionPolicyFunc(ctx context.Context, client dataProtectionPolic // ResourceArn is the topic ARN that the policy is associated with attr := map[string]interface{}{ - "topicArn": *input.ResourceArn, + "TopicArn": *input.ResourceArn, } - attributes, err := sources.ToAttributesCase(attr) + attributes, err := sources.ToAttributesWithExclude(attr) if err != nil { return nil, err } item := &sdp.Item{ Type: "sns-data-protection-policy", - UniqueAttribute: "topicArn", + UniqueAttribute: "TopicArn", Attributes: attributes, Scope: scope, } diff --git a/sources/sns/endpoint.go b/sources/sns/endpoint.go index f216e6a1..6a2629c8 100644 --- a/sources/sns/endpoint.go +++ b/sources/sns/endpoint.go @@ -27,19 +27,19 @@ func getEndpointFunc(ctx context.Context, client endpointClient, scope string, i } } - attributes, err := sources.ToAttributesCase(output.Attributes) + attributes, err := sources.ToAttributesWithExclude(output.Attributes) if err != nil { return nil, err } - err = attributes.Set("endpointArn", *input.EndpointArn) + err = attributes.Set("EndpointArn", *input.EndpointArn) if err != nil { return nil, err } item := &sdp.Item{ Type: "sns-endpoint", - UniqueAttribute: "endpointArn", + UniqueAttribute: "EndpointArn", Attributes: attributes, Scope: scope, } diff --git a/sources/sns/platform_application.go b/sources/sns/platform_application.go index 7481b88f..dc9033f2 100644 --- a/sources/sns/platform_application.go +++ b/sources/sns/platform_application.go @@ -27,19 +27,19 @@ func getPlatformApplicationFunc(ctx context.Context, client platformApplicationC } } - attributes, err := sources.ToAttributesCase(output.Attributes) + attributes, err := sources.ToAttributesWithExclude(output.Attributes) if err != nil { return nil, err } - err = attributes.Set("platformApplicationArn", *input.PlatformApplicationArn) + err = attributes.Set("PlatformApplicationArn", *input.PlatformApplicationArn) if err != nil { return nil, err } item := &sdp.Item{ Type: "sns-platform-application", - UniqueAttribute: "platformApplicationArn", + UniqueAttribute: "PlatformApplicationArn", Attributes: attributes, Scope: scope, } diff --git a/sources/sns/subscription.go b/sources/sns/subscription.go index d06d1261..37b632e2 100644 --- a/sources/sns/subscription.go +++ b/sources/sns/subscription.go @@ -28,14 +28,14 @@ func getSubsFunc(ctx context.Context, client subsCli, scope string, input *sns.G } } - attributes, err := sources.ToAttributesCase(output.Attributes) + attributes, err := sources.ToAttributesWithExclude(output.Attributes) if err != nil { return nil, err } item := &sdp.Item{ Type: "sns-subscription", - UniqueAttribute: "subscriptionArn", + UniqueAttribute: "SubscriptionArn", Attributes: attributes, Scope: scope, } diff --git a/sources/sns/topic.go b/sources/sns/topic.go index 33b273af..9f9ed6fd 100644 --- a/sources/sns/topic.go +++ b/sources/sns/topic.go @@ -28,14 +28,14 @@ func getTopicFunc(ctx context.Context, client topicClient, scope string, input * } } - attributes, err := sources.ToAttributesCase(output.Attributes) + attributes, err := sources.ToAttributesWithExclude(output.Attributes) if err != nil { return nil, err } item := &sdp.Item{ Type: "sns-topic", - UniqueAttribute: "topicArn", + UniqueAttribute: "TopicArn", Attributes: attributes, Scope: scope, } diff --git a/sources/sqs/queue.go b/sources/sqs/queue.go index ca36e61a..b716ddb1 100644 --- a/sources/sqs/queue.go +++ b/sources/sqs/queue.go @@ -28,12 +28,12 @@ func getFunc(ctx context.Context, client sqsClient, scope string, input *sqs.Get } } - attributes, err := sources.ToAttributesCase(output.Attributes) + attributes, err := sources.ToAttributesWithExclude(output.Attributes) if err != nil { return nil, err } - err = attributes.Set("queueURL", input.QueueUrl) + err = attributes.Set("QueueURL", input.QueueUrl) if err != nil { return nil, err } @@ -48,7 +48,7 @@ func getFunc(ctx context.Context, client sqsClient, scope string, input *sqs.Get return &sdp.Item{ Type: "sqs-queue", - UniqueAttribute: "queueURL", + UniqueAttribute: "QueueURL", Attributes: attributes, Scope: scope, Tags: resourceTags, diff --git a/sources/util.go b/sources/util.go index 167979f5..8e495c3d 100644 --- a/sources/util.go +++ b/sources/util.go @@ -347,3 +347,21 @@ func GetAutoConfig(t *testing.T) (aws.Config, string, string) { return config, *callerID.Account, config.Region } + +// Converts an interface to SDP attributes using the `sdp.ToAttributesSorted` +// function, and also allows the user to exclude certain top-level fields from +// teh resulting attributes +func ToAttributesWithExclude(i interface{}, exclusions ...string) (*sdp.ItemAttributes, error) { + attrs, err := sdp.ToAttributesViaJson(i) + if err != nil { + return nil, err + } + + for _, exclusion := range exclusions { + if s := attrs.GetAttrStruct(); s != nil { + delete(s.GetFields(), exclusion) + } + } + + return attrs, nil +}