Skip to content

Commit

Permalink
fixes #11395
Browse files Browse the repository at this point in the history
* Fix propagation of tags to connected resources

* Fix lint issue

* Update err msgs to new format

* Add reference to SDK issue in comments
  • Loading branch information
WodansSon authored Apr 21, 2021
1 parent ed7f447 commit fe1e86f
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ func resourceDatabricksWorkspaceCreateUpdate(d *schema.ResourceData, meta interf
customParamsRaw := d.Get("custom_parameters").([]interface{})
customParams := expandWorkspaceCustomParameters(customParamsRaw)

// Including the Tags in the workspace parameters will update the tags on
// the workspace only
workspace := databricks.Workspace{
Sku: &databricks.Sku{
Name: utils.String(skuName),
Expand All @@ -199,6 +201,25 @@ func resourceDatabricksWorkspaceCreateUpdate(d *schema.ResourceData, meta interf
return fmt.Errorf("waiting for create/update of %s: %+v", id, err)
}

// Only call Update(e.g. PATCH) if it is not a new resource and the Tags have changed
// this will cause the updated tags to be propagated to all of the connected
// workspace resources.
// TODO: can be removed once https://github.com/Azure/azure-sdk-for-go/issues/14571 is fixed
if !d.IsNewResource() && d.HasChange("tags") {
workspaceUpdate := databricks.WorkspaceUpdate{
Tags: expandedTags,
}

future, err := client.Update(ctx, workspaceUpdate, id.ResourceGroup, id.Name)
if err != nil {
return fmt.Errorf("updating %s Tags: %+v", id, err)
}

if err = future.WaitForCompletionRef(ctx, client.Client); err != nil {
return fmt.Errorf("waiting for %s Tags to be updated: %+v", id, err)
}
}

d.SetId(id.ID())
return resourceDatabricksWorkspaceRead(d, meta)
}
Expand Down

0 comments on commit fe1e86f

Please sign in to comment.