Skip to content

Add Rotate CSI Credentials #691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

Unreleased
----------

- feature: SKS: add SKSCluster.RotateCSICredentials() method

3.1.15
------

Expand Down
9 changes: 9 additions & 0 deletions v2/client_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,15 @@
return args.Get(0).(*oapi.RotateSksCcmCredentialsResponse), args.Error(1)
}

func (m *oapiClientMock) RotateSksCsiCredentialsWithResponse(
ctx context.Context,
id string,
reqEditors ...oapi.RequestEditorFn,
) (*oapi.RotateSksCsiCredentialsResponse, error) {

Check failure on line 835 in v2/client_mock.go

View workflow job for this annotation

GitHub Actions / CI

undefined: oapi.RotateSksCsiCredentialsResponse

Check failure on line 835 in v2/client_mock.go

View workflow job for this annotation

GitHub Actions / CI

undefined: oapi.RotateSksCsiCredentialsResponse

Check failure on line 835 in v2/client_mock.go

View workflow job for this annotation

GitHub Actions / govulncheck

undefined: oapi.RotateSksCsiCredentialsResponse

Check failure on line 835 in v2/client_mock.go

View workflow job for this annotation

GitHub Actions / CI

undefined: oapi.RotateSksCsiCredentialsResponse

Check failure on line 835 in v2/client_mock.go

View workflow job for this annotation

GitHub Actions / CI

undefined: oapi.RotateSksCsiCredentialsResponse
args := m.Called(ctx, id, reqEditors)
return args.Get(0).(*oapi.RotateSksCsiCredentialsResponse), args.Error(1)

Check failure on line 837 in v2/client_mock.go

View workflow job for this annotation

GitHub Actions / CI

undefined: oapi.RotateSksCsiCredentialsResponse

Check failure on line 837 in v2/client_mock.go

View workflow job for this annotation

GitHub Actions / CI

undefined: oapi.RotateSksCsiCredentialsResponse

Check failure on line 837 in v2/client_mock.go

View workflow job for this annotation

GitHub Actions / govulncheck

undefined: oapi.RotateSksCsiCredentialsResponse

Check failure on line 837 in v2/client_mock.go

View workflow job for this annotation

GitHub Actions / CI

undefined: oapi.RotateSksCsiCredentialsResponse

Check failure on line 837 in v2/client_mock.go

View workflow job for this annotation

GitHub Actions / CI

undefined: oapi.RotateSksCsiCredentialsResponse
}

func (m *oapiClientMock) ScaleInstanceWithResponse(
ctx context.Context,
id string,
Expand Down
23 changes: 23 additions & 0 deletions v2/sks_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,29 @@
return nil
}

// RotateSKSClusterCSICredentials rotates the Exoscale IAM credentials managed by the SKS control plane for the
// Kubernetes Exoscale Container Storage Interface Addon.
func (c *Client) RotateSKSClusterCSICredentials(ctx context.Context, zone string, cluster *SKSCluster) error {
if err := validateOperationParams(cluster, "update"); err != nil {
return err
}

resp, err := c.RotateSksCsiCredentialsWithResponse(apiv2.WithZone(ctx, zone), *cluster.ID)

Check failure on line 427 in v2/sks_cluster.go

View workflow job for this annotation

GitHub Actions / CI

c.RotateSksCsiCredentialsWithResponse undefined (type *Client has no field or method RotateSksCsiCredentialsWithResponse) (compile)

Check failure on line 427 in v2/sks_cluster.go

View workflow job for this annotation

GitHub Actions / CI

c.RotateSksCsiCredentialsWithResponse undefined (type *Client has no field or method RotateSksCsiCredentialsWithResponse)

Check failure on line 427 in v2/sks_cluster.go

View workflow job for this annotation

GitHub Actions / govulncheck

c.RotateSksCsiCredentialsWithResponse undefined (type *Client has no field or method RotateSksCsiCredentialsWithResponse)

Check failure on line 427 in v2/sks_cluster.go

View workflow job for this annotation

GitHub Actions / CI

c.RotateSksCsiCredentialsWithResponse undefined (type *Client has no field or method RotateSksCsiCredentialsWithResponse) (compile)

Check failure on line 427 in v2/sks_cluster.go

View workflow job for this annotation

GitHub Actions / CI

c.RotateSksCsiCredentialsWithResponse undefined (type *Client has no field or method RotateSksCsiCredentialsWithResponse)
if err != nil {
return err
}

_, err = oapi.NewPoller().
WithTimeout(c.timeout).
WithInterval(c.pollInterval).
Poll(ctx, oapi.OperationPoller(c, zone, *resp.JSON200.Id))
if err != nil {
return err
}

return nil
}

// UpdateSKSCluster updates an SKS cluster.
func (c *Client) UpdateSKSCluster(ctx context.Context, zone string, cluster *SKSCluster) error {
if err := validateOperationParams(cluster, "update"); err != nil {
Expand Down
44 changes: 44 additions & 0 deletions v2/sks_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,50 @@
ts.Require().True(rotated)
}

func (ts *testSuite) TestClient_RotateSKSClusterCSICredentials() {
var (
testOperationID = ts.randomID()
testOperationState = oapi.OperationStateSuccess
rotated = false
)

cluster := &SKSCluster{
ID: &testSKSClusterID,
}

ts.mock().
On(
"RotateSksCsiCredentialsWithResponse",
mock.Anything, // ctx
mock.Anything, // id
([]oapi.RequestEditorFn)(nil), // reqEditors
).
Run(func(args mock.Arguments) {
ts.Require().Equal(testSKSClusterID, args.Get(1))
rotated = true
}).
Return(
&oapi.RotateSksCsiCredentialsResponse{

Check failure on line 669 in v2/sks_cluster_test.go

View workflow job for this annotation

GitHub Actions / CI

undefined: oapi.RotateSksCsiCredentialsResponse (compile)

Check failure on line 669 in v2/sks_cluster_test.go

View workflow job for this annotation

GitHub Actions / CI

undefined: oapi.RotateSksCsiCredentialsResponse (compile)
HTTPResponse: &http.Response{StatusCode: http.StatusOK},
JSON200: &oapi.Operation{
Id: &testOperationID,
Reference: oapi.NewReference(nil, &testSKSClusterID, nil),
State: &testOperationState,
},
},
nil,
)

ts.mockGetOperation(&oapi.Operation{
Id: &testOperationID,
Reference: oapi.NewReference(nil, &testSKSClusterID, nil),
State: &testOperationState,
})

ts.Require().NoError(ts.client.RotateSKSClusterCSICredentials(context.Background(), testZone, cluster))
ts.Require().True(rotated)
}

func (ts *testSuite) TestClient_UpdateSKSCluster() {
var (
testSKSClusterAutoUpgradeUpdated = false
Expand Down
22 changes: 22 additions & 0 deletions v3/generator/source.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5195,6 +5195,7 @@ components:
state:
type: string
enum:
- rotating-csi-credentials
- rotating-ccm-credentials
- creating
- upgrading
Expand Down Expand Up @@ -13764,6 +13765,27 @@ paths:
type: string
format: uuid
operationId: evict-instance-pool-members
"/sks-cluster/{id}/rotate-csi-credentials":
put:
tags:
- sks
responses:
'200':
description: '200'
content:
application/json:
schema:
"$ref": "#/components/schemas/operation"
description: ''
parameters:
- in: path
required: true
name: id
schema:
type: string
format: uuid
summary: Rotate Exoscale CSI credentials
operationId: rotate-sks-csi-credentials
"/dbaas-grafana/{service-name}/user/{username}/password/reset":
put:
tags:
Expand Down
44 changes: 44 additions & 0 deletions v3/operations.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions v3/schemas.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading