Skip to content

Commit

Permalink
chore(docs): add examples for storage commands
Browse files Browse the repository at this point in the history
  • Loading branch information
kamil cybulski committed Apr 20, 2021
1 parent ebb35fd commit c142c9a
Show file tree
Hide file tree
Showing 15 changed files with 83 additions and 20 deletions.
7 changes: 6 additions & 1 deletion internal/commands/serverstorage/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ type attachParams struct {
// AttachCommand creates the "server storage attach" command
func AttachCommand() commands.Command {
return &attachCommand{
BaseCommand: commands.New("attach", "Attach a storage as a device to a server", ""),
BaseCommand: commands.New(
"attach",
"Attach a storage as a device to a server",
"upctl server storage attach 00038afc-d526-4148-af0e-d2f1eeaded9b --storage 015899e0-0a68-4949-85bb-261a99de5fdd",
`upctl server storage attach my_server1 --storage "My Storage"`,
),
}
}

Expand Down
7 changes: 6 additions & 1 deletion internal/commands/serverstorage/detach.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ var defaultDetachParams = &detachParams{
// DetachCommand creates the "server storage detach" command
func DetachCommand() commands.Command {
return &detachCommand{
BaseCommand: commands.New("detach", "Detaches a storage resource from a server", ""),
BaseCommand: commands.New(
"detach",
"Detaches a storage resource from a server",
"upctl server storage detach 00038afc-d526-4148-af0e-d2f1eeaded9b --address virtio:1",
"upctl server storage detach my_server1 --address virtio:2",
),
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/commands/serverstorage/server_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const (

// BaseServerStorageCommand creates the base "server storage" command
func BaseServerStorageCommand() commands.Command {
return &serverStorageCommand{commands.New("storage", "Manage server storages", "")}
return &serverStorageCommand{commands.New("storage", "Manage server storages")}
}

type serverStorageCommand struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/storage/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import "github.com/UpCloudLtd/upcloud-cli/internal/commands"
// BackupCommand creates the "storage backup" command
func BackupCommand() commands.Command {
return &storageCommand{
commands.New("backup", "Manage backups", ""),
commands.New("backup", "Manage backups"),
}
}
7 changes: 6 additions & 1 deletion internal/commands/storage/backup_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ type createBackupParams struct {
// CreateBackupCommand creates the "storage backup create" command
func CreateBackupCommand() commands.Command {
return &createBackupCommand{
BaseCommand: commands.New("create", "Create backup of a storage", ""),
BaseCommand: commands.New(
"create",
"Create backup of a storage",
`upctl storage backup create 01cbea5e-eb5b-4072-b2ac-9b635120e5d8 --title "first backup"`,
`upctl storage backup create "My Storage" --title second_backup`,
),
}
}

Expand Down
7 changes: 6 additions & 1 deletion internal/commands/storage/backup_restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ type restoreBackupParams struct {
// RestoreBackupCommand creates the "storage backup restore" command
func RestoreBackupCommand() commands.Command {
return &restoreBackupCommand{
BaseCommand: commands.New("restore", "Restore backup of a storage", ""),
BaseCommand: commands.New(
"restore",
"Restore backup of a storage",
"upctl storage backup restore 01177c9e-7f76-4ce4-b128-bcaa3448f7ec",
`upctl storage backup restore second_backup`,
),
}
}

Expand Down
8 changes: 7 additions & 1 deletion internal/commands/storage/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ type cloneParams struct {
// CloneCommand creates the "storage clone" command
func CloneCommand() commands.Command {
return &cloneCommand{
BaseCommand: commands.New("clone", "Clone a storage", ""),
BaseCommand: commands.New(
"clone",
"Clone a storage",
"upctl storage clone 015899e0-0a68-4949-85bb-261a99de5fdd --title my_storage_clone --zone fi-hel1",
"upctl storage clone 015899e0-0a68-4949-85bb-261a99de5fdd --title my_storage_clone2 --zone pl-waw1 --tier maxiops",
`upctl storage clone "My Storage" --title my_storage_clone3 --zone pl-waw1 --tier maxiops`,
),
}
}

Expand Down
7 changes: 6 additions & 1 deletion internal/commands/storage/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ import (
// CreateCommand creates the "storage create" command
func CreateCommand() commands.Command {
return &createCommand{
BaseCommand: commands.New("create", "Create a storage", ""),
BaseCommand: commands.New(
"create",
"Create a storage",
`upctl storage create --zone pl-waw1 --title "My Storage"`,
"upctl storage create --zone pl-waw1 --title my_storage --size 20 --backup-interval wed --backup-retention 4",
),
}
}

Expand Down
8 changes: 7 additions & 1 deletion internal/commands/storage/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ import (
// DeleteCommand creates the "storage delete" command
func DeleteCommand() commands.Command {
return &deleteCommand{
BaseCommand: commands.New("delete", "Delete a storage", ""),
BaseCommand: commands.New(
"delete",
"Delete a storage",
"upctl storage delete 01ac5319-08ac-4e7b-81e5-3140d2bbd7d8",
"upctl storage delete 0175bb34-8aed-47ce-9290-10cc45f78601 01fcb78f-e73d-4e4d-af5a-0bd6cdba4306",
`upctl storage delete "My Storage"`,
),
}
}

Expand Down
9 changes: 5 additions & 4 deletions internal/commands/storage/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ package storage
import (
"errors"
"fmt"
"github.com/UpCloudLtd/upcloud-cli/internal/resolver"
"github.com/UpCloudLtd/upcloud-cli/internal/ui"
"github.com/UpCloudLtd/upcloud-go-api/upcloud/request"
"io"
"net/url"
"os"
"path/filepath"
"sync/atomic"
"time"

"github.com/UpCloudLtd/upcloud-cli/internal/resolver"
"github.com/UpCloudLtd/upcloud-cli/internal/ui"
"github.com/UpCloudLtd/upcloud-go-api/upcloud/request"

"github.com/UpCloudLtd/upcloud-cli/internal/commands"
"github.com/UpCloudLtd/upcloud-cli/internal/output"

Expand All @@ -26,7 +27,7 @@ func ImportCommand() commands.Command {
BaseCommand: commands.New(
"import",
"Import a storage from external or local source",
"",
// TODO: Add examples
),
createParams: newCreateParams(),
}
Expand Down
7 changes: 6 additions & 1 deletion internal/commands/storage/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ import (
// ListCommand creates the "storage list" command
func ListCommand() commands.Command {
return &listCommand{
BaseCommand: commands.New("list", "List current storages", ""),
BaseCommand: commands.New(
"list",
"List current storages",
"upctl storage list",
"upctl storage list --all",
),
}
}

Expand Down
11 changes: 9 additions & 2 deletions internal/commands/storage/modify.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@ package storage

import (
"fmt"

"github.com/UpCloudLtd/upcloud-cli/internal/resolver"

"github.com/UpCloudLtd/upcloud-cli/internal/commands"
"github.com/UpCloudLtd/upcloud-cli/internal/completion"
"github.com/UpCloudLtd/upcloud-cli/internal/output"
"github.com/UpCloudLtd/upcloud-cli/internal/ui"

"time"

"github.com/UpCloudLtd/upcloud-go-api/upcloud"
"github.com/UpCloudLtd/upcloud-go-api/upcloud/request"
"github.com/UpCloudLtd/upcloud-go-api/upcloud/service"
"github.com/spf13/pflag"
"time"
)

type modifyCommand struct {
Expand Down Expand Up @@ -42,7 +44,12 @@ var defaultBackupRuleParams = upcloud.BackupRule{
// ModifyCommand creates the "storage modify" command
func ModifyCommand() commands.Command {
return &modifyCommand{
BaseCommand: commands.New("modify", "Modify a storage", ""),
BaseCommand: commands.New(
"modify",
"Modify a storage",
`upctl storage modify 01271548-2e92-44bb-9774-d282508cc762 --title "My Storage" --size 20`,
`upctl storage modify "My Storage" --size 25`,
),
}
}

Expand Down
11 changes: 9 additions & 2 deletions internal/commands/storage/show.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
package storage

import (
"strings"

"github.com/UpCloudLtd/upcloud-cli/internal/commands"
"github.com/UpCloudLtd/upcloud-cli/internal/completion"
"github.com/UpCloudLtd/upcloud-cli/internal/output"
"github.com/UpCloudLtd/upcloud-cli/internal/resolver"
"github.com/UpCloudLtd/upcloud-cli/internal/ui"
"strings"

"github.com/UpCloudLtd/upcloud-go-api/upcloud/request"
)

// ShowCommand creates the "storage show" command
func ShowCommand() commands.Command {
return &showCommand{
BaseCommand: commands.New("show", "Show storage details", ""),
BaseCommand: commands.New(
"show",
"Show storage details",
"upctl storage show 01271548-2e92-44bb-9774-d282508cc762",
"upctl storage show 01271548-2e92-44bb-9774-d282508cc762 01c60190-3a01-4108-b1c3-2e828855ccc0",
`upctl storage show "My Storage"`,
),
}
}

Expand Down
3 changes: 2 additions & 1 deletion internal/commands/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package storage

import (
"fmt"

"github.com/UpCloudLtd/upcloud-go-api/upcloud"
"github.com/UpCloudLtd/upcloud-go-api/upcloud/request"
"github.com/UpCloudLtd/upcloud-go-api/upcloud/service"
Expand All @@ -19,7 +20,7 @@ var (
// BaseStorageCommand creates the base "storage" command
func BaseStorageCommand() commands.Command {
return &storageCommand{
commands.New("storage", "Manage storages", ""),
commands.New("storage", "Manage storages"),
}
}

Expand Down
7 changes: 6 additions & 1 deletion internal/commands/storage/templatize.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ type templatizeParams struct {
// TODO: figure out consistent naming, one way or the other.
func TemplatizeCommand() commands.Command {
return &templatizeCommand{
BaseCommand: commands.New("templatise", "Templatise a storage", ""),
BaseCommand: commands.New(
"templatise",
"Templatise a storage",
`upctl storage templatise 01271548-2e92-44bb-9774-d282508cc762 --title "My Template"`,
`upctl storage templatise "My Storage" --title super_template`,
),
}
}

Expand Down

0 comments on commit c142c9a

Please sign in to comment.