From 2223964ff1a340b5a9f452687a64175255bc3156 Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Sun, 28 Aug 2016 17:15:45 +0100 Subject: [PATCH] provider/aws: Remove unsafe ptr dereferencing from ECS/ECR (#8514) --- .../providers/aws/resource_aws_ecr_repository.go | 8 ++++---- .../aws/resource_aws_ecr_repository_policy.go | 6 +++--- builtin/providers/aws/resource_aws_ecs_cluster.go | 2 +- builtin/providers/aws/resource_aws_ecs_service.go | 14 +++++++------- .../aws/resource_aws_ecs_task_definition.go | 8 ++++---- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/builtin/providers/aws/resource_aws_ecr_repository.go b/builtin/providers/aws/resource_aws_ecr_repository.go index 313cdbd4c..4be941e02 100644 --- a/builtin/providers/aws/resource_aws_ecr_repository.go +++ b/builtin/providers/aws/resource_aws_ecr_repository.go @@ -60,8 +60,8 @@ func resourceAwsEcrRepositoryCreate(d *schema.ResourceData, meta interface{}) er log.Printf("[DEBUG] ECR repository created: %q", *repository.RepositoryArn) d.SetId(*repository.RepositoryName) - d.Set("arn", *repository.RepositoryArn) - d.Set("registry_id", *repository.RegistryId) + d.Set("arn", repository.RepositoryArn) + d.Set("registry_id", repository.RegistryId) return resourceAwsEcrRepositoryRead(d, meta) } @@ -86,8 +86,8 @@ func resourceAwsEcrRepositoryRead(d *schema.ResourceData, meta interface{}) erro log.Printf("[DEBUG] Received repository %s", out) d.SetId(*repository.RepositoryName) - d.Set("arn", *repository.RepositoryArn) - d.Set("registry_id", *repository.RegistryId) + d.Set("arn", repository.RepositoryArn) + d.Set("registry_id", repository.RegistryId) d.Set("name", repository.RepositoryName) repositoryUrl := buildRepositoryUrl(repository, meta.(*AWSClient).region) diff --git a/builtin/providers/aws/resource_aws_ecr_repository_policy.go b/builtin/providers/aws/resource_aws_ecr_repository_policy.go index 8932ea557..77bfb78db 100644 --- a/builtin/providers/aws/resource_aws_ecr_repository_policy.go +++ b/builtin/providers/aws/resource_aws_ecr_repository_policy.go @@ -53,7 +53,7 @@ func resourceAwsEcrRepositoryPolicyCreate(d *schema.ResourceData, meta interface log.Printf("[DEBUG] ECR repository policy created: %s", *repositoryPolicy.RepositoryName) d.SetId(*repositoryPolicy.RepositoryName) - d.Set("registry_id", *repositoryPolicy.RegistryId) + d.Set("registry_id", repositoryPolicy.RegistryId) return resourceAwsEcrRepositoryPolicyRead(d, meta) } @@ -84,7 +84,7 @@ func resourceAwsEcrRepositoryPolicyRead(d *schema.ResourceData, meta interface{} repositoryPolicy := out d.SetId(*repositoryPolicy.RepositoryName) - d.Set("registry_id", *repositoryPolicy.RegistryId) + d.Set("registry_id", repositoryPolicy.RegistryId) return nil } @@ -110,7 +110,7 @@ func resourceAwsEcrRepositoryPolicyUpdate(d *schema.ResourceData, meta interface repositoryPolicy := *out d.SetId(*repositoryPolicy.RepositoryName) - d.Set("registry_id", *repositoryPolicy.RegistryId) + d.Set("registry_id", repositoryPolicy.RegistryId) return nil } diff --git a/builtin/providers/aws/resource_aws_ecs_cluster.go b/builtin/providers/aws/resource_aws_ecs_cluster.go index c1a115e9d..0867db1ae 100644 --- a/builtin/providers/aws/resource_aws_ecs_cluster.go +++ b/builtin/providers/aws/resource_aws_ecs_cluster.go @@ -43,7 +43,7 @@ func resourceAwsEcsClusterCreate(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] ECS cluster %s created", *out.Cluster.ClusterArn) d.SetId(*out.Cluster.ClusterArn) - d.Set("name", *out.Cluster.ClusterName) + d.Set("name", out.Cluster.ClusterName) return nil } diff --git a/builtin/providers/aws/resource_aws_ecs_service.go b/builtin/providers/aws/resource_aws_ecs_service.go index 9422a7387..859c3b4b4 100644 --- a/builtin/providers/aws/resource_aws_ecs_service.go +++ b/builtin/providers/aws/resource_aws_ecs_service.go @@ -201,21 +201,21 @@ func resourceAwsEcsServiceRead(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Received ECS service %s", service) d.SetId(*service.ServiceArn) - d.Set("name", *service.ServiceName) + d.Set("name", service.ServiceName) // Save task definition in the same format if strings.HasPrefix(d.Get("task_definition").(string), "arn:aws:ecs:") { - d.Set("task_definition", *service.TaskDefinition) + d.Set("task_definition", service.TaskDefinition) } else { taskDefinition := buildFamilyAndRevisionFromARN(*service.TaskDefinition) d.Set("task_definition", taskDefinition) } - d.Set("desired_count", *service.DesiredCount) + d.Set("desired_count", service.DesiredCount) // Save cluster in the same format if strings.HasPrefix(d.Get("cluster").(string), "arn:aws:ecs:") { - d.Set("cluster", *service.ClusterArn) + d.Set("cluster", service.ClusterArn) } else { clusterARN := getNameFromARN(*service.ClusterArn) d.Set("cluster", clusterARN) @@ -224,7 +224,7 @@ func resourceAwsEcsServiceRead(d *schema.ResourceData, meta interface{}) error { // Save IAM role in the same format if service.RoleArn != nil { if strings.HasPrefix(d.Get("iam_role").(string), "arn:aws:iam:") { - d.Set("iam_role", *service.RoleArn) + d.Set("iam_role", service.RoleArn) } else { roleARN := getNameFromARN(*service.RoleArn) d.Set("iam_role", roleARN) @@ -232,8 +232,8 @@ func resourceAwsEcsServiceRead(d *schema.ResourceData, meta interface{}) error { } if service.DeploymentConfiguration != nil { - d.Set("deployment_maximum_percent", *service.DeploymentConfiguration.MaximumPercent) - d.Set("deployment_minimum_healthy_percent", *service.DeploymentConfiguration.MinimumHealthyPercent) + d.Set("deployment_maximum_percent", service.DeploymentConfiguration.MaximumPercent) + d.Set("deployment_minimum_healthy_percent", service.DeploymentConfiguration.MinimumHealthyPercent) } if service.LoadBalancers != nil { diff --git a/builtin/providers/aws/resource_aws_ecs_task_definition.go b/builtin/providers/aws/resource_aws_ecs_task_definition.go index 2d21931f7..787df3044 100644 --- a/builtin/providers/aws/resource_aws_ecs_task_definition.go +++ b/builtin/providers/aws/resource_aws_ecs_task_definition.go @@ -140,7 +140,7 @@ func resourceAwsEcsTaskDefinitionCreate(d *schema.ResourceData, meta interface{} *taskDefinition.TaskDefinitionArn, *taskDefinition.Revision) d.SetId(*taskDefinition.Family) - d.Set("arn", *taskDefinition.TaskDefinitionArn) + d.Set("arn", taskDefinition.TaskDefinitionArn) return resourceAwsEcsTaskDefinitionRead(d, meta) } @@ -160,9 +160,9 @@ func resourceAwsEcsTaskDefinitionRead(d *schema.ResourceData, meta interface{}) taskDefinition := out.TaskDefinition d.SetId(*taskDefinition.Family) - d.Set("arn", *taskDefinition.TaskDefinitionArn) - d.Set("family", *taskDefinition.Family) - d.Set("revision", *taskDefinition.Revision) + d.Set("arn", taskDefinition.TaskDefinitionArn) + d.Set("family", taskDefinition.Family) + d.Set("revision", taskDefinition.Revision) d.Set("container_definitions", taskDefinition.ContainerDefinitions) d.Set("task_role_arn", taskDefinition.TaskRoleArn) d.Set("network_mode", taskDefinition.NetworkMode)