provider/aws: Remove unsafe ptr dereferencing from ECS/ECR (#8514)

This commit is contained in:
Radek Simko 2016-08-28 17:15:45 +01:00 committed by Paul Stack
parent ee4f96e07f
commit 2223964ff1
5 changed files with 19 additions and 19 deletions

View File

@ -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)

View File

@ -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
}

View File

@ -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
}

View File

@ -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 {

View File

@ -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)