From 93425e7089294237de9099f6a278d992d4d1cc0d Mon Sep 17 00:00:00 2001 From: danaelhe <42972711+danaelhe@users.noreply.github.com> Date: Tue, 8 Aug 2023 15:28:28 -0400 Subject: [PATCH 01/17] Draft: Configure Godo Retryable HTTP Client --- digitalocean/config/config.go | 23 +- examples/droplet/main.tf | 10 +- examples/kubernetes/main.tf | 35 +-- examples/kubernetes/outputs.tf | 12 +- go.mod | 4 +- go.sum | 4 + .../github.com/digitalocean/godo/CHANGELOG.md | 26 ++ vendor/github.com/digitalocean/godo/README.md | 2 +- .../github.com/digitalocean/godo/account.go | 1 + .../github.com/digitalocean/godo/apps.gen.go | 93 ++++++- vendor/github.com/digitalocean/godo/apps.go | 7 +- .../digitalocean/godo/apps_accessors.go | 256 ++++++++++++++++++ .../github.com/digitalocean/godo/databases.go | 60 ++-- vendor/github.com/digitalocean/godo/godo.go | 68 ++++- .../digitalocean/godo/load_balancers.go | 16 +- .../github.com/digitalocean/godo/registry.go | 21 ++ vendor/github.com/digitalocean/godo/tokens.go | 228 ---------------- .../hashicorp/go-retryablehttp/CHANGELOG.md | 9 + .../hashicorp/go-retryablehttp/CODEOWNERS | 1 + .../hashicorp/go-retryablehttp/LICENSE | 2 + .../hashicorp/go-retryablehttp/client.go | 16 +- .../go-retryablehttp/roundtripper.go | 3 + vendor/modules.txt | 4 +- 23 files changed, 583 insertions(+), 318 deletions(-) delete mode 100644 vendor/github.com/digitalocean/godo/tokens.go create mode 100644 vendor/github.com/hashicorp/go-retryablehttp/CHANGELOG.md create mode 100644 vendor/github.com/hashicorp/go-retryablehttp/CODEOWNERS diff --git a/digitalocean/config/config.go b/digitalocean/config/config.go index 688b62ec7..99187b5ff 100644 --- a/digitalocean/config/config.go +++ b/digitalocean/config/config.go @@ -8,13 +8,11 @@ import ( "net/http" "net/url" "strings" - "time" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/session" "github.com/digitalocean/godo" - "github.com/hashicorp/go-retryablehttp" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging" "golang.org/x/oauth2" ) @@ -76,25 +74,28 @@ func (c *Config) Client() (*CombinedConfig, error) { userAgent := fmt.Sprintf("Terraform/%s", c.TerraformVersion) var client *http.Client + var godoOpts []godo.ClientOpt + + client = oauth2.NewClient(context.Background(), tokenSrc) + client.Transport = logging.NewTransport("DigitalOcean", client.Transport) if c.HTTPRetryMax > 0 { - retryableClient := retryablehttp.NewClient() - retryableClient.RetryMax = c.HTTPRetryMax - retryableClient.RetryWaitMin = time.Duration(c.HTTPRetryWaitMin * float64(time.Second)) - retryableClient.RetryWaitMax = time.Duration(c.HTTPRetryWaitMax * float64(time.Second)) + retryConfig := godo.RetryConfig{ + RetryMax: 3, + RetryWaitMin: godo.PtrTo(c.HTTPRetryWaitMin), + RetryWaitMax: godo.PtrTo(c.HTTPRetryWaitMax), + } + + godoOpts = []godo.ClientOpt{godo.WithRetryAndBackoffs(retryConfig)} - client = retryableClient.StandardClient() client.Transport = &oauth2.Transport{ Base: client.Transport, Source: oauth2.ReuseTokenSource(nil, tokenSrc), } - } else { - client = oauth2.NewClient(context.Background(), tokenSrc) } - client.Transport = logging.NewTransport("DigitalOcean", client.Transport) + godoOpts = append(godoOpts, godo.SetUserAgent(userAgent)) - godoOpts := []godo.ClientOpt{godo.SetUserAgent(userAgent)} if c.RequestsPerSecond > 0.0 { godoOpts = append(godoOpts, godo.SetStaticRateLimit(c.RequestsPerSecond)) } diff --git a/examples/droplet/main.tf b/examples/droplet/main.tf index 9c070f826..f3cbac082 100644 --- a/examples/droplet/main.tf +++ b/examples/droplet/main.tf @@ -15,7 +15,7 @@ provider "digitalocean" { resource "digitalocean_droplet" "mywebserver" { # Obtain your ssh_key id number via your account. See Document https://developers.digitalocean.com/documentation/v2/#list-all-keys - ssh_keys = [digitalocean_ssh_key.example.fingerprint] + # ssh_keys = [digitalocean_ssh_key.example.fingerprint] image = var.ubuntu region = var.do_ams3 size = "s-1vcpu-1gb" @@ -34,10 +34,10 @@ resource "digitalocean_droplet" "mywebserver" { } } -resource "digitalocean_ssh_key" "example" { - name = "examplekey" - public_key = file(var.ssh_key_path) -} +# resource "digitalocean_ssh_key" "example" { +# name = "examplekey" +# public_key = file(var.ssh_key_path) +# } resource "digitalocean_domain" "mywebserver" { name = "www.mywebserver.com" diff --git a/examples/kubernetes/main.tf b/examples/kubernetes/main.tf index 31460c948..ed5931a2b 100644 --- a/examples/kubernetes/main.tf +++ b/examples/kubernetes/main.tf @@ -15,28 +15,17 @@ terraform { } } -resource "random_id" "cluster_name" { - byte_length = 5 +resource "digitalocean_database_cluster" "postgres-example" { + name = "example-postgres-cluster" + engine = "pg" + version = "13" + size = "db-s-1vcpu-1gb" + region = "nyc1" + node_count = 1 } -locals { - cluster_name = "tf-k8s-${random_id.cluster_name.hex}" -} - -module "doks-cluster" { - source = "./doks-cluster" - cluster_name = local.cluster_name - cluster_region = "nyc3" - cluster_version = var.cluster_version - - worker_size = var.worker_size - worker_count = var.worker_count -} - -module "kubernetes-config" { - source = "./kubernetes-config" - cluster_name = module.doks-cluster.cluster_name - cluster_id = module.doks-cluster.cluster_id - - write_kubeconfig = var.write_kubeconfig -} +resource "digitalocean_database_user" "user-example" { + cluster_id = digitalocean_database_cluster.postgres-example.id + name = "${count.index}-app" + count = 260 +} \ No newline at end of file diff --git a/examples/kubernetes/outputs.tf b/examples/kubernetes/outputs.tf index bdbcb1855..a53a79167 100644 --- a/examples/kubernetes/outputs.tf +++ b/examples/kubernetes/outputs.tf @@ -1,7 +1,7 @@ -output "cluster_name" { - value = module.doks-cluster.cluster_name -} +# output "cluster_name" { +# value = module.doks-cluster.cluster_name +# } -output "kubeconfig_path" { - value = var.write_kubeconfig ? abspath("${path.root}/kubeconfig") : "none" -} \ No newline at end of file +# output "kubeconfig_path" { +# value = var.write_kubeconfig ? abspath("${path.root}/kubeconfig") : "none" +# } \ No newline at end of file diff --git a/go.mod b/go.mod index 4078e3556..cca6a75f2 100644 --- a/go.mod +++ b/go.mod @@ -2,9 +2,9 @@ module github.com/digitalocean/terraform-provider-digitalocean require ( github.com/aws/aws-sdk-go v1.42.18 - github.com/digitalocean/godo v1.95.0 + github.com/digitalocean/godo v1.100.1-0.20230803192756-bc798b06c70f github.com/hashicorp/awspolicyequivalence v1.5.0 - github.com/hashicorp/go-retryablehttp v0.7.2 + github.com/hashicorp/go-retryablehttp v0.7.4 github.com/hashicorp/go-uuid v1.0.3 github.com/hashicorp/go-version v1.6.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1 diff --git a/go.sum b/go.sum index 511f749aa..ca134ae34 100644 --- a/go.sum +++ b/go.sum @@ -27,6 +27,8 @@ 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.95.0 h1:S48/byPKui7RHZc1wYEPfRvkcEvToADNb5I3guu95xg= github.com/digitalocean/godo v1.95.0/go.mod h1:NRpFznZFvhHjBoqZAaOD3khVzsJ3EibzKqFL4R60dmA= +github.com/digitalocean/godo v1.100.1-0.20230803192756-bc798b06c70f h1:Dx01wYQznKX/pHFVgPwIruCD+kEmqcPkrYfqhjZTdNw= +github.com/digitalocean/godo v1.100.1-0.20230803192756-bc798b06c70f/go.mod h1:SaUYccN7r+CO1QtsbXGypAsgobDrmSfVMJESEfXgoEg= 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= @@ -82,6 +84,8 @@ github.com/hashicorp/go-plugin v1.4.8 h1:CHGwpxYDOttQOY7HOWgETU9dyVjOXzniXDqJcYJ github.com/hashicorp/go-plugin v1.4.8/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s= github.com/hashicorp/go-retryablehttp v0.7.2 h1:AcYqCvkpalPnPF2pn0KamgwamS42TqUDDYFRKq/RAd0= github.com/hashicorp/go-retryablehttp v0.7.2/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8= +github.com/hashicorp/go-retryablehttp v0.7.4 h1:ZQgVdpTdAL7WpMIwLzCfbalOcSUdkDZnpUv3/+BxzFA= +github.com/hashicorp/go-retryablehttp v0.7.4/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= diff --git a/vendor/github.com/digitalocean/godo/CHANGELOG.md b/vendor/github.com/digitalocean/godo/CHANGELOG.md index 812828be7..fb90e99e1 100644 --- a/vendor/github.com/digitalocean/godo/CHANGELOG.md +++ b/vendor/github.com/digitalocean/godo/CHANGELOG.md @@ -1,5 +1,31 @@ # Change Log +## [v1.100.0] - 2023-07-20 + +- #618 - @asaha - load balancers: introduce new type field +- #620 - @andrewsomething - account: add name field. + +## [v1.99.0] - 2023-04-24 + +- #616 - @bentranter - Bump CI version for Go 1.20 +- #615 - @bentranter - Remove beta support for tokens API +- #604 - @dvigueras - Add support for "Validate a Container Registry Name" +- #613 - @ibilalkayy - updated the README file by showing up the build status icon + +## [v1.98.0] - 2023-03-09 + +- #608 - @anitgandhi - client: don't process body upon 204 response +- #607 - @gregmankes - add apps rewrites/redirects to app spec + +## [v1.97.0] - 2023-02-10 + +- #601 - @jcodybaker - APPS-6813: update app platform - pending_deployment + timing +- #602 - @jcodybaker - Use App Platform active deployment for GetLogs if not specified + +## [v1.96.0] - 2023-01-23 + +- #599 - @markpaulson - Adding PromoteReplicaToPrimary to client interface. + ## [v1.95.0] - 2023-01-23 - #595 - @dweinshenker - Add UpgradeMajorVersion to godo diff --git a/vendor/github.com/digitalocean/godo/README.md b/vendor/github.com/digitalocean/godo/README.md index 9a3ec2dad..4c9ee2d78 100644 --- a/vendor/github.com/digitalocean/godo/README.md +++ b/vendor/github.com/digitalocean/godo/README.md @@ -1,6 +1,6 @@ # Godo -[![Build Status](https://travis-ci.org/digitalocean/godo.svg)](https://travis-ci.org/digitalocean/godo) +[![GitHub Actions CI](https://github.com/digitalocean/godo/actions/workflows/ci.yml/badge.svg)](https://github.com/digitalocean/godo/actions/workflows/ci.yml) [![GoDoc](https://godoc.org/github.com/digitalocean/godo?status.svg)](https://godoc.org/github.com/digitalocean/godo) Godo is a Go client library for accessing the DigitalOcean V2 API. diff --git a/vendor/github.com/digitalocean/godo/account.go b/vendor/github.com/digitalocean/godo/account.go index 48582c9ee..7f619008e 100644 --- a/vendor/github.com/digitalocean/godo/account.go +++ b/vendor/github.com/digitalocean/godo/account.go @@ -27,6 +27,7 @@ type Account struct { ReservedIPLimit int `json:"reserved_ip_limit,omitempty"` VolumeLimit int `json:"volume_limit,omitempty"` Email string `json:"email,omitempty"` + Name string `json:"name,omitempty"` UUID string `json:"uuid,omitempty"` EmailVerified bool `json:"email_verified,omitempty"` Status string `json:"status,omitempty"` diff --git a/vendor/github.com/digitalocean/godo/apps.gen.go b/vendor/github.com/digitalocean/godo/apps.gen.go index 7761d9af5..8bb88858d 100644 --- a/vendor/github.com/digitalocean/godo/apps.gen.go +++ b/vendor/github.com/digitalocean/godo/apps.gen.go @@ -85,6 +85,7 @@ type App struct { UpdatedAt time.Time `json:"updated_at,omitempty"` ActiveDeployment *Deployment `json:"active_deployment,omitempty"` InProgressDeployment *Deployment `json:"in_progress_deployment,omitempty"` + PendingDeployment *Deployment `json:"pending_deployment,omitempty"` LastDeploymentCreatedAt time.Time `json:"last_deployment_created_at,omitempty"` LiveURL string `json:"live_url,omitempty"` Region *AppRegion `json:"region,omitempty"` @@ -94,7 +95,7 @@ type App struct { Domains []*AppDomain `json:"domains,omitempty"` PinnedDeployment *Deployment `json:"pinned_deployment,omitempty"` BuildConfig *AppBuildConfig `json:"build_config,omitempty"` - // The id of the project for the app. This will be empty if there is a lookup failure. + // The id of the project for the app. This will be empty if there is a fleet (project) lookup failure. ProjectID string `json:"project_id,omitempty"` } @@ -161,6 +162,8 @@ type AppBuildConfig struct { type AppBuildConfigCNBVersioning struct { // List of versioned buildpacks used for the application. Buildpacks are only versioned based on the major semver version, therefore exact versions will not be available at the app build config. Buildpacks []*Buildpack `json:"buildpacks,omitempty"` + // A version id that represents the underlying CNB stack. The version of the stack indicates what buildpacks are supported. + StackID string `json:"stack_id,omitempty"` } // AppDatabaseSpec struct for AppDatabaseSpec @@ -238,10 +241,12 @@ type AppFunctionsSpec struct { CORS *AppCORSPolicy `json:"cors,omitempty"` } -// AppIngressSpec struct for AppIngressSpec +// AppIngressSpec Specification for app ingress configurations. type AppIngressSpec struct { LoadBalancer AppIngressSpecLoadBalancer `json:"load_balancer,omitempty"` LoadBalancerSize int64 `json:"load_balancer_size,omitempty"` + // Rules for configuring HTTP ingress for component routes, CORS, rewrites, and redirects. + Rules []*AppIngressSpecRule `json:"rules,omitempty"` } // AppIngressSpecLoadBalancer the model 'AppIngressSpecLoadBalancer' @@ -253,6 +258,49 @@ const ( AppIngressSpecLoadBalancer_DigitalOcean AppIngressSpecLoadBalancer = "DIGITALOCEAN" ) +// AppIngressSpecRule A rule that configures component routes, rewrites, redirects and cors. +type AppIngressSpecRule struct { + Match *AppIngressSpecRuleMatch `json:"match,omitempty"` + Component *AppIngressSpecRuleRoutingComponent `json:"component,omitempty"` + Redirect *AppIngressSpecRuleRoutingRedirect `json:"redirect,omitempty"` + CORS *AppCORSPolicy `json:"cors,omitempty"` +} + +// AppIngressSpecRuleMatch The match configuration for a rule. +type AppIngressSpecRuleMatch struct { + Path *AppIngressSpecRuleStringMatch `json:"path,omitempty"` +} + +// AppIngressSpecRuleRoutingComponent The component routing configuration. +type AppIngressSpecRuleRoutingComponent struct { + // The name of the component to route to. + Name string `json:"name,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 and is mutually exclusive with `rewrite`. + PreservePathPrefix bool `json:"preserve_path_prefix,omitempty"` + // An optional field that will rewrite the path of the component to be what is specified here. 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 you specified the rewrite to be `/v1/`, requests to `/api/list` would be rewritten to `/v1/list`. Note: this is mutually exclusive with `preserve_path_prefix`. + Rewrite string `json:"rewrite,omitempty"` +} + +// AppIngressSpecRuleRoutingRedirect The redirect routing configuration. +type AppIngressSpecRuleRoutingRedirect struct { + // An optional URI path to redirect to. Note: if this is specified the whole URI of the original request will be overwritten to this value, irrespective of the original request URI being matched. + Uri string `json:"uri,omitempty"` + // The authority/host to redirect to. This can be a hostname or IP address. Note: use `port` to set the port. + Authority string `json:"authority,omitempty"` + // The port to redirect to. + 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. + RedirectCode int64 `json:"redirect_code,omitempty"` +} + +// AppIngressSpecRuleStringMatch The string match configuration. +type AppIngressSpecRuleStringMatch struct { + // Prefix-based match. For example, `/api` will match `/api`, `/api/`, and any nested paths such as `/api/v1/endpoint`. + Prefix string `json:"prefix,omitempty"` +} + // AppJobSpec struct for AppJobSpec type AppJobSpec struct { // The name. Must be unique across all components within the same app. @@ -594,6 +642,7 @@ type Deployment struct { PreviousDeploymentID string `json:"previous_deployment_id,omitempty"` CauseDetails *DeploymentCauseDetails `json:"cause_details,omitempty"` LoadBalancerID string `json:"load_balancer_id,omitempty"` + Timing *DeploymentTiming `json:"timing,omitempty"` } // DeploymentCauseDetails struct for DeploymentCauseDetails @@ -710,6 +759,30 @@ type DeploymentStaticSite struct { Buildpacks []*Buildpack `json:"buildpacks,omitempty"` } +// DeploymentTiming struct for DeploymentTiming +type DeploymentTiming struct { + // Pending describes the time spent waiting for the build to begin. This may include delays related to build concurrency limits. + Pending string `json:"pending,omitempty"` + // BuildTotal describes total time between the start of the build and its completion. + BuildTotal string `json:"build_total,omitempty"` + // BuildBillable describes the time spent executing the build. As builds may run concurrently this may be greater than the build total. + BuildBillable string `json:"build_billable,omitempty"` + // Components breaks down billable build time by component. + Components []*DeploymentTimingComponent `json:"components,omitempty"` + // DatabaseProvision describes the time spent creating databases. + DatabaseProvision string `json:"database_provision,omitempty"` + // Deploying is time spent starting containers and waiting for health checks to pass. + Deploying string `json:"deploying,omitempty"` +} + +// DeploymentTimingComponent struct for DeploymentTimingComponent +type DeploymentTimingComponent struct { + // Name of the component. + Name string `json:"name,omitempty"` + // BuildBillable is the billable build time for this component. + BuildBillable string `json:"build_billable,omitempty"` +} + // DeploymentWorker struct for DeploymentWorker type DeploymentWorker struct { Name string `json:"name,omitempty"` @@ -947,6 +1020,12 @@ const ( AppInstanceSizeCPUType_Dedicated AppInstanceSizeCPUType = "DEDICATED" ) +// ListBuildpacksResponse struct for ListBuildpacksResponse +type ListBuildpacksResponse struct { + // List of the available buildpacks on App Platform. + Buildpacks []*Buildpack `json:"buildpacks,omitempty"` +} + // AppProposeRequest struct for AppProposeRequest type AppProposeRequest struct { Spec *AppSpec `json:"spec"` @@ -956,22 +1035,22 @@ type AppProposeRequest struct { // AppProposeResponse struct for AppProposeResponse type AppProposeResponse struct { - // Deprecated. Please use AppIsStarter instead. + // Deprecated. Please use app_is_starter instead. AppIsStatic bool `json:"app_is_static,omitempty"` // Indicates whether the app name is available. AppNameAvailable bool `json:"app_name_available,omitempty"` // If the app name is unavailable, this will be set to a suggested available name. AppNameSuggestion string `json:"app_name_suggestion,omitempty"` - // Deprecated. Please use ExistingStarterApps instead. + // Deprecated. Please use existing_starter_apps instead. ExistingStaticApps string `json:"existing_static_apps,omitempty"` - // Deprecated. Please use MaxFreeStarterApps instead. + // Deprecated. Please use max_free_starter_apps instead. MaxFreeStaticApps string `json:"max_free_static_apps,omitempty"` 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 `AppTierUpgradeCost` 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. + // 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 `AppTierDowngradeCost` 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. + // 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.go b/vendor/github.com/digitalocean/godo/apps.go index f19ea1e5a..422b48acc 100644 --- a/vendor/github.com/digitalocean/godo/apps.go +++ b/vendor/github.com/digitalocean/godo/apps.go @@ -323,7 +323,12 @@ func (s *AppsServiceOp) CreateDeployment(ctx context.Context, appID string, crea // GetLogs retrieves app logs. func (s *AppsServiceOp) GetLogs(ctx context.Context, appID, deploymentID, component string, logType AppLogType, follow bool, tailLines int) (*AppLogs, *Response, error) { - url := fmt.Sprintf("%s/%s/deployments/%s/logs?type=%s&follow=%t&tail_lines=%d", appsBasePath, appID, deploymentID, logType, follow, tailLines) + var url string + if deploymentID == "" { + url = fmt.Sprintf("%s/%s/logs?type=%s&follow=%t&tail_lines=%d", appsBasePath, appID, logType, follow, tailLines) + } else { + url = fmt.Sprintf("%s/%s/deployments/%s/logs?type=%s&follow=%t&tail_lines=%d", appsBasePath, appID, deploymentID, logType, follow, tailLines) + } if component != "" { url = fmt.Sprintf("%s&component_name=%s", url, component) } diff --git a/vendor/github.com/digitalocean/godo/apps_accessors.go b/vendor/github.com/digitalocean/godo/apps_accessors.go index 6af35b2c1..82bba4347 100644 --- a/vendor/github.com/digitalocean/godo/apps_accessors.go +++ b/vendor/github.com/digitalocean/godo/apps_accessors.go @@ -110,6 +110,14 @@ func (a *App) GetOwnerUUID() string { return a.OwnerUUID } +// GetPendingDeployment returns the PendingDeployment field. +func (a *App) GetPendingDeployment() *Deployment { + if a == nil { + return nil + } + return a.PendingDeployment +} + // GetPinnedDeployment returns the PinnedDeployment field. func (a *App) GetPinnedDeployment() *Deployment { if a == nil { @@ -358,6 +366,14 @@ func (a *AppBuildConfigCNBVersioning) GetBuildpacks() []*Buildpack { return a.Buildpacks } +// GetStackID returns the StackID field. +func (a *AppBuildConfigCNBVersioning) GetStackID() string { + if a == nil { + return "" + } + return a.StackID +} + // GetAllowCredentials returns the AllowCredentials field. func (a *AppCORSPolicy) GetAllowCredentials() bool { if a == nil { @@ -790,6 +806,126 @@ func (a *AppIngressSpec) GetLoadBalancerSize() int64 { return a.LoadBalancerSize } +// GetRules returns the Rules field. +func (a *AppIngressSpec) GetRules() []*AppIngressSpecRule { + if a == nil { + return nil + } + return a.Rules +} + +// GetComponent returns the Component field. +func (a *AppIngressSpecRule) GetComponent() *AppIngressSpecRuleRoutingComponent { + if a == nil { + return nil + } + return a.Component +} + +// GetCORS returns the CORS field. +func (a *AppIngressSpecRule) GetCORS() *AppCORSPolicy { + if a == nil { + return nil + } + return a.CORS +} + +// GetMatch returns the Match field. +func (a *AppIngressSpecRule) GetMatch() *AppIngressSpecRuleMatch { + if a == nil { + return nil + } + return a.Match +} + +// GetRedirect returns the Redirect field. +func (a *AppIngressSpecRule) GetRedirect() *AppIngressSpecRuleRoutingRedirect { + if a == nil { + return nil + } + return a.Redirect +} + +// GetPath returns the Path field. +func (a *AppIngressSpecRuleMatch) GetPath() *AppIngressSpecRuleStringMatch { + if a == nil { + return nil + } + return a.Path +} + +// GetName returns the Name field. +func (a *AppIngressSpecRuleRoutingComponent) GetName() string { + if a == nil { + return "" + } + return a.Name +} + +// GetPreservePathPrefix returns the PreservePathPrefix field. +func (a *AppIngressSpecRuleRoutingComponent) GetPreservePathPrefix() bool { + if a == nil { + return false + } + return a.PreservePathPrefix +} + +// GetRewrite returns the Rewrite field. +func (a *AppIngressSpecRuleRoutingComponent) GetRewrite() string { + if a == nil { + return "" + } + return a.Rewrite +} + +// GetAuthority returns the Authority field. +func (a *AppIngressSpecRuleRoutingRedirect) GetAuthority() string { + if a == nil { + return "" + } + return a.Authority +} + +// GetPort returns the Port field. +func (a *AppIngressSpecRuleRoutingRedirect) GetPort() int64 { + if a == nil { + return 0 + } + return a.Port +} + +// GetRedirectCode returns the RedirectCode field. +func (a *AppIngressSpecRuleRoutingRedirect) GetRedirectCode() int64 { + if a == nil { + return 0 + } + return a.RedirectCode +} + +// GetScheme returns the Scheme field. +func (a *AppIngressSpecRuleRoutingRedirect) GetScheme() string { + if a == nil { + return "" + } + return a.Scheme +} + +// GetUri returns the Uri field. +func (a *AppIngressSpecRuleRoutingRedirect) GetUri() string { + if a == nil { + return "" + } + return a.Uri +} + +// GetPrefix returns the Prefix field. +func (a *AppIngressSpecRuleStringMatch) GetPrefix() string { + if a == nil { + return "" + } + return a.Prefix +} + // GetCPUs returns the CPUs field. func (a *AppInstanceSize) GetCPUs() string { if a == nil { @@ -894,6 +1030,14 @@ func (a *AppJobSpec) GetDockerfilePath() string { return a.DockerfilePath } +// GetEnvironmentSlug returns the EnvironmentSlug field. +func (a *AppJobSpec) GetEnvironmentSlug() string { + if a == nil { + return "" + } + return a.EnvironmentSlug +} + // GetEnvs returns the Envs field. func (a *AppJobSpec) GetEnvs() []*AppVariableDefinition { if a == nil { @@ -1318,6 +1462,14 @@ func (a *AppServiceSpec) GetDockerfilePath() string { return a.DockerfilePath } +// GetEnvironmentSlug returns the EnvironmentSlug field. +func (a *AppServiceSpec) GetEnvironmentSlug() string { + if a == nil { + return "" + } + return a.EnvironmentSlug +} + // GetEnvs returns the Envs field. func (a *AppServiceSpec) GetEnvs() []*AppVariableDefinition { if a == nil { @@ -1638,6 +1790,14 @@ func (a *AppStaticSiteSpec) GetDockerfilePath() string { return a.DockerfilePath } +// GetEnvironmentSlug returns the EnvironmentSlug field. +func (a *AppStaticSiteSpec) GetEnvironmentSlug() string { + if a == nil { + return "" + } + return a.EnvironmentSlug +} + // GetEnvs returns the Envs field. func (a *AppStaticSiteSpec) GetEnvs() []*AppVariableDefinition { if a == nil { @@ -1830,6 +1990,14 @@ func (a *AppWorkerSpec) GetDockerfilePath() string { return a.DockerfilePath } +// GetEnvironmentSlug returns the EnvironmentSlug field. +func (a *AppWorkerSpec) GetEnvironmentSlug() string { + if a == nil { + return "" + } + return a.EnvironmentSlug +} + // GetEnvs returns the Envs field. func (a *AppWorkerSpec) GetEnvs() []*AppVariableDefinition { if a == nil { @@ -2102,6 +2270,14 @@ func (d *Deployment) GetTierSlug() string { return d.TierSlug } +// GetTiming returns the Timing field. +func (d *Deployment) GetTiming() *DeploymentTiming { + if d == nil { + return nil + } + return d.Timing +} + // GetUpdatedAt returns the UpdatedAt field. func (d *Deployment) GetUpdatedAt() time.Time { if d == nil { @@ -2510,6 +2686,70 @@ func (d *DeploymentStaticSite) GetSourceCommitHash() string { return d.SourceCommitHash } +// GetBuildBillable returns the BuildBillable field. +func (d *DeploymentTiming) GetBuildBillable() string { + if d == nil { + return "" + } + return d.BuildBillable +} + +// GetBuildTotal returns the BuildTotal field. +func (d *DeploymentTiming) GetBuildTotal() string { + if d == nil { + return "" + } + return d.BuildTotal +} + +// GetComponents returns the Components field. +func (d *DeploymentTiming) GetComponents() []*DeploymentTimingComponent { + if d == nil { + return nil + } + return d.Components +} + +// GetDatabaseProvision returns the DatabaseProvision field. +func (d *DeploymentTiming) GetDatabaseProvision() string { + if d == nil { + return "" + } + return d.DatabaseProvision +} + +// GetDeploying returns the Deploying field. +func (d *DeploymentTiming) GetDeploying() string { + if d == nil { + return "" + } + return d.Deploying +} + +// GetPending returns the Pending field. +func (d *DeploymentTiming) GetPending() string { + if d == nil { + return "" + } + return d.Pending +} + +// GetBuildBillable returns the BuildBillable field. +func (d *DeploymentTimingComponent) GetBuildBillable() string { + if d == nil { + return "" + } + return d.BuildBillable +} + +// GetName returns the Name field. +func (d *DeploymentTimingComponent) GetName() string { + if d == nil { + return "" + } + return d.Name +} + // GetBuildpacks returns the Buildpacks field. func (d *DeploymentWorker) GetBuildpacks() []*Buildpack { if d == nil { @@ -2646,6 +2886,14 @@ func (d *DetectResponseComponent) GetDockerfiles() []string { return d.Dockerfiles } +// GetEnvironmentSlug returns the EnvironmentSlug field. +func (d *DetectResponseComponent) GetEnvironmentSlug() string { + if d == nil { + return "" + } + return d.EnvironmentSlug +} + // GetEnvVars returns the EnvVars field. func (d *DetectResponseComponent) GetEnvVars() []*AppVariableDefinition { if d == nil { @@ -2886,6 +3134,14 @@ func (i *ImageSourceSpecDeployOnPush) GetEnabled() bool { return i.Enabled } +// GetBuildpacks returns the Buildpacks field. +func (l *ListBuildpacksResponse) GetBuildpacks() []*Buildpack { + if l == nil { + return nil + } + return l.Buildpacks +} + // GetAffectedComponents returns the AffectedComponents field. func (u *UpgradeBuildpackResponse) GetAffectedComponents() []string { if u == nil { diff --git a/vendor/github.com/digitalocean/godo/databases.go b/vendor/github.com/digitalocean/godo/databases.go index c70e96561..a0240735e 100644 --- a/vendor/github.com/digitalocean/godo/databases.go +++ b/vendor/github.com/digitalocean/godo/databases.go @@ -9,28 +9,29 @@ import ( ) const ( - databaseBasePath = "/v2/databases" - databaseSinglePath = databaseBasePath + "/%s" - databaseCAPath = databaseBasePath + "/%s/ca" - databaseConfigPath = databaseBasePath + "/%s/config" - databaseResizePath = databaseBasePath + "/%s/resize" - databaseMigratePath = databaseBasePath + "/%s/migrate" - databaseMaintenancePath = databaseBasePath + "/%s/maintenance" - databaseBackupsPath = databaseBasePath + "/%s/backups" - databaseUsersPath = databaseBasePath + "/%s/users" - databaseUserPath = databaseBasePath + "/%s/users/%s" - databaseResetUserAuthPath = databaseUserPath + "/reset_auth" - databaseDBPath = databaseBasePath + "/%s/dbs/%s" - databaseDBsPath = databaseBasePath + "/%s/dbs" - databasePoolPath = databaseBasePath + "/%s/pools/%s" - databasePoolsPath = databaseBasePath + "/%s/pools" - databaseReplicaPath = databaseBasePath + "/%s/replicas/%s" - databaseReplicasPath = databaseBasePath + "/%s/replicas" - databaseEvictionPolicyPath = databaseBasePath + "/%s/eviction_policy" - databaseSQLModePath = databaseBasePath + "/%s/sql_mode" - databaseFirewallRulesPath = databaseBasePath + "/%s/firewall" - databaseOptionsPath = databaseBasePath + "/options" - databaseUpgradeMajorVersionPath = databaseBasePath + "/%s/upgrade" + databaseBasePath = "/v2/databases" + databaseSinglePath = databaseBasePath + "/%s" + databaseCAPath = databaseBasePath + "/%s/ca" + databaseConfigPath = databaseBasePath + "/%s/config" + databaseResizePath = databaseBasePath + "/%s/resize" + databaseMigratePath = databaseBasePath + "/%s/migrate" + databaseMaintenancePath = databaseBasePath + "/%s/maintenance" + databaseBackupsPath = databaseBasePath + "/%s/backups" + databaseUsersPath = databaseBasePath + "/%s/users" + databaseUserPath = databaseBasePath + "/%s/users/%s" + databaseResetUserAuthPath = databaseUserPath + "/reset_auth" + databaseDBPath = databaseBasePath + "/%s/dbs/%s" + databaseDBsPath = databaseBasePath + "/%s/dbs" + databasePoolPath = databaseBasePath + "/%s/pools/%s" + databasePoolsPath = databaseBasePath + "/%s/pools" + databaseReplicaPath = databaseBasePath + "/%s/replicas/%s" + databaseReplicasPath = databaseBasePath + "/%s/replicas" + databaseEvictionPolicyPath = databaseBasePath + "/%s/eviction_policy" + databaseSQLModePath = databaseBasePath + "/%s/sql_mode" + databaseFirewallRulesPath = databaseBasePath + "/%s/firewall" + databaseOptionsPath = databaseBasePath + "/options" + databaseUpgradeMajorVersionPath = databaseBasePath + "/%s/upgrade" + databasePromoteReplicaToPrimaryPath = databaseReplicaPath + "/promote" ) // SQL Mode constants allow for MySQL-specific SQL flavor configuration. @@ -130,6 +131,7 @@ type DatabasesService interface { ListReplicas(context.Context, string, *ListOptions) ([]DatabaseReplica, *Response, error) CreateReplica(context.Context, string, *DatabaseCreateReplicaRequest) (*DatabaseReplica, *Response, error) DeleteReplica(context.Context, string, string) (*Response, error) + PromoteReplicaToPrimary(context.Context, string, string) (*Response, error) GetEvictionPolicy(context.Context, string) (string, *Response, error) SetEvictionPolicy(context.Context, string, string) (*Response, error) GetSQLMode(context.Context, string) (string, *Response, error) @@ -1013,6 +1015,20 @@ func (svc *DatabasesServiceOp) DeleteReplica(ctx context.Context, databaseID, na return resp, nil } +// PromoteReplicaToPrimary will sever the read replica integration and then promote the replica cluster to be a R/W cluster +func (svc *DatabasesServiceOp) PromoteReplicaToPrimary(ctx context.Context, databaseID, name string) (*Response, error) { + path := fmt.Sprintf(databasePromoteReplicaToPrimaryPath, databaseID, name) + req, err := svc.client.NewRequest(ctx, http.MethodPut, path, nil) + if err != nil { + return nil, err + } + resp, err := svc.client.Do(ctx, req, nil) + if err != nil { + return resp, err + } + return resp, nil +} + // GetEvictionPolicy loads the eviction policy for a given Redis cluster. func (svc *DatabasesServiceOp) GetEvictionPolicy(ctx context.Context, databaseID string) (string, *Response, error) { path := fmt.Sprintf(databaseEvictionPolicyPath, databaseID) diff --git a/vendor/github.com/digitalocean/godo/godo.go b/vendor/github.com/digitalocean/godo/godo.go index b226c220a..04cc42bfe 100644 --- a/vendor/github.com/digitalocean/godo/godo.go +++ b/vendor/github.com/digitalocean/godo/godo.go @@ -16,12 +16,13 @@ import ( "time" "github.com/google/go-querystring/query" + "github.com/hashicorp/go-retryablehttp" "golang.org/x/oauth2" "golang.org/x/time/rate" ) const ( - libraryVersion = "1.95.0" + libraryVersion = "1.100.0" defaultBaseURL = "https://api.digitalocean.com/" userAgent = "godo/" + libraryVersion mediaType = "application/json" @@ -81,7 +82,6 @@ type Client struct { Storage StorageService StorageActions StorageActionsService Tags TagsService - Tokens TokensService UptimeChecks UptimeChecksService VPCs VPCsService @@ -93,6 +93,29 @@ type Client struct { // Optional rate limiter to ensure QoS. rateLimiter *rate.Limiter + + // Optional retry values. Setting the RetryConfig.RetryMax value enables automatically retrying requests + // that fail with 429 or 500-level response codes using the go-retryablehttp client + RetryConfig RetryConfig +} + +// RetryConfig sets the values used for enabling retries and backoffs for +// requests that fail with 429 or 500-level response codes using the go-retryablehttp client. +// RetryConfig.RetryMax must be configured to enable this behavior. RetryConfig.RetryWaitMin and +// RetryConfig.RetryWaitMax are optional, with the default values being 1.0 and 30.0, respectively. +// +// You can use +// +// godo.PtrTo(1.0) +// +// to explicitly set the RetryWaitMin and RetryWaitMax values. +// +// Note: Opting to use the go-retryablehttp client will overwrite any custom HTTP client passed into New(). +// Only the custom HTTP client's custom transport and timeout will be maintained. +type RetryConfig struct { + RetryMax int + RetryWaitMin *float64 // Minimum time to wait + RetryWaitMax *float64 // Maximum time to wait } // RequestCompletionCallback defines the type of the request callback function @@ -252,7 +275,6 @@ func NewClient(httpClient *http.Client) *Client { c.Storage = &StorageServiceOp{client: c} c.StorageActions = &StorageActionsServiceOp{client: c} c.Tags = &TagsServiceOp{client: c} - c.Tokens = &TokensServiceOp{client: c} c.UptimeChecks = &UptimeChecksServiceOp{client: c} c.VPCs = &VPCsServiceOp{client: c} @@ -273,6 +295,33 @@ func New(httpClient *http.Client, opts ...ClientOpt) (*Client, error) { } } + // if retryMax is set it will use the retryablehttp client. + if c.RetryConfig.RetryMax > 0 { + retryableClient := retryablehttp.NewClient() + retryableClient.RetryMax = c.RetryConfig.RetryMax + + if c.RetryConfig.RetryWaitMin != nil { + retryableClient.RetryWaitMin = time.Duration(*c.RetryConfig.RetryWaitMin * float64(time.Second)) + } + if c.RetryConfig.RetryWaitMax != nil { + retryableClient.RetryWaitMax = time.Duration(*c.RetryConfig.RetryWaitMax * float64(time.Second)) + } + + // if timeout is set, it is maintained before overwriting client with StandardClient() + retryableClient.HTTPClient.Timeout = c.client.Timeout + + var source *oauth2.Transport + if _, ok := c.client.Transport.(*oauth2.Transport); ok { + source = c.client.Transport.(*oauth2.Transport) + } + c.client = retryableClient.StandardClient() + c.client.Transport = &oauth2.Transport{ + Base: c.client.Transport, + Source: source.Source, + } + + } + return c, nil } @@ -317,6 +366,17 @@ func SetStaticRateLimit(rps float64) ClientOpt { } } +// WithRetryAndBackoffs sets retry values. Setting the RetryConfig.RetryMax value enables automatically retrying requests +// that fail with 429 or 500-level response codes using the go-retryablehttp client +func WithRetryAndBackoffs(retryConfig RetryConfig) ClientOpt { + return func(c *Client) error { + c.RetryConfig.RetryMax = retryConfig.RetryMax + c.RetryConfig.RetryWaitMax = retryConfig.RetryWaitMax + c.RetryConfig.RetryWaitMin = retryConfig.RetryWaitMin + return nil + } +} + // NewRequest creates an API request. A relative URL can be provided in urlStr, which will be resolved to the // BaseURL of the Client. Relative URLS should always be specified without a preceding slash. If specified, the // value pointed to by body is JSON encoded and included in as the request body. @@ -442,7 +502,7 @@ func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Res return response, err } - if v != nil { + if resp.StatusCode != http.StatusNoContent && v != nil { if w, ok := v.(io.Writer); ok { _, err = io.Copy(w, resp.Body) if err != nil { diff --git a/vendor/github.com/digitalocean/godo/load_balancers.go b/vendor/github.com/digitalocean/godo/load_balancers.go index 6a9a70efe..7e1cfc164 100644 --- a/vendor/github.com/digitalocean/godo/load_balancers.go +++ b/vendor/github.com/digitalocean/godo/load_balancers.go @@ -6,10 +6,17 @@ import ( "net/http" ) -const loadBalancersBasePath = "/v2/load_balancers" -const forwardingRulesPath = "forwarding_rules" +const ( + dropletsPath = "droplets" + forwardingRulesPath = "forwarding_rules" + loadBalancersBasePath = "/v2/load_balancers" +) -const dropletsPath = "droplets" +// Load Balancer types. +const ( + LoadBalancerTypeGlobal = "GLOBAL" + LoadBalancerTypeRegional = "REGIONAL" +) // LoadBalancersService is an interface for managing load balancers with the DigitalOcean API. // See: https://docs.digitalocean.com/reference/api/api-reference/#tag/Load-Balancers @@ -35,6 +42,7 @@ type LoadBalancer struct { SizeSlug string `json:"size,omitempty"` // SizeUnit is mutually exclusive with SizeSlug. Only one should be specified SizeUnit uint32 `json:"size_unit,omitempty"` + Type string `json:"type,omitempty"` Algorithm string `json:"algorithm,omitempty"` Status string `json:"status,omitempty"` Created string `json:"created_at,omitempty"` @@ -74,6 +82,7 @@ func (l LoadBalancer) AsRequest() *LoadBalancerRequest { Algorithm: l.Algorithm, SizeSlug: l.SizeSlug, SizeUnit: l.SizeUnit, + Type: l.Type, ForwardingRules: append([]ForwardingRule(nil), l.ForwardingRules...), DropletIDs: append([]int(nil), l.DropletIDs...), Tag: l.Tag, @@ -190,6 +199,7 @@ type LoadBalancerRequest struct { SizeSlug string `json:"size,omitempty"` // SizeUnit is mutually exclusive with SizeSlug. Only one should be specified SizeUnit uint32 `json:"size_unit,omitempty"` + Type string `json:"type,omitempty"` ForwardingRules []ForwardingRule `json:"forwarding_rules,omitempty"` HealthCheck *HealthCheck `json:"health_check,omitempty"` StickySessions *StickySessions `json:"sticky_sessions,omitempty"` diff --git a/vendor/github.com/digitalocean/godo/registry.go b/vendor/github.com/digitalocean/godo/registry.go index 2fe9d2bd9..b0c243281 100644 --- a/vendor/github.com/digitalocean/godo/registry.go +++ b/vendor/github.com/digitalocean/godo/registry.go @@ -37,6 +37,7 @@ type RegistryService interface { GetOptions(context.Context) (*RegistryOptions, *Response, error) GetSubscription(context.Context) (*RegistrySubscription, *Response, error) UpdateSubscription(context.Context, *RegistrySubscriptionUpdateRequest) (*RegistrySubscription, *Response, error) + ValidateName(context.Context, *RegistryValidateNameRequest) (*Response, error) } var _ RegistryService = &RegistryServiceOp{} @@ -233,6 +234,12 @@ type RegistrySubscriptionUpdateRequest struct { TierSlug string `json:"tier_slug"` } +// RegistryValidateNameRequest represents a request to validate that a +// container registry name is available for use. +type RegistryValidateNameRequest struct { + Name string `json:"name"` +} + // Get retrieves the details of a Registry. func (svc *RegistryServiceOp) Get(ctx context.Context) (*Registry, *Response, error) { req, err := svc.client.NewRequest(ctx, http.MethodGet, registryPath, nil) @@ -589,3 +596,17 @@ func (svc *RegistryServiceOp) UpdateSubscription(ctx context.Context, request *R } return root.Subscription, resp, nil } + +// ValidateName validates that a container registry name is available for use. +func (svc *RegistryServiceOp) ValidateName(ctx context.Context, request *RegistryValidateNameRequest) (*Response, error) { + path := fmt.Sprintf("%s/validate-name", registryPath) + req, err := svc.client.NewRequest(ctx, http.MethodPost, path, request) + if err != nil { + return nil, err + } + resp, err := svc.client.Do(ctx, req, nil) + if err != nil { + return resp, err + } + return resp, nil +} diff --git a/vendor/github.com/digitalocean/godo/tokens.go b/vendor/github.com/digitalocean/godo/tokens.go deleted file mode 100644 index 13aa418df..000000000 --- a/vendor/github.com/digitalocean/godo/tokens.go +++ /dev/null @@ -1,228 +0,0 @@ -package godo - -import ( - "context" - "fmt" - "net/http" - "time" -) - -const ( - accessTokensBasePath = "v2/tokens" - tokenScopesBasePath = accessTokensBasePath + "/scopes" -) - -// TokensService is an interface for managing DigitalOcean API access tokens. -// It is not currently generally available. Follow the release notes for -// updates: https://docs.digitalocean.com/release-notes/api/ -type TokensService interface { - List(context.Context, *ListOptions) ([]Token, *Response, error) - Get(context.Context, int) (*Token, *Response, error) - Create(context.Context, *TokenCreateRequest) (*Token, *Response, error) - Update(context.Context, int, *TokenUpdateRequest) (*Token, *Response, error) - Revoke(context.Context, int) (*Response, error) - ListScopes(context.Context, *ListOptions) ([]TokenScope, *Response, error) - ListScopesByNamespace(context.Context, string, *ListOptions) ([]TokenScope, *Response, error) -} - -// TokensServiceOp handles communication with the tokens related methods of the -// DigitalOcean API. -type TokensServiceOp struct { - client *Client -} - -var _ TokensService = &TokensServiceOp{} - -// Token represents a DigitalOcean API token. -type Token struct { - ID int `json:"id"` - Name string `json:"name"` - Scopes []string `json:"scopes"` - ExpirySeconds *int `json:"expiry_seconds"` - CreatedAt time.Time `json:"created_at"` - LastUsedAt string `json:"last_used_at"` - - // AccessToken contains the actual Oauth token string. It is only included - // in the create response. - AccessToken string `json:"access_token,omitempty"` -} - -// tokenRoot represents a response from the DigitalOcean API -type tokenRoot struct { - Token *Token `json:"token"` -} - -type tokensRoot struct { - Tokens []Token `json:"tokens"` - Links *Links `json:"links"` - Meta *Meta `json:"meta"` -} - -// TokenCreateRequest represents a request to create a token. -type TokenCreateRequest struct { - Name string `json:"name"` - Scopes []string `json:"scopes"` - ExpirySeconds *int `json:"expiry_seconds,omitempty"` -} - -// TokenUpdateRequest represents a request to update a token. -type TokenUpdateRequest struct { - Name string `json:"name,omitempty"` - Scopes []string `json:"scopes,omitempty"` -} - -// TokenScope is a representation of a scope for the public API. -type TokenScope struct { - Name string `json:"name"` -} - -type tokenScopesRoot struct { - TokenScopes []TokenScope `json:"scopes"` - Links *Links `json:"links"` - Meta *Meta `json:"meta"` -} - -type tokenScopeNamespaceParam struct { - Namespace string `url:"namespace,omitempty"` -} - -// List all DigitalOcean API access tokens. -func (c TokensServiceOp) List(ctx context.Context, opt *ListOptions) ([]Token, *Response, error) { - path, err := addOptions(accessTokensBasePath, opt) - if err != nil { - return nil, nil, err - } - - req, err := c.client.NewRequest(ctx, http.MethodGet, path, nil) - if err != nil { - return nil, nil, err - } - - root := new(tokensRoot) - resp, err := c.client.Do(ctx, req, root) - if err != nil { - return nil, resp, err - } - if l := root.Links; l != nil { - resp.Links = l - } - if m := root.Meta; m != nil { - resp.Meta = m - } - - return root.Tokens, resp, err -} - -// Get a specific DigitalOcean API access token. -func (c TokensServiceOp) Get(ctx context.Context, tokenID int) (*Token, *Response, error) { - path := fmt.Sprintf("%s/%d", accessTokensBasePath, tokenID) - req, err := c.client.NewRequest(ctx, http.MethodGet, path, nil) - if err != nil { - return nil, nil, err - } - - root := new(tokenRoot) - resp, err := c.client.Do(ctx, req, root) - if err != nil { - return nil, resp, err - } - - return root.Token, resp, err -} - -// Create a new DigitalOcean API access token. -func (c TokensServiceOp) Create(ctx context.Context, createRequest *TokenCreateRequest) (*Token, *Response, error) { - req, err := c.client.NewRequest(ctx, http.MethodPost, accessTokensBasePath, createRequest) - if err != nil { - return nil, nil, err - } - - root := new(tokenRoot) - resp, err := c.client.Do(ctx, req, root) - if err != nil { - return nil, resp, err - } - - return root.Token, resp, err -} - -// Update the name or scopes of a specific DigitalOcean API access token. -func (c TokensServiceOp) Update(ctx context.Context, tokenID int, updateRequest *TokenUpdateRequest) (*Token, *Response, error) { - path := fmt.Sprintf("%s/%d", accessTokensBasePath, tokenID) - req, err := c.client.NewRequest(ctx, http.MethodPatch, path, updateRequest) - if err != nil { - return nil, nil, err - } - - root := new(tokenRoot) - resp, err := c.client.Do(ctx, req, root) - if err != nil { - return nil, resp, err - } - - return root.Token, resp, err -} - -// Revoke a specific DigitalOcean API access token. -func (c TokensServiceOp) Revoke(ctx context.Context, tokenID int) (*Response, error) { - path := fmt.Sprintf("%s/%d", accessTokensBasePath, tokenID) - req, err := c.client.NewRequest(ctx, http.MethodDelete, path, nil) - if err != nil { - return nil, err - } - - resp, err := c.client.Do(ctx, req, nil) - - return resp, err -} - -// ListScopes lists all available scopes that can be granted to a token. -func (c TokensServiceOp) ListScopes(ctx context.Context, opt *ListOptions) ([]TokenScope, *Response, error) { - path, err := addOptions(tokenScopesBasePath, opt) - if err != nil { - return nil, nil, err - } - - return listTokenScopes(ctx, c, path) -} - -// ListScopesByNamespace lists available scopes in a namespace that can be granted -// to a token (e.g. the namespace for the `droplet:read“ scope is `droplet`). -func (c TokensServiceOp) ListScopesByNamespace(ctx context.Context, namespace string, opt *ListOptions) ([]TokenScope, *Response, error) { - path, err := addOptions(tokenScopesBasePath, opt) - if err != nil { - return nil, nil, err - } - - namespaceOpt := tokenScopeNamespaceParam{ - Namespace: namespace, - } - - path, err = addOptions(path, namespaceOpt) - if err != nil { - return nil, nil, err - } - - return listTokenScopes(ctx, c, path) -} - -func listTokenScopes(ctx context.Context, c TokensServiceOp, path string) ([]TokenScope, *Response, error) { - req, err := c.client.NewRequest(ctx, http.MethodGet, path, nil) - if err != nil { - return nil, nil, err - } - - root := new(tokenScopesRoot) - resp, err := c.client.Do(ctx, req, root) - if err != nil { - return nil, resp, err - } - if l := root.Links; l != nil { - resp.Links = l - } - if m := root.Meta; m != nil { - resp.Meta = m - } - - return root.TokenScopes, resp, err -} diff --git a/vendor/github.com/hashicorp/go-retryablehttp/CHANGELOG.md b/vendor/github.com/hashicorp/go-retryablehttp/CHANGELOG.md new file mode 100644 index 000000000..33686e4da --- /dev/null +++ b/vendor/github.com/hashicorp/go-retryablehttp/CHANGELOG.md @@ -0,0 +1,9 @@ +## 0.7.4 (Jun 6, 2023) + +BUG FIXES + +- client: fixing an issue where the Content-Type header wouldn't be sent with an empty payload when using HTTP/2 [GH-194] + +## 0.7.3 (May 15, 2023) + +Initial release diff --git a/vendor/github.com/hashicorp/go-retryablehttp/CODEOWNERS b/vendor/github.com/hashicorp/go-retryablehttp/CODEOWNERS new file mode 100644 index 000000000..f8389c995 --- /dev/null +++ b/vendor/github.com/hashicorp/go-retryablehttp/CODEOWNERS @@ -0,0 +1 @@ +* @hashicorp/release-engineering \ No newline at end of file diff --git a/vendor/github.com/hashicorp/go-retryablehttp/LICENSE b/vendor/github.com/hashicorp/go-retryablehttp/LICENSE index e87a115e4..f4f97ee58 100644 --- a/vendor/github.com/hashicorp/go-retryablehttp/LICENSE +++ b/vendor/github.com/hashicorp/go-retryablehttp/LICENSE @@ -1,3 +1,5 @@ +Copyright (c) 2015 HashiCorp, Inc. + Mozilla Public License, version 2.0 1. Definitions diff --git a/vendor/github.com/hashicorp/go-retryablehttp/client.go b/vendor/github.com/hashicorp/go-retryablehttp/client.go index f40d2411c..cad96bd97 100644 --- a/vendor/github.com/hashicorp/go-retryablehttp/client.go +++ b/vendor/github.com/hashicorp/go-retryablehttp/client.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + // Package retryablehttp provides a familiar HTTP client interface with // automatic retries and exponential backoff. It is a thin wrapper over the // standard net/http client library and exposes nearly the same public API. @@ -257,10 +260,17 @@ func getBodyReaderAndContentLength(rawBody interface{}) (ReaderFunc, int64, erro if err != nil { return nil, 0, err } - bodyReader = func() (io.Reader, error) { - return bytes.NewReader(buf), nil + if len(buf) == 0 { + bodyReader = func() (io.Reader, error) { + return http.NoBody, nil + } + contentLength = 0 + } else { + bodyReader = func() (io.Reader, error) { + return bytes.NewReader(buf), nil + } + contentLength = int64(len(buf)) } - contentLength = int64(len(buf)) // No body provided, nothing to do case nil: diff --git a/vendor/github.com/hashicorp/go-retryablehttp/roundtripper.go b/vendor/github.com/hashicorp/go-retryablehttp/roundtripper.go index 8f3ee3584..8c407adb3 100644 --- a/vendor/github.com/hashicorp/go-retryablehttp/roundtripper.go +++ b/vendor/github.com/hashicorp/go-retryablehttp/roundtripper.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package retryablehttp import ( diff --git a/vendor/modules.txt b/vendor/modules.txt index 96a2be1d7..097e48622 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.95.0 +# github.com/digitalocean/godo v1.100.1-0.20230803192756-bc798b06c70f ## explicit; go 1.18 github.com/digitalocean/godo github.com/digitalocean/godo/metrics @@ -114,7 +114,7 @@ github.com/hashicorp/go-multierror ## explicit; go 1.17 github.com/hashicorp/go-plugin github.com/hashicorp/go-plugin/internal/plugin -# github.com/hashicorp/go-retryablehttp v0.7.2 +# github.com/hashicorp/go-retryablehttp v0.7.4 ## explicit; go 1.13 github.com/hashicorp/go-retryablehttp # github.com/hashicorp/go-uuid v1.0.3 From d21c4d63dc848b3c58af9e100acb33096558bfd5 Mon Sep 17 00:00:00 2001 From: danaelhe <42972711+danaelhe@users.noreply.github.com> Date: Thu, 10 Aug 2023 10:54:11 -0400 Subject: [PATCH 02/17] Update main.tf --- examples/droplet/main.tf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/droplet/main.tf b/examples/droplet/main.tf index f3cbac082..9c070f826 100644 --- a/examples/droplet/main.tf +++ b/examples/droplet/main.tf @@ -15,7 +15,7 @@ provider "digitalocean" { resource "digitalocean_droplet" "mywebserver" { # Obtain your ssh_key id number via your account. See Document https://developers.digitalocean.com/documentation/v2/#list-all-keys - # ssh_keys = [digitalocean_ssh_key.example.fingerprint] + ssh_keys = [digitalocean_ssh_key.example.fingerprint] image = var.ubuntu region = var.do_ams3 size = "s-1vcpu-1gb" @@ -34,10 +34,10 @@ resource "digitalocean_droplet" "mywebserver" { } } -# resource "digitalocean_ssh_key" "example" { -# name = "examplekey" -# public_key = file(var.ssh_key_path) -# } +resource "digitalocean_ssh_key" "example" { + name = "examplekey" + public_key = file(var.ssh_key_path) +} resource "digitalocean_domain" "mywebserver" { name = "www.mywebserver.com" From 525207a59ccdec2fc8fba8d806d65e70051977eb Mon Sep 17 00:00:00 2001 From: danaelhe <42972711+danaelhe@users.noreply.github.com> Date: Thu, 10 Aug 2023 10:54:37 -0400 Subject: [PATCH 03/17] Update main.tf --- examples/kubernetes/main.tf | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/examples/kubernetes/main.tf b/examples/kubernetes/main.tf index ed5931a2b..31460c948 100644 --- a/examples/kubernetes/main.tf +++ b/examples/kubernetes/main.tf @@ -15,17 +15,28 @@ terraform { } } -resource "digitalocean_database_cluster" "postgres-example" { - name = "example-postgres-cluster" - engine = "pg" - version = "13" - size = "db-s-1vcpu-1gb" - region = "nyc1" - node_count = 1 +resource "random_id" "cluster_name" { + byte_length = 5 } -resource "digitalocean_database_user" "user-example" { - cluster_id = digitalocean_database_cluster.postgres-example.id - name = "${count.index}-app" - count = 260 -} \ No newline at end of file +locals { + cluster_name = "tf-k8s-${random_id.cluster_name.hex}" +} + +module "doks-cluster" { + source = "./doks-cluster" + cluster_name = local.cluster_name + cluster_region = "nyc3" + cluster_version = var.cluster_version + + worker_size = var.worker_size + worker_count = var.worker_count +} + +module "kubernetes-config" { + source = "./kubernetes-config" + cluster_name = module.doks-cluster.cluster_name + cluster_id = module.doks-cluster.cluster_id + + write_kubeconfig = var.write_kubeconfig +} From 5634ccf4e92a4cc5c74c05ebffe88a421cecf826 Mon Sep 17 00:00:00 2001 From: danaelhe <42972711+danaelhe@users.noreply.github.com> Date: Thu, 10 Aug 2023 10:54:55 -0400 Subject: [PATCH 04/17] Update outputs.tf --- examples/kubernetes/outputs.tf | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/kubernetes/outputs.tf b/examples/kubernetes/outputs.tf index a53a79167..4b0a2315a 100644 --- a/examples/kubernetes/outputs.tf +++ b/examples/kubernetes/outputs.tf @@ -1,7 +1,7 @@ -# output "cluster_name" { -# value = module.doks-cluster.cluster_name -# } +output "cluster_name" { + value = module.doks-cluster.cluster_name +} -# output "kubeconfig_path" { -# value = var.write_kubeconfig ? abspath("${path.root}/kubeconfig") : "none" -# } \ No newline at end of file +output "kubeconfig_path" { + value = var.write_kubeconfig ? abspath("${path.root}/kubeconfig") : "none" +} From 34c308db1448bcec997c47852f0cb4bcd5db76e7 Mon Sep 17 00:00:00 2001 From: danaelhe <42972711+danaelhe@users.noreply.github.com> Date: Thu, 10 Aug 2023 10:55:12 -0400 Subject: [PATCH 05/17] Update outputs.tf From df57a8503d5659800de5fe9354f4c87b9bb66058 Mon Sep 17 00:00:00 2001 From: danaelhe <42972711+danaelhe@users.noreply.github.com> Date: Thu, 10 Aug 2023 10:55:44 -0400 Subject: [PATCH 06/17] Update outputs.tf From e7fd3fa940dce399a8dff87cdccf5bbe75019809 Mon Sep 17 00:00:00 2001 From: danaelhe <42972711+danaelhe@users.noreply.github.com> Date: Thu, 10 Aug 2023 11:02:41 -0400 Subject: [PATCH 07/17] update outputs.tf --- examples/kubernetes/outputs.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/kubernetes/outputs.tf b/examples/kubernetes/outputs.tf index 4b0a2315a..bdbcb1855 100644 --- a/examples/kubernetes/outputs.tf +++ b/examples/kubernetes/outputs.tf @@ -4,4 +4,4 @@ output "cluster_name" { output "kubeconfig_path" { value = var.write_kubeconfig ? abspath("${path.root}/kubeconfig") : "none" -} +} \ No newline at end of file From 4fa3acc83b544bbabecdd5d48dfdaf62422018b8 Mon Sep 17 00:00:00 2001 From: danaelhe <42972711+danaelhe@users.noreply.github.com> Date: Thu, 10 Aug 2023 11:07:26 -0400 Subject: [PATCH 08/17] make default retrymax=4 --- digitalocean/provider.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/digitalocean/provider.go b/digitalocean/provider.go index 1efc16f35..b16edf641 100644 --- a/digitalocean/provider.go +++ b/digitalocean/provider.go @@ -76,7 +76,7 @@ func Provider() *schema.Provider { "http_retry_max": { Type: schema.TypeInt, Optional: true, - DefaultFunc: schema.EnvDefaultFunc("DIGITALOCEAN_HTTP_RETRY_MAX", 0), + DefaultFunc: schema.EnvDefaultFunc("DIGITALOCEAN_HTTP_RETRY_MAX", 4), Description: "The maximum number of retries on a failed API request.", }, "http_retry_wait_min": { From d574954d149885364c3cea058b7fabc48e307eec Mon Sep 17 00:00:00 2001 From: danaelhe <42972711+danaelhe@users.noreply.github.com> Date: Thu, 10 Aug 2023 14:30:11 -0400 Subject: [PATCH 09/17] export transport --- digitalocean/config/config.go | 5 ++++- vendor/github.com/digitalocean/godo/godo.go | 18 +++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/digitalocean/config/config.go b/digitalocean/config/config.go index 99187b5ff..4a9cb0f1e 100644 --- a/digitalocean/config/config.go +++ b/digitalocean/config/config.go @@ -77,7 +77,6 @@ func (c *Config) Client() (*CombinedConfig, error) { var godoOpts []godo.ClientOpt client = oauth2.NewClient(context.Background(), tokenSrc) - client.Transport = logging.NewTransport("DigitalOcean", client.Transport) if c.HTTPRetryMax > 0 { retryConfig := godo.RetryConfig{ @@ -101,6 +100,10 @@ func (c *Config) Client() (*CombinedConfig, error) { } godoClient, err := godo.New(client, godoOpts...) + clientTransport := logging.NewTransport("DigitalOcean", client.Transport) + + godoClient.Client.Transport = clientTransport + if err != nil { return nil, err } diff --git a/vendor/github.com/digitalocean/godo/godo.go b/vendor/github.com/digitalocean/godo/godo.go index 3dcfa54e2..9cafc62cf 100644 --- a/vendor/github.com/digitalocean/godo/godo.go +++ b/vendor/github.com/digitalocean/godo/godo.go @@ -35,7 +35,7 @@ const ( // Client manages communication with DigitalOcean V2 API. type Client struct { // HTTP client used to communicate with the DO API. - client *http.Client + Client *http.Client // Base URL for API requests. BaseURL *url.URL @@ -240,7 +240,7 @@ func NewClient(httpClient *http.Client) *Client { baseURL, _ := url.Parse(defaultBaseURL) - c := &Client{client: httpClient, BaseURL: baseURL, UserAgent: userAgent} + c := &Client{Client: httpClient, BaseURL: baseURL, UserAgent: userAgent} c.Account = &AccountServiceOp{client: c} c.Actions = &ActionsServiceOp{client: c} @@ -308,15 +308,15 @@ func New(httpClient *http.Client, opts ...ClientOpt) (*Client, error) { } // if timeout is set, it is maintained before overwriting client with StandardClient() - retryableClient.HTTPClient.Timeout = c.client.Timeout + retryableClient.HTTPClient.Timeout = c.Client.Timeout var source *oauth2.Transport - if _, ok := c.client.Transport.(*oauth2.Transport); ok { - source = c.client.Transport.(*oauth2.Transport) + if _, ok := c.Client.Transport.(*oauth2.Transport); ok { + source = c.Client.Transport.(*oauth2.Transport) } - c.client = retryableClient.StandardClient() - c.client.Transport = &oauth2.Transport{ - Base: c.client.Transport, + c.Client = retryableClient.StandardClient() + c.Client.Transport = &oauth2.Transport{ + Base: c.Client.Transport, Source: source.Source, } @@ -467,7 +467,7 @@ func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Res } } - resp, err := DoRequestWithClient(ctx, c.client, req) + resp, err := DoRequestWithClient(ctx, c.Client, req) if err != nil { return nil, err } From 3a13d125115769c8465a055a707ac6cf49fd81a5 Mon Sep 17 00:00:00 2001 From: danaelhe <42972711+danaelhe@users.noreply.github.com> Date: Tue, 15 Aug 2023 10:46:50 -0400 Subject: [PATCH 10/17] Client -> HTTPClient --- digitalocean/config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/digitalocean/config/config.go b/digitalocean/config/config.go index 4a9cb0f1e..1814a7d69 100644 --- a/digitalocean/config/config.go +++ b/digitalocean/config/config.go @@ -102,7 +102,7 @@ func (c *Config) Client() (*CombinedConfig, error) { godoClient, err := godo.New(client, godoOpts...) clientTransport := logging.NewTransport("DigitalOcean", client.Transport) - godoClient.Client.Transport = clientTransport + godoClient.HTTPClient.Transport = clientTransport if err != nil { return nil, err From d61d02a182b860e2174e3fc1e0a2e3493246a4a3 Mon Sep 17 00:00:00 2001 From: danaelhe <42972711+danaelhe@users.noreply.github.com> Date: Tue, 15 Aug 2023 11:27:02 -0400 Subject: [PATCH 11/17] change hardcoded var --- digitalocean/config/config.go | 2 +- examples/kubernetes/kubernetes-config/main.tf | 280 +++++++++--------- .../kubernetes/kubernetes-config/variables.tf | 20 +- examples/kubernetes/main.tf | 33 +-- examples/kubernetes/outputs.tf | 12 +- examples/kubernetes/variables.tf | 26 +- 6 files changed, 181 insertions(+), 192 deletions(-) diff --git a/digitalocean/config/config.go b/digitalocean/config/config.go index 1814a7d69..3422bfdde 100644 --- a/digitalocean/config/config.go +++ b/digitalocean/config/config.go @@ -80,7 +80,7 @@ func (c *Config) Client() (*CombinedConfig, error) { if c.HTTPRetryMax > 0 { retryConfig := godo.RetryConfig{ - RetryMax: 3, + RetryMax: c.HTTPRetryMax, RetryWaitMin: godo.PtrTo(c.HTTPRetryWaitMin), RetryWaitMax: godo.PtrTo(c.HTTPRetryWaitMax), } diff --git a/examples/kubernetes/kubernetes-config/main.tf b/examples/kubernetes/kubernetes-config/main.tf index 4367d3354..16f49fb51 100644 --- a/examples/kubernetes/kubernetes-config/main.tf +++ b/examples/kubernetes/kubernetes-config/main.tf @@ -1,155 +1,155 @@ -terraform { - required_providers { - digitalocean = { - source = "digitalocean/digitalocean" - version = ">= 2.4.0" - } - kubernetes = { - source = "hashicorp/kubernetes" - version = ">= 2.7.0" - } - helm = { - source = "hashicorp/helm" - version = ">= 2.0.1" - } - } -} +# terraform { +# required_providers { +# digitalocean = { +# source = "digitalocean/digitalocean" +# version = ">= 2.4.0" +# } +# kubernetes = { +# source = "hashicorp/kubernetes" +# version = ">= 2.7.0" +# } +# helm = { +# source = "hashicorp/helm" +# version = ">= 2.0.1" +# } +# } +# } -data "digitalocean_kubernetes_cluster" "primary" { - name = var.cluster_name -} +# data "digitalocean_kubernetes_cluster" "primary" { +# name = var.cluster_name +# } -resource "local_file" "kubeconfig" { - depends_on = [var.cluster_id] - count = var.write_kubeconfig ? 1 : 0 - content = data.digitalocean_kubernetes_cluster.primary.kube_config[0].raw_config - filename = "${path.root}/kubeconfig" -} +# resource "local_file" "kubeconfig" { +# depends_on = [var.cluster_id] +# count = var.write_kubeconfig ? 1 : 0 +# content = data.digitalocean_kubernetes_cluster.primary.kube_config[0].raw_config +# filename = "${path.root}/kubeconfig" +# } -provider "kubernetes" { - host = data.digitalocean_kubernetes_cluster.primary.endpoint - token = data.digitalocean_kubernetes_cluster.primary.kube_config[0].token - cluster_ca_certificate = base64decode( - data.digitalocean_kubernetes_cluster.primary.kube_config[0].cluster_ca_certificate - ) -} +# provider "kubernetes" { +# host = data.digitalocean_kubernetes_cluster.primary.endpoint +# token = data.digitalocean_kubernetes_cluster.primary.kube_config[0].token +# cluster_ca_certificate = base64decode( +# data.digitalocean_kubernetes_cluster.primary.kube_config[0].cluster_ca_certificate +# ) +# } -provider "helm" { - kubernetes { - host = data.digitalocean_kubernetes_cluster.primary.endpoint - token = data.digitalocean_kubernetes_cluster.primary.kube_config[0].token - cluster_ca_certificate = base64decode( - data.digitalocean_kubernetes_cluster.primary.kube_config[0].cluster_ca_certificate - ) - } -} +# provider "helm" { +# kubernetes { +# host = data.digitalocean_kubernetes_cluster.primary.endpoint +# token = data.digitalocean_kubernetes_cluster.primary.kube_config[0].token +# cluster_ca_certificate = base64decode( +# data.digitalocean_kubernetes_cluster.primary.kube_config[0].cluster_ca_certificate +# ) +# } +# } -resource "kubernetes_namespace" "test" { - metadata { - name = "test" - } -} +# resource "kubernetes_namespace" "test" { +# metadata { +# name = "test" +# } +# } -resource "kubernetes_deployment" "test" { - metadata { - name = "test" - namespace= kubernetes_namespace.test.metadata.0.name - } - spec { - replicas = 2 - selector { - match_labels = { - app = "test" - } - } - template { - metadata { - labels = { - app = "test" - } - } - spec { - container { - image = "hashicorp/http-echo" - name = "http-echo" - args = ["-text=test"] +# resource "kubernetes_deployment" "test" { +# metadata { +# name = "test" +# namespace= kubernetes_namespace.test.metadata.0.name +# } +# spec { +# replicas = 2 +# selector { +# match_labels = { +# app = "test" +# } +# } +# template { +# metadata { +# labels = { +# app = "test" +# } +# } +# spec { +# container { +# image = "hashicorp/http-echo" +# name = "http-echo" +# args = ["-text=test"] - resources { - limits = { - memory = "512M" - cpu = "1" - } - requests = { - memory = "256M" - cpu = "50m" - } - } - } - } - } - } -} +# resources { +# limits = { +# memory = "512M" +# cpu = "1" +# } +# requests = { +# memory = "256M" +# cpu = "50m" +# } +# } +# } +# } +# } +# } +# } -resource "kubernetes_service" "test" { - metadata { - name = "test-service" - namespace = kubernetes_namespace.test.metadata.0.name - } - spec { - selector = { - app = kubernetes_deployment.test.metadata.0.name - } +# resource "kubernetes_service" "test" { +# metadata { +# name = "test-service" +# namespace = kubernetes_namespace.test.metadata.0.name +# } +# spec { +# selector = { +# app = kubernetes_deployment.test.metadata.0.name +# } - port { - port = 5678 - } - } -} +# port { +# port = 5678 +# } +# } +# } -resource "helm_release" "nginx_ingress" { - name = "nginx-ingress-controller" - namespace = kubernetes_namespace.test.metadata.0.name +# resource "helm_release" "nginx_ingress" { +# name = "nginx-ingress-controller" +# namespace = kubernetes_namespace.test.metadata.0.name - repository = "https://charts.bitnami.com/bitnami" - chart = "nginx-ingress-controller" +# repository = "https://charts.bitnami.com/bitnami" +# chart = "nginx-ingress-controller" - set { - name = "service.type" - value = "LoadBalancer" - } - set { - name = "service.annotations.service\\.beta\\.kubernetes\\.io/do-loadbalancer-name" - value = format("%s-nginx-ingress", var.cluster_name) - } -} +# set { +# name = "service.type" +# value = "LoadBalancer" +# } +# set { +# name = "service.annotations.service\\.beta\\.kubernetes\\.io/do-loadbalancer-name" +# value = format("%s-nginx-ingress", var.cluster_name) +# } +# } -resource "kubernetes_ingress_v1" "test_ingress" { - wait_for_load_balancer = true - metadata { - name = "test-ingress" - namespace = kubernetes_namespace.test.metadata.0.name - annotations = { - "kubernetes.io/ingress.class" = "nginx" - "ingress.kubernetes.io/rewrite-target" = "/" - } - } +# resource "kubernetes_ingress_v1" "test_ingress" { +# wait_for_load_balancer = true +# metadata { +# name = "test-ingress" +# namespace = kubernetes_namespace.test.metadata.0.name +# annotations = { +# "kubernetes.io/ingress.class" = "nginx" +# "ingress.kubernetes.io/rewrite-target" = "/" +# } +# } - spec { - rule { - http { - path { - backend { - service { - name = kubernetes_service.test.metadata.0.name - port { - number = 5678 - } - } - } +# spec { +# rule { +# http { +# path { +# backend { +# service { +# name = kubernetes_service.test.metadata.0.name +# port { +# number = 5678 +# } +# } +# } - path = "/test" - } - } - } - } -} +# path = "/test" +# } +# } +# } +# } +# } diff --git a/examples/kubernetes/kubernetes-config/variables.tf b/examples/kubernetes/kubernetes-config/variables.tf index 22cb16da8..c812b987c 100644 --- a/examples/kubernetes/kubernetes-config/variables.tf +++ b/examples/kubernetes/kubernetes-config/variables.tf @@ -1,12 +1,12 @@ -variable "cluster_name" { - type = string -} +# variable "cluster_name" { +# type = string +# } -variable "cluster_id" { - type = string -} +# variable "cluster_id" { +# type = string +# } -variable "write_kubeconfig" { - type = bool - default = false -} \ No newline at end of file +# variable "write_kubeconfig" { +# type = bool +# default = false +# } \ No newline at end of file diff --git a/examples/kubernetes/main.tf b/examples/kubernetes/main.tf index 31460c948..88ecca78b 100644 --- a/examples/kubernetes/main.tf +++ b/examples/kubernetes/main.tf @@ -15,28 +15,17 @@ terraform { } } -resource "random_id" "cluster_name" { - byte_length = 5 +resource "digitalocean_database_cluster" "postgres-example" { + name = "example-postgres-cluster" + engine = "pg" + version = "13" + size = "db-s-1vcpu-1gb" + region = "nyc1" + node_count = 1 } -locals { - cluster_name = "tf-k8s-${random_id.cluster_name.hex}" -} - -module "doks-cluster" { - source = "./doks-cluster" - cluster_name = local.cluster_name - cluster_region = "nyc3" - cluster_version = var.cluster_version - - worker_size = var.worker_size - worker_count = var.worker_count -} - -module "kubernetes-config" { - source = "./kubernetes-config" - cluster_name = module.doks-cluster.cluster_name - cluster_id = module.doks-cluster.cluster_id - - write_kubeconfig = var.write_kubeconfig +resource "digitalocean_database_user" "user-example" { + cluster_id = digitalocean_database_cluster.postgres-example.id + name = "${count.index}-app" + count = 270 } diff --git a/examples/kubernetes/outputs.tf b/examples/kubernetes/outputs.tf index bdbcb1855..a53a79167 100644 --- a/examples/kubernetes/outputs.tf +++ b/examples/kubernetes/outputs.tf @@ -1,7 +1,7 @@ -output "cluster_name" { - value = module.doks-cluster.cluster_name -} +# output "cluster_name" { +# value = module.doks-cluster.cluster_name +# } -output "kubeconfig_path" { - value = var.write_kubeconfig ? abspath("${path.root}/kubeconfig") : "none" -} \ No newline at end of file +# output "kubeconfig_path" { +# value = var.write_kubeconfig ? abspath("${path.root}/kubeconfig") : "none" +# } \ No newline at end of file diff --git a/examples/kubernetes/variables.tf b/examples/kubernetes/variables.tf index 469440019..af336eaae 100644 --- a/examples/kubernetes/variables.tf +++ b/examples/kubernetes/variables.tf @@ -1,17 +1,17 @@ -variable "cluster_version" { - default = "1.22" -} +# variable "cluster_version" { +# default = "1.22" +# } -variable "worker_count" { - default = 3 -} +# variable "worker_count" { +# default = 3 +# } -variable "worker_size" { - default = "s-2vcpu-4gb" -} +# variable "worker_size" { +# default = "s-2vcpu-4gb" +# } -variable "write_kubeconfig" { - type = bool - default = false -} \ No newline at end of file +# variable "write_kubeconfig" { +# type = bool +# default = false +# } \ No newline at end of file From e4b82ee652e5b0130a8d8ec7728c59d89c01eb9b Mon Sep 17 00:00:00 2001 From: danaelhe <42972711+danaelhe@users.noreply.github.com> Date: Tue, 15 Aug 2023 13:03:00 -0400 Subject: [PATCH 12/17] Revert "change hardcoded var" This reverts commit d61d02a182b860e2174e3fc1e0a2e3493246a4a3. --- digitalocean/config/config.go | 2 +- examples/kubernetes/kubernetes-config/main.tf | 280 +++++++++--------- .../kubernetes/kubernetes-config/variables.tf | 20 +- examples/kubernetes/main.tf | 33 ++- examples/kubernetes/outputs.tf | 12 +- examples/kubernetes/variables.tf | 26 +- 6 files changed, 192 insertions(+), 181 deletions(-) diff --git a/digitalocean/config/config.go b/digitalocean/config/config.go index 3422bfdde..1814a7d69 100644 --- a/digitalocean/config/config.go +++ b/digitalocean/config/config.go @@ -80,7 +80,7 @@ func (c *Config) Client() (*CombinedConfig, error) { if c.HTTPRetryMax > 0 { retryConfig := godo.RetryConfig{ - RetryMax: c.HTTPRetryMax, + RetryMax: 3, RetryWaitMin: godo.PtrTo(c.HTTPRetryWaitMin), RetryWaitMax: godo.PtrTo(c.HTTPRetryWaitMax), } diff --git a/examples/kubernetes/kubernetes-config/main.tf b/examples/kubernetes/kubernetes-config/main.tf index 16f49fb51..4367d3354 100644 --- a/examples/kubernetes/kubernetes-config/main.tf +++ b/examples/kubernetes/kubernetes-config/main.tf @@ -1,155 +1,155 @@ -# terraform { -# required_providers { -# digitalocean = { -# source = "digitalocean/digitalocean" -# version = ">= 2.4.0" -# } -# kubernetes = { -# source = "hashicorp/kubernetes" -# version = ">= 2.7.0" -# } -# helm = { -# source = "hashicorp/helm" -# version = ">= 2.0.1" -# } -# } -# } +terraform { + required_providers { + digitalocean = { + source = "digitalocean/digitalocean" + version = ">= 2.4.0" + } + kubernetes = { + source = "hashicorp/kubernetes" + version = ">= 2.7.0" + } + helm = { + source = "hashicorp/helm" + version = ">= 2.0.1" + } + } +} -# data "digitalocean_kubernetes_cluster" "primary" { -# name = var.cluster_name -# } +data "digitalocean_kubernetes_cluster" "primary" { + name = var.cluster_name +} -# resource "local_file" "kubeconfig" { -# depends_on = [var.cluster_id] -# count = var.write_kubeconfig ? 1 : 0 -# content = data.digitalocean_kubernetes_cluster.primary.kube_config[0].raw_config -# filename = "${path.root}/kubeconfig" -# } +resource "local_file" "kubeconfig" { + depends_on = [var.cluster_id] + count = var.write_kubeconfig ? 1 : 0 + content = data.digitalocean_kubernetes_cluster.primary.kube_config[0].raw_config + filename = "${path.root}/kubeconfig" +} -# provider "kubernetes" { -# host = data.digitalocean_kubernetes_cluster.primary.endpoint -# token = data.digitalocean_kubernetes_cluster.primary.kube_config[0].token -# cluster_ca_certificate = base64decode( -# data.digitalocean_kubernetes_cluster.primary.kube_config[0].cluster_ca_certificate -# ) -# } +provider "kubernetes" { + host = data.digitalocean_kubernetes_cluster.primary.endpoint + token = data.digitalocean_kubernetes_cluster.primary.kube_config[0].token + cluster_ca_certificate = base64decode( + data.digitalocean_kubernetes_cluster.primary.kube_config[0].cluster_ca_certificate + ) +} -# provider "helm" { -# kubernetes { -# host = data.digitalocean_kubernetes_cluster.primary.endpoint -# token = data.digitalocean_kubernetes_cluster.primary.kube_config[0].token -# cluster_ca_certificate = base64decode( -# data.digitalocean_kubernetes_cluster.primary.kube_config[0].cluster_ca_certificate -# ) -# } -# } +provider "helm" { + kubernetes { + host = data.digitalocean_kubernetes_cluster.primary.endpoint + token = data.digitalocean_kubernetes_cluster.primary.kube_config[0].token + cluster_ca_certificate = base64decode( + data.digitalocean_kubernetes_cluster.primary.kube_config[0].cluster_ca_certificate + ) + } +} -# resource "kubernetes_namespace" "test" { -# metadata { -# name = "test" -# } -# } +resource "kubernetes_namespace" "test" { + metadata { + name = "test" + } +} -# resource "kubernetes_deployment" "test" { -# metadata { -# name = "test" -# namespace= kubernetes_namespace.test.metadata.0.name -# } -# spec { -# replicas = 2 -# selector { -# match_labels = { -# app = "test" -# } -# } -# template { -# metadata { -# labels = { -# app = "test" -# } -# } -# spec { -# container { -# image = "hashicorp/http-echo" -# name = "http-echo" -# args = ["-text=test"] +resource "kubernetes_deployment" "test" { + metadata { + name = "test" + namespace= kubernetes_namespace.test.metadata.0.name + } + spec { + replicas = 2 + selector { + match_labels = { + app = "test" + } + } + template { + metadata { + labels = { + app = "test" + } + } + spec { + container { + image = "hashicorp/http-echo" + name = "http-echo" + args = ["-text=test"] -# resources { -# limits = { -# memory = "512M" -# cpu = "1" -# } -# requests = { -# memory = "256M" -# cpu = "50m" -# } -# } -# } -# } -# } -# } -# } + resources { + limits = { + memory = "512M" + cpu = "1" + } + requests = { + memory = "256M" + cpu = "50m" + } + } + } + } + } + } +} -# resource "kubernetes_service" "test" { -# metadata { -# name = "test-service" -# namespace = kubernetes_namespace.test.metadata.0.name -# } -# spec { -# selector = { -# app = kubernetes_deployment.test.metadata.0.name -# } +resource "kubernetes_service" "test" { + metadata { + name = "test-service" + namespace = kubernetes_namespace.test.metadata.0.name + } + spec { + selector = { + app = kubernetes_deployment.test.metadata.0.name + } -# port { -# port = 5678 -# } -# } -# } + port { + port = 5678 + } + } +} -# resource "helm_release" "nginx_ingress" { -# name = "nginx-ingress-controller" -# namespace = kubernetes_namespace.test.metadata.0.name +resource "helm_release" "nginx_ingress" { + name = "nginx-ingress-controller" + namespace = kubernetes_namespace.test.metadata.0.name -# repository = "https://charts.bitnami.com/bitnami" -# chart = "nginx-ingress-controller" + repository = "https://charts.bitnami.com/bitnami" + chart = "nginx-ingress-controller" -# set { -# name = "service.type" -# value = "LoadBalancer" -# } -# set { -# name = "service.annotations.service\\.beta\\.kubernetes\\.io/do-loadbalancer-name" -# value = format("%s-nginx-ingress", var.cluster_name) -# } -# } + set { + name = "service.type" + value = "LoadBalancer" + } + set { + name = "service.annotations.service\\.beta\\.kubernetes\\.io/do-loadbalancer-name" + value = format("%s-nginx-ingress", var.cluster_name) + } +} -# resource "kubernetes_ingress_v1" "test_ingress" { -# wait_for_load_balancer = true -# metadata { -# name = "test-ingress" -# namespace = kubernetes_namespace.test.metadata.0.name -# annotations = { -# "kubernetes.io/ingress.class" = "nginx" -# "ingress.kubernetes.io/rewrite-target" = "/" -# } -# } +resource "kubernetes_ingress_v1" "test_ingress" { + wait_for_load_balancer = true + metadata { + name = "test-ingress" + namespace = kubernetes_namespace.test.metadata.0.name + annotations = { + "kubernetes.io/ingress.class" = "nginx" + "ingress.kubernetes.io/rewrite-target" = "/" + } + } -# spec { -# rule { -# http { -# path { -# backend { -# service { -# name = kubernetes_service.test.metadata.0.name -# port { -# number = 5678 -# } -# } -# } + spec { + rule { + http { + path { + backend { + service { + name = kubernetes_service.test.metadata.0.name + port { + number = 5678 + } + } + } -# path = "/test" -# } -# } -# } -# } -# } + path = "/test" + } + } + } + } +} diff --git a/examples/kubernetes/kubernetes-config/variables.tf b/examples/kubernetes/kubernetes-config/variables.tf index c812b987c..22cb16da8 100644 --- a/examples/kubernetes/kubernetes-config/variables.tf +++ b/examples/kubernetes/kubernetes-config/variables.tf @@ -1,12 +1,12 @@ -# variable "cluster_name" { -# type = string -# } +variable "cluster_name" { + type = string +} -# variable "cluster_id" { -# type = string -# } +variable "cluster_id" { + type = string +} -# variable "write_kubeconfig" { -# type = bool -# default = false -# } \ No newline at end of file +variable "write_kubeconfig" { + type = bool + default = false +} \ No newline at end of file diff --git a/examples/kubernetes/main.tf b/examples/kubernetes/main.tf index 88ecca78b..31460c948 100644 --- a/examples/kubernetes/main.tf +++ b/examples/kubernetes/main.tf @@ -15,17 +15,28 @@ terraform { } } -resource "digitalocean_database_cluster" "postgres-example" { - name = "example-postgres-cluster" - engine = "pg" - version = "13" - size = "db-s-1vcpu-1gb" - region = "nyc1" - node_count = 1 +resource "random_id" "cluster_name" { + byte_length = 5 } -resource "digitalocean_database_user" "user-example" { - cluster_id = digitalocean_database_cluster.postgres-example.id - name = "${count.index}-app" - count = 270 +locals { + cluster_name = "tf-k8s-${random_id.cluster_name.hex}" +} + +module "doks-cluster" { + source = "./doks-cluster" + cluster_name = local.cluster_name + cluster_region = "nyc3" + cluster_version = var.cluster_version + + worker_size = var.worker_size + worker_count = var.worker_count +} + +module "kubernetes-config" { + source = "./kubernetes-config" + cluster_name = module.doks-cluster.cluster_name + cluster_id = module.doks-cluster.cluster_id + + write_kubeconfig = var.write_kubeconfig } diff --git a/examples/kubernetes/outputs.tf b/examples/kubernetes/outputs.tf index a53a79167..bdbcb1855 100644 --- a/examples/kubernetes/outputs.tf +++ b/examples/kubernetes/outputs.tf @@ -1,7 +1,7 @@ -# output "cluster_name" { -# value = module.doks-cluster.cluster_name -# } +output "cluster_name" { + value = module.doks-cluster.cluster_name +} -# output "kubeconfig_path" { -# value = var.write_kubeconfig ? abspath("${path.root}/kubeconfig") : "none" -# } \ No newline at end of file +output "kubeconfig_path" { + value = var.write_kubeconfig ? abspath("${path.root}/kubeconfig") : "none" +} \ No newline at end of file diff --git a/examples/kubernetes/variables.tf b/examples/kubernetes/variables.tf index af336eaae..469440019 100644 --- a/examples/kubernetes/variables.tf +++ b/examples/kubernetes/variables.tf @@ -1,17 +1,17 @@ -# variable "cluster_version" { -# default = "1.22" -# } +variable "cluster_version" { + default = "1.22" +} -# variable "worker_count" { -# default = 3 -# } +variable "worker_count" { + default = 3 +} -# variable "worker_size" { -# default = "s-2vcpu-4gb" -# } +variable "worker_size" { + default = "s-2vcpu-4gb" +} -# variable "write_kubeconfig" { -# type = bool -# default = false -# } \ No newline at end of file +variable "write_kubeconfig" { + type = bool + default = false +} \ No newline at end of file From b6201314a154bc0e45c2564d04521276758702b2 Mon Sep 17 00:00:00 2001 From: danaelhe <42972711+danaelhe@users.noreply.github.com> Date: Tue, 15 Aug 2023 13:18:06 -0400 Subject: [PATCH 13/17] remove hardcoded var --- digitalocean/config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/digitalocean/config/config.go b/digitalocean/config/config.go index 1814a7d69..3422bfdde 100644 --- a/digitalocean/config/config.go +++ b/digitalocean/config/config.go @@ -80,7 +80,7 @@ func (c *Config) Client() (*CombinedConfig, error) { if c.HTTPRetryMax > 0 { retryConfig := godo.RetryConfig{ - RetryMax: 3, + RetryMax: c.HTTPRetryMax, RetryWaitMin: godo.PtrTo(c.HTTPRetryWaitMin), RetryWaitMax: godo.PtrTo(c.HTTPRetryWaitMax), } From eefc5f56ddf76d32747af93b5030d7eb676cb2db Mon Sep 17 00:00:00 2001 From: danaelhe <42972711+danaelhe@users.noreply.github.com> Date: Thu, 17 Aug 2023 15:21:59 -0400 Subject: [PATCH 14/17] update client, add log --- digitalocean/config/config.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/digitalocean/config/config.go b/digitalocean/config/config.go index 3422bfdde..2b417d95a 100644 --- a/digitalocean/config/config.go +++ b/digitalocean/config/config.go @@ -7,6 +7,7 @@ import ( "log" "net/http" "net/url" + "os" "strings" "github.com/aws/aws-sdk-go/aws" @@ -83,6 +84,7 @@ func (c *Config) Client() (*CombinedConfig, error) { RetryMax: c.HTTPRetryMax, RetryWaitMin: godo.PtrTo(c.HTTPRetryWaitMin), RetryWaitMax: godo.PtrTo(c.HTTPRetryWaitMax), + Logger: log.New(os.Stderr, "", log.LstdFlags), } godoOpts = []godo.ClientOpt{godo.WithRetryAndBackoffs(retryConfig)} @@ -100,7 +102,7 @@ func (c *Config) Client() (*CombinedConfig, error) { } godoClient, err := godo.New(client, godoOpts...) - clientTransport := logging.NewTransport("DigitalOcean", client.Transport) + clientTransport := logging.NewTransport("DigitalOcean", godoClient.HTTPClient.Transport) godoClient.HTTPClient.Transport = clientTransport From 2c522ee3eead8b9c990b2bf0a27819ea8d5548d7 Mon Sep 17 00:00:00 2001 From: danaelhe <42972711+danaelhe@users.noreply.github.com> Date: Mon, 21 Aug 2023 11:13:45 -0400 Subject: [PATCH 15/17] doc update --- docs/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.md b/docs/index.md index 8e676bd7f..fd47a03b0 100644 --- a/docs/index.md +++ b/docs/index.md @@ -70,7 +70,7 @@ The following arguments are supported: of retries on a failed API request (client errors, 422, 500, 502...), the exponential backoff can be configured by the `http_retry_wait_min` and `http_retry_wait_max` arguments (Defaults to the value of the `DIGITALOCEAN_HTTP_RETRY_MAX` environment variable or - `0`, which means no retries, if unset). + `4` if unset). * `http_retry_wait_min` - (Optional) This can be used to configure the minimum waiting time (**in seconds**) between failed requests for the backoff strategy (Defaults to the value of the `DIGITALOCEAN_HTTP_RETRY_WAIT_MIN` environment From 7e3873ae203dedc8072268cd6c4dd4a506084ece Mon Sep 17 00:00:00 2001 From: danaelhe <42972711+danaelhe@users.noreply.github.com> Date: Tue, 22 Aug 2023 09:56:25 -0400 Subject: [PATCH 16/17] update log --- digitalocean/config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/digitalocean/config/config.go b/digitalocean/config/config.go index 2b417d95a..10f0caa2d 100644 --- a/digitalocean/config/config.go +++ b/digitalocean/config/config.go @@ -84,7 +84,7 @@ func (c *Config) Client() (*CombinedConfig, error) { RetryMax: c.HTTPRetryMax, RetryWaitMin: godo.PtrTo(c.HTTPRetryWaitMin), RetryWaitMax: godo.PtrTo(c.HTTPRetryWaitMax), - Logger: log.New(os.Stderr, "", log.LstdFlags), + Logger: log.Default(), } godoOpts = []godo.ClientOpt{godo.WithRetryAndBackoffs(retryConfig)} From a8250f4bb7c02c2b731d7a58e71b69af5da51832 Mon Sep 17 00:00:00 2001 From: danaelhe <42972711+danaelhe@users.noreply.github.com> Date: Tue, 22 Aug 2023 12:01:56 -0400 Subject: [PATCH 17/17] remove transport --- digitalocean/config/config.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/digitalocean/config/config.go b/digitalocean/config/config.go index 10f0caa2d..28fcc76df 100644 --- a/digitalocean/config/config.go +++ b/digitalocean/config/config.go @@ -7,7 +7,6 @@ import ( "log" "net/http" "net/url" - "os" "strings" "github.com/aws/aws-sdk-go/aws" @@ -88,11 +87,6 @@ func (c *Config) Client() (*CombinedConfig, error) { } godoOpts = []godo.ClientOpt{godo.WithRetryAndBackoffs(retryConfig)} - - client.Transport = &oauth2.Transport{ - Base: client.Transport, - Source: oauth2.ReuseTokenSource(nil, tokenSrc), - } } godoOpts = append(godoOpts, godo.SetUserAgent(userAgent))