Skip to content

Commit

Permalink
Fix issues with wrong reading
Browse files Browse the repository at this point in the history
  • Loading branch information
lego963 committed Jun 17, 2021
1 parent 9a775cb commit 02a02ac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ resource opentelekomcloud_swr_repository_v2 repo_1 {
resource opentelekomcloud_swr_domain_v2 domain_1 {
organization = opentelekomcloud_swr_organization_v2.org_1.name
repository = opentelekomcloud_swr_repository_v2.name
repository = opentelekomcloud_swr_repository_v2.repo_1.name
access_domain = "%[2]s"
permission = "read"
deadline = "forever"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ func ResourceSwrDomainV2() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
StateFunc: func(v interface{}) string {
return strings.ToUpper(v.(string))
},
},
"permission": {
Type: schema.TypeString,
Expand Down Expand Up @@ -103,7 +100,7 @@ func resourceSwrDomainCreate(ctx context.Context, d *schema.ResourceData, meta i
}
d.SetId(opts.AccessDomain)

return resourceRepositoryRead(ctx, d, meta)
return resourceSwrDomainRead(ctx, d, meta)
}

func resourceSwrDomainRead(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
Expand All @@ -115,11 +112,11 @@ func resourceSwrDomainRead(_ context.Context, d *schema.ResourceData, meta inter

domain, err := domains.Get(client, organization(d), repository(d), d.Id()).Extract()
if err != nil {
return fmterr.Errorf("error reading repository: %w", err)
return fmterr.Errorf("error reading domain: %w", err)
}

mErr := multierror.Append(
d.Set("access_domain", domain.AccessDomain),
d.Set("access_domain", strings.ToUpper(domain.AccessDomain)),
d.Set("repository", domain.Repository),
d.Set("organization", domain.Organization),
d.Set("description", domain.Description),
Expand Down Expand Up @@ -149,12 +146,13 @@ func resourceSwrDomainUpdate(ctx context.Context, d *schema.ResourceData, meta i
Deadline: d.Get("deadline").(string),
Description: d.Get("description").(string),
}

err = domains.Update(client, organization(d), repository(d), d.Id(), opts).ExtractErr()
if err != nil {
return fmterr.Errorf("error updating domain: %w", err)
}

return resourceRepositoryRead(ctx, d, meta)
return resourceSwrDomainRead(ctx, d, meta)
}

func resourceSwrDomainDelete(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
Expand Down

0 comments on commit 02a02ac

Please sign in to comment.