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

New Beta resource: azurerm_windows_function_app #14247

Merged
merged 18 commits into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
1,060 changes: 898 additions & 162 deletions internal/services/appservice/helpers/function_app_schema.go

Large diffs are not rendered by default.

66 changes: 66 additions & 0 deletions internal/services/appservice/helpers/fx_strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ func EncodeFunctionAppLinuxFxVersion(input []ApplicationStackLinuxFunctionApp) *
case appStack.JavaVersion != "":
appType = "Java"
appString = appStack.JavaVersion
case appStack.PowerShellCoreVersion != "":
appType = "PowerShell"
appString = appStack.PowerShellCoreVersion
case len(appStack.Docker) > 0 && appStack.Docker[0].ImageName != "":
appType = "Docker"
dockerCfg := appStack.Docker[0]
Expand Down Expand Up @@ -115,6 +118,10 @@ func DecodeFunctionAppLinuxFxVersion(input string) ([]ApplicationStackLinuxFunct
appStack := ApplicationStackLinuxFunctionApp{JavaVersion: parts[1]}
result = append(result, appStack)

case "powershell":
appStack := ApplicationStackLinuxFunctionApp{PowerShellCoreVersion: parts[1]}
result = append(result, appStack)

case "docker":
// This is handled as part of unpacking the app_settings using DecodeFunctionAppDockerFxString but included here for signposting as this is not intuitive.
}
Expand Down Expand Up @@ -147,3 +154,62 @@ func DecodeFunctionAppDockerFxString(input string, partial ApplicationStackDocke

return []ApplicationStackDocker{partial}, nil
}

func EncodeFunctionAppWindowsFxVersion(input []ApplicationStackWindowsFunctionApp) *string {
if len(input) == 0 {
return utils.String("")
}

appStack := input[0]
var appType, appString string
switch {
case appStack.NodeVersion != "":
appType = "Node"
appString = appStack.NodeVersion
case appStack.DotNetVersion != "":
appType = "DotNet"
appString = appStack.DotNetVersion
case appStack.JavaVersion != "":
appType = "Java"
appString = appStack.JavaVersion
case appStack.PowerShellCoreVersion != "":
appType = "PowerShell"
appString = appStack.PowerShellCoreVersion
}

return utils.String(fmt.Sprintf("%s|%s", appType, appString))
}

func DecodeFunctionAppWindowsFxVersion(input string) ([]ApplicationStackWindowsFunctionApp, error) {
if input == "" {
// This is a valid string for "Custom" stack which we picked up earlier, so we can skip here
return nil, nil
}

parts := strings.Split(input, "|")
if len(parts) != 2 {
return nil, fmt.Errorf("unrecognised WindowsFxVersion format received, got %s", input)
}

result := make([]ApplicationStackWindowsFunctionApp, 0)

switch strings.ToLower(parts[0]) {
case "dotnet":
appStack := ApplicationStackWindowsFunctionApp{DotNetVersion: parts[1]}
result = append(result, appStack)

case "node":
appStack := ApplicationStackWindowsFunctionApp{NodeVersion: parts[1]}
result = append(result, appStack)

case "java":
appStack := ApplicationStackWindowsFunctionApp{JavaVersion: parts[1]}
result = append(result, appStack)

case "powershell":
appStack := ApplicationStackWindowsFunctionApp{PowerShellCoreVersion: parts[1]}
result = append(result, appStack)
}

return result, nil
}
9 changes: 5 additions & 4 deletions internal/services/appservice/helpers/web_app_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/Azure/go-autorest/autorest/date"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
apimValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/apimanagement/validate"
msiValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/msi/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
"github.com/hashicorp/terraform-provider-azurerm/utils"
Expand Down Expand Up @@ -145,7 +144,7 @@ func SiteConfigSchemaWindows() *pluginsdk.Schema {
"container_registry_managed_identity_client_id": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: msiValidate.UserAssignedIdentityID,
ValidateFunc: validation.IsUUID,
},

"default_documents": {
Expand Down Expand Up @@ -540,7 +539,7 @@ func SiteConfigSchemaLinux() *pluginsdk.Schema {
"container_registry_managed_identity_client_id": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: msiValidate.UserAssignedIdentityID,
ValidateFunc: validation.IsUUID,
},

"default_documents": {
Expand Down Expand Up @@ -3487,6 +3486,7 @@ func FlattenSiteConfigWindows(appSiteConfig *web.SiteConfig, currentStack string
UseManagedIdentityACR: utils.NormaliseNilableBool(appSiteConfig.AcrUseManagedIdentityCreds),
VirtualApplications: flattenVirtualApplications(appSiteConfig.VirtualApplications),
WebSockets: utils.NormaliseNilableBool(appSiteConfig.WebSocketsEnabled),
VnetRouteAllEnabled: utils.NormaliseNilableBool(appSiteConfig.VnetRouteAllEnabled),
}

if appSiteConfig.APIManagementConfig != nil && appSiteConfig.APIManagementConfig.ID != nil {
Expand Down Expand Up @@ -3682,6 +3682,7 @@ func FlattenAppSettings(input web.StringDictionary) (map[string]string, *int) {
"DIAGNOSTICS_AZUREBLOBRETENTIONINDAYS",
"WEBSITE_HTTPLOGGING_CONTAINER_URL",
"WEBSITE_HTTPLOGGING_RETENTION_DAYS",
"WEBSITE_VNET_ROUTE_ALL",
maxPingFailures,
}

Expand All @@ -3692,7 +3693,7 @@ func FlattenAppSettings(input web.StringDictionary) (map[string]string, *int) {
healthCheckCount = &h
}

// Remove the settings the service adds for legacy reasons when logging settings are specified.
// Remove the settings the service adds for legacy reasons.
for _, v := range unmanagedSettings { //nolint:typecheck
delete(appSettings, v)
}
Expand Down
Loading