Skip to content
This repository is currently being migrated. It's locked while the migration is in progress.

Commit

Permalink
Reconcile master (#196)
Browse files Browse the repository at this point in the history
* Merge pull request #102 in STORAGEOS/c2-cli from feature/FEED-186-alias-licence to master

Squashed commit of the following:

commit f97f9af02ff7136ef1066165e96bf6b63002259f
Author: Alex Vest <[email protected]>
Date:   Thu Nov 5 14:32:01 2020 +0000

    Adds license alias for licence command

* Merge pull request #103 in STORAGEOS/c2-cli from bugfix/CP-4569-diagnostics-invalid-character-u0080-looking-for-beginning-of-value-via-cli-when-a to master

Squashed commit of the following:

commit ecd57d0c58dc297e4f31f6fb11a9c7e8553f47de
Author: Fraser Savage <[email protected]>
Date:   Thu Jan 21 11:02:27 2021 +0000

    Support diagnostic bundle octet-stream for partial response

* Merge pull request #104 in STORAGEOS/c2-cli from feature/CP-4570-cli-use-.bin-extension-for-encrypted-bundles-in-get-diagnostics to master

Squashed commit of the following:

commit 554bee788904ea83a6b93f9f76104f70db98ecda
Author: Fraser Savage <[email protected]>
Date:   Thu Jan 21 15:27:55 2021 +0000

    get diagnostics: Use provided name if possible

commit 416e6580820238f694779840e50e0e016614eb8b
Author: Fraser Savage <[email protected]>
Date:   Thu Jan 21 15:10:55 2021 +0000

    diagnostics: Add BundleReadCloser extender, construct in apiclient

* Merge pull request #105 in STORAGEOS/c2-cli from feature/CP-4567-cli-support-setting-failure-mode-failure-threshold-behaviour to master

Squashed commit of the following:

commit 961874a95b5280b01073c7d4231a45cfd01ccaa9
Author: Fraser Savage <[email protected]>
Date:   Fri Jan 29 17:20:51 2021 +0000

    Update vendored openapi code for CP-4567

* Merge pull request #106 in STORAGEOS/c2-cli from feature/CP-4567-cli-support-setting-failure-mode-failure-threshold-behaviour to master

Squashed commit of the following:

commit 82d06f7184b488c2728b453b3d0cd5cd2ce7c810
Author: Fraser Savage <[email protected]>
Date:   Mon Feb 1 17:31:56 2021 +0000

    cmd/update: Add update volume failure-mode command

commit c900dfaaa604a1cfdeeefa005728d34c77ac2cda
Author: Fraser Savage <[email protected]>
Date:   Mon Feb 1 16:14:55 2021 +0000

    openapi: Implement SetFailureModeIntent/Threshold

commit 2d5cae713000776a6512121566328b5cb2336b21
Author: Fraser Savage <[email protected]>
Date:   Mon Feb 1 15:26:42 2021 +0000

    apiclient: Add SetFailureModeIntent/SetFailureThreshold

* Merge pull request #107 in STORAGEOS/c2-cli from feature/CP-4575-all-namespace-alias to master

Squashed commit of the following:

commit eb6ecf590f36984f624eace9bc26bdd2462879c5
Author: Alex Vest <[email protected]>
Date:   Tue Feb 2 17:31:44 2021 +0000

    Add logic to support describing volumes in all namespaces

commit 3289681e2b8305f4593999cc3944680cb6f9e056
Author: Alex Vest <[email protected]>
Date:   Tue Feb 2 17:31:03 2021 +0000

    Add allNamespaces field to volumeCommand

commit f8e6a06252614ee1ea4892e4128745cfe30fec6f
Author: Alex Vest <[email protected]>
Date:   Tue Feb 2 16:53:37 2021 +0000

    Add -A shorthand for --all-namespaces to get volume

* Merge pull request #108 in STORAGEOS/c2-cli from feature/CP-4571-diagnostics-support-single-node-bundle-collection to master

Squashed commit of the following:

commit 246a02468771ef60829c1c44011b20da7955a26b
Author: cachemoi <[email protected]>
Date:   Mon Feb 8 14:46:12 2021 +0000

    update comment

commit 46a06688988062799dbbe0a5f9b5471ad041627b
Author: cachemoi <[email protected]>
Date:   Mon Feb 8 14:30:34 2021 +0000

    support ids in get diagnostics

commit 72d31f281da9fa0fd100982d24f6e258da97ad6c
Author: cachemoi <[email protected]>
Date:   Wed Feb 3 16:18:50 2021 +0000

    support single node diagnostics fetching

* Merge pull request #110 in STORAGEOS/c2-cli from feature/CP-4280-node-labels-truncated to master

Squashed commit of the following:

commit 296a8bda1f1531fe036bccfb3c1b94ed77f6c241
Author: Fraser Savage <[email protected]>
Date:   Fri Feb 12 11:50:12 2021 +0000

    textoutput: Wrap for all resources, update unit tests to be friendlier

commit 3d2e93350cc244de8526fc1317399aa53c2ec344
Author: Alex Vest <[email protected]>
Date:   Thu Feb 11 17:20:25 2021 +0000

    Describe nodes formats labels on one line per label

    Labels are no longer truncated if they overflow the table width

* Merge pull request #112 in STORAGEOS/c2-cli from bugfix/CP-4612-cli-volume-label-examples-improvement to master

Squashed commit of the following:

commit a5db48c06ebddca2771baf639be1d11f80ed3600
Author: Ferran <[email protected]>
Date:   Fri Mar 5 09:11:00 2021 +0000

    Update volume labels help improvement

* Merge pull request #113 in STORAGEOS/c2-cli from feature/CP-4632-cli-make-sure-user-understand-that-updating-labels-action-can-be-reverted to master

Squashed commit of the following:

commit 1db950f580af992a846d8184753638d5d798bb72
Author: Maciej Galkowski <[email protected]>
Date:   Wed Apr 21 10:56:33 2021 +0100

    Silence the linters

commit 328b05f3fee8f7a1d7dca826cec7df730cc03b81
Author: Maciej Galkowski <[email protected]>
Date:   Tue Apr 20 13:12:07 2021 +0100

    CP-4632 add warnings about k8s overwriting the configuration from the CLI

    Kubernetes controller will now overwrite any flags that are not set in kubernetes
    chart. Any value set in the CLI that is conveyed via a label will be
    resetted the next time the label synchronisation process finishes.

    The user needs to pass in a required flag indicating that one understands that.

* Merge pull request #116 in STORAGEOS/c2-cli from feature/CP-4659-fix to master

Squashed commit of the following:

commit ab9ab54cd3ad955a8c5b1fd6a8e72b53b5c4a4c0
Author: Alex Vest <[email protected]>
Date:   Tue May 18 14:54:50 2021 +0100

    Add table wrap so describe volume lists volume labels

commit 758fa67938cd2e2299713cfdbb720f15ed5a7c4a
Author: Alex Vest <[email protected]>
Date:   Tue May 18 14:54:31 2021 +0100

    FEED-207

    Reorder volume fields in describe node to make it easier to copy/paste

* Merge pull request #117 in STORAGEOS/c2-cli from feature/CP-4660-remove-labels-from-get-nodes to master

Squashed commit of the following:

commit b871bccfe995852e6cbf2bb3602b4054357e4c58
Author: Alex Vest <[email protected]>
Date:   Tue May 18 19:48:52 2021 +0100

    remove labels from get nodes output in keeping with get of other resources

commit ab9ab54cd3ad955a8c5b1fd6a8e72b53b5c4a4c0
Author: Alex Vest <[email protected]>
Date:   Tue May 18 14:54:50 2021 +0100

    Add table wrap so describe volume lists volume labels

commit 758fa67938cd2e2299713cfdbb720f15ed5a7c4a
Author: Alex Vest <[email protected]>
Date:   Tue May 18 14:54:31 2021 +0100

    FEED-207

    Reorder volume fields in describe node to make it easier to copy/paste

* Merge pull request #115 in STORAGEOS/c2-cli from feature/CP-4522-add-cordon-command to master

Squashed commit of the following:

commit 3eed5792108fb2c8853dc2accd244e2b84037f19
Author: Joe Stephenson <[email protected]>
Date:   Fri Jun 4 15:38:52 2021 +0100

    fix example spacing + update example

commit fbe69c87ca4ce9b8a5468ec011026834a5a4a41d
Author: Joe Stephenson <[email protected]>
Date:   Tue Jun 1 14:52:47 2021 +0100

    test re-auth transport for SetCordoned

commit 3c3c63e4d1c25ad588605d622011429100f190a5
Author: Joe Stephenson <[email protected]>
Date:   Fri May 21 16:20:32 2021 +0100

    use ioutil.Discard (io.Discard is from go 1.16 onwards)

commit 461b1911027c35f5d5eaba38eccd49fd5badff30
Author: Joe Stephenson <[email protected]>
Date:   Fri May 21 16:02:20 2021 +0100

    lint

commit baf1a303fd3bb839a8862631ceff56c091ca0921
Author: Joe Stephenson <[email protected]>
Date:   Fri May 21 14:39:43 2021 +0100

    run go mod tidy

commit 4f37c22488dc392a2d51a880d87ced4e8f4d8020
Author: Joe Stephenson <[email protected]>
Date:   Fri May 21 14:25:48 2021 +0100

    display cordoned status on describe node command

commit 5008c1ee45c8c27a5ccc0902726ce47d54619bcf
Author: Joe Stephenson <[email protected]>
Date:   Fri May 21 14:22:00 2021 +0100

    regen openapi spec

commit f5b1d8a905e8496a2dfef6143b714a14ef20248a
Author: Joe Stephenson <[email protected]>
Date:   Tue May 4 11:51:31 2021 +0100

    vendor testify

commit dca784365546c28e74a2ce438b0ffc7552cea130
Author: Joe Stephenson <[email protected]>
Date:   Thu Apr 29 16:32:20 2021 +0100

    add uncordon tests

commit c01ba72caf3b09d0bc2a1de535fcd1270df7ffc3
Author: Joe Stephenson <[email protected]>
Date:   Thu Apr 29 15:42:31 2021 +0100

    implement cordon command tests

commit ed7e05aeca8304ac7b785a26a7fcae4c4ecb0976
Author: Joe Stephenson <[email protected]>
Date:   Thu Apr 29 15:34:17 2021 +0100

    allow logging to arbitary writers

commit d104f4e3f9048b72e49a4808a7caf694f5b02656
Author: Joe Stephenson <[email protected]>
Date:   Thu Apr 29 15:29:31 2021 +0100

    add testify

commit d20c7f534b6c50d232bf08f8625816af7d26a336
Author: Joe Stephenson <[email protected]>
Date:   Thu Apr 29 15:17:46 2021 +0100

    remove unused funcs

commit 52e820980143b0aa487cd9c2c55dfcfb3a1b4741
Author: Joe Stephenson <[email protected]>
Date:   Thu Apr 29 11:45:13 2021 +0100

    wip - add (un)cordon command

commit 3de3e3e8e1d3e81be091f3fb47c50eae6bb5bdbe
Author: Joe Stephenson <[email protected]>
Date:   Tue May 4 11:39:11 2021 +0100

    update vendor folder

commit def2e57a408e83b98b42d1447ae6e6be4a00ac32
Author: Joe Stephenson <[email protected]>
Date:   Wed Apr 28 15:32:22 2021 +0100

    regen openapi (with correct version)

* Merge pull request #120 in STORAGEOS/c2-cli from feature/CP-4522-add-show-cordoned-flag to master

Squashed commit of the following:

commit 6f174ac85e572910991866b284d35be92d6bf5ca
Author: Joe Stephenson <[email protected]>
Date:   Fri Jul 9 10:44:15 2021 +0100

    fix grammar

commit fa6ffd95b96b5dd2868e8f51e5f38f74e9b179fa
Author: Joe Stephenson <[email protected]>
Date:   Wed Jun 2 15:51:37 2021 +0100

    add show cordoned flag

* Merge pull request #121 in STORAGEOS/c2-cli from feature/CP-4678-add-cordonedat-field-to-the-c2-cli-take-2 to master

Squashed commit of the following:

commit 5eb4909
Author: Maciej Gałkowski <[email protected]>
Date:   Fri Jul 2 14:08:27 2021 +0100

    Merge pull request #119 in STORAGEOS/c2-cli from feature/CP-4678-add-cordonedat-field-to-the-c2-cli to feature/CP-4522-add-cordon-command

    Squashed commit of the following:

    commit fbb3dac4923ce3ed621415f95bcb34a8b3ee4bac
    Author: Maciej Galkowski <[email protected]>
    Date:   Fri Jul 2 12:03:31 2021 +0100

        Fix goimports

    commit 7008cdf4f1dea8a66d6967d9cc4c299d2884bed6
    Author: Maciej Galkowski <[email protected]>
    Date:   Thu Jun 10 14:53:13 2021 +0100

        Display the Cordoned at timestamp

    commit 6280365033a87a5a2b860584b2bd631b0596b1e9
    Author: Maciej Galkowski <[email protected]>
    Date:   Thu Jun 10 14:35:13 2021 +0100

        Regenerate the openapi code with the CordonedAt field

* Merge pull request #122 in STORAGEOS/c2-cli from feature/CP-4752-show-topology-domains to master

Squashed commit of the following:

commit 045b07cab098e43095d9b01bc9aab57f71d03cb3
Author: Joe Stephenson <[email protected]>
Date:   Thu Sep 23 15:30:01 2021 +0100

    n/a not unknown

commit 0eeab94786a49f4d8e033d88059e2c759d331ebb
Author: Joe Stephenson <[email protected]>
Date:   Wed Sep 22 10:33:01 2021 +0100

    vendor deps

commit 7d60871c0b8b5a27ccd5bd6e88d79eaf57ae16d7
Author: Joe Stephenson <[email protected]>
Date:   Tue Sep 21 17:01:37 2021 +0100

    use default values, show unknown if label is unset or empty when vol is topology-aware

commit 3b3fb2a70607722b6f719e8c8d5f5df2ad528e68
Author: Joe Stephenson <[email protected]>
Date:   Mon Sep 13 15:58:16 2021 +0100

    add describe test

commit c70733007a2ea8c6765e08cfc4e189db3021def2
Author: Joe Stephenson <[email protected]>
Date:   Mon Sep 13 15:44:56 2021 +0100

    volume describe - show deployments topology domains when topology aware label is set

Co-authored-by: Alex Vest <[email protected]>
Co-authored-by: Fraser Savage <[email protected]>
Co-authored-by: Max Bautzer <[email protected]>
Co-authored-by: Maciej Gałkowski <[email protected]>
Co-authored-by: Joe Stephenson <[email protected]>
  • Loading branch information
6 people authored Oct 21, 2021
1 parent 8dff2b5 commit c2230a8
Show file tree
Hide file tree
Showing 225 changed files with 16,216 additions and 1,462 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ bin/*
go.mod.md5
go.sum.md5
coverage.out
.DS_Store
c2-cli
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules

# version information
SEMANTIC_VERSION ?= "2.3.0"
SEMANTIC_VERSION ?= "2.4.0-alpha"

# build flags
LDFLAGS += -X main.Version=$(SEMANTIC_VERSION)
Expand Down
22 changes: 20 additions & 2 deletions apiclient/apiclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ package apiclient
import (
"context"
"errors"
"io"
"sync"

"code.storageos.net/storageos/c2-cli/cluster"
"code.storageos.net/storageos/c2-cli/diagnostics"
"code.storageos.net/storageos/c2-cli/licence"
"code.storageos.net/storageos/c2-cli/namespace"
"code.storageos.net/storageos/c2-cli/node"
Expand Down Expand Up @@ -66,7 +66,10 @@ type Transport interface {
GetNamespace(ctx context.Context, namespaceID id.Namespace) (*namespace.Resource, error)
// GetDiagnostics requests a new diagnostics bundle for the cluster
// from the StorageOS API.
GetDiagnostics(ctx context.Context) (io.ReadCloser, error)
GetDiagnostics(ctx context.Context) (*diagnostics.BundleReadCloser, error)
// GetSingleNodeDiagnostics requests a new single node diagnostics bundle for
// the cluster from the StorageOS API.
GetSingleNodeDiagnostics(ctx context.Context, nodeID id.Node) (*diagnostics.BundleReadCloser, error)
// GetPolicyGroup requests a new policy group resource which corresponds to
// uid from the StorageOS API.
GetPolicyGroup(ctx context.Context, uid id.PolicyGroup) (*policygroup.Resource, error)
Expand Down Expand Up @@ -129,6 +132,12 @@ type Transport interface {
// UpdateNFSVolumeMountEndpoint attempts to perform an update of the NFS
// mount endpoint for the specific volume.
UpdateNFSVolumeMountEndpoint(ctx context.Context, namespaceID id.Namespace, volumeID id.Volume, endpoint string, params *UpdateNFSVolumeMountEndpointRequestParams) error
// SetFailureModeIntent attempts to perform an update of the failure mode
// for the target volume to the provided intent-based behaviour.
SetFailureModeIntent(ctx context.Context, namespaceID id.Namespace, volumeID id.Volume, intent string, params *SetFailureModeRequestParams) (*volume.Resource, error)
// SetFailureThreshold attempts to perform an update of the failure mode
// for the target volume to the provided numerical threshold.
SetFailureThreshold(ctx context.Context, namespaceID id.Namespace, volumeID id.Volume, threshold uint64, params *SetFailureModeRequestParams) (*volume.Resource, error)

// DeleteVolume makes a delete request for volumeID in namespaceID.
//
Expand Down Expand Up @@ -209,6 +218,15 @@ type Transport interface {
// - If params.CASVersion is set, the request is conditional upon it
// matching the volume entity's version as seen by the server.
DetachVolume(ctx context.Context, namespaceID id.Namespace, volumeID id.Volume, params *DetachVolumeRequestParams) error
// SetCordoned sets a nodes cordoned state
// The behaviour of the operation is dictated by params:
//
// Version constraints:
// - If params is nil or params.CASVersion is empty then the cordon
// request is unconditional
// - If params.CASVersion is set, the request is conditional upon it
// matching the node entity's version as seen by the server.
SetCordoned(ctx context.Context, nodeID id.Node, params *SetCordonedRequestParams) error
}

// Client provides a collection of methods for consumers to interact with the
Expand Down
20 changes: 20 additions & 0 deletions apiclient/diagnostics.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package apiclient

import (
"context"

"code.storageos.net/storageos/c2-cli/diagnostics"
)

// GetSingleNodeDiagnosticsByName requests a local diagnostics bundle from the given
// node.
func (c *Client) GetSingleNodeDiagnosticsByName(ctx context.Context, name string) (*diagnostics.BundleReadCloser, error) {

node, err := c.GetNodeByName(ctx, name)
if err != nil {
return nil, err
}

return c.Transport.GetSingleNodeDiagnostics(ctx, node.ID)

}
17 changes: 9 additions & 8 deletions apiclient/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package apiclient

import (
"fmt"
"io"

"code.storageos.net/storageos/c2-cli/diagnostics"
)

// AuthenticationError indicates that the requested operation could not be
Expand Down Expand Up @@ -200,22 +201,22 @@ func NewEncodingError(err error, targetType, value interface{}) EncodingError {

// IncompleteDiagnosticsError provides an error type
type IncompleteDiagnosticsError struct {
bundleData io.ReadCloser
bundleReadCloser *diagnostics.BundleReadCloser
}

func (e IncompleteDiagnosticsError) Error() string {
return "received an incomplete diagnostic bundle"
}

// BundleData returns the read closer for the bundle data associated with the error.
func (e IncompleteDiagnosticsError) BundleData() io.ReadCloser {
return e.bundleData
// BundleReadCloser returns the read closer for the bundle data associated with the error.
func (e IncompleteDiagnosticsError) BundleReadCloser() *diagnostics.BundleReadCloser {
return e.bundleReadCloser
}

// NewIncompleteDiagnosticsError constructs an incomplete diagnostics error for
// the provided bundle data.
func NewIncompleteDiagnosticsError(bundleData io.ReadCloser) IncompleteDiagnosticsError {
// the provided bundle read closer.
func NewIncompleteDiagnosticsError(bundleReadCloser *diagnostics.BundleReadCloser) IncompleteDiagnosticsError {
return IncompleteDiagnosticsError{
bundleData: bundleData,
bundleReadCloser: bundleReadCloser,
}
}
53 changes: 50 additions & 3 deletions apiclient/mock_transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package apiclient

import (
"context"
"io"
"sync"

"code.storageos.net/storageos/c2-cli/cluster"
"code.storageos.net/storageos/c2-cli/diagnostics"
"code.storageos.net/storageos/c2-cli/licence"
"code.storageos.net/storageos/c2-cli/namespace"
"code.storageos.net/storageos/c2-cli/node"
Expand Down Expand Up @@ -37,9 +37,12 @@ type mockTransport struct {
GetUserResource *user.Resource
GetUserError error

GetDiagnosticsReadCloser io.ReadCloser
GetDiagnosticsReadCloser *diagnostics.BundleReadCloser
GetDiagnosticsError error

GetSingleNodeDiagnosticsReadCloser *diagnostics.BundleReadCloser
GetSingleNodeDiagnosticsError error

GetNodeGotID id.Node
GetNodeResource *node.Resource
GetNodeError error
Expand Down Expand Up @@ -143,6 +146,20 @@ type mockTransport struct {
UpdateNFSVolumeMountEndpointGotParams *UpdateNFSVolumeMountEndpointRequestParams
UpdateNFSVolumeMountEndpointError error

SetFailureModeIntentGotNamespaceID id.Namespace
SetFailureModeIntentGotVolumeID id.Volume
SetFailureModeIntentGotIntent string
SetFailureModeIntentGotParams *SetFailureModeRequestParams
SetFailureModeIntentResource *volume.Resource
SetFailureModeIntentError error

SetFailureThresholdGotNamespaceID id.Namespace
SetFailureThresholdGotVolumeID id.Volume
SetFailureThresholdGotThreshold uint64
SetFailureThresholdGotParams *SetFailureModeRequestParams
SetFailureThresholdResource *volume.Resource
SetFailureThresholdError error

DeleteUserGotID id.User
DeleteUserGotParams *DeleteUserRequestParams
DeleteUserError error
Expand Down Expand Up @@ -178,6 +195,10 @@ type mockTransport struct {
DetachGotVolume id.Volume
DetachGotParams *DetachVolumeRequestParams
DetachError error

SetCordonedGotParams *SetCordonedRequestParams
SetCordonedGotNode id.Node
SetCordonedErr error
}

var _ Transport = (*mockTransport)(nil)
Expand Down Expand Up @@ -210,10 +231,14 @@ func (m *mockTransport) ListUsers(ctx context.Context) ([]*user.Resource, error)
return m.ListUsersResource, m.ListUserError
}

func (m *mockTransport) GetDiagnostics(ctx context.Context) (io.ReadCloser, error) {
func (m *mockTransport) GetDiagnostics(ctx context.Context) (*diagnostics.BundleReadCloser, error) {
return m.GetDiagnosticsReadCloser, m.GetDiagnosticsError
}

func (m *mockTransport) GetSingleNodeDiagnostics(ctx context.Context, nodeID id.Node) (*diagnostics.BundleReadCloser, error) {
return m.GetSingleNodeDiagnosticsReadCloser, m.GetSingleNodeDiagnosticsError
}

func (m *mockTransport) GetNode(ctx context.Context, nodeID id.Node) (*node.Resource, error) {
m.GetNodeGotID = nodeID
return m.GetNodeResource, m.GetNodeError
Expand Down Expand Up @@ -332,6 +357,22 @@ func (m *mockTransport) UpdateNFSVolumeMountEndpoint(ctx context.Context, namesp
return m.UpdateNFSVolumeMountEndpointError
}

func (m *mockTransport) SetFailureModeIntent(ctx context.Context, namespaceID id.Namespace, volumeID id.Volume, intent string, params *SetFailureModeRequestParams) (*volume.Resource, error) {
m.SetFailureModeIntentGotNamespaceID = namespaceID
m.SetFailureModeIntentGotVolumeID = volumeID
m.SetFailureModeIntentGotIntent = intent
m.SetFailureModeIntentGotParams = params
return m.SetFailureModeIntentResource, m.SetFailureModeIntentError
}

func (m *mockTransport) SetFailureThreshold(ctx context.Context, namespaceID id.Namespace, volumeID id.Volume, threshold uint64, params *SetFailureModeRequestParams) (*volume.Resource, error) {
m.SetFailureThresholdGotNamespaceID = namespaceID
m.SetFailureThresholdGotVolumeID = volumeID
m.SetFailureThresholdGotThreshold = threshold
m.SetFailureThresholdGotParams = params
return m.SetFailureThresholdResource, m.SetFailureThresholdError
}

func (m *mockTransport) UpdateLicence(ctx context.Context, licence []byte, params *UpdateLicenceRequestParams) (*licence.Resource, error) {
m.UpdateLicenceGotLicence = licence
m.UpdateLicenceGotParams = params
Expand Down Expand Up @@ -389,3 +430,9 @@ func (m *mockTransport) DetachVolume(ctx context.Context, namespaceID id.Namespa
m.DetachGotParams = params
return m.DetachError
}

func (m *mockTransport) SetCordoned(ctx context.Context, nodeID id.Node, params *SetCordonedRequestParams) error {
m.SetCordonedGotNode = nodeID
m.SetCordonedGotParams = params
return m.SetCordonedErr
}
8 changes: 4 additions & 4 deletions apiclient/namespace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ func TestGetNamespaceByName(t *testing.T) {

transport: &mockTransport{
ListNamespacesResource: []*namespace.Resource{
&namespace.Resource{
{
Name: "possibly-dave",
},
&namespace.Resource{
{
Name: "definitely-steve",
},
},
Expand All @@ -48,10 +48,10 @@ func TestGetNamespaceByName(t *testing.T) {

transport: &mockTransport{
ListNamespacesResource: []*namespace.Resource{
&namespace.Resource{
{
Name: "possibly-dave",
},
&namespace.Resource{
{
Name: "not-steve",
},
},
Expand Down
20 changes: 18 additions & 2 deletions apiclient/no_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package apiclient

import (
"context"
"io"

"code.storageos.net/storageos/c2-cli/cluster"
"code.storageos.net/storageos/c2-cli/diagnostics"
"code.storageos.net/storageos/c2-cli/licence"
"code.storageos.net/storageos/c2-cli/namespace"
"code.storageos.net/storageos/c2-cli/node"
Expand Down Expand Up @@ -39,7 +39,11 @@ func (t *noTransport) GetLicence(ctx context.Context) (*licence.Resource, error)
return nil, ErrNoTransportConfigured
}

func (t *noTransport) GetDiagnostics(ctx context.Context) (io.ReadCloser, error) {
func (t *noTransport) GetDiagnostics(ctx context.Context) (*diagnostics.BundleReadCloser, error) {
return nil, ErrNoTransportConfigured
}

func (t *noTransport) GetSingleNodeDiagnostics(ctx context.Context, nodeID id.Node) (*diagnostics.BundleReadCloser, error) {
return nil, ErrNoTransportConfigured
}

Expand Down Expand Up @@ -127,6 +131,14 @@ func (t *noTransport) UpdateNFSVolumeMountEndpoint(ctx context.Context, namespac
return ErrNoTransportConfigured
}

func (t *noTransport) SetFailureModeIntent(ctx context.Context, namespaceID id.Namespace, volumeID id.Volume, intent string, params *SetFailureModeRequestParams) (*volume.Resource, error) {
return nil, ErrNoTransportConfigured
}

func (t *noTransport) SetFailureThreshold(ctx context.Context, namespaceID id.Namespace, volumeID id.Volume, threshold uint64, params *SetFailureModeRequestParams) (*volume.Resource, error) {
return nil, ErrNoTransportConfigured
}

func (t *noTransport) DeleteUser(ctx context.Context, uid id.User, params *DeleteUserRequestParams) error {
return ErrNoTransportConfigured
}
Expand Down Expand Up @@ -158,3 +170,7 @@ func (t *noTransport) AttachNFSVolume(ctx context.Context, namespaceID id.Namesp
func (t *noTransport) DetachVolume(ctx context.Context, namespaceID id.Namespace, volumeID id.Volume, params *DetachVolumeRequestParams) error {
return ErrNoTransportConfigured
}

func (t *noTransport) SetCordoned(ctx context.Context, nodeID id.Node, params *SetCordonedRequestParams) error {
return ErrNoTransportConfigured
}
7 changes: 7 additions & 0 deletions apiclient/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ type DeleteNodeRequestParams struct {
AsyncMax time.Duration
}

// SetCordonedRequestParams contains the required and optional parameteres
// for a set cordoned operation
type SetCordonedRequestParams struct {
Cordoned bool
CASVersion version.Version
}

// NodeNotFoundError indicates that the API could not find the StorageOS node
// specified.
type NodeNotFoundError struct {
Expand Down
Loading

0 comments on commit c2230a8

Please sign in to comment.