diff --git a/commands/displayers/partner_interconnect_attachment.go b/commands/displayers/partner_interconnect_attachment.go index ecdec432d..6b787565b 100644 --- a/commands/displayers/partner_interconnect_attachment.go +++ b/commands/displayers/partner_interconnect_attachment.go @@ -112,3 +112,42 @@ func (v *PartnerInterconnectAttachmentRoute) KV() []map[string]any { return out } + +type PartnerInterconnectAttachmentServiceKey struct { + Key do.PartnerInterconnectAttachmentServiceKey +} + +var _ Displayable = &PartnerInterconnectAttachmentServiceKey{} + +func (v *PartnerInterconnectAttachmentServiceKey) JSON(out io.Writer) error { + return writeJSON(v.Key, out) +} + +func (v *PartnerInterconnectAttachmentServiceKey) Cols() []string { + return []string{ + "Value", + "State", + "CreatedAt", + } +} + +func (v *PartnerInterconnectAttachmentServiceKey) ColMap() map[string]string { + return map[string]string{ + "Value": "Value", + "State": "State", + "CreatedAt": "CreatedAt", + } +} + +func (v *PartnerInterconnectAttachmentServiceKey) KV() []map[string]any { + out := make([]map[string]any, 0, 1) + + o := map[string]any{ + "Value": v.Key.ServiceKey.Value, + "State": v.Key.ServiceKey.State, + "CreatedAt": v.Key.ServiceKey.CreatedAt, + } + out = append(out, o) + + return out +} diff --git a/commands/partner_interconnect_attachment.go b/commands/partner_interconnect_attachment.go index ac88f48e1..6945c36f6 100644 --- a/commands/partner_interconnect_attachment.go +++ b/commands/partner_interconnect_attachment.go @@ -131,6 +131,17 @@ vpc-ids "270a76ed-1bb7-4c5d-a6a5-e863de086940"` cmdPartnerIARouteList.Example = `The following example lists the Network Interconnect Attachments on your account :` + ` doctl network --type "partner" interconnect-attachment list-routes --format ID,Cidr ` + interconnectAttachmentServiceKeyDetails := ` +- The Service key Value +- The Service key State` + + cmdGetPartnerIAServiceKey := CmdBuilder(cmd, RunGetPartnerInterconnectAttachmentServiceKey, "get-service-key ", + "Retrieves a Service key of Partner Interconnect Attachment", "Retrieves information about a Service key of Partner Interconnect Attachment, including:"+interconnectAttachmentServiceKeyDetails, Writer, + aliasOpt("g-service-key"), displayerType(&displayers.PartnerInterconnectAttachmentServiceKey{})) + AddStringFlag(cmdGetPartnerIAServiceKey, doctl.ArgInterconnectAttachmentType, "", "partner", "Specify interconnect attachment type (e.g., partner)") + cmdGetPartnerIAServiceKey.Example = `The following example retrieves information about a Service key of Partner Interconnect Attachment with the ID ` + "`" + `f81d4fae-7dec-11d0-a765-00a0c91e6bf6` + "`" + + `: doctl network --type "partner" interconnect-attachment get-service-key f81d4fae-7dec-11d0-a765-00a0c91e6bf6` + return cmd } @@ -296,6 +307,31 @@ func RunPartnerInterconnectAttachmentUpdate(c *CmdConfig) error { return c.Display(item) } +// RunGetPartnerInterconnectAttachmentServiceKey retrieves service key of existing Partner Interconnect Attachment +func RunGetPartnerInterconnectAttachmentServiceKey(c *CmdConfig) error { + + if err := ensurePartnerAttachmentType(c); err != nil { + return err + } + + err := ensureOneArg(c) + if err != nil { + return err + } + iaID := c.Args[0] + + pias := c.PartnerInterconnectAttachments() + serviceKey, err := pias.GetServiceKey(iaID) + if err != nil { + return err + } + + item := &displayers.PartnerInterconnectAttachmentServiceKey{ + Key: *serviceKey, + } + return c.Display(item) +} + // RunPartnerInterconnectAttachmentDelete deletes an existing Partner Interconnect Attachment by its identifier. func RunPartnerInterconnectAttachmentDelete(c *CmdConfig) error { diff --git a/commands/partner_interconnect_attachment_test.go b/commands/partner_interconnect_attachment_test.go index 97de2c9a2..3914c4afa 100644 --- a/commands/partner_interconnect_attachment_test.go +++ b/commands/partner_interconnect_attachment_test.go @@ -5,10 +5,11 @@ import ( "testing" "time" - "github.com/digitalocean/doctl" - "github.com/digitalocean/doctl/do" "github.com/digitalocean/godo" "github.com/stretchr/testify/assert" + + "github.com/digitalocean/doctl" + "github.com/digitalocean/doctl/do" ) var ( @@ -39,13 +40,21 @@ var ( testPartnerIARouteList = do.PartnerInterconnectAttachmentRoutes{ testPartnerAttachmentRoute, } + + testServiceKey = do.PartnerInterconnectAttachmentServiceKey{ + ServiceKey: &godo.ServiceKey{ + Value: "test-service-key", + State: "active", + CreatedAt: time.Date(2025, 1, 30, 0, 0, 0, 0, time.UTC), + }, + } ) func TestPartnerInterconnectAttachmentsCommand(t *testing.T) { cmd := PartnerInterconnectAttachments() assert.NotNil(t, cmd) - assertCommandNames(t, cmd, "create", "get", "list", "delete", "update", "list-routes") + assertCommandNames(t, cmd, "create", "get", "list", "delete", "update", "list-routes", "get-service-key") } func TestPartnerInterconnectAttachmentCreate(t *testing.T) { @@ -174,3 +183,17 @@ func TestInterconnectAttachmentRoutesList(t *testing.T) { assert.NoError(t, err) }) } + +func TestInterconnectAttachmentsGetServiceKey(t *testing.T) { + withTestClient(t, func(config *CmdConfig, tm *tcMocks) { + config.Doit.Set(config.NS, doctl.ArgInterconnectAttachmentType, "partner") + + iaID := "e819b321-a9a1-4078-b437-8e6b8bf13530" + tm.partnerInterconnectAttachment.EXPECT().GetServiceKey(iaID).Return(&testServiceKey, nil) + + config.Args = append(config.Args, iaID) + + err := RunGetPartnerInterconnectAttachmentServiceKey(config) + assert.NoError(t, err) + }) +} diff --git a/do/mocks/PartnerInterconnectAttachmentsService.go b/do/mocks/PartnerInterconnectAttachmentsService.go index 404c5d331..f83fd7145 100644 --- a/do/mocks/PartnerInterconnectAttachmentsService.go +++ b/do/mocks/PartnerInterconnectAttachmentsService.go @@ -85,6 +85,21 @@ func (mr *MockPartnerInterconnectAttachmentsServiceMockRecorder) GetPartnerInter return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPartnerInterconnectAttachment", reflect.TypeOf((*MockPartnerInterconnectAttachmentsService)(nil).GetPartnerInterconnectAttachment), iaID) } +// GetServiceKey mocks base method. +func (m *MockPartnerInterconnectAttachmentsService) GetServiceKey(iaID string) (*do.PartnerInterconnectAttachmentServiceKey, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetServiceKey", iaID) + ret0, _ := ret[0].(*do.PartnerInterconnectAttachmentServiceKey) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetServiceKey indicates an expected call of GetServiceKey. +func (mr *MockPartnerInterconnectAttachmentsServiceMockRecorder) GetServiceKey(iaID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetServiceKey", reflect.TypeOf((*MockPartnerInterconnectAttachmentsService)(nil).GetServiceKey), iaID) +} + // ListPartnerInterconnectAttachmentRoutes mocks base method. func (m *MockPartnerInterconnectAttachmentsService) ListPartnerInterconnectAttachmentRoutes(iaID string) (do.PartnerInterconnectAttachmentRoutes, error) { m.ctrl.T.Helper() diff --git a/do/partner_interconnect_attachments.go b/do/partner_interconnect_attachments.go index 2972205a2..40498d44d 100644 --- a/do/partner_interconnect_attachments.go +++ b/do/partner_interconnect_attachments.go @@ -35,6 +35,11 @@ type PartnerInterconnectAttachmentRoute struct { // PartnerInterconnectAttachmentRoutes is a slice of PartnerInterconnectAttachmentRoute. type PartnerInterconnectAttachmentRoutes []PartnerInterconnectAttachmentRoute +// PartnerInterconnectAttachmentServiceKey wraps a godo ServiceKey. +type PartnerInterconnectAttachmentServiceKey struct { + *godo.ServiceKey +} + // PartnerInterconnectAttachmentsService is an interface for interacting with // DigitalOcean's partner interconnect attachments api. type PartnerInterconnectAttachmentsService interface { @@ -44,6 +49,7 @@ type PartnerInterconnectAttachmentsService interface { DeletePartnerInterconnectAttachment(iaID string) error UpdatePartnerInterconnectAttachment(iaID string, req *godo.PartnerInterconnectAttachmentUpdateRequest) (*PartnerInterconnectAttachment, error) ListPartnerInterconnectAttachmentRoutes(iaID string) (PartnerInterconnectAttachmentRoutes, error) + GetServiceKey(iaID string) (*PartnerInterconnectAttachmentServiceKey, error) } var _ PartnerInterconnectAttachmentsService = &partnerInterconnectAttachmentsService{} @@ -150,3 +156,12 @@ func (p *partnerInterconnectAttachmentsService) ListPartnerInterconnectAttachmen return list, nil } + +// GetServiceKey retrieves a service key of a partner interconnect attachment. +func (p *partnerInterconnectAttachmentsService) GetServiceKey(iaID string) (*PartnerInterconnectAttachmentServiceKey, error) { + serviceKey, _, err := p.client.PartnerInterconnectAttachments.GetServiceKey(context.TODO(), iaID) + if err != nil { + return nil, err + } + return &PartnerInterconnectAttachmentServiceKey{ServiceKey: serviceKey}, nil +} diff --git a/go.mod b/go.mod index 695e7f930..ee9c81082 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.22 require ( github.com/blang/semver v3.5.1+incompatible github.com/creack/pty v1.1.21 - github.com/digitalocean/godo v1.136.0 + github.com/digitalocean/godo v1.138.0 github.com/docker/cli v24.0.5+incompatible github.com/docker/docker v25.0.6+incompatible github.com/docker/docker-credential-helpers v0.7.0 // indirect @@ -39,6 +39,8 @@ require ( sigs.k8s.io/yaml v1.3.0 ) +replace github.com/digitalocean/godo v1.138.0 => github.com/guptado/godo v0.0.0-20250219083849-2f80d81d1f61 + require ( github.com/MakeNowJust/heredoc v1.0.0 github.com/apache/openwhisk-client-go v0.0.0-20221014112704-1ca897633f2d diff --git a/go.sum b/go.sum index 298c4ec24..fc2adf848 100644 --- a/go.sum +++ b/go.sum @@ -93,6 +93,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/digitalocean/godo v1.136.0 h1:DTxugljFJSMBPfEGq4KeXpnKeAHicggNqogcrw/YdZw= github.com/digitalocean/godo v1.136.0/go.mod h1:PU8JB6I1XYkQIdHFop8lLAY9ojp6M0XcU0TWaQSxbrc= +github.com/digitalocean/godo v1.138.0 h1:0l0UEaVyNKvEmrn4r5NkZCpDysimJjVhLj30Gl6HgiQ= +github.com/digitalocean/godo v1.138.0/go.mod h1:PU8JB6I1XYkQIdHFop8lLAY9ojp6M0XcU0TWaQSxbrc= github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/docker/cli v24.0.5+incompatible h1:WeBimjvS0eKdH4Ygx+ihVq1Q++xg36M/rMi4aXAvodc= @@ -217,6 +219,8 @@ github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWm github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms= github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0/go.mod h1:YN5jB8ie0yfIUg6VvR9Kz84aCaG7AsGZnLjhHbUqwPg= +github.com/guptado/godo v0.0.0-20250219083849-2f80d81d1f61 h1:OyzWZganTGA7zHbB2hVnvV/qdG0qtOWAko4bgu0Oa7M= +github.com/guptado/godo v0.0.0-20250219083849-2f80d81d1f61/go.mod h1:PU8JB6I1XYkQIdHFop8lLAY9ojp6M0XcU0TWaQSxbrc= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= diff --git a/integration/partner_interconnect_attachment_test.go b/integration/partner_interconnect_attachment_test.go index ba63e8bd4..82e691003 100644 --- a/integration/partner_interconnect_attachment_test.go +++ b/integration/partner_interconnect_attachment_test.go @@ -68,6 +68,19 @@ a0eb6eb0-fa38-41a8-a5de-1a75524667fe 169.250.0.0/29 } } ` + interconnectGetServiceKeyOutput = ` +Value State CreatedAt +test-service-key active 2025-01-30 12:00:00 +0000 UTC + ` + + interconnectGetServiceKeyResponse = ` +{ + "service_key": { + "created_at": "2025-01-30T12:00:00Z", + "value": "test-service-key", + "state": "active" + } +}` ) var _ = suite("partner_interconnect_attachments/create", func(t *testing.T, when spec.G, it spec.S) { @@ -216,3 +229,75 @@ var _ = suite("partner_interconnect_attachments/list-routes", func(t *testing.T, }) }) }) + +var _ = suite("partner_interconnect_attachments/get-service-key", func(t *testing.T, when spec.G, it spec.S) { + var ( + expect *require.Assertions + server *httptest.Server + ) + + it.Before(func() { + expect = require.New(t) + + server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + switch req.URL.Path { + case "/v2/partner_interconnect/attachments/c5537207-ebf0-47cb-bc10-6fac717cd672/service_key": + auth := req.Header.Get("Authorization") + if auth != "Bearer some-magic-token" { + w.WriteHeader(http.StatusUnauthorized) + return + } + + if req.Method != http.MethodGet { + w.WriteHeader(http.StatusMethodNotAllowed) + return + } + + w.Write([]byte(interconnectGetServiceKeyResponse)) + default: + dump, err := httputil.DumpRequest(req, true) + if err != nil { + t.Fatal("failed to dump request") + } + + t.Fatalf("received unknown request: %s", dump) + } + })) + }) + + when("no flags are passed", func() { + it("gets the specified service key", func() { + cmd := exec.Command(builtBinaryPath, + "-t", "some-magic-token", + "-u", server.URL, + "network", + "interconnect-attachment", + "get-service-key", + "c5537207-ebf0-47cb-bc10-6fac717cd672", + ) + + output, err := cmd.CombinedOutput() + expect.NoError(err, fmt.Sprintf("received error output: %s", output)) + expect.Equal(strings.TrimSpace(interconnectGetServiceKeyOutput), strings.TrimSpace(string(output))) + }) + }) + + when("format and no-header flags are passed", func() { + it("gets the specified service key", func() { + cmd := exec.Command(builtBinaryPath, + "-t", "some-magic-token", + "-u", server.URL, + "network", + "interconnect-attachment", + "get-service-key", + "--format", "Value", + "--no-header", + "c5537207-ebf0-47cb-bc10-6fac717cd672", + ) + + output, err := cmd.CombinedOutput() + expect.NoError(err, fmt.Sprintf("received error output: %s", output)) + expect.Equal("test-service-key", strings.TrimSpace(string(output))) + }) + }) +}) diff --git a/vendor/github.com/digitalocean/godo/CHANGELOG.md b/vendor/github.com/digitalocean/godo/CHANGELOG.md index 8f926be62..6d6892263 100644 --- a/vendor/github.com/digitalocean/godo/CHANGELOG.md +++ b/vendor/github.com/digitalocean/godo/CHANGELOG.md @@ -1,5 +1,17 @@ # Change Log +## [v1.138.0] - 2025-03-18 + +- #785 - @guptado - Support partner interconnect GetBgpAuthKey and RegenerateServiceKey operations +- #787 - @andrewsomething - ci: upgrade to actions/cache@v4 +- #786 - @m3co-code - add flags for doks routing-agent plugin +- #784 - @asaha2 - Support name and id filters for list op + +## [v1.137.0] - 2025-02-12 + +- #782 - @apinonformoso - fix partner interconnect json tag +- #781 - @dylanrhysscott - CON-11810 Implement GetNodePoolTemplate endpoint for DOKS godo client + ## [v1.136.0] - 2025-01-28 - #776 - @danaelhe - Databases: Support online-migrations diff --git a/vendor/github.com/digitalocean/godo/godo.go b/vendor/github.com/digitalocean/godo/godo.go index ff4c04e1e..db841d5ca 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.136.0" + libraryVersion = "1.138.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 8353e78c1..4a1530aa2 100644 --- a/vendor/github.com/digitalocean/godo/kubernetes.go +++ b/vendor/github.com/digitalocean/godo/kubernetes.go @@ -40,6 +40,7 @@ type KubernetesService interface { CreateNodePool(ctx context.Context, clusterID string, req *KubernetesNodePoolCreateRequest) (*KubernetesNodePool, *Response, error) GetNodePool(ctx context.Context, clusterID, poolID string) (*KubernetesNodePool, *Response, error) + GetNodePoolTemplate(ctx context.Context, clusterID string, nodePoolName string) (*KubernetesNodePoolTemplateResponse, *Response, error) ListNodePools(ctx context.Context, clusterID string, opts *ListOptions) ([]*KubernetesNodePool, *Response, error) UpdateNodePool(ctx context.Context, clusterID, poolID string, req *KubernetesNodePoolUpdateRequest) (*KubernetesNodePool, *Response, error) // RecycleNodePoolNodes is DEPRECATED please use DeleteNode @@ -83,6 +84,7 @@ type KubernetesClusterCreateRequest struct { SurgeUpgrade bool `json:"surge_upgrade"` ControlPlaneFirewall *KubernetesControlPlaneFirewall `json:"control_plane_firewall,omitempty"` ClusterAutoscalerConfiguration *KubernetesClusterAutoscalerConfiguration `json:"cluster_autoscaler_configuration,omitempty"` + RoutingAgent *KubernetesRoutingAgent `json:"routing_agent,omitempty"` } // KubernetesClusterUpdateRequest represents a request to update a Kubernetes cluster. @@ -94,6 +96,7 @@ type KubernetesClusterUpdateRequest struct { SurgeUpgrade bool `json:"surge_upgrade,omitempty"` ControlPlaneFirewall *KubernetesControlPlaneFirewall `json:"control_plane_firewall,omitempty"` ClusterAutoscalerConfiguration *KubernetesClusterAutoscalerConfiguration `json:"cluster_autoscaler_configuration,omitempty"` + RoutingAgent *KubernetesRoutingAgent `json:"routing_agent,omitempty"` // Convert cluster to run highly available control plane HA *bool `json:"ha,omitempty"` @@ -213,6 +216,7 @@ type KubernetesCluster struct { RegistryEnabled bool `json:"registry_enabled,omitempty"` ControlPlaneFirewall *KubernetesControlPlaneFirewall `json:"control_plane_firewall,omitempty"` ClusterAutoscalerConfiguration *KubernetesClusterAutoscalerConfiguration `json:"cluster_autoscaler_configuration,omitempty"` + RoutingAgent *KubernetesRoutingAgent `json:"routing_agent,omitempty"` Status *KubernetesClusterStatus `json:"status,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` @@ -255,6 +259,11 @@ type KubernetesControlPlaneFirewall struct { AllowedAddresses []string `json:"allowed_addresses"` } +// KubernetesRoutingAgent represents information about the routing-agent cluster plugin. +type KubernetesRoutingAgent struct { + Enabled *bool `json:"enabled"` +} + // KubernetesClusterAutoscalerConfiguration represents Kubernetes cluster autoscaler configuration. type KubernetesClusterAutoscalerConfiguration struct { ScaleDownUtilizationThreshold *float64 `json:"scale_down_utilization_threshold"` @@ -426,6 +435,30 @@ type KubernetesNodePool struct { Nodes []*KubernetesNode `json:"nodes,omitempty"` } +// KubernetesNodePool represents a node pool template response from the node template endpoint +type KubernetesNodePoolTemplateResponse struct { + ClusterUUID string `json:"cluster_uuid,omitempty"` + Name string `json:"name,omitempty"` + Slug string `json:"slug,omitempty"` + Template *KubernetesNodePoolTemplate `json:"template,omitempty"` +} + +// KubernetesNodePool represents the node pool template data for a given pool. +type KubernetesNodePoolTemplate struct { + Labels map[string]string `json:"labels,omitempty"` + Capacity *KubernetesNodePoolResources `json:"capacity,omitempty"` + Allocatable *KubernetesNodePoolResources `json:"allocatable,omitempty"` +} + +// KubernetesNodePoolResources represents the resources within a given template for a node pool +// This follows https://pkg.go.dev/k8s.io/kubernetes@v1.32.1/pkg/scheduler/framework#Resource to represent +// node resources within the node object. +type KubernetesNodePoolResources struct { + CPU int64 `json:"cpu,omitempty"` + Memory string `json:"memory,omitempty"` + Pods int64 `json:"pods,omitempty"` +} + // KubernetesNode represents a Node in a node pool in a Kubernetes cluster. type KubernetesNode struct { ID string `json:"id,omitempty"` @@ -804,6 +837,24 @@ func (svc *KubernetesServiceOp) GetNodePool(ctx context.Context, clusterID, pool return root.NodePool, resp, nil } +// GetNodePoolTemplate retrieves the template used for a given node pool to scale up from zero. +func (svc *KubernetesServiceOp) GetNodePoolTemplate(ctx context.Context, clusterID string, nodePoolName string) (*KubernetesNodePoolTemplateResponse, *Response, error) { + path, err := url.JoinPath(kubernetesClustersPath, clusterID, "node_pools_template", nodePoolName) + if err != nil { + return nil, nil, err + } + req, err := svc.client.NewRequest(ctx, http.MethodGet, path, nil) + if err != nil { + return nil, nil, err + } + root := new(KubernetesNodePoolTemplateResponse) + resp, err := svc.client.Do(ctx, req, root) + if err != nil { + return nil, resp, err + } + return root, resp, nil +} + // ListNodePools lists all the node pools found in a Kubernetes cluster. func (svc *KubernetesServiceOp) ListNodePools(ctx context.Context, clusterID string, opts *ListOptions) ([]*KubernetesNodePool, *Response, error) { path := fmt.Sprintf("%s/%s/node_pools", kubernetesClustersPath, clusterID) diff --git a/vendor/github.com/digitalocean/godo/load_balancers.go b/vendor/github.com/digitalocean/godo/load_balancers.go index 54bec0c4f..a1b833b6a 100644 --- a/vendor/github.com/digitalocean/godo/load_balancers.go +++ b/vendor/github.com/digitalocean/godo/load_balancers.go @@ -33,6 +33,8 @@ const ( type LoadBalancersService interface { Get(context.Context, string) (*LoadBalancer, *Response, error) List(context.Context, *ListOptions) ([]LoadBalancer, *Response, error) + ListByNames(context.Context, []string, *ListOptions) ([]LoadBalancer, *Response, error) + ListByUUIDs(context.Context, []string, *ListOptions) ([]LoadBalancer, *Response, error) Create(context.Context, *LoadBalancerRequest) (*LoadBalancer, *Response, error) Update(ctx context.Context, lbID string, lbr *LoadBalancerRequest) (*LoadBalancer, *Response, error) Delete(ctx context.Context, lbID string) (*Response, error) @@ -403,6 +405,72 @@ func (l *LoadBalancersServiceOp) List(ctx context.Context, opt *ListOptions) ([] return root.LoadBalancers, resp, err } +// ListByNames lists load balancers filtered by resource names, with optional pagination. +func (l *LoadBalancersServiceOp) ListByNames(ctx context.Context, names []string, opt *ListOptions) ([]LoadBalancer, *Response, error) { + path, err := addOptions(loadBalancersBasePath, opt) + if err != nil { + return nil, nil, err + } + + req, err := l.client.NewRequest(ctx, http.MethodGet, path, nil) + if err != nil { + return nil, nil, err + } + + q := req.URL.Query() + for _, name := range names { + q.Add("names", name) + } + req.URL.RawQuery = q.Encode() + + root := new(loadBalancersRoot) + resp, err := l.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.LoadBalancers, resp, err +} + +// ListByUUIDs lists load balancers filtered by resource UUIDs, with optional pagination. +func (l *LoadBalancersServiceOp) ListByUUIDs(ctx context.Context, uuids []string, opt *ListOptions) ([]LoadBalancer, *Response, error) { + path, err := addOptions(loadBalancersBasePath, opt) + if err != nil { + return nil, nil, err + } + + req, err := l.client.NewRequest(ctx, http.MethodGet, path, nil) + if err != nil { + return nil, nil, err + } + + q := req.URL.Query() + for _, uuid := range uuids { + q.Add("uuids", uuid) + } + req.URL.RawQuery = q.Encode() + + root := new(loadBalancersRoot) + resp, err := l.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.LoadBalancers, resp, err +} + // Create a new load balancer with a given configuration. func (l *LoadBalancersServiceOp) Create(ctx context.Context, lbr *LoadBalancerRequest) (*LoadBalancer, *Response, error) { req, err := l.client.NewRequest(ctx, http.MethodPost, loadBalancersBasePath, lbr) diff --git a/vendor/github.com/digitalocean/godo/partner_interconnect_attachments.go b/vendor/github.com/digitalocean/godo/partner_interconnect_attachments.go index df21c9292..e0a439f7e 100644 --- a/vendor/github.com/digitalocean/godo/partner_interconnect_attachments.go +++ b/vendor/github.com/digitalocean/godo/partner_interconnect_attachments.go @@ -21,6 +21,8 @@ type PartnerInterconnectAttachmentsService interface { GetServiceKey(context.Context, string) (*ServiceKey, *Response, error) SetRoutes(context.Context, string, *PartnerInterconnectAttachmentSetRoutesRequest) (*PartnerInterconnectAttachment, *Response, error) ListRoutes(context.Context, string, *ListOptions) ([]*RemoteRoute, *Response, error) + GetBGPAuthKey(ctx context.Context, iaID string) (*BgpAuthKey, *Response, error) + RegenerateServiceKey(ctx context.Context, iaID string) (*RegenerateServiceKey, *Response, error) } var _ PartnerInterconnectAttachmentsService = &PartnerInterconnectAttachmentsServiceOp{} @@ -97,14 +99,16 @@ type BGP struct { // LocalRouterIP is the local router IP LocalRouterIP string `json:"local_router_ip,omitempty"` // PeerASN is the peer ASN - PeerASN int `json:"peer_asn,omitempty"` + PeerASN int `json:"peer_router_asn,omitempty"` // PeerRouterIP is the peer router IP PeerRouterIP string `json:"peer_router_ip,omitempty"` } // ServiceKey represents the service key of a Partner Interconnect Attachment. type ServiceKey struct { - ServiceKey string `json:"service_key,omitempty"` + Value string `json:"value,omitempty"` + State string `json:"state,omitempty"` + CreatedAt time.Time `json:"created_at,omitempty"` } // RemoteRoute represents a route for a Partner Interconnect Attachment. @@ -157,6 +161,21 @@ type remoteRoutesRoot struct { Meta *Meta `json:"meta"` } +type BgpAuthKey struct { + Value string `json:"value"` +} + +type bgpAuthKeyRoot struct { + BgpAuthKey *BgpAuthKey `json:"bgp_auth_key"` +} + +type RegenerateServiceKey struct { +} + +type regenerateServiceKeyRoot struct { + RegenerateServiceKey *RegenerateServiceKey `json:"-"` +} + // List returns a list of all Partner Interconnect Attachments, with optional pagination. func (s *PartnerInterconnectAttachmentsServiceOp) List(ctx context.Context, opt *ListOptions) ([]*PartnerInterconnectAttachment, *Response, error) { path, err := addOptions(partnerInterconnectAttachmentsBasePath, opt) @@ -308,3 +327,37 @@ func (s *PartnerInterconnectAttachmentsServiceOp) SetRoutes(ctx context.Context, return root.PartnerInterconnectAttachment, resp, nil } + +// GetBGPAuthKey returns Partner Interconnect Attachment bgp auth key +func (s *PartnerInterconnectAttachmentsServiceOp) GetBGPAuthKey(ctx context.Context, iaID string) (*BgpAuthKey, *Response, error) { + path := fmt.Sprintf("%s/%s/bgp_auth_key", partnerInterconnectAttachmentsBasePath, iaID) + req, err := s.client.NewRequest(ctx, http.MethodGet, path, nil) + if err != nil { + return nil, nil, err + } + + root := new(bgpAuthKeyRoot) + resp, err := s.client.Do(ctx, req, root) + if err != nil { + return nil, resp, err + } + + return root.BgpAuthKey, resp, nil +} + +// RegenerateServiceKey regenerates the service key of a Partner Interconnect Attachment. +func (s *PartnerInterconnectAttachmentsServiceOp) RegenerateServiceKey(ctx context.Context, iaID string) (*RegenerateServiceKey, *Response, error) { + path := fmt.Sprintf("%s/%s/service_key", partnerInterconnectAttachmentsBasePath, iaID) + req, err := s.client.NewRequest(ctx, http.MethodPost, path, nil) + if err != nil { + return nil, nil, err + } + + root := new(regenerateServiceKeyRoot) + resp, err := s.client.Do(ctx, req, root) + if err != nil { + return nil, resp, err + } + + return root.RegenerateServiceKey, resp, nil +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 4f4af1808..26ee6714d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -61,7 +61,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.136.0 +# github.com/digitalocean/godo v1.138.0 => github.com/guptado/godo v0.0.0-20250219083849-2f80d81d1f61 ## explicit; go 1.22 github.com/digitalocean/godo github.com/digitalocean/godo/metrics