Skip to content

Commit

Permalink
fix: completions for DNS if api url set to api.ionos.com (#330)
Browse files Browse the repository at this point in the history
* fix: completions for DNS if serverUrl set to api.ionos.com

* doc: update changelog

* refactor: remove redundant string trim calls
  • Loading branch information
avirtopeanu-ionos committed Jul 26, 2023
1 parent ca594d6 commit 288f076
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
## [v6.6.5] (July 2023)

### Fixed
* Changed `dataplatform cluster create --version` to 23.4 as 22.11 is no longer supported
* Changed default for `dataplatform cluster create --version` to 23.4 as 22.11 is no longer supported
* Fixed a bug for DNS completions regarding overriding the default value for `api-url`
* Fixed filters breaking for camelcase properties (e.g. `imageAlias`)
* Fixed missing filters for `RequestStatusMetadata` for command `request list` i.e. now you can also filter by `message, status`
* Removed the hardcoded `INTEL_SKYLAKE` value for `CPU_FAMILY` if creating a CUBE server. Now, by default for CUBE servers, this field is sent as nil to the API.
Expand Down
6 changes: 6 additions & 0 deletions commands/dns/record/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/gofrs/uuid/v5"
"github.com/ionos-cloud/ionosctl/v6/commands/dns/zone"
"github.com/ionos-cloud/ionosctl/v6/pkg/config"
"github.com/spf13/viper"

"github.com/ionos-cloud/ionosctl/v6/internal/functional"
Expand Down Expand Up @@ -118,6 +119,11 @@ func RecordsProperty[V any](f func(dns.RecordRead) V, fs ...Filter) []V {

// Records returns all records matching the given filters
func Records(fs ...Filter) (dns.RecordReadList, error) {
// Hack to enforce the dns-level flag default for API URL on the completions too
if url := config.GetServerUrl(); url == constants.DefaultApiURL {
viper.Set(constants.ArgServerUrl, "")
}

req := client.Must().DnsClient.RecordsApi.RecordsGet(context.Background())

for _, f := range fs {
Expand Down
7 changes: 7 additions & 0 deletions commands/dns/zone/zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import (
"github.com/gofrs/uuid/v5"
"github.com/ionos-cloud/ionosctl/v6/internal/client"
"github.com/ionos-cloud/ionosctl/v6/internal/functional"
"github.com/ionos-cloud/ionosctl/v6/pkg/config"
"github.com/ionos-cloud/ionosctl/v6/pkg/constants"
"github.com/ionos-cloud/ionosctl/v6/pkg/core"
"github.com/ionos-cloud/ionosctl/v6/pkg/printer"
dns "github.com/ionos-cloud/sdk-go-dns"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

func ZoneCommand() *core.Command {
Expand Down Expand Up @@ -101,6 +103,11 @@ func makeZonePrintObj(data ...dns.ZoneRead) []map[string]interface{} {

// Zones returns all zones matching the given filters
func Zones(fs ...Filter) (dns.ZoneReadList, error) {
// Hack to enforce the dns-level flag default for API URL on the completions too
if url := config.GetServerUrl(); url == constants.DefaultApiURL {
viper.Set(constants.ArgServerUrl, "")
}

req := client.Must().DnsClient.ZonesApi.ZonesGet(context.Background())

for _, f := range fs {
Expand Down

0 comments on commit 288f076

Please sign in to comment.