Skip to content
Merged
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
16 changes: 8 additions & 8 deletions docs/stackit_curl.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ stackit curl URL [flags]
### Examples

```
Make a GET request to http://locahost:8000
$ stackit curl http://locahost:8000
Get all the DNS zones for project with ID xxx via GET request to https://dns.api.stackit.cloud/v1/projects/xxx/zones
$ stackit curl https://dns.api.stackit.cloud/v1/projects/xxx/zones

Make a GET request to http://locahost:8000, write complete response (headers and body) to file "./output.txt"
$ stackit curl http://locahost:8000 -include --output ./output.txt
Get all the DNS zones for project with ID xxx via GET request to https://dns.api.stackit.cloud/v1/projects/xxx/zones, write complete response (headers and body) to file "./output.txt"
$ stackit curl https://dns.api.stackit.cloud/v1/projects/xxx/zones -include --output ./output.txt

Make a POST request to http://locahost:8000 with payload from file "./payload.json"
$ stackit curl http://locahost:8000 -X POST --data @./payload.json
Create a new DNS zone for project with ID xxx via POST request to https://dns.api.stackit.cloud/v1/projects/xxx/zones with payload from file "./payload.json"
$ stackit curl https://dns.api.stackit.cloud/v1/projects/xxx/zones -X POST --data @./payload.json

Make a POST request to http://locahost:8000 with header "Foo: Bar", fail if server returns error (such as 403 Forbidden)
$ stackit curl http://locahost:8000 -X POST -H "Foo: Bar" --fail
Get all the DNS zones for project with ID xxx via GET request to https://dns.api.stackit.cloud/v1/projects/xxx/zones, with header "Authorization: Bearer yyy", fail if server returns error (such as 403 Forbidden)
$ stackit curl https://dns.api.stackit.cloud/v1/projects/xxx/zones -X POST -H "Authorization: Bearer yyy" --fail
```

### Options
Expand Down
18 changes: 9 additions & 9 deletions internal/cmd/curl/curl.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,20 @@ func NewCmd() *cobra.Command {
Long: "Executes an HTTP request to an endpoint, using the authentication provided by the CLI.",
Example: examples.Build(
examples.NewExample(
"Make a GET request to http://locahost:8000",
"$ stackit curl http://locahost:8000",
"Get all the DNS zones for project with ID xxx via GET request to https://dns.api.stackit.cloud/v1/projects/xxx/zones",
"$ stackit curl https://dns.api.stackit.cloud/v1/projects/xxx/zones",
),
examples.NewExample(
`Make a GET request to http://locahost:8000, write complete response (headers and body) to file "./output.txt"`,
"$ stackit curl http://locahost:8000 -include --output ./output.txt",
`Get all the DNS zones for project with ID xxx via GET request to https://dns.api.stackit.cloud/v1/projects/xxx/zones, write complete response (headers and body) to file "./output.txt"`,
"$ stackit curl https://dns.api.stackit.cloud/v1/projects/xxx/zones -include --output ./output.txt",
),
examples.NewExample(
`Make a POST request to http://locahost:8000 with payload from file "./payload.json"`,
`$ stackit curl http://locahost:8000 -X POST --data @./payload.json`,
`Create a new DNS zone for project with ID xxx via POST request to https://dns.api.stackit.cloud/v1/projects/xxx/zones with payload from file "./payload.json"`,
`$ stackit curl https://dns.api.stackit.cloud/v1/projects/xxx/zones -X POST --data @./payload.json`,
),
examples.NewExample(
`Make a POST request to http://locahost:8000 with header "Foo: Bar", fail if server returns error (such as 403 Forbidden)`,
`$ stackit curl http://locahost:8000 -X POST -H "Foo: Bar" --fail`,
`Get all the DNS zones for project with ID xxx via GET request to https://dns.api.stackit.cloud/v1/projects/xxx/zones, with header "Authorization: Bearer yyy", fail if server returns error (such as 403 Forbidden)`,
`$ stackit curl https://dns.api.stackit.cloud/v1/projects/xxx/zones -X POST -H "Authorization: Bearer yyy" --fail`,
),
),
Args: args.SingleArg(urlArg, validateURL),
Expand Down Expand Up @@ -122,7 +122,7 @@ func validateURL(value string) error {
return fmt.Errorf("bad url")
}
if !strings.HasSuffix(urlHost, "stackit.cloud") {
return fmt.Errorf("only urls belonging to STACKIT are permitted")
return fmt.Errorf("only urls belonging to STACKIT are permitted, hostname must end in stackit.cloud")
}
return nil
}
Expand Down
9 changes: 9 additions & 0 deletions internal/cmd/ske/cluster/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"

"github.com/stackitcloud/stackit-cli/internal/pkg/args"
"github.com/stackitcloud/stackit-cli/internal/pkg/confirm"
"github.com/stackitcloud/stackit-cli/internal/pkg/errors"
"github.com/stackitcloud/stackit-cli/internal/pkg/examples"
"github.com/stackitcloud/stackit-cli/internal/pkg/flags"
Expand Down Expand Up @@ -67,6 +68,14 @@ func NewCmd() *cobra.Command {
return err
}

if !model.AssumeYes {
prompt := fmt.Sprintf("Are you sure you want to update cluster %s?", model.ClusterName)
err = confirm.PromptForConfirmation(cmd, prompt)
if err != nil {
return err
}
}

// Check if cluster exists
exists, err := skeUtils.ClusterExists(ctx, apiClient, model.ProjectId, model.ClusterName)
if err != nil {
Expand Down