From 342abd41c3828b66608762140bd6fb5d62bfd051 Mon Sep 17 00:00:00 2001 From: Oliver Love Date: Thu, 13 Jun 2024 07:35:20 -0400 Subject: [PATCH] Add control plane permission flags --- args.go | 4 ++ commands/kubernetes.go | 66 ++++++++++++++++++- commands/kubernetes_test.go | 40 ++++++++++- go.mod | 2 +- go.sum | 6 +- .../github.com/digitalocean/godo/CHANGELOG.md | 7 ++ .../github.com/digitalocean/godo/apps.gen.go | 19 ++++++ .../digitalocean/godo/apps_accessors.go | 48 ++++++++++++++ vendor/github.com/digitalocean/godo/godo.go | 2 +- .../digitalocean/godo/kubernetes.go | 33 ++++++---- .../digitalocean/godo/load_balancers.go | 9 ++- vendor/modules.txt | 2 +- 12 files changed, 213 insertions(+), 25 deletions(-) diff --git a/args.go b/args.go index 9b2b381ad..031e00fd0 100644 --- a/args.go +++ b/args.go @@ -92,6 +92,10 @@ const ( ArgAutoUpgrade = "auto-upgrade" // ArgHA is a cluster's highly available control plane argument. ArgHA = "ha" + // ArgControlPlanePermissionEnable enable control plane permission. + ArgControlPlanePermissionEnable = "control-plane-permission-enable" + // ArgControlPlanePermissionAllowedAddresses list of allowed addresses that can access the control plane. + ArgControlPlanePermissionAllowedAddresses = "control-plane-permission-allowed-addresses" // ArgSurgeUpgrade is a cluster's surge-upgrade argument. ArgSurgeUpgrade = "surge-upgrade" // ArgCommandUpsert is an upsert for a resource to be created or updated argument. diff --git a/commands/kubernetes.go b/commands/kubernetes.go index 290d0d92c..1acb3fcf5 100644 --- a/commands/kubernetes.go +++ b/commands/kubernetes.go @@ -26,14 +26,15 @@ import ( "time" "github.com/blang/semver" - "github.com/digitalocean/doctl" - "github.com/digitalocean/doctl/commands/displayers" - "github.com/digitalocean/doctl/do" "github.com/digitalocean/godo" "github.com/google/uuid" "github.com/spf13/cobra" "github.com/spf13/viper" + "github.com/digitalocean/doctl" + "github.com/digitalocean/doctl/commands/displayers" + "github.com/digitalocean/doctl/do" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" kubeerrors "k8s.io/apimachinery/pkg/util/errors" clientauthentication "k8s.io/client-go/pkg/apis/clientauthentication/v1beta1" @@ -282,6 +283,10 @@ After creating a cluster, a configuration context is added to kubectl and made a "Enables surge-upgrade for the cluster") AddBoolFlag(cmdKubeClusterCreate, doctl.ArgHA, "", false, "Creates the cluster with a highly-available control plane. Defaults to false. To enable the HA control plane, supply --ha=true.") + AddStringFlag(cmdKubeClusterCreate, doctl.ArgControlPlanePermissionEnable, "", "", + "Creates the cluster with a control plane permission. Defaults to false. To enable the control plane permission, supply --enable-control-plane-permission=true.") + AddStringSliceFlag(cmdKubeClusterCreate, doctl.ArgControlPlanePermissionAllowedAddresses, "", nil, + "A comma-separated list of allowed addresses that can access the control plane.") AddStringSliceFlag(cmdKubeClusterCreate, doctl.ArgTag, "", nil, "A comma-separated list of `tags` to apply to the cluster, in addition to the default tags of `k8s` and `k8s:$K8S_CLUSTER_ID`.") AddStringFlag(cmdKubeClusterCreate, doctl.ArgSizeSlug, "", @@ -328,6 +333,10 @@ Updates the configuration values for a Kubernetes cluster. The cluster must be r "Enables surge-upgrade for the cluster") AddBoolFlag(cmdKubeClusterUpdate, doctl.ArgHA, "", false, "Enables the highly-available control plane for the cluster") + AddStringFlag(cmdKubeClusterUpdate, doctl.ArgControlPlanePermissionEnable, "", "", + "Creates the cluster with a control plane permission. Defaults to false. To enable the control plane permission, supply --enable-control-plane-permission=true.") + AddStringSliceFlag(cmdKubeClusterUpdate, doctl.ArgControlPlanePermissionAllowedAddresses, "", nil, + "A comma-separated list of allowed addresses that can access the control plane.") AddBoolFlag(cmdKubeClusterUpdate, doctl.ArgClusterUpdateKubeconfig, "", true, "Updates the cluster in your kubeconfig") AddBoolFlag(cmdKubeClusterUpdate, doctl.ArgSetCurrentContext, "", true, @@ -1648,6 +1657,31 @@ func buildClusterCreateRequestFromArgs(c *CmdConfig, r *godo.KubernetesClusterCr } r.HA = ha + enableControlPlanePermission, err := c.Doit.GetString(c.NS, doctl.ArgControlPlanePermissionEnable) + if err != nil { + return err + } + if enableControlPlanePermission != "" { + enableControlPlanePermissionBool, err := strconv.ParseBool(enableControlPlanePermission) + if err != nil { + return err + } + r.ControlPlanePermission = &godo.KubernetesControlPlanePermission{ + Enabled: &enableControlPlanePermissionBool, + } + } + + controlPlanePermissionAllowedAddresses, err := c.Doit.GetStringSlice(c.NS, doctl.ArgControlPlanePermissionAllowedAddresses) + if err != nil { + return err + } + if len(controlPlanePermissionAllowedAddresses) > 0 { + if r.ControlPlanePermission == nil { + r.ControlPlanePermission = &godo.KubernetesControlPlanePermission{} + } + r.ControlPlanePermission.AllowedAddresses = controlPlanePermissionAllowedAddresses + } + tags, err := c.Doit.GetStringSlice(c.NS, doctl.ArgTag) if err != nil { return err @@ -1737,6 +1771,32 @@ func buildClusterUpdateRequestFromArgs(c *CmdConfig, r *godo.KubernetesClusterUp return err } r.HA = ha + + enableControlPlanePermission, err := c.Doit.GetString(c.NS, doctl.ArgControlPlanePermissionEnable) + if err != nil { + return err + } + if enableControlPlanePermission != "" { + enableControlPlanePermissionBool, err := strconv.ParseBool(enableControlPlanePermission) + if err != nil { + return err + } + r.ControlPlanePermission = &godo.KubernetesControlPlanePermission{ + Enabled: &enableControlPlanePermissionBool, + } + } + + controlPlanePermissionAllowedAddresses, err := c.Doit.GetStringSlice(c.NS, doctl.ArgControlPlanePermissionAllowedAddresses) + if err != nil { + return err + } + if len(controlPlanePermissionAllowedAddresses) > 0 { + if r.ControlPlanePermission == nil { + r.ControlPlanePermission = &godo.KubernetesControlPlanePermission{} + } + r.ControlPlanePermission.AllowedAddresses = controlPlanePermissionAllowedAddresses + } + return nil } diff --git a/commands/kubernetes_test.go b/commands/kubernetes_test.go index 73f960e79..e4b9c6c34 100644 --- a/commands/kubernetes_test.go +++ b/commands/kubernetes_test.go @@ -5,13 +5,14 @@ import ( "sort" "testing" - "github.com/digitalocean/doctl" - "github.com/digitalocean/doctl/do" "github.com/digitalocean/godo" "github.com/google/uuid" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" clientcmdapi "k8s.io/client-go/tools/clientcmd/api" + + "github.com/digitalocean/doctl" + "github.com/digitalocean/doctl/do" ) var ( @@ -30,6 +31,13 @@ var ( }, AutoUpgrade: true, HA: true, + ControlPlanePermission: &godo.KubernetesControlPlanePermission{ + Enabled: boolPtr(true), + AllowedAddresses: []string{ + "1.2.3.4", + "4.3.2.1/32", + }, + }, }, } @@ -497,6 +505,13 @@ func TestKubernetesCreate(t *testing.T) { }, AutoUpgrade: true, HA: true, + ControlPlanePermission: &godo.KubernetesControlPlanePermission{ + Enabled: boolPtr(true), + AllowedAddresses: []string{ + "1.2.3.4", + "4.3.2.1/32", + }, + }, } tm.kubernetes.EXPECT().Create(&r).Return(&testCluster, nil) @@ -517,6 +532,9 @@ func TestKubernetesCreate(t *testing.T) { config.Doit.Set(config.NS, doctl.ArgAutoUpgrade, testCluster.AutoUpgrade) config.Doit.Set(config.NS, doctl.ArgHA, testCluster.HA) + config.Doit.Set(config.NS, doctl.ArgControlPlanePermissionEnable, testCluster.ControlPlanePermission.Enabled) + config.Doit.Set(config.NS, doctl.ArgControlPlanePermissionAllowedAddresses, testCluster.ControlPlanePermission.AllowedAddresses) + // Test with no vpc-uuid specified err := testK8sCmdService().RunKubernetesClusterCreate("c-8", 3)(config) assert.NoError(t, err) @@ -550,6 +568,13 @@ func TestKubernetesUpdate(t *testing.T) { }, AutoUpgrade: boolPtr(false), HA: boolPtr(true), + ControlPlanePermission: &godo.KubernetesControlPlanePermission{ + Enabled: boolPtr(true), + AllowedAddresses: []string{ + "1.2.3.4", + "4.3.2.1/32", + }, + }, } tm.kubernetes.EXPECT().Update(testCluster.ID, &r).Return(&testCluster, nil) @@ -559,6 +584,8 @@ func TestKubernetesUpdate(t *testing.T) { config.Doit.Set(config.NS, doctl.ArgMaintenanceWindow, "any=00:00") config.Doit.Set(config.NS, doctl.ArgAutoUpgrade, false) config.Doit.Set(config.NS, doctl.ArgHA, true) + config.Doit.Set(config.NS, doctl.ArgControlPlanePermissionEnable, testCluster.ControlPlanePermission.Enabled) + config.Doit.Set(config.NS, doctl.ArgControlPlanePermissionAllowedAddresses, testCluster.ControlPlanePermission.AllowedAddresses) err := testK8sCmdService().RunKubernetesClusterUpdate(config) assert.NoError(t, err) @@ -574,6 +601,13 @@ func TestKubernetesUpdate(t *testing.T) { Day: godo.KubernetesMaintenanceDayAny, }, AutoUpgrade: boolPtr(false), + ControlPlanePermission: &godo.KubernetesControlPlanePermission{ + Enabled: boolPtr(true), + AllowedAddresses: []string{ + "1.2.3.4", + "4.3.2.1/32", + }, + }, } tm.kubernetes.EXPECT().List().Return(testClusterList, nil) tm.kubernetes.EXPECT().Update(testCluster.ID, &r).Return(&testCluster, nil) @@ -583,6 +617,8 @@ func TestKubernetesUpdate(t *testing.T) { config.Doit.Set(config.NS, doctl.ArgTag, testCluster.Tags) config.Doit.Set(config.NS, doctl.ArgMaintenanceWindow, "any=00:00") config.Doit.Set(config.NS, doctl.ArgAutoUpgrade, false) + config.Doit.Set(config.NS, doctl.ArgControlPlanePermissionEnable, testCluster.ControlPlanePermission.Enabled) + config.Doit.Set(config.NS, doctl.ArgControlPlanePermissionAllowedAddresses, testCluster.ControlPlanePermission.AllowedAddresses) err := testK8sCmdService().RunKubernetesClusterUpdate(config) assert.NoError(t, err) diff --git a/go.mod b/go.mod index 380485ef5..9cda598f3 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.21 require ( github.com/blang/semver v3.5.1+incompatible github.com/creack/pty v1.1.11 - github.com/digitalocean/godo v1.116.0 + github.com/digitalocean/godo v1.117.0 github.com/docker/cli v24.0.5+incompatible github.com/docker/docker v24.0.9+incompatible github.com/docker/docker-credential-helpers v0.7.0 // indirect diff --git a/go.sum b/go.sum index 05424209d..3de9287cc 100644 --- a/go.sum +++ b/go.sum @@ -86,10 +86,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/digitalocean/godo v1.115.1-0.20240515191029-705fb26c5aa5 h1:bAO9uVDeZhwy1DdKmtAqgjS9+isKWnzxzxiKvNHKNtQ= -github.com/digitalocean/godo v1.115.1-0.20240515191029-705fb26c5aa5/go.mod h1:Vk0vpCot2HOAJwc5WE8wljZGtJ3ZtWIc8MQ8rF38sdo= -github.com/digitalocean/godo v1.116.0 h1:SuF/Imd1/dE/nYrUFVkJ2itesQNnJQE1a/vmtHknxeE= -github.com/digitalocean/godo v1.116.0/go.mod h1:Vk0vpCot2HOAJwc5WE8wljZGtJ3ZtWIc8MQ8rF38sdo= +github.com/digitalocean/godo v1.117.0 h1:WVlTe09melDYTd7VCVyvHcNWbgB+uI1O115+5LOtdSw= +github.com/digitalocean/godo v1.117.0/go.mod h1:Vk0vpCot2HOAJwc5WE8wljZGtJ3ZtWIc8MQ8rF38sdo= github.com/docker/cli v24.0.5+incompatible h1:WeBimjvS0eKdH4Ygx+ihVq1Q++xg36M/rMi4aXAvodc= github.com/docker/cli v24.0.5+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= diff --git a/vendor/github.com/digitalocean/godo/CHANGELOG.md b/vendor/github.com/digitalocean/godo/CHANGELOG.md index 1d3102b2e..ce940ccbf 100644 --- a/vendor/github.com/digitalocean/godo/CHANGELOG.md +++ b/vendor/github.com/digitalocean/godo/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +## [v1.117.0] - 2024-06-04 + +- #696 - @llDrLove - Support specifying control plane firewall rules when creating or updating DOKS clusters +- #697 - @asaha2 - Add support for lb internal network type +- #695 - @ElanHasson - APPS-8732 - Update documentation on App Platform OpenSearch endpoint structure. +- #692 - @ElanHasson - APPS-8732 - Add OpenSearch as a Log Destination for App Platform. + ## [v1.116.0] - 2024-05-16 - #693 - @guptado - Introduce VPC peering methods diff --git a/vendor/github.com/digitalocean/godo/apps.gen.go b/vendor/github.com/digitalocean/godo/apps.gen.go index f734ab022..f5be2992f 100644 --- a/vendor/github.com/digitalocean/godo/apps.gen.go +++ b/vendor/github.com/digitalocean/godo/apps.gen.go @@ -221,6 +221,7 @@ const ( AppDatabaseSpecEngine_PG AppDatabaseSpecEngine = "PG" AppDatabaseSpecEngine_Redis AppDatabaseSpecEngine = "REDIS" AppDatabaseSpecEngine_MongoDB AppDatabaseSpecEngine = "MONGODB" + AppDatabaseSpecEngine_Kafka AppDatabaseSpecEngine = "KAFKA" ) // AppDedicatedIp Represents a dedicated egress ip. @@ -415,6 +416,7 @@ type AppLogDestinationSpec struct { Papertrail *AppLogDestinationSpecPapertrail `json:"papertrail,omitempty"` Datadog *AppLogDestinationSpecDataDog `json:"datadog,omitempty"` Logtail *AppLogDestinationSpecLogtail `json:"logtail,omitempty"` + OpenSearch *AppLogDestinationSpecOpenSearch `json:"open_search,omitempty"` Endpoint string `json:"endpoint,omitempty"` TLSInsecure bool `json:"tls_insecure,omitempty"` Headers []*AppLogDestinationSpecHeader `json:"headers,omitempty"` @@ -442,6 +444,15 @@ type AppLogDestinationSpecLogtail struct { Token string `json:"token"` } +// AppLogDestinationSpecOpenSearch OpenSearch configuration. +type AppLogDestinationSpecOpenSearch struct { + // OpenSearch API Endpoint. Only HTTPS is supported. Format: https://:. + Endpoint string `json:"endpoint"` + BasicAuth *OpenSearchBasicAuth `json:"basic_auth,omitempty"` + // The index name to use for the logs. If not set, the default index name is \"logs\". + IndexName string `json:"index_name,omitempty"` +} + // AppLogDestinationSpecPapertrail Papertrail configuration. type AppLogDestinationSpecPapertrail struct { // Papertrail syslog endpoint. @@ -1171,6 +1182,14 @@ type ListBuildpacksResponse struct { Buildpacks []*Buildpack `json:"buildpacks,omitempty"` } +// OpenSearchBasicAuth Configure Username and/or Password for Basic authentication. +type OpenSearchBasicAuth struct { + // Username to authenticate with. + User string `json:"user"` + // Password for user defined in User. + Password string `json:"password"` +} + // AppProposeRequest struct for AppProposeRequest type AppProposeRequest struct { Spec *AppSpec `json:"spec"` diff --git a/vendor/github.com/digitalocean/godo/apps_accessors.go b/vendor/github.com/digitalocean/godo/apps_accessors.go index 734c27ea9..0bbba2ddf 100644 --- a/vendor/github.com/digitalocean/godo/apps_accessors.go +++ b/vendor/github.com/digitalocean/godo/apps_accessors.go @@ -1317,6 +1317,14 @@ func (a *AppLogDestinationSpec) GetName() string { return a.Name } +// GetOpenSearch returns the OpenSearch field. +func (a *AppLogDestinationSpec) GetOpenSearch() *AppLogDestinationSpecOpenSearch { + if a == nil { + return nil + } + return a.OpenSearch +} + // GetPapertrail returns the Papertrail field. func (a *AppLogDestinationSpec) GetPapertrail() *AppLogDestinationSpecPapertrail { if a == nil { @@ -1373,6 +1381,30 @@ func (a *AppLogDestinationSpecLogtail) GetToken() string { return a.Token } +// GetBasicAuth returns the BasicAuth field. +func (a *AppLogDestinationSpecOpenSearch) GetBasicAuth() *OpenSearchBasicAuth { + if a == nil { + return nil + } + return a.BasicAuth +} + +// GetEndpoint returns the Endpoint field. +func (a *AppLogDestinationSpecOpenSearch) GetEndpoint() string { + if a == nil { + return "" + } + return a.Endpoint +} + +// GetIndexName returns the IndexName field. +func (a *AppLogDestinationSpecOpenSearch) GetIndexName() string { + if a == nil { + return "" + } + return a.IndexName +} + // GetEndpoint returns the Endpoint field. func (a *AppLogDestinationSpecPapertrail) GetEndpoint() string { if a == nil { @@ -3533,6 +3565,22 @@ func (l *ListBuildpacksResponse) GetBuildpacks() []*Buildpack { return l.Buildpacks } +// GetPassword returns the Password field. +func (o *OpenSearchBasicAuth) GetPassword() string { + if o == nil { + return "" + } + return o.Password +} + +// GetUser returns the User field. +func (o *OpenSearchBasicAuth) GetUser() string { + if o == nil { + return "" + } + return o.User +} + // GetAppID returns the AppID field. func (r *ResetDatabasePasswordRequest) GetAppID() string { if r == nil { diff --git a/vendor/github.com/digitalocean/godo/godo.go b/vendor/github.com/digitalocean/godo/godo.go index 1ec4df208..c16aac430 100644 --- a/vendor/github.com/digitalocean/godo/godo.go +++ b/vendor/github.com/digitalocean/godo/godo.go @@ -21,7 +21,7 @@ import ( ) const ( - libraryVersion = "1.116.0" + libraryVersion = "1.117.0" defaultBaseURL = "https://api.digitalocean.com/" userAgent = "godo/" + libraryVersion mediaType = "application/json" diff --git a/vendor/github.com/digitalocean/godo/kubernetes.go b/vendor/github.com/digitalocean/godo/kubernetes.go index 38c380a51..e275fa108 100644 --- a/vendor/github.com/digitalocean/godo/kubernetes.go +++ b/vendor/github.com/digitalocean/godo/kubernetes.go @@ -76,18 +76,20 @@ type KubernetesClusterCreateRequest struct { NodePools []*KubernetesNodePoolCreateRequest `json:"node_pools,omitempty"` - MaintenancePolicy *KubernetesMaintenancePolicy `json:"maintenance_policy"` - AutoUpgrade bool `json:"auto_upgrade"` - SurgeUpgrade bool `json:"surge_upgrade"` + MaintenancePolicy *KubernetesMaintenancePolicy `json:"maintenance_policy"` + AutoUpgrade bool `json:"auto_upgrade"` + SurgeUpgrade bool `json:"surge_upgrade"` + ControlPlanePermission *KubernetesControlPlanePermission `json:"control_plane_permission,omitempty"` } // KubernetesClusterUpdateRequest represents a request to update a Kubernetes cluster. type KubernetesClusterUpdateRequest struct { - Name string `json:"name,omitempty"` - Tags []string `json:"tags,omitempty"` - MaintenancePolicy *KubernetesMaintenancePolicy `json:"maintenance_policy,omitempty"` - AutoUpgrade *bool `json:"auto_upgrade,omitempty"` - SurgeUpgrade bool `json:"surge_upgrade,omitempty"` + Name string `json:"name,omitempty"` + Tags []string `json:"tags,omitempty"` + MaintenancePolicy *KubernetesMaintenancePolicy `json:"maintenance_policy,omitempty"` + AutoUpgrade *bool `json:"auto_upgrade,omitempty"` + SurgeUpgrade bool `json:"surge_upgrade,omitempty"` + ControlPlanePermission *KubernetesControlPlanePermission `json:"control_plane_permission,omitempty"` // Convert cluster to run highly available control plane HA *bool `json:"ha,omitempty"` @@ -201,10 +203,11 @@ type KubernetesCluster struct { NodePools []*KubernetesNodePool `json:"node_pools,omitempty"` - MaintenancePolicy *KubernetesMaintenancePolicy `json:"maintenance_policy,omitempty"` - AutoUpgrade bool `json:"auto_upgrade,omitempty"` - SurgeUpgrade bool `json:"surge_upgrade,omitempty"` - RegistryEnabled bool `json:"registry_enabled,omitempty"` + MaintenancePolicy *KubernetesMaintenancePolicy `json:"maintenance_policy,omitempty"` + AutoUpgrade bool `json:"auto_upgrade,omitempty"` + SurgeUpgrade bool `json:"surge_upgrade,omitempty"` + RegistryEnabled bool `json:"registry_enabled,omitempty"` + ControlPlanePermission *KubernetesControlPlanePermission `json:"control_plane_permission,omitempty"` Status *KubernetesClusterStatus `json:"status,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` @@ -240,6 +243,12 @@ type KubernetesMaintenancePolicy struct { Day KubernetesMaintenancePolicyDay `json:"day"` } +// KubernetesControlPlanePermission represents Kubernetes cluster control plane permission. +type KubernetesControlPlanePermission struct { + Enabled *bool `json:"enabled"` + AllowedAddresses []string `json:"allowed_addresses"` +} + // KubernetesMaintenancePolicyDay represents the possible days of a maintenance // window type KubernetesMaintenancePolicyDay int diff --git a/vendor/github.com/digitalocean/godo/load_balancers.go b/vendor/github.com/digitalocean/godo/load_balancers.go index 396790530..703aa8426 100644 --- a/vendor/github.com/digitalocean/godo/load_balancers.go +++ b/vendor/github.com/digitalocean/godo/load_balancers.go @@ -13,11 +13,15 @@ const ( loadBalancersBasePath = "/v2/load_balancers" ) -// Load Balancer types. const ( + // Load Balancer types LoadBalancerTypeGlobal = "GLOBAL" LoadBalancerTypeRegional = "REGIONAL" LoadBalancerTypeRegionalNetwork = "REGIONAL_NETWORK" + + // Load Balancer network types + LoadBalancerNetworkTypeExternal = "EXTERNAL" + LoadBalancerNetworkTypeInternal = "INTERNAL" ) // LoadBalancersService is an interface for managing load balancers with the DigitalOcean API. @@ -68,6 +72,7 @@ type LoadBalancer struct { Domains []*LBDomain `json:"domains,omitempty"` GLBSettings *GLBSettings `json:"glb_settings,omitempty"` TargetLoadBalancerIDs []string `json:"target_load_balancer_ids,omitempty"` + Network string `json:"network,omitempty"` } // String creates a human-readable description of a LoadBalancer. @@ -101,6 +106,7 @@ func (l LoadBalancer) AsRequest() *LoadBalancerRequest { ProjectID: l.ProjectID, HTTPIdleTimeoutSeconds: l.HTTPIdleTimeoutSeconds, TargetLoadBalancerIDs: append([]string(nil), l.TargetLoadBalancerIDs...), + Network: l.Network, } if l.DisableLetsEncryptDNSRecords != nil { @@ -238,6 +244,7 @@ type LoadBalancerRequest struct { Domains []*LBDomain `json:"domains,omitempty"` GLBSettings *GLBSettings `json:"glb_settings,omitempty"` TargetLoadBalancerIDs []string `json:"target_load_balancer_ids,omitempty"` + Network string `json:"network,omitempty"` } // String creates a human-readable description of a LoadBalancerRequest. diff --git a/vendor/modules.txt b/vendor/modules.txt index 3f9b348a0..484c604f7 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -58,7 +58,7 @@ github.com/creack/pty # github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc ## explicit github.com/davecgh/go-spew/spew -# github.com/digitalocean/godo v1.116.0 +# github.com/digitalocean/godo v1.117.0 ## explicit; go 1.20 github.com/digitalocean/godo github.com/digitalocean/godo/metrics