Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for Icon URL in azurerm_bot_service_azure_bot resource #23114

Merged
merged 8 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": {
fdmsantos marked this conversation as resolved.
Show resolved Hide resolved
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.To(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