Skip to content

Commit

Permalink
Remove duplicate columns from the tables (#2267)
Browse files Browse the repository at this point in the history
  • Loading branch information
ParthaI authored Aug 19, 2024
1 parent f8385e1 commit 730bb0f
Show file tree
Hide file tree
Showing 73 changed files with 79 additions and 204 deletions.
2 changes: 1 addition & 1 deletion aws/canonical_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ func TestConvertPolicy(t *testing.T) {
func prettyPrint(src interface{}) {
pretty, err := json.MarshalIndent(src, "", " ")
if err != nil {
log.Fatalf(err.Error())
log.Fatal(err.Error())
}
fmt.Printf("\n %s\n", string(pretty))

Expand Down
2 changes: 1 addition & 1 deletion aws/table_aws_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func getOrganizationDetails(ctx context.Context, d *plugin.QueryData, _ *plugin.
func accountDataToTitle(ctx context.Context, d *transform.TransformData) (interface{}, error) {
accountInfo := d.HydrateItem.(*accountData)

if accountInfo.Aliases != nil && len(accountInfo.Aliases) > 0 {
if len(accountInfo.Aliases) > 0 {
return accountInfo.Aliases[0], nil
}

Expand Down
2 changes: 1 addition & 1 deletion aws/table_aws_appautoscaling_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func getAwsApplicationAutoScalingTarget(ctx context.Context, d *plugin.QueryData
plugin.Logger(ctx).Error("aws_appautoscaling_target.getAwsApplicationAutoScalingTarget", "api_error", err)
return nil, err
}
if op.ScalableTargets != nil && len(op.ScalableTargets) > 0 {
if len(op.ScalableTargets) > 0 {
return op.ScalableTargets[0], nil
}

Expand Down
4 changes: 2 additions & 2 deletions aws/table_aws_cloudtrail_trail.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func getCloudtrailTrail(ctx context.Context, d *plugin.QueryData, _ *plugin.Hydr
return nil, err
}

if item.TrailList != nil && len(item.TrailList) > 0 {
if len(item.TrailList) > 0 {
return item.TrailList[0], nil
}

Expand Down Expand Up @@ -493,7 +493,7 @@ func getCloudtrailTrailTags(ctx context.Context, d *plugin.QueryData, h *plugin.
return nil, err
}

if resp.ResourceTagList != nil && len(resp.ResourceTagList) > 0 {
if len(resp.ResourceTagList) > 0 {
return resp.ResourceTagList[0].TagsList, nil
}

Expand Down
8 changes: 1 addition & 7 deletions aws/table_aws_cloudwatch_alarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,6 @@ func tableAwsCloudWatchAlarm(_ context.Context) *plugin.Table {
Description: "An array of MetricDataQuery structures, used in an alarm based on a metric math expression.",
Type: proto.ColumnType_JSON,
},
{
Name: "ok_actions",
Description: "An array of MetricDataQuery structures, used in an alarm based on a metric math expression.",
Type: proto.ColumnType_JSON,
Transform: transform.FromField("OKActions"),
},
{
Name: "ok_actions",
Description: "The actions to execute when this alarm transitions to the OK state from any other state. Each action is specified as an Amazon Resource Name (ARN).",
Expand Down Expand Up @@ -320,7 +314,7 @@ func getCloudWatchAlarm(ctx context.Context, d *plugin.QueryData, _ *plugin.Hydr
return nil, err
}

if item.MetricAlarms != nil && len(item.MetricAlarms) > 0 {
if len(item.MetricAlarms) > 0 {
return item.MetricAlarms[0], nil
}

Expand Down
2 changes: 1 addition & 1 deletion aws/table_aws_cloudwatch_log_metric_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func getCloudwatchLogMetricFilterAkas(ctx context.Context, d *plugin.QueryData,
func logMetricTransformationsData(ctx context.Context, d *transform.TransformData) (interface{}, error) {
metricFilterData := d.HydrateItem.(types.MetricFilter)

if metricFilterData.MetricTransformations != nil && len(metricFilterData.MetricTransformations) > 0 {
if len(metricFilterData.MetricTransformations) > 0 {
if d.Param.(string) == "MetricName" {
return metricFilterData.MetricTransformations[0].MetricName, nil
} else if d.Param.(string) == "MetricNamespace" {
Expand Down
2 changes: 1 addition & 1 deletion aws/table_aws_codebuild_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func getCodeBuildProject(ctx context.Context, d *plugin.QueryData, h *plugin.Hyd
return nil, err
}

if op.Projects != nil && len(op.Projects) > 0 {
if len(op.Projects) > 0 {
return op.Projects[0], nil
}
return nil, nil
Expand Down
2 changes: 1 addition & 1 deletion aws/table_aws_dax_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func getDaxCluster(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateDa
return nil, err
}

if op.Clusters != nil && len(op.Clusters) > 0 {
if len(op.Clusters) > 0 {
return op.Clusters[0], nil
}
return nil, nil
Expand Down
2 changes: 1 addition & 1 deletion aws/table_aws_directory_service_directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ func getDirectoryServiceDirectory(ctx context.Context, d *plugin.QueryData, _ *p
return nil, err
}

if op.DirectoryDescriptions != nil && len(op.DirectoryDescriptions) > 0 {
if len(op.DirectoryDescriptions) > 0 {
return op.DirectoryDescriptions[0], nil
}
return nil, nil
Expand Down
2 changes: 1 addition & 1 deletion aws/table_aws_dms_replication_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ func getDmsReplicationInstance(ctx context.Context, d *plugin.QueryData, _ *plug
return nil, err
}

if op.ReplicationInstances != nil && len(op.ReplicationInstances) > 0 {
if len(op.ReplicationInstances) > 0 {
return op.ReplicationInstances[0], nil
}
return nil, nil
Expand Down
2 changes: 1 addition & 1 deletion aws/table_aws_docdb_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ func getDocDBCluster(ctx context.Context, d *plugin.QueryData, _ *plugin.Hydrate
return nil, err
}

if op.DBClusters != nil && len(op.DBClusters) > 0 {
if len(op.DBClusters) > 0 {
cluster := op.DBClusters[0]
if *cluster.Engine == "docdb" {
return cluster, nil
Expand Down
2 changes: 1 addition & 1 deletion aws/table_aws_docdb_cluster_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func getDocDBClusterSnapshot(ctx context.Context, d *plugin.QueryData, _ *plugin
return nil, err
}

if op.DBClusterSnapshots != nil && len(op.DBClusterSnapshots) > 0 {
if len(op.DBClusterSnapshots) > 0 {
return op.DBClusterSnapshots[0], nil
}
return nil, nil
Expand Down
2 changes: 1 addition & 1 deletion aws/table_aws_ec2_ami.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func getEc2Ami(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData)
return nil, err
}

if op.Images != nil && len(op.Images) > 0 {
if len(op.Images) > 0 {
return op.Images[0], nil
}
return nil, nil
Expand Down
4 changes: 2 additions & 2 deletions aws/table_aws_ec2_application_load_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func getEc2ApplicationLoadBalancer(ctx context.Context, d *plugin.QueryData, _ *
return nil, err
}

if op.LoadBalancers != nil && len(op.LoadBalancers) > 0 {
if len(op.LoadBalancers) > 0 {
return op.LoadBalancers[0], nil
}
return nil, nil
Expand Down Expand Up @@ -316,7 +316,7 @@ func getAwsEc2ApplicationLoadBalancerTags(ctx context.Context, d *plugin.QueryDa
return nil, err
}

if loadBalancerData.TagDescriptions != nil && len(loadBalancerData.TagDescriptions) > 0 {
if len(loadBalancerData.TagDescriptions) > 0 {
return loadBalancerData.TagDescriptions[0].Tags, nil
}

Expand Down
2 changes: 1 addition & 1 deletion aws/table_aws_ec2_capacity_reservation.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func getEc2CapacityReservation(ctx context.Context, d *plugin.QueryData, _ *plug
return nil, err
}

if op.CapacityReservations != nil && len(op.CapacityReservations) > 0 {
if len(op.CapacityReservations) > 0 {
return op.CapacityReservations[0], nil
}
return nil, nil
Expand Down
4 changes: 2 additions & 2 deletions aws/table_aws_ec2_classic_load_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ func getEc2ClassicLoadBalancer(ctx context.Context, d *plugin.QueryData, _ *plug
return nil, err
}

if op.LoadBalancerDescriptions != nil && len(op.LoadBalancerDescriptions) > 0 {
if len(op.LoadBalancerDescriptions) > 0 {
return op.LoadBalancerDescriptions[0], nil
}
return nil, nil
Expand Down Expand Up @@ -405,7 +405,7 @@ func getAwsEc2ClassicLoadBalancerTags(ctx context.Context, d *plugin.QueryData,
return nil, err
}

if loadBalancerData.TagDescriptions != nil && len(loadBalancerData.TagDescriptions) > 0 {
if len(loadBalancerData.TagDescriptions) > 0 {
return loadBalancerData.TagDescriptions[0].Tags, nil
}

Expand Down
4 changes: 2 additions & 2 deletions aws/table_aws_ec2_gateway_load_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func getEc2GatewayLoadBalancer(ctx context.Context, d *plugin.QueryData, _ *plug
return nil, err
}

if op.LoadBalancers != nil && len(op.LoadBalancers) > 0 && op.LoadBalancers[0].Type == types.LoadBalancerTypeEnumGateway {
if len(op.LoadBalancers) > 0 && op.LoadBalancers[0].Type == types.LoadBalancerTypeEnumGateway {
return op.LoadBalancers[0], nil
}
return nil, nil
Expand All @@ -278,7 +278,7 @@ func getAwsEc2GatewayLoadBalancerTags(ctx context.Context, d *plugin.QueryData,
return nil, err
}

if loadBalancerData.TagDescriptions != nil && len(loadBalancerData.TagDescriptions) > 0 {
if len(loadBalancerData.TagDescriptions) > 0 {
return loadBalancerData.TagDescriptions[0].Tags, nil
}

Expand Down
4 changes: 2 additions & 2 deletions aws/table_aws_ec2_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,8 @@ func getEc2Instance(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateD
return nil, err
}

if op.Reservations != nil && len(op.Reservations) > 0 {
if op.Reservations[0].Instances != nil && len(op.Reservations[0].Instances) > 0 {
if len(op.Reservations) > 0 {
if len(op.Reservations[0].Instances) > 0 {
return op.Reservations[0].Instances[0], nil
}
}
Expand Down
12 changes: 0 additions & 12 deletions aws/table_aws_ec2_instance_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,6 @@ func tableAwsInstanceType(_ context.Context) *plugin.Table {
Type: proto.ColumnType_BOOL,
Hydrate: describeInstanceType,
},
{
Name: "nitro_enclaves_support",
Description: "Indicates whether instance storage is supported.",
Type: proto.ColumnType_STRING,
Hydrate: describeInstanceType,
},
{
Name: "nitro_tpm_support",
Description: "Indicates whether NitroTPM is supported.",
Type: proto.ColumnType_STRING,
Hydrate: describeInstanceType,
},
{
Name: "hypervisor",
Description: "The hypervisor for the instance type.",
Expand Down
7 changes: 1 addition & 6 deletions aws/table_aws_ec2_key_pair.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ func tableAwsEc2KeyPair(_ context.Context) *plugin.Table {
Hydrate: getAwsEc2KeyPairAkas,
Transform: transform.FromValue(),
},
{
Name: "create_time",
Description: "The time that the keypair was created or imported",
Type: proto.ColumnType_TIMESTAMP,
},
}),
}
}
Expand Down Expand Up @@ -161,7 +156,7 @@ func getEc2KeyPair(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateDa
return nil, err
}

if op.KeyPairs != nil && len(op.KeyPairs) > 0 {
if len(op.KeyPairs) > 0 {
return op.KeyPairs[0], nil
}
return nil, nil
Expand Down
2 changes: 1 addition & 1 deletion aws/table_aws_ec2_load_balancer_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func getEc2LoadBalancerListener(ctx context.Context, d *plugin.QueryData, _ *plu
return nil, err
}

if op.Listeners != nil && len(op.Listeners) > 0 {
if len(op.Listeners) > 0 {
return op.Listeners[0], nil
}
return nil, nil
Expand Down
2 changes: 1 addition & 1 deletion aws/table_aws_ec2_network_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ func getEc2NetworkInterface(ctx context.Context, d *plugin.QueryData, _ *plugin.
return nil, err
}

if op.NetworkInterfaces != nil && len(op.NetworkInterfaces) > 0 {
if len(op.NetworkInterfaces) > 0 {
return op.NetworkInterfaces[0], nil
}
return nil, nil
Expand Down
4 changes: 2 additions & 2 deletions aws/table_aws_ec2_network_load_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func getEc2NetworkLoadBalancer(ctx context.Context, d *plugin.QueryData, _ *plug
return nil, err
}

if op.LoadBalancers != nil && len(op.LoadBalancers) > 0 {
if len(op.LoadBalancers) > 0 {
return op.LoadBalancers[0], nil
}
return nil, nil
Expand Down Expand Up @@ -312,7 +312,7 @@ func getAwsEc2NetworkLoadBalancerTags(ctx context.Context, d *plugin.QueryData,
return nil, err
}

if loadBalancerData.TagDescriptions != nil && len(loadBalancerData.TagDescriptions) > 0 {
if len(loadBalancerData.TagDescriptions) > 0 {
return loadBalancerData.TagDescriptions[0].Tags, nil
}

Expand Down
2 changes: 1 addition & 1 deletion aws/table_aws_ec2_reserved_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func getEc2ReservedInstance(ctx context.Context, d *plugin.QueryData, _ *plugin.
return nil, err
}

if op.ReservedInstances != nil && len(op.ReservedInstances) > 0 {
if len(op.ReservedInstances) > 0 {
return op.ReservedInstances[0], nil
}
return nil, nil
Expand Down
2 changes: 1 addition & 1 deletion aws/table_aws_ec2_ssl_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func getEc2SslPolicy(ctx context.Context, d *plugin.QueryData, _ *plugin.Hydrate
return nil, err
}

if op.SslPolicies != nil && len(op.SslPolicies) > 0 {
if len(op.SslPolicies) > 0 {
return op.SslPolicies[0], nil
}
}
Expand Down
6 changes: 3 additions & 3 deletions aws/table_aws_ec2_target_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func getEc2TargetGroup(ctx context.Context, d *plugin.QueryData, _ *plugin.Hydra
return nil, err
}

if op.TargetGroups != nil && len(op.TargetGroups) > 0 {
if len(op.TargetGroups) > 0 {
return op.TargetGroups[0], nil
}
return nil, nil
Expand Down Expand Up @@ -327,7 +327,7 @@ func getAwsEc2TargetGroupTags(ctx context.Context, d *plugin.QueryData, h *plugi
func targetGroupTagsToTurbotTags(_ context.Context, d *transform.TransformData) (interface{}, error) {
data := d.HydrateItem.(*elasticloadbalancingv2.DescribeTagsOutput)
var turbotTagsMap map[string]string
if data.TagDescriptions != nil && len(data.TagDescriptions) > 0 {
if len(data.TagDescriptions) > 0 {
if data.TagDescriptions[0].Tags != nil {
turbotTagsMap = map[string]string{}
for _, i := range data.TagDescriptions[0].Tags {
Expand All @@ -341,7 +341,7 @@ func targetGroupTagsToTurbotTags(_ context.Context, d *transform.TransformData)

func targetGroupRawTags(_ context.Context, d *transform.TransformData) (interface{}, error) {
data := d.HydrateItem.(*elasticloadbalancingv2.DescribeTagsOutput)
if data.TagDescriptions != nil && len(data.TagDescriptions) > 0 {
if len(data.TagDescriptions) > 0 {
if data.TagDescriptions[0].Tags != nil {
return data.TagDescriptions[0].Tags, nil
}
Expand Down
2 changes: 1 addition & 1 deletion aws/table_aws_ec2_transit_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func getEc2TransitGateway(ctx context.Context, d *plugin.QueryData, _ *plugin.Hy
return nil, err
}

if op.TransitGateways != nil && len(op.TransitGateways) > 0 {
if len(op.TransitGateways) > 0 {
return op.TransitGateways[0], nil
}
return nil, nil
Expand Down
2 changes: 1 addition & 1 deletion aws/table_aws_ec2_transit_gateway_route_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func getEc2TransitGatewayRouteTable(ctx context.Context, d *plugin.QueryData, _
return nil, err
}

if op.TransitGatewayRouteTables != nil && len(op.TransitGatewayRouteTables) > 0 {
if len(op.TransitGatewayRouteTables) > 0 {
return op.TransitGatewayRouteTables[0], nil
}
return nil, nil
Expand Down
2 changes: 1 addition & 1 deletion aws/table_aws_ec2_transit_gateway_vpc_attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func getEc2TransitGatewayVpcAttachment(ctx context.Context, d *plugin.QueryData,
return nil, err
}

if op.TransitGatewayAttachments != nil && len(op.TransitGatewayAttachments) > 0 {
if len(op.TransitGatewayAttachments) > 0 {
return op.TransitGatewayAttachments[0], nil
}
return nil, nil
Expand Down
2 changes: 1 addition & 1 deletion aws/table_aws_ecrpublic_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func getAwsEcrpublicRepository(ctx context.Context, d *plugin.QueryData, _ *plug
plugin.Logger(ctx).Error("aws_ecrpublic_repository.getAwsEcrpublicRepository", "api_error", err)
return nil, err
}
if data.Repositories != nil && len(data.Repositories) > 0 {
if len(data.Repositories) > 0 {
return data.Repositories[0], nil
}

Expand Down
2 changes: 1 addition & 1 deletion aws/table_aws_ecs_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func getEcsCluster(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateDa
return nil, err
}

if op.Clusters != nil && len(op.Clusters) > 0 {
if op != nil && len(op.Clusters) > 0 {
return op.Clusters[0], nil
}

Expand Down
2 changes: 1 addition & 1 deletion aws/table_aws_efs_access_point.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func getEfsAccessPoint(ctx context.Context, d *plugin.QueryData, _ *plugin.Hydra
return nil, err
}

if data.AccessPoints != nil && len(data.AccessPoints) > 0 {
if data != nil && len(data.AccessPoints) > 0 {
return data.AccessPoints[0], nil
}
return nil, nil
Expand Down
2 changes: 1 addition & 1 deletion aws/table_aws_efs_file_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func getElasticFileSystem(ctx context.Context, d *plugin.QueryData, _ *plugin.Hy
return nil, err
}

if op.FileSystems != nil && len(op.FileSystems) > 0 {
if op != nil && len(op.FileSystems) > 0 {
return op.FileSystems[0], nil
}

Expand Down
Loading

0 comments on commit 730bb0f

Please sign in to comment.