Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
7 changes: 5 additions & 2 deletions docs/stackit_beta_volume_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ stackit beta volume create [flags]
Create a volume with availability zone "eu01-1" and size 64 GB
$ stackit beta volume create --availability-zone eu01-1 --size 64

Create a volume with name "volume-1", source id "xxx" and type "image"
Create a volume with availability zone "eu01-1", size 64 GB and labels
$ stackit beta volume create --availability-zone eu01-1 --size 64 --labels key=value,foo=bar

Create a volume with name "volume-1", from a source image with ID "xxx"
$ stackit beta volume create --availability-zone eu01-1 --name volume-1 --source-id xxx --source-type image

Create a volume with availability zone "eu01-1", performance class "storage_premium_perf1" and size 64 GB
Expand All @@ -29,7 +32,7 @@ stackit beta volume create [flags]
--availability-zone string Availability zone
--description string Volume description
-h, --help Help for "stackit beta volume create"
--label stringToString Labels are key-value string pairs which can be attached to a volume. A label can be provided with the format key=value and the flag can be used multiple times to provide a list of labels (default [])
--labels stringToString Labels are key-value string pairs which can be attached to a volume. A label can be provided with the format key=value. To provide a list of labels, key=value pairs must be separated by commas(,) e.g. --labels key=value,foo=bar. (default [])
-n, --name string Volume name
--performance-class string Performance class
--size int Volume size (GB). Either 'size' or the 'source-id' and 'source-type' flags must be given
Expand Down
11 changes: 7 additions & 4 deletions docs/stackit_beta_volume_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@ stackit beta volume update [flags]

Update volume with ID "xxx" with new name "volume-1-new" and new description "volume-1-desc-new"
$ stackit beta volume update xxx --name volume-1-new --description volume-1-desc-new

Update volume with ID "xxx" with new name "volume-1-new", new description "volume-1-desc-new" and label(s)
$ stackit beta volume update xxx --name volume-1-new --description volume-1-desc-new --labels key=value,foo=bar
```

### Options

```
--description string Volume description
-h, --help Help for "stackit beta volume update"
--label stringToString Labels are key-value string pairs which can be attached to a volume. A label can be provided with the format key=value and the flag can be used multiple times to provide a list of labels (default [])
-n, --name string Volume name
--description string Volume description
-h, --help Help for "stackit beta volume update"
--labels stringToString Labels are key-value string pairs which can be attached to a volume. A label can be provided with the format key=value. To provide a list of labels, key=value pairs must be separated by commas(,) e.g. --labels key=value,foo=bar. (default [])
-n, --name string Volume name
```

### Options inherited from parent commands
Expand Down
8 changes: 6 additions & 2 deletions internal/cmd/beta/volume/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const (
availabilityZoneFlag = "availability-zone"
nameFlag = "name"
descriptionFlag = "description"
labelFlag = "label"
labelFlag = "labels"
performanceClassFlag = "performance-class"
sizeFlag = "size"
sourceIdFlag = "source-id"
Expand Down Expand Up @@ -56,6 +56,10 @@ func NewCmd(p *print.Printer) *cobra.Command {
`Create a volume with availability zone "eu01-1" and size 64 GB`,
`$ stackit beta volume create --availability-zone eu01-1 --size 64`,
),
examples.NewExample(
`Create a volume with availability zone "eu01-1", size 64 GB and labels`,
`$ stackit beta volume create --availability-zone eu01-1 --size 64 --labels key=value,foo=bar`,
),
examples.NewExample(
`Create a volume with name "volume-1", from a source image with ID "xxx"`,
`$ stackit beta volume create --availability-zone eu01-1 --name volume-1 --source-id xxx --source-type image`,
Expand Down Expand Up @@ -122,7 +126,7 @@ func configureFlags(cmd *cobra.Command) {
cmd.Flags().String(availabilityZoneFlag, "", "Availability zone")
cmd.Flags().StringP(nameFlag, "n", "", "Volume name")
cmd.Flags().String(descriptionFlag, "", "Volume description")
cmd.Flags().StringToString(labelFlag, nil, "Labels are key-value string pairs which can be attached to a volume. A label can be provided with the format key=value and the flag can be used multiple times to provide a list of labels")
cmd.Flags().StringToString(labelFlag, nil, "Labels are key-value string pairs which can be attached to a volume. A label can be provided with the format key=value. To provide a list of labels, key=value pairs must be separated by commas(,) e.g. --labels key=value,foo=bar.")
cmd.Flags().String(performanceClassFlag, "", "Performance class")
cmd.Flags().Int64(sizeFlag, 0, "Volume size (GB). Either 'size' or the 'source-id' and 'source-type' flags must be given")
cmd.Flags().String(sourceIdFlag, "", "ID of the source object of volume. Either 'size' or the 'source-id' and 'source-type' flags must be given")
Expand Down
9 changes: 9 additions & 0 deletions internal/cmd/beta/volume/describe/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"strings"

"github.com/goccy/go-yaml"

Expand Down Expand Up @@ -145,6 +146,14 @@ func outputResult(p *print.Printer, outputFormat string, volume *iaas.Volume) er
table.AddSeparator()
}

if volume.Labels != nil && len(*volume.Labels) > 0 {
labels := []string{}
for key, value := range *volume.Labels {
labels = append(labels, fmt.Sprintf("%s: %s", key, value))
}
table.AddRow("LABELS", strings.Join(labels, "\n"))
}

err := table.Display(p)
if err != nil {
return fmt.Errorf("render table: %w", err)
Expand Down
8 changes: 6 additions & 2 deletions internal/cmd/beta/volume/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (

nameFlag = "name"
descriptionFlag = "description"
labelFlag = "label"
labelFlag = "labels"
)

type inputModel struct {
Expand All @@ -51,6 +51,10 @@ func NewCmd(p *print.Printer) *cobra.Command {
`Update volume with ID "xxx" with new name "volume-1-new" and new description "volume-1-desc-new"`,
`$ stackit beta volume update xxx --name volume-1-new --description volume-1-desc-new`,
),
examples.NewExample(
`Update volume with ID "xxx" with new name "volume-1-new", new description "volume-1-desc-new" and label(s)`,
`$ stackit beta volume update xxx --name volume-1-new --description volume-1-desc-new --labels key=value,foo=bar`,
),
),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := context.Background()
Expand Down Expand Up @@ -96,7 +100,7 @@ func NewCmd(p *print.Printer) *cobra.Command {
func configureFlags(cmd *cobra.Command) {
cmd.Flags().StringP(nameFlag, "n", "", "Volume name")
cmd.Flags().String(descriptionFlag, "", "Volume description")
cmd.Flags().StringToString(labelFlag, nil, "Labels are key-value string pairs which can be attached to a volume. A label can be provided with the format key=value and the flag can be used multiple times to provide a list of labels")
cmd.Flags().StringToString(labelFlag, nil, "Labels are key-value string pairs which can be attached to a volume. A label can be provided with the format key=value. To provide a list of labels, key=value pairs must be separated by commas(,) e.g. --labels key=value,foo=bar.")
}

func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inputModel, error) {
Expand Down