This repository is currently being migrated. It's locked while the migration is in progress.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 in STORAGEOS/c2-cli from feature/CP-4170-descr…
…ibe-cluster to master Squashed commit of the following: commit 93fdc7b04f705655c26e80362548e461546f7b50 Author: Luciano Quercia <luciano.quercia@gmail.com> Date: Mon Mar 30 19:25:50 2020 +0100 rebased + GetAllNodes client function + textformat extensions for get cluster and describe cluster. commit 170b5697b34d08678ec420bf15d6ec93688f1663 Author: Luciano Quercia <luciano.quercia@gmail.com> Date: Thu Mar 26 15:53:33 2020 +0000 Display bools for Disable options commit 9e42a1a2587a4133d9cedbf762aa5d55fc358ce2 Author: Luciano Quercia <luciano.quercia@gmail.com> Date: Thu Mar 26 12:50:29 2020 +0000 storageos describe cluster
- Loading branch information
Showing
10 changed files
with
297 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package describe | ||
|
||
import ( | ||
"context" | ||
"io" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"code.storageos.net/storageos/c2-cli/cmd/argwrappers" | ||
"code.storageos.net/storageos/c2-cli/cmd/runwrappers" | ||
"code.storageos.net/storageos/c2-cli/output" | ||
) | ||
|
||
type clusterCommand struct { | ||
config ConfigProvider | ||
client Client | ||
display Displayer | ||
|
||
writer io.Writer | ||
} | ||
|
||
func (c *clusterCommand) runWithCtx(ctx context.Context, cmd *cobra.Command, args []string) error { | ||
cluster, err := c.client.GetCluster(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
nodes, err := c.client.GetAllNodes(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return c.display.DescribeCluster(ctx, c.writer, output.NewCluster(cluster, nodes)) | ||
} | ||
|
||
func newCluster(w io.Writer, client Client, config ConfigProvider) *cobra.Command { | ||
c := &clusterCommand{ | ||
config: config, | ||
client: client, | ||
writer: w, | ||
} | ||
|
||
cobraCommand := &cobra.Command{ | ||
Aliases: []string{"nodes"}, | ||
Use: "cluster", | ||
Short: "Retrieve detailed information for the current cluster", | ||
Example: ` | ||
$ storageos describe cluster | ||
`, | ||
|
||
PreRunE: argwrappers.WrapInvalidArgsError(func(_ *cobra.Command, args []string) error { | ||
c.display = SelectDisplayer(c.config) | ||
return nil | ||
}), | ||
|
||
RunE: func(cmd *cobra.Command, args []string) error { | ||
run := runwrappers.Chain( | ||
runwrappers.RunWithTimeout(c.config), | ||
)(c.runWithCtx) | ||
return run(context.Background(), cmd, args) | ||
}, | ||
|
||
SilenceUsage: true, | ||
} | ||
|
||
return cobraCommand | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.