diff --git a/digitalocean/loadbalancer/datasource_loadbalancer.go b/digitalocean/loadbalancer/datasource_loadbalancer.go index e373416a7..89f90f0db 100644 --- a/digitalocean/loadbalancer/datasource_loadbalancer.go +++ b/digitalocean/loadbalancer/datasource_loadbalancer.go @@ -310,6 +310,19 @@ func DataSourceDigitalOceanLoadbalancer() *schema.Resource { Computed: true, Description: "target port rules", }, + "region_priorities": { + Type: schema.TypeMap, + Computed: true, + Description: "region priority map", + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "failover_threshold": { + Type: schema.TypeInt, + Computed: true, + Description: "fail-over threshold", + }, "cdn": { Type: schema.TypeList, Computed: true, diff --git a/digitalocean/loadbalancer/datasource_loadbalancer_test.go b/digitalocean/loadbalancer/datasource_loadbalancer_test.go index bc8f2f905..cdcb05192 100644 --- a/digitalocean/loadbalancer/datasource_loadbalancer_test.go +++ b/digitalocean/loadbalancer/datasource_loadbalancer_test.go @@ -650,6 +650,12 @@ data "digitalocean_loadbalancer" "foobar" { "data.digitalocean_loadbalancer.foobar", "glb_settings.0.target_port", "80"), resource.TestCheckResourceAttr( "data.digitalocean_loadbalancer.foobar", "glb_settings.0.cdn.0.is_enabled", "true"), + resource.TestCheckResourceAttr( + "data.digitalocean_loadbalancer.foobar", "glb_settings.0.region_priorities.%", "2"), + resource.TestCheckResourceAttr( + "data.digitalocean_loadbalancer.foobar", "glb_settings.0.region_priorities.nyc1", "1"), + resource.TestCheckResourceAttr( + "data.digitalocean_loadbalancer.foobar", "glb_settings.0.region_priorities.nyc2", "2"), resource.TestCheckResourceAttr( "data.digitalocean_loadbalancer.foobar", "domains.#", "2"), resource.TestCheckResourceAttr( @@ -798,6 +804,11 @@ resource "digitalocean_loadbalancer" "lorem" { cdn { is_enabled = true } + region_priorities = { + nyc1 = 1 + nyc2 = 2 + } + failover_threshold = 10 } domains { diff --git a/digitalocean/loadbalancer/loadbalancer.go b/digitalocean/loadbalancer/loadbalancer.go index 145f7ff18..c99e7eadd 100644 --- a/digitalocean/loadbalancer/loadbalancer.go +++ b/digitalocean/loadbalancer/loadbalancer.go @@ -300,6 +300,16 @@ func expandGLBSettings(config []interface{}) *godo.GLBSettings { } } + if v, ok := glbConfig["region_priorities"]; ok { + for region, priority := range v.(map[string]interface{}) { + if glbSettings.RegionPriorities == nil { + glbSettings.RegionPriorities = make(map[string]uint32) + } + glbSettings.RegionPriorities[region] = uint32(priority.(int)) + } + glbSettings.FailoverThreshold = uint32(glbConfig["failover_threshold"].(int)) + } + return glbSettings } @@ -351,6 +361,15 @@ func flattenGLBSettings(settings *godo.GLBSettings) []map[string]interface{} { } } + if len(settings.RegionPriorities) > 0 { + pMap := make(map[string]interface{}) + for region, priority := range settings.RegionPriorities { + pMap[region] = priority + } + r["region_priorities"] = pMap + r["failover_threshold"] = (*settings).FailoverThreshold + } + result = append(result, r) } diff --git a/digitalocean/loadbalancer/resource_loadbalancer.go b/digitalocean/loadbalancer/resource_loadbalancer.go index 091bce1e3..21165e70d 100644 --- a/digitalocean/loadbalancer/resource_loadbalancer.go +++ b/digitalocean/loadbalancer/resource_loadbalancer.go @@ -509,6 +509,20 @@ func resourceDigitalOceanLoadBalancerV0() *schema.Resource { ValidateFunc: validation.IntInSlice([]int{80, 443}), Description: "target port rules", }, + "region_priorities": { + Type: schema.TypeMap, + Optional: true, + Description: "region priority map", + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "failover_threshold": { + Type: schema.TypeInt, + Optional: true, + ValidateFunc: validation.IntBetween(1, 99), + Description: "fail-over threshold", + }, "cdn": { Type: schema.TypeList, Optional: true, diff --git a/digitalocean/loadbalancer/resource_loadbalancer_test.go b/digitalocean/loadbalancer/resource_loadbalancer_test.go index 0de9edc03..0f245b09f 100644 --- a/digitalocean/loadbalancer/resource_loadbalancer_test.go +++ b/digitalocean/loadbalancer/resource_loadbalancer_test.go @@ -882,6 +882,12 @@ func TestAccDigitalOceanGlobalLoadbalancer(t *testing.T) { "digitalocean_loadbalancer.lorem", "glb_settings.0.target_port", "80"), resource.TestCheckResourceAttr( "digitalocean_loadbalancer.lorem", "glb_settings.0.cdn.0.is_enabled", "false"), + resource.TestCheckResourceAttr( + "data.digitalocean_loadbalancer.foobar", "glb_settings.0.region_priorities.%", "2"), + resource.TestCheckResourceAttr( + "data.digitalocean_loadbalancer.foobar", "glb_settings.0.region_priorities.nyc1", "1"), + resource.TestCheckResourceAttr( + "data.digitalocean_loadbalancer.foobar", "glb_settings.0.region_priorities.nyc2", "2"), resource.TestCheckResourceAttr( "digitalocean_loadbalancer.lorem", "domains.#", "2"), resource.TestCheckResourceAttr( @@ -1435,6 +1441,11 @@ resource "digitalocean_loadbalancer" "lorem" { cdn { is_enabled = false } + region_priorities = { + nyc1 = 1 + nyc2 = 2 + } + failover_threshold = 10 } domains { diff --git a/go.mod b/go.mod index 36a62e779..5cc79abe7 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module github.com/digitalocean/terraform-provider-digitalocean require ( github.com/aws/aws-sdk-go v1.42.18 - github.com/digitalocean/godo v1.113.0 + github.com/digitalocean/godo v1.115.0 github.com/hashicorp/awspolicyequivalence v1.5.0 github.com/hashicorp/go-uuid v1.0.3 github.com/hashicorp/go-version v1.6.0 diff --git a/go.sum b/go.sum index 084e44c92..434593a7b 100644 --- a/go.sum +++ b/go.sum @@ -25,8 +25,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/digitalocean/godo v1.113.0 h1:CLtCxlP4wDAjKIQ+Hshht/UNbgAp8/J/XBH1ZtDCF9Y= -github.com/digitalocean/godo v1.113.0/go.mod h1:Z2mTP848Vi3IXXl5YbPekUgr4j4tOePomA+OE1Ag98w= +github.com/digitalocean/godo v1.115.0 h1:Xv0gwN0t7ldD61QKeYeHHwCEKfTXzAOmnUDgGAzoZw4= +github.com/digitalocean/godo v1.115.0/go.mod h1:Vk0vpCot2HOAJwc5WE8wljZGtJ3ZtWIc8MQ8rF38sdo= github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= diff --git a/vendor/github.com/digitalocean/godo/CHANGELOG.md b/vendor/github.com/digitalocean/godo/CHANGELOG.md index d1051832c..e1fb20fe7 100644 --- a/vendor/github.com/digitalocean/godo/CHANGELOG.md +++ b/vendor/github.com/digitalocean/godo/CHANGELOG.md @@ -1,5 +1,15 @@ # Change Log +## [v1.115.0] - 2024-05-08 + +- #688 - @asaha2 - load balancers: support glb active-passive fail-over settings, currently in closed beta + +## [v1.114.0] - 2024-04-12 + +- #686 - @greeshmapill - APPS-8386: Add comments to mark deprecation of unused instance size fields +- #685 - @jcodybaker - APPS-8711: container termination controls +- #682 - @dependabot[bot] - Bump golang.org/x/net from 0.17.0 to 0.23.0 + ## [v1.113.0] - 2024-04-12 - #679 - @bhardwajRahul - Enable ui_connection parameter for Opensearch diff --git a/vendor/github.com/digitalocean/godo/apps.gen.go b/vendor/github.com/digitalocean/godo/apps.gen.go index c037559d4..f734ab022 100644 --- a/vendor/github.com/digitalocean/godo/apps.gen.go +++ b/vendor/github.com/digitalocean/godo/apps.gen.go @@ -388,6 +388,7 @@ type AppJobSpec struct { Alerts []*AppAlertSpec `json:"alerts,omitempty"` // A list of configured log forwarding destinations. LogDestinations []*AppLogDestinationSpec `json:"log_destinations,omitempty"` + Termination *AppJobSpecTermination `json:"termination,omitempty"` } // AppJobSpecKind - UNSPECIFIED: Default job type, will auto-complete to POST_DEPLOY kind. - PRE_DEPLOY: Indicates a job that runs before an app deployment. - POST_DEPLOY: Indicates a job that runs after an app deployment. - FAILED_DEPLOY: Indicates a job that runs after a component fails to deploy. @@ -401,6 +402,12 @@ const ( AppJobSpecKind_FailedDeploy AppJobSpecKind = "FAILED_DEPLOY" ) +// AppJobSpecTermination struct for AppJobSpecTermination +type AppJobSpecTermination struct { + // The number of seconds to wait between sending a TERM signal to a container and issuing a KILL which causes immediate shutdown. Default: 120, Minimum 1, Maximum 600. + GracePeriodSeconds int32 `json:"grace_period_seconds,omitempty"` +} + // AppLogDestinationSpec struct for AppLogDestinationSpec type AppLogDestinationSpec struct { // Name of the log destination. @@ -484,22 +491,23 @@ type AppServiceSpec struct { // A list of configured alerts which apply to the component. Alerts []*AppAlertSpec `json:"alerts,omitempty"` // A list of configured log forwarding destinations. - LogDestinations []*AppLogDestinationSpec `json:"log_destinations,omitempty"` + LogDestinations []*AppLogDestinationSpec `json:"log_destinations,omitempty"` + Termination *AppServiceSpecTermination `json:"termination,omitempty"` } // AppServiceSpecHealthCheck struct for AppServiceSpecHealthCheck type AppServiceSpecHealthCheck struct { // Deprecated. Use http_path instead. Path string `json:"path,omitempty"` - // The number of seconds to wait before beginning health checks. Default: 0 seconds; start health checks as soon as the service starts. + // The number of seconds to wait before beginning health checks. Default: 0 seconds, Minimum 0, Maximum 3600. InitialDelaySeconds int32 `json:"initial_delay_seconds,omitempty"` - // The number of seconds to wait between health checks. Default: 10 seconds. + // The number of seconds to wait between health checks. Default: 10 seconds, Minimum 1, Maximum 300. PeriodSeconds int32 `json:"period_seconds,omitempty"` - // The number of seconds after which the check times out. Default: 1 second. + // The number of seconds after which the check times out. Default: 1 second, Minimum 1, Maximum 120. TimeoutSeconds int32 `json:"timeout_seconds,omitempty"` - // The number of successful health checks before considered healthy. Default: 1. + // The number of successful health checks before considered healthy. Default: 1, Minimum 1, Maximum 50. SuccessThreshold int32 `json:"success_threshold,omitempty"` - // The number of failed health checks before considered unhealthy. Default: 9. + // The number of failed health checks before considered unhealthy. Default: 9, Minimum 1, Maximum 50. FailureThreshold int32 `json:"failure_threshold,omitempty"` // The route path used for the HTTP health check ping. If not set, the HTTP health check will be disabled and a TCP health check used instead. HTTPPath string `json:"http_path,omitempty"` @@ -507,6 +515,14 @@ type AppServiceSpecHealthCheck struct { Port int64 `json:"port,omitempty"` } +// AppServiceSpecTermination struct for AppServiceSpecTermination +type AppServiceSpecTermination struct { + // The number of seconds to wait between selecting a container instance for termination and issuing the TERM signal. Selecting a container instance for termination begins an asynchronous drain of new requests on upstream load-balancers. Default: 15 seconds, Minimum 1, Maximum 110. + DrainSeconds int32 `json:"drain_seconds,omitempty"` + // The number of seconds to wait between sending a TERM signal to a container and issuing a KILL which causes immediate shutdown. Default: 120, Minimum 1, Maximum 600. + GracePeriodSeconds int32 `json:"grace_period_seconds,omitempty"` +} + // AppSpec The desired configuration of an application. type AppSpec struct { // The name of the app. Must be unique across all apps in the same account. @@ -601,7 +617,14 @@ type AppWorkerSpec struct { // A list of configured alerts which apply to the component. Alerts []*AppAlertSpec `json:"alerts,omitempty"` // A list of configured log forwarding destinations. - LogDestinations []*AppLogDestinationSpec `json:"log_destinations,omitempty"` + LogDestinations []*AppLogDestinationSpec `json:"log_destinations,omitempty"` + Termination *AppWorkerSpecTermination `json:"termination,omitempty"` +} + +// AppWorkerSpecTermination struct for AppWorkerSpecTermination +type AppWorkerSpecTermination struct { + // The number of seconds to wait between sending a TERM signal to a container and issuing a KILL which causes immediate shutdown. Default: 120, Minimum 1, Maximum 600. + GracePeriodSeconds int32 `json:"grace_period_seconds,omitempty"` } // Buildpack struct for Buildpack @@ -1109,16 +1132,18 @@ const ( // AppInstanceSize struct for AppInstanceSize type AppInstanceSize struct { - Name string `json:"name,omitempty"` - Slug string `json:"slug,omitempty"` - CPUType AppInstanceSizeCPUType `json:"cpu_type,omitempty"` - CPUs string `json:"cpus,omitempty"` - MemoryBytes string `json:"memory_bytes,omitempty"` - USDPerMonth string `json:"usd_per_month,omitempty"` - USDPerSecond string `json:"usd_per_second,omitempty"` - TierSlug string `json:"tier_slug,omitempty"` - TierUpgradeTo string `json:"tier_upgrade_to,omitempty"` - TierDowngradeTo string `json:"tier_downgrade_to,omitempty"` + Name string `json:"name,omitempty"` + Slug string `json:"slug,omitempty"` + CPUType AppInstanceSizeCPUType `json:"cpu_type,omitempty"` + CPUs string `json:"cpus,omitempty"` + MemoryBytes string `json:"memory_bytes,omitempty"` + USDPerMonth string `json:"usd_per_month,omitempty"` + USDPerSecond string `json:"usd_per_second,omitempty"` + TierSlug string `json:"tier_slug,omitempty"` + // (Deprecated) The slug of the corresponding upgradable instance size on the higher tier. + TierUpgradeTo string `json:"tier_upgrade_to,omitempty"` + // (Deprecated) The slug of the corresponding downgradable instance size on the lower tier. + TierDowngradeTo string `json:"tier_downgrade_to,omitempty"` // Indicates if the tier instance size can enable autoscaling. Scalable bool `json:"scalable,omitempty"` FeaturePreview bool `json:"feature_preview,omitempty"` @@ -1168,9 +1193,9 @@ type AppProposeResponse struct { Spec *AppSpec `json:"spec,omitempty"` // The monthly cost of the proposed app in USD. AppCost float32 `json:"app_cost,omitempty"` - // The monthly cost of the proposed app in USD using the next pricing plan tier. For example, if you propose an app that uses the Basic tier, the `app_tier_upgrade_cost` field displays the monthly cost of the app if it were to use the Professional tier. If the proposed app already uses the most expensive tier, the field is empty. + // (Deprecated) The monthly cost of the proposed app in USD using the next pricing plan tier. For example, if you propose an app that uses the Basic tier, the `app_tier_upgrade_cost` field displays the monthly cost of the app if it were to use the Professional tier. If the proposed app already uses the most expensive tier, the field is empty. AppTierUpgradeCost float32 `json:"app_tier_upgrade_cost,omitempty"` - // The monthly cost of the proposed app in USD using the previous pricing plan tier. For example, if you propose an app that uses the Professional tier, the `app_tier_downgrade_cost` field displays the monthly cost of the app if it were to use the Basic tier. If the proposed app already uses the lest expensive tier, the field is empty. + // (Deprecated) The monthly cost of the proposed app in USD using the previous pricing plan tier. For example, if you propose an app that uses the Professional tier, the `app_tier_downgrade_cost` field displays the monthly cost of the app if it were to use the Basic tier. If the proposed app already uses the lest expensive tier, the field is empty. AppTierDowngradeCost float32 `json:"app_tier_downgrade_cost,omitempty"` // The number of existing starter tier apps the account has. ExistingStarterApps string `json:"existing_starter_apps,omitempty"` diff --git a/vendor/github.com/digitalocean/godo/apps_accessors.go b/vendor/github.com/digitalocean/godo/apps_accessors.go index 0d655d84a..734c27ea9 100644 --- a/vendor/github.com/digitalocean/godo/apps_accessors.go +++ b/vendor/github.com/digitalocean/godo/apps_accessors.go @@ -1261,6 +1261,22 @@ func (a *AppJobSpec) GetSourceDir() string { return a.SourceDir } +// GetTermination returns the Termination field. +func (a *AppJobSpec) GetTermination() *AppJobSpecTermination { + if a == nil { + return nil + } + return a.Termination +} + +// GetGracePeriodSeconds returns the GracePeriodSeconds field. +func (a *AppJobSpecTermination) GetGracePeriodSeconds() int32 { + if a == nil { + return 0 + } + return a.GracePeriodSeconds +} + // GetDatadog returns the Datadog field. func (a *AppLogDestinationSpec) GetDatadog() *AppLogDestinationSpecDataDog { if a == nil { @@ -1725,6 +1741,14 @@ func (a *AppServiceSpec) GetSourceDir() string { return a.SourceDir } +// GetTermination returns the Termination field. +func (a *AppServiceSpec) GetTermination() *AppServiceSpecTermination { + if a == nil { + return nil + } + return a.Termination +} + // GetFailureThreshold returns the FailureThreshold field. func (a *AppServiceSpecHealthCheck) GetFailureThreshold() int32 { if a == nil { @@ -1789,6 +1813,22 @@ func (a *AppServiceSpecHealthCheck) GetTimeoutSeconds() int32 { return a.TimeoutSeconds } +// GetDrainSeconds returns the DrainSeconds field. +func (a *AppServiceSpecTermination) GetDrainSeconds() int32 { + if a == nil { + return 0 + } + return a.DrainSeconds +} + +// GetGracePeriodSeconds returns the GracePeriodSeconds field. +func (a *AppServiceSpecTermination) GetGracePeriodSeconds() int32 { + if a == nil { + return 0 + } + return a.GracePeriodSeconds +} + // GetAlerts returns the Alerts field. func (a *AppSpec) GetAlerts() []*AppAlertSpec { if a == nil { @@ -2237,6 +2277,22 @@ func (a *AppWorkerSpec) GetSourceDir() string { return a.SourceDir } +// GetTermination returns the Termination field. +func (a *AppWorkerSpec) GetTermination() *AppWorkerSpecTermination { + if a == nil { + return nil + } + return a.Termination +} + +// GetGracePeriodSeconds returns the GracePeriodSeconds field. +func (a *AppWorkerSpecTermination) GetGracePeriodSeconds() int32 { + if a == nil { + return 0 + } + return a.GracePeriodSeconds +} + // GetDescription returns the Description field. func (b *Buildpack) GetDescription() []string { if b == nil { diff --git a/vendor/github.com/digitalocean/godo/godo.go b/vendor/github.com/digitalocean/godo/godo.go index d71e71933..0713df51b 100644 --- a/vendor/github.com/digitalocean/godo/godo.go +++ b/vendor/github.com/digitalocean/godo/godo.go @@ -21,7 +21,7 @@ import ( ) const ( - libraryVersion = "1.113.0" + libraryVersion = "1.115.0" defaultBaseURL = "https://api.digitalocean.com/" userAgent = "godo/" + libraryVersion mediaType = "application/json" diff --git a/vendor/github.com/digitalocean/godo/load_balancers.go b/vendor/github.com/digitalocean/godo/load_balancers.go index a044adaeb..396790530 100644 --- a/vendor/github.com/digitalocean/godo/load_balancers.go +++ b/vendor/github.com/digitalocean/godo/load_balancers.go @@ -290,6 +290,10 @@ type GLBSettings struct { TargetPort uint32 `json:"target_port"` // CDNSettings is the CDN configurations CDN *CDNSettings `json:"cdn"` + // RegionPriorities embeds regional priority information for regional active-passive failover policy + RegionPriorities map[string]uint32 `json:"region_priorities,omitempty"` + // FailoverThreshold embeds failover threshold percentage for regional active-passive failover policy + FailoverThreshold uint32 `json:"failover_threshold,omitempty"` } // String creates a human-readable description of a GLBSettings @@ -299,8 +303,10 @@ func (s GLBSettings) String() string { func (s GLBSettings) deepCopy() *GLBSettings { settings := &GLBSettings{ - TargetProtocol: s.TargetProtocol, - TargetPort: s.TargetPort, + TargetProtocol: s.TargetProtocol, + TargetPort: s.TargetPort, + RegionPriorities: s.RegionPriorities, + FailoverThreshold: s.FailoverThreshold, } if s.CDN != nil { settings.CDN = &CDNSettings{IsEnabled: s.CDN.IsEnabled} diff --git a/vendor/modules.txt b/vendor/modules.txt index 63cb5847c..4c7d39dcd 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -58,7 +58,7 @@ github.com/aws/aws-sdk-go/service/sts/stsiface # github.com/davecgh/go-spew v1.1.1 ## explicit github.com/davecgh/go-spew/spew -# github.com/digitalocean/godo v1.113.0 +# github.com/digitalocean/godo v1.115.0 ## explicit; go 1.20 github.com/digitalocean/godo github.com/digitalocean/godo/metrics