-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
azurerm_windows[linux]_web_app_[slot]
- add docker setting to app_setting
block
#22484
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -619,6 +619,9 @@ func (s *SiteConfigLinuxWebAppSlot) ExpandForCreate(appSettings map[string]strin | |
|
||
if linuxAppStack.DockerImageName != "" { | ||
expanded.LinuxFxVersion = pointer.To(EncodeDockerFxString(linuxAppStack.DockerImageName, linuxAppStack.DockerRegistryUrl)) | ||
if appSettings == nil { | ||
appSettings = map[string]string{} | ||
} | ||
Comment on lines
+622
to
+624
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above, the missing values bug is due to the app settings not being written to the expanded.AppSettings = ExpandAppSettingsForCreate(appSettings) after the entries are added. |
||
appSettings["DOCKER_REGISTRY_SERVER_URL"] = linuxAppStack.DockerRegistryUrl | ||
appSettings["DOCKER_REGISTRY_SERVER_USERNAME"] = linuxAppStack.DockerRegistryUsername | ||
appSettings["DOCKER_REGISTRY_SERVER_PASSWORD"] = linuxAppStack.DockerRegistryPassword | ||
|
@@ -748,6 +751,9 @@ func (s *SiteConfigLinuxWebAppSlot) ExpandForUpdate(metadata sdk.ResourceMetaDat | |
|
||
if linuxAppStack.DockerImageName != "" { | ||
expanded.LinuxFxVersion = pointer.To(EncodeDockerFxString(linuxAppStack.DockerImageName, linuxAppStack.DockerRegistryUrl)) | ||
if appSettings == nil { | ||
appSettings = map[string]string{} | ||
} | ||
Comment on lines
+754
to
+756
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, as above. |
||
appSettings["DOCKER_REGISTRY_SERVER_URL"] = linuxAppStack.DockerRegistryUrl | ||
appSettings["DOCKER_REGISTRY_SERVER_USERNAME"] = linuxAppStack.DockerRegistryUsername | ||
appSettings["DOCKER_REGISTRY_SERVER_PASSWORD"] = linuxAppStack.DockerRegistryPassword | ||
|
@@ -1028,6 +1034,9 @@ func (s *SiteConfigWindowsWebAppSlot) ExpandForCreate(appSettings map[string]str | |
|
||
if winAppStack.DockerImageName != "" { | ||
expanded.WindowsFxVersion = pointer.To(EncodeDockerFxStringWindows(winAppStack.DockerImageName, winAppStack.DockerRegistryUrl)) | ||
if appSettings == nil { | ||
appSettings = map[string]string{} | ||
} | ||
Comment on lines
+1037
to
+1039
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. again here |
||
appSettings["DOCKER_REGISTRY_SERVER_URL"] = winAppStack.DockerRegistryUrl | ||
appSettings["DOCKER_REGISTRY_SERVER_USERNAME"] = winAppStack.DockerRegistryUsername | ||
appSettings["DOCKER_REGISTRY_SERVER_PASSWORD"] = winAppStack.DockerRegistryPassword | ||
|
@@ -1165,6 +1174,9 @@ func (s *SiteConfigWindowsWebAppSlot) ExpandForUpdate(metadata sdk.ResourceMetaD | |
|
||
if winAppStack.DockerImageName != "" { | ||
expanded.WindowsFxVersion = pointer.To(EncodeDockerFxStringWindows(winAppStack.DockerImageName, winAppStack.DockerRegistryUrl)) | ||
if appSettings == nil { | ||
appSettings = map[string]string{} | ||
} | ||
Comment on lines
+1177
to
+1179
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and again here |
||
appSettings["DOCKER_REGISTRY_SERVER_URL"] = winAppStack.DockerRegistryUrl | ||
appSettings["DOCKER_REGISTRY_SERVER_USERNAME"] = winAppStack.DockerRegistryUsername | ||
appSettings["DOCKER_REGISTRY_SERVER_PASSWORD"] = winAppStack.DockerRegistryPassword | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -525,6 +525,9 @@ func (s *SiteConfigWindows) ExpandForCreate(appSettings map[string]string) (*web | |
|
||
if winAppStack.DockerImageName != "" { | ||
expanded.WindowsFxVersion = pointer.To(EncodeDockerFxStringWindows(winAppStack.DockerImageName, winAppStack.DockerRegistryUrl)) | ||
if appSettings == nil { | ||
appSettings = map[string]string{} | ||
} | ||
Comment on lines
+528
to
+530
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and again here |
||
appSettings["DOCKER_REGISTRY_SERVER_URL"] = winAppStack.DockerRegistryUrl | ||
appSettings["DOCKER_REGISTRY_SERVER_USERNAME"] = winAppStack.DockerRegistryUsername | ||
appSettings["DOCKER_REGISTRY_SERVER_PASSWORD"] = winAppStack.DockerRegistryPassword | ||
|
@@ -659,6 +662,9 @@ func (s *SiteConfigWindows) ExpandForUpdate(metadata sdk.ResourceMetaData, exist | |
|
||
if winAppStack.DockerImageName != "" { | ||
expanded.WindowsFxVersion = pointer.To(EncodeDockerFxStringWindows(winAppStack.DockerImageName, winAppStack.DockerRegistryUrl)) | ||
if appSettings == nil { | ||
appSettings = map[string]string{} | ||
} | ||
appSettings["DOCKER_REGISTRY_SERVER_URL"] = winAppStack.DockerRegistryUrl | ||
appSettings["DOCKER_REGISTRY_SERVER_USERNAME"] = winAppStack.DockerRegistryUsername | ||
appSettings["DOCKER_REGISTRY_SERVER_PASSWORD"] = winAppStack.DockerRegistryPassword | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -390,6 +390,22 @@ func (r LinuxWebAppResource) Create() sdk.ResourceFunc { | |
|
||
metadata.SetID(id) | ||
|
||
if siteConfigAppSetting := siteConfig.AppSettings; siteConfigAppSetting != nil && len(*siteConfigAppSetting) > 0 { | ||
if webApp.AppSettings == nil { | ||
webApp.AppSettings = make(map[string]string) | ||
} | ||
for _, pair := range *siteConfigAppSetting { | ||
if pair.Name == nil || pair.Value == nil { | ||
continue | ||
} | ||
if *pair.Name == "DOCKER_REGISTRY_SERVER_URL" || | ||
*pair.Name == "DOCKER_REGISTRY_SERVER_USERNAME" || | ||
*pair.Name == "DOCKER_REGISTRY_SERVER_PASSWORD" { | ||
webApp.AppSettings[*pair.Name] = *pair.Value | ||
} | ||
} | ||
} | ||
|
||
Comment on lines
+393
to
+408
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't be necessary with with the above bug fixes in the expands. |
||
appSettingsUpdate := helpers.ExpandAppSettingsForUpdate(webApp.AppSettings) | ||
if metadata.ResourceData.HasChange("site_config.0.health_check_eviction_time_in_min") { | ||
appSettingsUpdate.Properties["WEBSITE_HEALTHCHECK_MAXPINGFAILURES"] = pointer.To(strconv.Itoa(webApp.SiteConfig[0].HealthCheckEvictionTime)) | ||
|
@@ -804,7 +820,22 @@ func (r LinuxWebAppResource) Update() sdk.ResourceFunc { | |
} | ||
|
||
// (@jackofallops) - App Settings can clobber logs configuration so must be updated before we send any Log updates | ||
if metadata.ResourceData.HasChange("app_settings") || metadata.ResourceData.HasChange("site_config.0.health_check_eviction_time_in_min") { | ||
if metadata.ResourceData.HasChange("app_settings") || metadata.ResourceData.HasChange("site_config.0.health_check_eviction_time_in_min") || metadata.ResourceData.HasChanges("site_config.0.application_stack") { | ||
if siteConfigAppSetting := existing.SiteConfig.AppSettings; siteConfigAppSetting != nil && len(*siteConfigAppSetting) > 0 { | ||
if state.AppSettings == nil { | ||
state.AppSettings = make(map[string]string) | ||
} | ||
for _, pair := range *siteConfigAppSetting { | ||
if pair.Name == nil || pair.Value == nil { | ||
continue | ||
} | ||
if *pair.Name == "DOCKER_REGISTRY_SERVER_URL" || | ||
*pair.Name == "DOCKER_REGISTRY_SERVER_USERNAME" || | ||
*pair.Name == "DOCKER_REGISTRY_SERVER_PASSWORD" { | ||
state.AppSettings[*pair.Name] = *pair.Value | ||
} | ||
} | ||
} | ||
Comment on lines
+823
to
+838
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as above, the fixes to the expands should remove the need for this |
||
appSettingsUpdate := helpers.ExpandAppSettingsForUpdate(state.AppSettings) | ||
appSettingsUpdate.Properties["WEBSITE_HEALTHCHECK_MAXPINGFAILURES"] = pointer.To(strconv.Itoa(state.SiteConfig[0].HealthCheckEvictionTime)) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -369,6 +369,22 @@ func (r LinuxWebAppSlotResource) Create() sdk.ResourceFunc { | |
|
||
metadata.SetID(id) | ||
|
||
if siteConfigAppSetting := siteConfig.AppSettings; siteConfigAppSetting != nil && len(*siteConfigAppSetting) > 0 { | ||
if webAppSlot.AppSettings == nil { | ||
webAppSlot.AppSettings = make(map[string]string) | ||
} | ||
for _, pair := range *siteConfigAppSetting { | ||
if pair.Name == nil || pair.Value == nil { | ||
continue | ||
} | ||
if *pair.Name == "DOCKER_REGISTRY_SERVER_URL" || | ||
*pair.Name == "DOCKER_REGISTRY_SERVER_USERNAME" || | ||
*pair.Name == "DOCKER_REGISTRY_SERVER_PASSWORD" { | ||
webAppSlot.AppSettings[*pair.Name] = *pair.Value | ||
} | ||
} | ||
} | ||
|
||
Comment on lines
+372
to
+387
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. again here |
||
appSettings := helpers.ExpandAppSettingsForUpdate(webAppSlot.AppSettings) | ||
if metadata.ResourceData.HasChange("site_config.0.health_check_eviction_time_in_min") { | ||
appSettings.Properties["WEBSITE_HEALTHCHECK_MAXPINGFAILURES"] = pointer.To(strconv.Itoa(webAppSlot.SiteConfig[0].HealthCheckEvictionTime)) | ||
|
@@ -776,7 +792,22 @@ func (r LinuxWebAppSlotResource) Update() sdk.ResourceFunc { | |
} | ||
|
||
// (@jackofallops) - App Settings can clobber logs configuration so must be updated before we send any Log updates | ||
if metadata.ResourceData.HasChange("app_settings") || metadata.ResourceData.HasChange("site_config.0.health_check_eviction_time_in_min") { | ||
if metadata.ResourceData.HasChange("app_settings") || metadata.ResourceData.HasChange("site_config.0.health_check_eviction_time_in_min") || metadata.ResourceData.HasChanges("site_config.0.application_stack") { | ||
if siteConfigAppSetting := existing.SiteConfig.AppSettings; siteConfigAppSetting != nil && len(*siteConfigAppSetting) > 0 { | ||
if state.AppSettings == nil { | ||
state.AppSettings = make(map[string]string) | ||
} | ||
for _, pair := range *siteConfigAppSetting { | ||
if pair.Name == nil || pair.Value == nil { | ||
continue | ||
} | ||
if *pair.Name == "DOCKER_REGISTRY_SERVER_URL" || | ||
*pair.Name == "DOCKER_REGISTRY_SERVER_USERNAME" || | ||
*pair.Name == "DOCKER_REGISTRY_SERVER_PASSWORD" { | ||
state.AppSettings[*pair.Name] = *pair.Value | ||
} | ||
} | ||
} | ||
Comment on lines
+795
to
+810
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and here |
||
appSettingsUpdate := helpers.ExpandAppSettingsForUpdate(state.AppSettings) | ||
appSettingsUpdate.Properties["WEBSITE_HEALTHCHECK_MAXPINGFAILURES"] = pointer.To(strconv.Itoa(state.SiteConfig[0].HealthCheckEvictionTime)) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -406,6 +406,22 @@ func (r WindowsWebAppResource) Create() sdk.ResourceFunc { | |
} | ||
} | ||
|
||
if siteConfigAppSetting := siteConfig.AppSettings; siteConfigAppSetting != nil && len(*siteConfigAppSetting) > 0 { | ||
if webApp.AppSettings == nil { | ||
webApp.AppSettings = make(map[string]string) | ||
} | ||
for _, pair := range *siteConfigAppSetting { | ||
if pair.Name == nil || pair.Value == nil { | ||
continue | ||
} | ||
if *pair.Name == "DOCKER_REGISTRY_SERVER_URL" || | ||
*pair.Name == "DOCKER_REGISTRY_SERVER_USERNAME" || | ||
*pair.Name == "DOCKER_REGISTRY_SERVER_PASSWORD" { | ||
webApp.AppSettings[*pair.Name] = *pair.Value | ||
} | ||
} | ||
} | ||
|
||
Comment on lines
+409
to
+424
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and here |
||
appSettings := helpers.ExpandAppSettingsForUpdate(webApp.AppSettings) | ||
if metadata.ResourceData.HasChange("site_config.0.health_check_eviction_time_in_min") { | ||
appSettings.Properties["WEBSITE_HEALTHCHECK_MAXPINGFAILURES"] = pointer.To(strconv.Itoa(webApp.SiteConfig[0].HealthCheckEvictionTime)) | ||
|
@@ -852,7 +868,22 @@ func (r WindowsWebAppResource) Update() sdk.ResourceFunc { | |
} | ||
|
||
// (@jackofallops) - App Settings can clobber logs configuration so must be updated before we send any Log updates | ||
if metadata.ResourceData.HasChange("app_settings") || metadata.ResourceData.HasChange("site_config.0.health_check_eviction_time_in_min") { | ||
if metadata.ResourceData.HasChange("app_settings") || metadata.ResourceData.HasChange("site_config.0.health_check_eviction_time_in_min") || metadata.ResourceData.HasChanges("site_config.0.application_stack") { | ||
if siteConfigAppSetting := existing.SiteConfig.AppSettings; siteConfigAppSetting != nil && len(*siteConfigAppSetting) > 0 { | ||
if state.AppSettings == nil { | ||
state.AppSettings = make(map[string]string) | ||
} | ||
for _, pair := range *siteConfigAppSetting { | ||
if pair.Name == nil || pair.Value == nil { | ||
continue | ||
} | ||
if *pair.Name == "DOCKER_REGISTRY_SERVER_URL" || | ||
*pair.Name == "DOCKER_REGISTRY_SERVER_USERNAME" || | ||
*pair.Name == "DOCKER_REGISTRY_SERVER_PASSWORD" { | ||
state.AppSettings[*pair.Name] = *pair.Value | ||
} | ||
} | ||
} | ||
Comment on lines
+871
to
+886
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. again here |
||
appSettingsUpdate := helpers.ExpandAppSettingsForUpdate(state.AppSettings) | ||
appSettingsUpdate.Properties["WEBSITE_HEALTHCHECK_MAXPINGFAILURES"] = pointer.To(strconv.Itoa(state.SiteConfig[0].HealthCheckEvictionTime)) | ||
if _, err := client.UpdateApplicationSettings(ctx, id.ResourceGroup, id.SiteName, *appSettingsUpdate); err != nil { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -385,6 +385,22 @@ func (r WindowsWebAppSlotResource) Create() sdk.ResourceFunc { | |
} | ||
} | ||
|
||
if siteConfigAppSetting := siteConfig.AppSettings; siteConfigAppSetting != nil && len(*siteConfigAppSetting) > 0 { | ||
if webAppSlot.AppSettings == nil { | ||
webAppSlot.AppSettings = make(map[string]string) | ||
} | ||
for _, pair := range *siteConfigAppSetting { | ||
if pair.Name == nil || pair.Value == nil { | ||
continue | ||
} | ||
if *pair.Name == "DOCKER_REGISTRY_SERVER_URL" || | ||
*pair.Name == "DOCKER_REGISTRY_SERVER_USERNAME" || | ||
*pair.Name == "DOCKER_REGISTRY_SERVER_PASSWORD" { | ||
webAppSlot.AppSettings[*pair.Name] = *pair.Value | ||
} | ||
} | ||
} | ||
|
||
Comment on lines
+388
to
+403
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and again here |
||
appSettings := helpers.ExpandAppSettingsForUpdate(webAppSlot.AppSettings) | ||
if metadata.ResourceData.HasChange("site_config.0.health_check_eviction_time_in_min") { | ||
appSettings.Properties["WEBSITE_HEALTHCHECK_MAXPINGFAILURES"] = pointer.To(strconv.Itoa(webAppSlot.SiteConfig[0].HealthCheckEvictionTime)) | ||
|
@@ -815,10 +831,27 @@ func (r WindowsWebAppSlotResource) Update() sdk.ResourceFunc { | |
} | ||
|
||
// (@jackofallops) - App Settings can clobber logs configuration so must be updated before we send any Log updates | ||
if metadata.ResourceData.HasChange("app_settings") || metadata.ResourceData.HasChange("site_config.0.health_check_eviction_time_in_min") || metadata.ResourceData.HasChange("site_config.0.application_stack.0.node_version") { | ||
if metadata.ResourceData.HasChange("app_settings") || metadata.ResourceData.HasChange("site_config.0.health_check_eviction_time_in_min") || metadata.ResourceData.HasChange("site_config.0.application_stack") { | ||
if siteConfigAppSetting := existing.SiteConfig.AppSettings; siteConfigAppSetting != nil && len(*siteConfigAppSetting) > 0 { | ||
if state.AppSettings == nil { | ||
state.AppSettings = make(map[string]string) | ||
} | ||
for _, pair := range *siteConfigAppSetting { | ||
if pair.Name == nil || pair.Value == nil { | ||
continue | ||
} | ||
if *pair.Name == "DOCKER_REGISTRY_SERVER_URL" || | ||
*pair.Name == "DOCKER_REGISTRY_SERVER_USERNAME" || | ||
*pair.Name == "DOCKER_REGISTRY_SERVER_PASSWORD" { | ||
state.AppSettings[*pair.Name] = *pair.Value | ||
} | ||
} | ||
} | ||
Comment on lines
+834
to
+849
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and here |
||
appSettingsUpdate := helpers.ExpandAppSettingsForUpdate(state.AppSettings) | ||
appSettingsUpdate.Properties["WEBSITE_HEALTHCHECK_MAXPINGFAILURES"] = pointer.To(strconv.Itoa(state.SiteConfig[0].HealthCheckEvictionTime)) | ||
appSettingsUpdate.Properties["WEBSITE_NODE_DEFAULT_VERSION"] = pointer.To(state.SiteConfig[0].ApplicationStack[0].NodeVersion) | ||
if metadata.ResourceData.HasChange("site_config.0.application_stack.0.node_version") { | ||
appSettingsUpdate.Properties["WEBSITE_NODE_DEFAULT_VERSION"] = pointer.To(state.SiteConfig[0].ApplicationStack[0].NodeVersion) | ||
} | ||
if _, err := client.UpdateApplicationSettingsSlot(ctx, id.ResourceGroup, id.SiteName, *appSettingsUpdate, id.SlotName); err != nil { | ||
return fmt.Errorf("updating App Settings for Windows %s: %+v", id, err) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This avoids the crash, but unfortunately doesn't correctly address the bug of the values not being set, as the line
is missing from this function.