From 929575b5a0573ab2b860584d663659fd0cb81387 Mon Sep 17 00:00:00 2001 From: jackofallops Date: Wed, 4 May 2022 10:16:26 +0100 Subject: [PATCH 1/2] fix WEBSITE_RUN_FROM_PACKAGE handling from external sources --- internal/services/appservice/linux_function_app_resource.go | 6 ++++++ .../services/appservice/linux_function_app_slot_resource.go | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/internal/services/appservice/linux_function_app_resource.go b/internal/services/appservice/linux_function_app_resource.go index 895cd64470af..7c2afbcd6177 100644 --- a/internal/services/appservice/linux_function_app_resource.go +++ b/internal/services/appservice/linux_function_app_resource.go @@ -1022,6 +1022,12 @@ func (m *LinuxFunctionAppModel) unpackLinuxFunctionAppSettings(input web.StringD case "AzureWebJobsDashboard__accountName": m.BuiltinLogging = true + case "WEBSITE_RUN_FROM_PACKAGE": + // Keep if user explicitly set, otherwise filter out as will have been added by ADO et al + if _, ok := metadata.ResourceData.GetOk("app_settings.WEBSITE_RUN_FROM_PACKAGE"); ok { + appSettings[k] = utils.NormalizeNilableString(v) + } + default: appSettings[k] = utils.NormalizeNilableString(v) } diff --git a/internal/services/appservice/linux_function_app_slot_resource.go b/internal/services/appservice/linux_function_app_slot_resource.go index 3dd686a2de4a..c9dc5c0ff34e 100644 --- a/internal/services/appservice/linux_function_app_slot_resource.go +++ b/internal/services/appservice/linux_function_app_slot_resource.go @@ -868,6 +868,11 @@ func (m *LinuxFunctionAppSlotModel) unpackLinuxFunctionAppSettings(input web.Str case "AzureWebJobsDashboard__accountName": m.BuiltinLogging = true + case "WEBSITE_RUN_FROM_PACKAGE": + if _, ok := metadata.ResourceData.GetOk("app_settings.WEBSITE_RUN_FROM_PACKAGE"); ok { + appSettings[k] = utils.NormalizeNilableString(v) + } + default: appSettings[k] = utils.NormalizeNilableString(v) } From f3cfca5535128073806fed6cc8e0aec1c2c00f42 Mon Sep 17 00:00:00 2001 From: jackofallops Date: Wed, 4 May 2022 15:01:49 +0100 Subject: [PATCH 2/2] fix intermittent unit test --- .../helpers/function_app_schema_test.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/internal/services/appservice/helpers/function_app_schema_test.go b/internal/services/appservice/helpers/function_app_schema_test.go index bc5453c9bc40..74650baaf155 100644 --- a/internal/services/appservice/helpers/function_app_schema_test.go +++ b/internal/services/appservice/helpers/function_app_schema_test.go @@ -2,6 +2,7 @@ package helpers_test import ( "reflect" + "sort" "testing" "github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-02-01/web" @@ -56,6 +57,10 @@ func TestMergeUserAppSettings(t *testing.T) { "test4": "UserValue4", }, expected: []web.NameValuePair{ + { + Name: utils.String("test"), + Value: utils.String("UserValue"), + }, { Name: utils.String("test2"), Value: utils.String("ServiceValue2"), @@ -64,10 +69,6 @@ func TestMergeUserAppSettings(t *testing.T) { Name: utils.String("test3"), Value: utils.String("ServiceValue3"), }, - { - Name: utils.String("test"), - Value: utils.String("UserValue"), - }, { Name: utils.String("test4"), Value: utils.String("UserValue4"), @@ -77,9 +78,13 @@ func TestMergeUserAppSettings(t *testing.T) { } for _, v := range cases { - actual := helpers.MergeUserAppSettings(&v.service, v.user) - if !reflect.DeepEqual(*actual, v.expected) { - t.Fatalf("expected %+v, got %+v", v.expected, *actual) + actualRaw := helpers.MergeUserAppSettings(&v.service, v.user) + actual := *actualRaw + sort.Slice(actual, func(i, j int) bool { + return *actual[i].Name < *actual[j].Name + }) + if !reflect.DeepEqual(actual, v.expected) { + t.Fatalf("expected %+v, got %+v", v.expected, actual) } } }