Skip to content

Commit

Permalink
Add Support for Icon URL in azurerm_bot_service_azure_bot resource (#…
Browse files Browse the repository at this point in the history
…23114)

* Add Support for Icon URL in azurerm_bot_service_azure_bot resource

* Apply suggestions from code review

Co-authored-by: Tom Harvey <tombuildsstuff@users.noreply.github.com>

* Add icon_url attribute to documentation

* update property description

* Add icon_url attribute to acceptance test

* Add default value to icon_url parameter

Co-authored-by: stephybun <steph@hashicorp.com>

* rebase and terrafmt

* switch to pointer.From in read

---------

Co-authored-by: Tom Harvey <tombuildsstuff@users.noreply.github.com>
Co-authored-by: stephybun <steph@hashicorp.com>
  • Loading branch information
3 people committed Sep 22, 2023
1 parent 8ff4825 commit 085cc1d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
14 changes: 7 additions & 7 deletions internal/services/bot/bot_service_azure_bot_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,13 @@ resource "azurerm_application_insights_api_key" "test" {
}
resource "azurerm_bot_service_azure_bot" "test" {
name = "acctestdf%[1]d"
resource_group_name = azurerm_resource_group.test.name
location = "global"
microsoft_app_id = data.azurerm_client_config.current.client_id
sku = "F0"
local_authentication_enabled = false
name = "acctestdf%[1]d"
resource_group_name = azurerm_resource_group.test.name
location = "global"
microsoft_app_id = data.azurerm_client_config.current.client_id
sku = "F0"
local_authentication_enabled = false
icon_url = "https://registry.terraform.io/images/providers/azure.png"
endpoint = "https://example.com"
developer_app_insights_api_key = azurerm_application_insights_api_key.test.api_key
developer_app_insights_application_id = azurerm_application_insights.test.app_id
Expand Down
15 changes: 15 additions & 0 deletions internal/services/bot/bot_service_resource_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"time"

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonids"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
Expand Down Expand Up @@ -135,6 +136,13 @@ func (br botBaseResource) arguments(fields map[string]*pluginsdk.Schema) map[str
Default: false,
},

"icon_url": {
Type: pluginsdk.TypeString,
Optional: true,
Default: "https://docs.botframework.com/static/devportal/client/images/bot-framework-default.png",
ValidateFunc: validation.StringIsNotEmpty,
},

"tags": tags.Schema(),
}

Expand Down Expand Up @@ -190,6 +198,7 @@ func (br botBaseResource) createFunc(resourceName, botKind string) sdk.ResourceF
LuisAppIds: utils.ExpandStringSlice(metadata.ResourceData.Get("luis_app_ids").([]interface{})),
LuisKey: utils.String(metadata.ResourceData.Get("luis_key").(string)),
IsStreamingSupported: utils.Bool(metadata.ResourceData.Get("streaming_endpoint_enabled").(bool)),
IconURL: utils.String(metadata.ResourceData.Get("icon_url").(string)),
},
Tags: tags.Expand(metadata.ResourceData.Get("tags").(map[string]interface{})),
}
Expand Down Expand Up @@ -319,6 +328,8 @@ func (br botBaseResource) readFunc() sdk.ResourceFunc {
streamingEndpointEnabled = *v
}
metadata.ResourceData.Set("streaming_endpoint_enabled", streamingEndpointEnabled)

metadata.ResourceData.Set("icon_url", pointer.From(props.IconURL))
}

return nil
Expand Down Expand Up @@ -396,6 +407,10 @@ func (br botBaseResource) updateFunc() sdk.ResourceFunc {
existing.Properties.IsStreamingSupported = utils.Bool(metadata.ResourceData.Get("streaming_endpoint_enabled").(bool))
}

if metadata.ResourceData.HasChange("icon_url") {
existing.Properties.IconURL = utils.String(metadata.ResourceData.Get("icon_url").(string))
}

if _, err := client.Update(ctx, id.ResourceGroup, id.Name, existing); err != nil {
return fmt.Errorf("updating %s: %+v", *id, err)
}
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/bot_service_azure_bot.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ The following arguments are supported:

* `endpoint` - (Optional) The Azure Bot Service endpoint.

* `icon_url` - (Optional) The Icon Url of the Azure Bot Service.

* `microsoft_app_msi_id` - (Optional) The ID of the Microsoft App Managed Identity for this Azure Bot Service. Changing this forces a new resource to be created.

* `microsoft_app_tenant_id` - (Optional) The Tenant ID of the Microsoft App for this Azure Bot Service. Changing this forces a new resource to be created.
Expand Down

0 comments on commit 085cc1d

Please sign in to comment.