Skip to content

Commit

Permalink
Merge branch 'exoscale:master' into update-dns-v3
Browse files Browse the repository at this point in the history
  • Loading branch information
mlec1 authored Dec 28, 2024
2 parents 3cfa970 + 25ddea5 commit 5b19361
Show file tree
Hide file tree
Showing 106 changed files with 5,728 additions and 918 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ on:
- 'v[0-9]+\.[0-9]+\.[0-9]+'

jobs:
community-docs:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.EXOSCALE_BUILD_GH_TOKEN }}
steps:
- run: gh workflow run gen-cli.yaml -R exoscale/community-ng -f version=${{ github.ref_name }}
goreleaser:
runs-on: ubuntu-latest

Expand Down
40 changes: 39 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,45 @@
## Unreleased

### Features
- instance pool: added min-available flag to exo compute #629

- storage: Adding recursive feature to the storage command #653
- Update help for instance protection #658

## Unreleased

### Bug fixes
- instance update: fixing no err check after creating client #657

## 1.82.0

### Features
- dbaas: added commands for managing service users #654

### Bug fixes
- config: fixing bug sosEndpoint lost after user switch account #652

## 1.81.0

### Features

- Private Network: support for DHCP options (dns-server/ntp-server/router/domain-search) #644

### Improvements

- Private Network: related commands are migrated to egoscale v3
- refactor(iam-api-key): Update IAM API Key manipulation to egoscale v3 #643

### Bug fixes

- Storage: handle errors in batch objects delete action #627
- Instance: Fix instance protection flag update zone context #648
- Anti-affinity group: fix show command to print all the attached instances from different zones #649

## 1.80.0

### Features
- Instance pool: added min-available flag to exo compute #629
- dbaas: external endpoints and external integration commands and sub-commands

## 1.79.1

Expand Down
6 changes: 3 additions & 3 deletions bucket/exoscale-cli.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"version": "1.79.1",
"version": "1.82.0",
"architecture": {
"64bit": {
"url": "https://github.com/exoscale/cli/releases/download/v1.79.1/exoscale-cli_1.79.1_windows_amd64.zip",
"url": "https://github.com/exoscale/cli/releases/download/v1.82.0/exoscale-cli_1.82.0_windows_amd64.zip",
"bin": [
"exo.exe"
],
"hash": "c89a7d526925a37d55caa4a9c1ba04407b2e2e0cc1f2116693914f033cd104e8"
"hash": "14242db1eb79f07909989263e1d4f25ad9a862383c8d57da59dc3e34ed744e0d"
}
},
"homepage": "https://github.com/exoscale/cli",
Expand Down
42 changes: 28 additions & 14 deletions cmd/anti_affinity_group_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ import (

"github.com/spf13/cobra"

"github.com/exoscale/cli/pkg/account"
"github.com/exoscale/cli/pkg/globalstate"
"github.com/exoscale/cli/pkg/output"
"github.com/exoscale/cli/utils"
egoscale "github.com/exoscale/egoscale/v2"
exoapi "github.com/exoscale/egoscale/v2/api"
v3 "github.com/exoscale/egoscale/v3"
)

type antiAffinityGroupCreateCmd struct {
Expand Down Expand Up @@ -42,26 +39,43 @@ func (c *antiAffinityGroupCreateCmd) cmdPreRun(cmd *cobra.Command, args []string
}

func (c *antiAffinityGroupCreateCmd) cmdRun(_ *cobra.Command, _ []string) error {
zone := account.CurrentAccount.DefaultZone
ctx := gContext

ctx := exoapi.WithEndpoint(gContext, exoapi.NewReqEndpoint(account.CurrentAccount.Environment, zone))

antiAffinityGroup := &egoscale.AntiAffinityGroup{
Description: utils.NonEmptyStringPtr(c.Description),
Name: &c.Name,
antiAffinityGroupCreateRequest := v3.CreateAntiAffinityGroupRequest{
Description: c.Description,
Name: c.Name,
}

var err error
decorateAsyncOperation(fmt.Sprintf("Creating Anti-Affinity Group %q...", c.Name), func() {
antiAffinityGroup, err = globalstate.EgoscaleClient.CreateAntiAffinityGroup(ctx, zone, antiAffinityGroup)
err := decorateAsyncOperations(fmt.Sprintf("Creating Anti-Affinity Group %q...", c.Name), func() error {
op, err := globalstate.EgoscaleV3Client.CreateAntiAffinityGroup(ctx, antiAffinityGroupCreateRequest)
if err != nil {
return fmt.Errorf("exoscale: error while creating Anti Affinity Group: %w", err)
}

_, err = globalstate.EgoscaleV3Client.Wait(ctx, op, v3.OperationStateSuccess)
if err != nil {
return fmt.Errorf("exoscale: error while waiting for Anti Affinity Group creation: %w", err)
}

return nil
})
if err != nil {
return err
}

antiAffinityGroupsResp, err := globalstate.EgoscaleV3Client.ListAntiAffinityGroups(ctx)
if err != nil {
return err
}

antiAffinityGroup, err := antiAffinityGroupsResp.FindAntiAffinityGroup(c.Name)
if err != nil {
return err
}

return (&antiAffinityGroupShowCmd{
cliCommandSettings: c.cliCommandSettings,
AntiAffinityGroup: *antiAffinityGroup.ID,
AntiAffinityGroup: antiAffinityGroup.ID.String(),
}).cmdRun(nil, nil)
}

Expand Down
31 changes: 19 additions & 12 deletions cmd/anti_affinity_group_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import (

"github.com/spf13/cobra"

"github.com/exoscale/cli/pkg/account"
"github.com/exoscale/cli/pkg/globalstate"
exoapi "github.com/exoscale/egoscale/v2/api"
v3 "github.com/exoscale/egoscale/v3"
)

type antiAffinityGroupDeleteCmd struct {
Expand All @@ -33,11 +32,14 @@ func (c *antiAffinityGroupDeleteCmd) cmdPreRun(cmd *cobra.Command, args []string
}

func (c *antiAffinityGroupDeleteCmd) cmdRun(_ *cobra.Command, _ []string) error {
zone := account.CurrentAccount.DefaultZone
ctx := gContext

ctx := exoapi.WithEndpoint(gContext, exoapi.NewReqEndpoint(account.CurrentAccount.Environment, zone))
antiAffinityGroupsResp, err := globalstate.EgoscaleV3Client.ListAntiAffinityGroups(ctx)
if err != nil {
return err
}

antiAffinityGroup, err := globalstate.EgoscaleClient.FindAntiAffinityGroup(ctx, zone, c.AntiAffinityGroup)
antiAffinityGroup, err := antiAffinityGroupsResp.FindAntiAffinityGroup(c.AntiAffinityGroup)
if err != nil {
return err
}
Expand All @@ -51,14 +53,19 @@ func (c *antiAffinityGroupDeleteCmd) cmdRun(_ *cobra.Command, _ []string) error
}
}

decorateAsyncOperation(fmt.Sprintf("Deleting Anti-Affinity Group %s...", c.AntiAffinityGroup), func() {
err = globalstate.EgoscaleClient.DeleteAntiAffinityGroup(ctx, zone, antiAffinityGroup)
})
if err != nil {
return err
}
return decorateAsyncOperations(fmt.Sprintf("Deleting Anti-Affinity Group %s...", c.AntiAffinityGroup), func() error {
op, err := globalstate.EgoscaleV3Client.DeleteAntiAffinityGroup(ctx, antiAffinityGroup.ID)
if err != nil {
return fmt.Errorf("exoscale: error while deleting Anti Affinity Group: %w", err)
}

return nil
_, err = globalstate.EgoscaleV3Client.Wait(ctx, op, v3.OperationStateSuccess)
if err != nil {
return fmt.Errorf("exoscale: error while waiting for Anti Affinity Group deletion: %w", err)
}

return nil
})
}

func init() {
Expand Down
20 changes: 8 additions & 12 deletions cmd/anti_affinity_group_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ import (

"github.com/spf13/cobra"

"github.com/exoscale/cli/pkg/account"
"github.com/exoscale/cli/pkg/globalstate"
"github.com/exoscale/cli/pkg/output"
exoapi "github.com/exoscale/egoscale/v2/api"
v3 "github.com/exoscale/egoscale/v3"
)

type antiAffinityGroupListItemOutput struct {
ID string `json:"id"`
Name string `json:"name"`
ID v3.UUID `json:"id"`
Name string `json:"name"`
}

type antiAffinityGroupListOutput []antiAffinityGroupListItemOutput
Expand Down Expand Up @@ -45,22 +44,19 @@ func (c *antiAffinityGroupListCmd) cmdPreRun(cmd *cobra.Command, args []string)
}

func (c *antiAffinityGroupListCmd) cmdRun(_ *cobra.Command, _ []string) error {
ctx := exoapi.WithEndpoint(
gContext,
exoapi.NewReqEndpoint(account.CurrentAccount.Environment, account.CurrentAccount.DefaultZone),
)
ctx := gContext

antiAffinityGroups, err := globalstate.EgoscaleClient.ListAntiAffinityGroups(ctx, account.CurrentAccount.DefaultZone)
antiAffinityGroups, err := globalstate.EgoscaleV3Client.ListAntiAffinityGroups(ctx)
if err != nil {
return err
}

out := make(antiAffinityGroupListOutput, 0)

for _, t := range antiAffinityGroups {
for _, t := range antiAffinityGroups.AntiAffinityGroups {
out = append(out, antiAffinityGroupListItemOutput{
ID: *t.ID,
Name: *t.Name,
ID: t.ID,
Name: t.Name,
})
}

Expand Down
47 changes: 22 additions & 25 deletions cmd/anti_affinity_group_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@ package cmd

import (
"fmt"
"strings"

"github.com/spf13/cobra"

"github.com/exoscale/cli/pkg/account"
"github.com/exoscale/cli/pkg/globalstate"
"github.com/exoscale/cli/pkg/output"
"github.com/exoscale/cli/utils"
exoapi "github.com/exoscale/egoscale/v2/api"
v3 "github.com/exoscale/egoscale/v3"
"github.com/spf13/cobra"
"strings"
)

type antiAffinityGroupShowOutput struct {
ID string `json:"id"`
ID v3.UUID `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Instances []string `json:"instances"`
Expand Down Expand Up @@ -50,32 +46,33 @@ func (c *antiAffinityGroupShowCmd) cmdPreRun(cmd *cobra.Command, args []string)
}

func (c *antiAffinityGroupShowCmd) cmdRun(_ *cobra.Command, _ []string) error {
zone := account.CurrentAccount.DefaultZone
ctx := gContext

ctx := exoapi.WithEndpoint(gContext, exoapi.NewReqEndpoint(account.CurrentAccount.Environment, zone))

antiAffinityGroup, err := globalstate.EgoscaleClient.FindAntiAffinityGroup(ctx, zone, c.AntiAffinityGroup)
antiAffinityGroupsResp, err := globalstate.EgoscaleV3Client.ListAntiAffinityGroups(ctx)
if err != nil {
return err
return fmt.Errorf("unable to retrieve list of anti-affinity groups: %w", err)
}

antiAffinityGroup, err := antiAffinityGroupsResp.FindAntiAffinityGroup(c.AntiAffinityGroup)
if err != nil {
return fmt.Errorf("unable to find anti-affinity group %q: %w", c.AntiAffinityGroup, err)
}
out := antiAffinityGroupShowOutput{
ID: *antiAffinityGroup.ID,
Name: *antiAffinityGroup.Name,
Description: utils.DefaultString(antiAffinityGroup.Description, ""),
ID: antiAffinityGroup.ID,
Name: antiAffinityGroup.Name,
Description: antiAffinityGroup.Description,
}

if antiAffinityGroup.InstanceIDs != nil {
out.Instances = make([]string, len(*antiAffinityGroup.InstanceIDs))
for i, id := range *antiAffinityGroup.InstanceIDs {
instance, err := globalstate.EgoscaleClient.GetInstance(ctx, zone, id)
if err != nil {
return fmt.Errorf("unable to retrieve Compute instance %s: %w", id, err)
}
out.Instances[i] = *instance.Name
antiAffinityGroupWithInstanceDetails, err := globalstate.EgoscaleV3Client.GetAntiAffinityGroup(ctx, antiAffinityGroup.ID)
if err != nil {
return fmt.Errorf("unable to retrieve anti-affinity group with instance details %q: %w", c.AntiAffinityGroup, err)
}
if antiAffinityGroupWithInstanceDetails.Instances != nil {
out.Instances = make([]string, len(antiAffinityGroupWithInstanceDetails.Instances))
for i, instance := range antiAffinityGroupWithInstanceDetails.Instances {
out.Instances[i] = instance.ID.String()
}
}

return c.outputFunc(&out, nil)
}

Expand Down
3 changes: 3 additions & 0 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ func saveConfig(filePath string, newAccounts *account.Config) error {
if acc.Account != "" {
accounts[i]["account"] = acc.Account
}
if acc.SosEndpoint != "" {
accounts[i]["sosendpoint"] = acc.SosEndpoint
}
if len(acc.SecretCommand) != 0 {
accounts[i]["secretCommand"] = acc.SecretCommand
} else {
Expand Down
22 changes: 22 additions & 0 deletions cmd/dbaas.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

"github.com/exoscale/cli/pkg/globalstate"
"github.com/exoscale/cli/table"
v3 "github.com/exoscale/egoscale/v3"
)

var dbServiceMaintenanceDOWs = []string{
Expand Down Expand Up @@ -176,3 +177,24 @@ func dbaasGetType(ctx context.Context, name, zone string) (string, error) {

return "", fmt.Errorf("%q Database Service not found in zone %q", name, zone)
}

func dbaasGetV3(ctx context.Context, name, zone string) (v3.DBAASServiceCommon, error) {

client, err := switchClientZoneV3(ctx, globalstate.EgoscaleV3Client, v3.ZoneName(zone))
if err != nil {
return v3.DBAASServiceCommon{}, err
}

dbs, err := client.ListDBAASServices(ctx)
if err != nil {
return v3.DBAASServiceCommon{}, err
}

for _, db := range dbs.DBAASServices {
if string(db.Name) == name {
return db, nil
}
}

return v3.DBAASServiceCommon{}, fmt.Errorf("%q Database Service not found in zone %q", name, zone)
}
14 changes: 14 additions & 0 deletions cmd/dbaas_external_endpoint.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package cmd

import (
"github.com/spf13/cobra"
)

var dbaasExternalEndpointCmd = &cobra.Command{
Use: "external-endpoint",
Short: "Manage DBaaS external endpoints",
}

func init() {
dbaasCmd.AddCommand(dbaasExternalEndpointCmd)
}
Loading

0 comments on commit 5b19361

Please sign in to comment.