From dab707b912c35b2d8987d63dbed81527d634e9b8 Mon Sep 17 00:00:00 2001 From: Gregory Mankes Date: Mon, 16 Oct 2023 10:23:26 -0400 Subject: [PATCH] update app godo spec (#645) deprecates app component routing/cors config, adds app autoscaling config, new app alerting rules --- apps.gen.go | 60 ++++++++++++++++++++++++------- apps_accessors.go | 81 +++++++++++++++++++++++++++++++++++++++++- apps_accessors_test.go | 63 ++++++++++++++++++++++++++++++++ 3 files changed, 190 insertions(+), 14 deletions(-) diff --git a/apps.gen.go b/apps.gen.go index a3c89fae..8b01dbb7 100644 --- a/apps.gen.go +++ b/apps.gen.go @@ -1,4 +1,5 @@ -// Code generated automatically. DO NOT EDIT. +// Code generated by golang.org/x/tools/cmd/bundle. DO NOT EDIT. +// $ bundle -pkg godo -prefix ./dev/dist/godo package godo @@ -68,7 +69,7 @@ const ( // AppAlertSlackWebhook Configuration of a Slack alerting destination. type AppAlertSlackWebhook struct { - // URL for the Slack webhook. The value will be encrypted on the app spec after it is submitted. + // URL for the Slack webhook. URL string `json:"url,omitempty"` // Name of the Slack channel. Channel string `json:"channel,omitempty"` @@ -120,7 +121,7 @@ const ( AppAlertSpecOperator_LessThan AppAlertSpecOperator = "LESS_THAN" ) -// AppAlertSpecRule - CPU_UTILIZATION: Represents CPU for a given container instance. Only applicable at the component level. - MEM_UTILIZATION: Represents RAM for a given container instance. Only applicable at the component level. - RESTART_COUNT: Represents restart count for a given container instance. Only applicable at the component level. - DEPLOYMENT_FAILED: Represents whether a deployment has failed. Only applicable at the app level. - DEPLOYMENT_LIVE: Represents whether a deployment has succeeded. Only applicable at the app level. - DOMAIN_FAILED: Represents whether a domain configuration has failed. Only applicable at the app level. - DOMAIN_LIVE: Represents whether a domain configuration has succeeded. Only applicable at the app level. - FUNCTIONS_ACTIVATION_COUNT: Represents an activation count for a given functions instance. Only applicable to functions components. - FUNCTIONS_AVERAGE_DURATION_MS: Represents the average duration for function runtimes. Only applicable to functions components. - FUNCTIONS_ERROR_RATE_PER_MINUTE: Represents an error rate per minute for a given functions instance. Only applicable to functions components. - FUNCTIONS_AVERAGE_WAIT_TIME_MS: Represents the average wait time for functions. Only applicable to functions components. - FUNCTIONS_ERROR_COUNT: Represents an error count for a given functions instance. Only applicable to functions components. - FUNCTIONS_GB_RATE_PER_SECOND: Represents the rate of memory consumption (GB x seconds) for functions. Only applicable to functions components. +// AppAlertSpecRule - CPU_UTILIZATION: Represents CPU for a given container instance. Only applicable at the component level. - MEM_UTILIZATION: Represents RAM for a given container instance. Only applicable at the component level. - RESTART_COUNT: Represents restart count for a given container instance. Only applicable at the component level. - DEPLOYMENT_FAILED: Represents whether a deployment has failed. Only applicable at the app level. - DEPLOYMENT_LIVE: Represents whether a deployment has succeeded. Only applicable at the app level. - DEPLOYMENT_STARTED: Represents whether a deployment has started. Only applicable at the app level. - DEPLOYMENT_CANCELED: Represents whether a deployment has been canceled. Only applicable at the app level. - DOMAIN_FAILED: Represents whether a domain configuration has failed. Only applicable at the app level. - DOMAIN_LIVE: Represents whether a domain configuration has succeeded. Only applicable at the app level. - FUNCTIONS_ACTIVATION_COUNT: Represents an activation count for a given functions instance. Only applicable to functions components. - FUNCTIONS_AVERAGE_DURATION_MS: Represents the average duration for function runtimes. Only applicable to functions components. - FUNCTIONS_ERROR_RATE_PER_MINUTE: Represents an error rate per minute for a given functions instance. Only applicable to functions components. - FUNCTIONS_AVERAGE_WAIT_TIME_MS: Represents the average wait time for functions. Only applicable to functions components. - FUNCTIONS_ERROR_COUNT: Represents an error count for a given functions instance. Only applicable to functions components. - FUNCTIONS_GB_RATE_PER_SECOND: Represents the rate of memory consumption (GB x seconds) for functions. Only applicable to functions components. type AppAlertSpecRule string // List of AppAlertSpecRule @@ -131,6 +132,8 @@ const ( AppAlertSpecRule_RestartCount AppAlertSpecRule = "RESTART_COUNT" AppAlertSpecRule_DeploymentFailed AppAlertSpecRule = "DEPLOYMENT_FAILED" AppAlertSpecRule_DeploymentLive AppAlertSpecRule = "DEPLOYMENT_LIVE" + AppAlertSpecRule_DeploymentStarted AppAlertSpecRule = "DEPLOYMENT_STARTED" + AppAlertSpecRule_DeploymentCanceled AppAlertSpecRule = "DEPLOYMENT_CANCELED" AppAlertSpecRule_DomainFailed AppAlertSpecRule = "DOMAIN_FAILED" AppAlertSpecRule_DomainLive AppAlertSpecRule = "DOMAIN_LIVE" AppAlertSpecRule_FunctionsActivationCount AppAlertSpecRule = "FUNCTIONS_ACTIVATION_COUNT" @@ -153,6 +156,26 @@ const ( AppAlertSpecWindow_OneHour AppAlertSpecWindow = "ONE_HOUR" ) +// AppAutoscalingSpec struct for AppAutoscalingSpec +type AppAutoscalingSpec struct { + // The minimum amount of instances for this component. + MinInstanceCount int64 `json:"min_instance_count,omitempty"` + // The maximum amount of instances for this component. + MaxInstanceCount int64 `json:"max_instance_count,omitempty"` + Metrics *AppAutoscalingSpecMetrics `json:"metrics,omitempty"` +} + +// AppAutoscalingSpecMetricCPU struct for AppAutoscalingSpecMetricCPU +type AppAutoscalingSpecMetricCPU struct { + // The average target CPU utilization for the component. + Percent int64 `json:"percent,omitempty"` +} + +// AppAutoscalingSpecMetrics struct for AppAutoscalingSpecMetrics +type AppAutoscalingSpecMetrics struct { + CPU *AppAutoscalingSpecMetricCPU `json:"cpu,omitempty"` +} + // AppBuildConfig struct for AppBuildConfig type AppBuildConfig struct { CNBVersioning *AppBuildConfigCNBVersioning `json:"cnb_versioning,omitempty"` @@ -232,7 +255,7 @@ type AppFunctionsSpec struct { SourceDir string `json:"source_dir,omitempty"` // A list of environment variables made available to the component. Envs []*AppVariableDefinition `json:"envs,omitempty"` - // A list of HTTP routes that should be routed to this component. + // (Deprecated) A list of HTTP routes that should be routed to this component. Routes []*AppRouteSpec `json:"routes,omitempty"` // A list of configured alerts the user has enabled. Alerts []*AppAlertSpec `json:"alerts,omitempty"` @@ -291,7 +314,7 @@ type AppIngressSpecRuleRoutingRedirect struct { Port int64 `json:"port,omitempty"` // The scheme to redirect to. Supported values are `http` or `https`. Default: `https`. Scheme string `json:"scheme,omitempty"` - // The redirect code to use. Defaults to `302`. Supported values are 300, 301, 302, 303, 304, 305, 307, 308. + // The redirect code to use. Defaults to `302`. Supported values are 300, 301, 302, 303, 304, 307, 308. RedirectCode int64 `json:"redirect_code,omitempty"` } @@ -384,9 +407,9 @@ type AppLogDestinationSpecPapertrail struct { // AppRouteSpec struct for AppRouteSpec type AppRouteSpec struct { - // An HTTP path prefix. Paths must start with / and must be unique across all components within an app. + // (Deprecated) An HTTP path prefix. Paths must start with / and must be unique across all components within an app. Path string `json:"path,omitempty"` - // An optional flag to preserve the path that is forwarded to the backend service. By default, the HTTP request path will be trimmed from the left when forwarded to the component. For example, a component with `path=/api` will have requests to `/api/list` trimmed to `/list`. If this value is `true`, the path will remain `/api/list`. Note: this is not applicable for Functions Components. + // (Deprecated) An optional flag to preserve the path that is forwarded to the backend service. By default, the HTTP request path will be trimmed from the left when forwarded to the component. For example, a component with `path=/api` will have requests to `/api/list` trimmed to `/list`. If this value is `true`, the path will remain `/api/list`. Note: this is not applicable for Functions Components. PreservePathPrefix bool `json:"preserve_path_prefix,omitempty"` } @@ -411,10 +434,12 @@ type AppServiceSpec struct { // A list of environment variables made available to the component. Envs []*AppVariableDefinition `json:"envs,omitempty"` InstanceSizeSlug string `json:"instance_size_slug,omitempty"` - InstanceCount int64 `json:"instance_count,omitempty"` + // The amount of instances that this component should be scaled to. + InstanceCount int64 `json:"instance_count,omitempty"` + Autoscaling *AppAutoscalingSpec `json:"autoscaling,omitempty"` // The internal port on which this service's run command will listen. Default: 8080 If there is not an environment variable with the name `PORT`, one will be automatically added with its value set to the value of this field. HTTPPort int64 `json:"http_port,omitempty"` - // A list of HTTP routes that should be routed to this component. + // (Deprecated) A list of HTTP routes that should be routed to this component. Routes []*AppRouteSpec `json:"routes,omitempty"` HealthCheck *AppServiceSpecHealthCheck `json:"health_check,omitempty"` CORS *AppCORSPolicy `json:"cors,omitempty"` @@ -495,7 +520,7 @@ type AppStaticSiteSpec struct { ErrorDocument string `json:"error_document,omitempty"` // A list of environment variables made available to the component. Envs []*AppVariableDefinition `json:"envs,omitempty"` - // A list of HTTP routes that should be routed to this component. + // (Deprecated) A list of HTTP routes that should be routed to this component. Routes []*AppRouteSpec `json:"routes,omitempty"` CORS *AppCORSPolicy `json:"cors,omitempty"` // The name of the document to use as the fallback for any requests to documents that are not found when serving this static site. Only 1 of `catchall_document` or `error_document` can be set. @@ -533,8 +558,9 @@ type AppWorkerSpec struct { // A list of environment variables made available to the component. Envs []*AppVariableDefinition `json:"envs,omitempty"` // The instance size to use for this component. - InstanceSizeSlug string `json:"instance_size_slug,omitempty"` - InstanceCount int64 `json:"instance_count,omitempty"` + InstanceSizeSlug string `json:"instance_size_slug,omitempty"` + InstanceCount int64 `json:"instance_count,omitempty"` + Autoscaling *AppAutoscalingSpec `json:"autoscaling,omitempty"` // A list of configured alerts which apply to the component. Alerts []*AppAlertSpec `json:"alerts,omitempty"` // A list of configured log forwarding destinations. @@ -559,6 +585,12 @@ type Buildpack struct { DocsLink string `json:"docs_link,omitempty"` } +// DeploymentCauseDetailsAutoscalerAction struct for DeploymentCauseDetailsAutoscalerAction +type DeploymentCauseDetailsAutoscalerAction struct { + // Marker for the deployment being autoscaled. Necessary because the generation tooling can't handle empty messages. + Autoscaled bool `json:"autoscaled,omitempty"` +} + // DeploymentCauseDetailsDigitalOceanUser struct for DeploymentCauseDetailsDigitalOceanUser type DeploymentCauseDetailsDigitalOceanUser struct { UUID string `json:"uuid,omitempty"` @@ -651,10 +683,11 @@ type DeploymentCauseDetails struct { GitPush *DeploymentCauseDetailsGitPush `json:"git_push,omitempty"` DOCRPush *DeploymentCauseDetailsDOCRPush `json:"docr_push,omitempty"` Internal bool `json:"internal,omitempty"` + Autoscaler *DeploymentCauseDetailsAutoscalerAction `json:"autoscaler,omitempty"` Type DeploymentCauseDetailsType `json:"type,omitempty"` } -// DeploymentCauseDetailsType - MANUAL: A deployment that was manually created - DEPLOY_ON_PUSH: A deployment that was automatically created by a Deploy on Push hook - MAINTENANCE: A deployment created for App Platform maintenance - MANUAL_ROLLBACK: A rollback deployment that was manually created - AUTO_ROLLBACK: An automatic rollback deployment created as a result of a previous deployment failing - UPDATE_DATABASE_TRUSTED_SOURCES: A deployment that was created due to an update in database trusted sources. +// DeploymentCauseDetailsType - MANUAL: A deployment that was manually created - DEPLOY_ON_PUSH: A deployment that was automatically created by a Deploy on Push hook - MAINTENANCE: A deployment created for App Platform maintenance - MANUAL_ROLLBACK: A rollback deployment that was manually created - AUTO_ROLLBACK: An automatic rollback deployment created as a result of a previous deployment failing - UPDATE_DATABASE_TRUSTED_SOURCES: A deployment that was created due to an update in database trusted sources. - AUTOSCALED: A deployment that was created due to an autoscaler update. type DeploymentCauseDetailsType string // List of DeploymentCauseDetailsType @@ -666,6 +699,7 @@ const ( DeploymentCauseDetailsType_ManualRollback DeploymentCauseDetailsType = "MANUAL_ROLLBACK" DeploymentCauseDetailsType_AutoRollback DeploymentCauseDetailsType = "AUTO_ROLLBACK" DeploymentCauseDetailsType_UpdateDatabaseTrustedSources DeploymentCauseDetailsType = "UPDATE_DATABASE_TRUSTED_SOURCES" + DeploymentCauseDetailsType_Autoscaled DeploymentCauseDetailsType = "AUTOSCALED" ) // DeploymentFunctions struct for DeploymentFunctions diff --git a/apps_accessors.go b/apps_accessors.go index 85a34638..486c7597 100644 --- a/apps_accessors.go +++ b/apps_accessors.go @@ -1,4 +1,11 @@ -// Code generated automatically. DO NOT EDIT. +// Copyright 2017 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Code generated by gen-accessors; DO NOT EDIT. +// Instead, please run "go generate ./..." as described here: +// https://github.com/google/go-github/blob/master/CONTRIBUTING.md#submitting-a-patch package godo @@ -350,6 +357,46 @@ func (a *AppAlertSpec) GetWindow() AppAlertSpecWindow { return a.Window } +// GetMaxInstanceCount returns the MaxInstanceCount field. +func (a *AppAutoscalingSpec) GetMaxInstanceCount() int64 { + if a == nil { + return 0 + } + return a.MaxInstanceCount +} + +// GetMetrics returns the Metrics field. +func (a *AppAutoscalingSpec) GetMetrics() *AppAutoscalingSpecMetrics { + if a == nil { + return nil + } + return a.Metrics +} + +// GetMinInstanceCount returns the MinInstanceCount field. +func (a *AppAutoscalingSpec) GetMinInstanceCount() int64 { + if a == nil { + return 0 + } + return a.MinInstanceCount +} + +// GetPercent returns the Percent field. +func (a *AppAutoscalingSpecMetricCPU) GetPercent() int64 { + if a == nil { + return 0 + } + return a.Percent +} + +// GetCPU returns the CPU field. +func (a *AppAutoscalingSpecMetrics) GetCPU() *AppAutoscalingSpecMetricCPU { + if a == nil { + return nil + } + return a.CPU +} + // GetCNBVersioning returns the CNBVersioning field. func (a *AppBuildConfig) GetCNBVersioning() *AppBuildConfigCNBVersioning { if a == nil { @@ -1438,6 +1485,14 @@ func (a *AppServiceSpec) GetAlerts() []*AppAlertSpec { return a.Alerts } +// GetAutoscaling returns the Autoscaling field. +func (a *AppServiceSpec) GetAutoscaling() *AppAutoscalingSpec { + if a == nil { + return nil + } + return a.Autoscaling +} + // GetBuildCommand returns the BuildCommand field. func (a *AppServiceSpec) GetBuildCommand() string { if a == nil { @@ -1974,6 +2029,14 @@ func (a *AppWorkerSpec) GetAlerts() []*AppAlertSpec { return a.Alerts } +// GetAutoscaling returns the Autoscaling field. +func (a *AppWorkerSpec) GetAutoscaling() *AppAutoscalingSpec { + if a == nil { + return nil + } + return a.Autoscaling +} + // GetBuildCommand returns the BuildCommand field. func (a *AppWorkerSpec) GetBuildCommand() string { if a == nil { @@ -2294,6 +2357,14 @@ func (d *Deployment) GetWorkers() []*DeploymentWorker { return d.Workers } +// GetAutoscaler returns the Autoscaler field. +func (d *DeploymentCauseDetails) GetAutoscaler() *DeploymentCauseDetailsAutoscalerAction { + if d == nil { + return nil + } + return d.Autoscaler +} + // GetDigitalOceanUserAction returns the DigitalOceanUserAction field. func (d *DeploymentCauseDetails) GetDigitalOceanUserAction() *DeploymentCauseDetailsDigitalOceanUserAction { if d == nil { @@ -2334,6 +2405,14 @@ func (d *DeploymentCauseDetails) GetType() DeploymentCauseDetailsType { return d.Type } +// GetAutoscaled returns the Autoscaled field. +func (d *DeploymentCauseDetailsAutoscalerAction) GetAutoscaled() bool { + if d == nil { + return false + } + return d.Autoscaled +} + // GetEmail returns the Email field. func (d *DeploymentCauseDetailsDigitalOceanUser) GetEmail() string { if d == nil { diff --git a/apps_accessors_test.go b/apps_accessors_test.go index ad21b5f3..5cfdb486 100644 --- a/apps_accessors_test.go +++ b/apps_accessors_test.go @@ -314,6 +314,41 @@ func TestAppAlertSpec_GetWindow(tt *testing.T) { a.GetWindow() } +func TestAppAutoscalingSpec_GetMaxInstanceCount(tt *testing.T) { + a := &AppAutoscalingSpec{} + a.GetMaxInstanceCount() + a = nil + a.GetMaxInstanceCount() +} + +func TestAppAutoscalingSpec_GetMetrics(tt *testing.T) { + a := &AppAutoscalingSpec{} + a.GetMetrics() + a = nil + a.GetMetrics() +} + +func TestAppAutoscalingSpec_GetMinInstanceCount(tt *testing.T) { + a := &AppAutoscalingSpec{} + a.GetMinInstanceCount() + a = nil + a.GetMinInstanceCount() +} + +func TestAppAutoscalingSpecMetricCPU_GetPercent(tt *testing.T) { + a := &AppAutoscalingSpecMetricCPU{} + a.GetPercent() + a = nil + a.GetPercent() +} + +func TestAppAutoscalingSpecMetrics_GetCPU(tt *testing.T) { + a := &AppAutoscalingSpecMetrics{} + a.GetCPU() + a = nil + a.GetCPU() +} + func TestAppBuildConfig_GetCNBVersioning(tt *testing.T) { a := &AppBuildConfig{} a.GetCNBVersioning() @@ -1266,6 +1301,13 @@ func TestAppServiceSpec_GetAlerts(tt *testing.T) { a.GetAlerts() } +func TestAppServiceSpec_GetAutoscaling(tt *testing.T) { + a := &AppServiceSpec{} + a.GetAutoscaling() + a = nil + a.GetAutoscaling() +} + func TestAppServiceSpec_GetBuildCommand(tt *testing.T) { a := &AppServiceSpec{} a.GetBuildCommand() @@ -1735,6 +1777,13 @@ func TestAppWorkerSpec_GetAlerts(tt *testing.T) { a.GetAlerts() } +func TestAppWorkerSpec_GetAutoscaling(tt *testing.T) { + a := &AppWorkerSpec{} + a.GetAutoscaling() + a = nil + a.GetAutoscaling() +} + func TestAppWorkerSpec_GetBuildCommand(tt *testing.T) { a := &AppWorkerSpec{} a.GetBuildCommand() @@ -2015,6 +2064,13 @@ func TestDeployment_GetWorkers(tt *testing.T) { d.GetWorkers() } +func TestDeploymentCauseDetails_GetAutoscaler(tt *testing.T) { + d := &DeploymentCauseDetails{} + d.GetAutoscaler() + d = nil + d.GetAutoscaler() +} + func TestDeploymentCauseDetails_GetDigitalOceanUserAction(tt *testing.T) { d := &DeploymentCauseDetails{} d.GetDigitalOceanUserAction() @@ -2050,6 +2106,13 @@ func TestDeploymentCauseDetails_GetType(tt *testing.T) { d.GetType() } +func TestDeploymentCauseDetailsAutoscalerAction_GetAutoscaled(tt *testing.T) { + d := &DeploymentCauseDetailsAutoscalerAction{} + d.GetAutoscaled() + d = nil + d.GetAutoscaled() +} + func TestDeploymentCauseDetailsDigitalOceanUser_GetEmail(tt *testing.T) { d := &DeploymentCauseDetailsDigitalOceanUser{} d.GetEmail()