Skip to content

Commit

Permalink
Fix resource id when using default conn
Browse files Browse the repository at this point in the history
  • Loading branch information
tenstad committed Aug 29, 2021
1 parent f8064d6 commit 94345e7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions internal/provider/resource_remote_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ func resourceRemoteFile() *schema.Resource {
}

func resourceRemoteFileCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
d.SetId(fmt.Sprintf("%s:%s", d.Get("conn.0.host").(string), d.Get("path").(string)))
connectionResourceData, err := meta.(*apiClient).connectionResourceData(d)
if err != nil {
return diag.Errorf(err.Error())
}
d.SetId(fmt.Sprintf("%s:%s", connectionResourceData.Get("conn.0.host").(string), d.Get("path").(string)))

client, err := meta.(*apiClient).getRemoteClient(d)
if err != nil {
Expand Down Expand Up @@ -83,7 +87,11 @@ func resourceRemoteFileCreate(ctx context.Context, d *schema.ResourceData, meta
}

func resourceRemoteFileRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
d.SetId(fmt.Sprintf("%s:%s", d.Get("conn.0.host").(string), d.Get("path").(string)))
connectionResourceData, err := meta.(*apiClient).connectionResourceData(d)
if err != nil {
return diag.Errorf(err.Error())
}
d.SetId(fmt.Sprintf("%s:%s", connectionResourceData.Get("conn.0.host").(string), d.Get("path").(string)))

client, err := meta.(*apiClient).getRemoteClient(d)
if err != nil {
Expand Down

0 comments on commit 94345e7

Please sign in to comment.