Skip to content
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

Add Support for objectstore_credentials_show.go #369

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions cmd/objectstore/objectstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func init() {
objectStoreCredentialCmd.AddCommand(objectStoreCredentialCreateCmd)
objectStoreCredentialCmd.AddCommand(objectStoreCredentialUpdateCmd)
objectStoreCredentialCmd.AddCommand(objectStoreCredentialDeleteCmd)
objectStoreCredentialCmd.AddCommand(objectStoreCredentialFindCmd)

//Flags for credential create command
objectStoreCredentialCreateCmd.Flags().BoolVarP(&waitOS, "wait", "w", false, "a simple flag (e.g. --wait) that will cause the CLI to spin and wait for the credential to be ready")
Expand Down
42 changes: 42 additions & 0 deletions cmd/objectstore/objectstore_credentials_show.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package objectstore

import (
"github.com/civo/cli/common"
"github.com/civo/cli/config"
"github.com/civo/cli/utility"
"github.com/spf13/cobra"
"os"
"strconv"
)

var objectStoreCredentialFindCmd = &cobra.Command{
Use: "show",
Aliases: []string{"get", "get"},
Example: `civo objectstore credential show `,
Short: "Displays an Object Store Credential",
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
client, err := config.CivoAPIClient()
if err != nil {
utility.Error("Creating the connection to Civo's API failed with %s", err)
os.Exit(1)
}

creds, err := client.GetObjectStoreCredential(args[0])
if err != nil {
utility.Error("ObjectStore Credentials %s", err)
os.Exit(1)
}

ow := utility.NewOutputWriterWithMap(map[string]string{"id": creds.ID, "name": creds.Name, "Access Key ID": creds.AccessKeyID, "Secret AccessKey ID": creds.SecretAccessKeyID, "Max Size GB": strconv.Itoa(creds.MaxSizeGB), "Suspended": strconv.FormatBool(creds.Suspended), "Status": creds.Status})

switch common.OutputFormat {
case "json":
ow.WriteSingleObjectJSON(common.PrettySet)
case "custom":
ow.WriteCustomOutput(common.OutputFields)
default:
ow.WriteTable()
}
},
}