From 88df89067216464258ebd7292f71f6d4bc3110dc Mon Sep 17 00:00:00 2001 From: Albertone Quentin Date: Fri, 18 Sep 2026 16:12:05 +0200 Subject: [PATCH 1/2] feat: allows labels + reverse dns at eip creation --- cmd/compute/elastic_ip/elastic_ip_create.go | 64 ++++++++++++++------- cmd/compute/elastic_ip/elastic_ip_show.go | 50 ++++++++++------ 2 files changed, 74 insertions(+), 40 deletions(-) diff --git a/cmd/compute/elastic_ip/elastic_ip_create.go b/cmd/compute/elastic_ip/elastic_ip_create.go index b8fad935a..0819687b8 100644 --- a/cmd/compute/elastic_ip/elastic_ip_create.go +++ b/cmd/compute/elastic_ip/elastic_ip_create.go @@ -18,18 +18,20 @@ type elasticIPCreateCmd struct { _ bool `cli-cmd:"create"` - Description string `cli-usage:"Elastic IP description"` - IPv6 bool `cli-flag:"ipv6" cli-usage:"create Elastic IPv6 prefix"` - HealthcheckInterval int64 `cli-usage:"managed Elastic IP health checking interval in seconds"` - HealthcheckMode string `cli-usage:"managed Elastic IP health checking mode (tcp|http|https)"` - HealthcheckPort int64 `cli-usage:"managed Elastic IP health checking port"` - HealthcheckStrikesFail int64 `cli-usage:"number of failed attempts before considering a managed Elastic IP health check unhealthy"` - HealthcheckStrikesOK int64 `cli-usage:"number of successful attempts before considering a managed Elastic IP health check healthy"` - HealthcheckTLSSNI string `cli-flag:"healthcheck-tls-sni" cli-usage:"managed Elastic IP health checking server name to present with SNI in https mode"` - HealthcheckTLSSSkipVerify bool `cli-flag:"healthcheck-tls-skip-verify" cli-usage:"disable TLS certificate verification for managed Elastic IP health checking in https mode"` - HealthcheckTimeout int64 `cli-usage:"managed Elastic IP health checking timeout in seconds"` - HealthcheckURI string `cli-usage:"managed Elastic IP health checking URI (required in http(s) mode)"` - Zone string `cli-short:"z" cli-usage:"Elastic IP zone"` + Description string `cli-usage:"Elastic IP description"` + IPv6 bool `cli-flag:"ipv6" cli-usage:"create Elastic IPv6 prefix"` + HealthcheckInterval int64 `cli-usage:"managed Elastic IP health checking interval in seconds"` + HealthcheckMode string `cli-usage:"managed Elastic IP health checking mode (tcp|http|https)"` + HealthcheckPort int64 `cli-usage:"managed Elastic IP health checking port"` + HealthcheckStrikesFail int64 `cli-usage:"number of failed attempts before considering a managed Elastic IP health check unhealthy"` + HealthcheckStrikesOK int64 `cli-usage:"number of successful attempts before considering a managed Elastic IP health check healthy"` + HealthcheckTLSSNI string `cli-flag:"healthcheck-tls-sni" cli-usage:"managed Elastic IP health checking server name to present with SNI in https mode"` + HealthcheckTLSSSkipVerify bool `cli-flag:"healthcheck-tls-skip-verify" cli-usage:"disable TLS certificate verification for managed Elastic IP health checking in https mode"` + HealthcheckTimeout int64 `cli-usage:"managed Elastic IP health checking timeout in seconds"` + HealthcheckURI string `cli-usage:"managed Elastic IP health checking URI (required in http(s) mode)"` + Zone string `cli-short:"z" cli-usage:"Elastic IP zone"` + Labels map[string]string `cli-flag:"label" cli-usage:"Elastic IP labels (format: key=value, ex: a=1,b=2)"` + ReverseDNS string `cli-flag:"reverse-dns" cli-usage:"Domain name for reverse DNS record."` } func (c *elasticIPCreateCmd) CmdAliases() []string { return exocmd.GCreateAlias } @@ -83,27 +85,45 @@ func (c *elasticIPCreateCmd) CmdRun(_ *cobra.Command, _ []string) error { elasticIP := v3.CreateElasticIPRequest{ Healthcheck: healthcheck, Description: c.Description, + Labels: c.Labels, } if c.IPv6 { elasticIP.Addressfamily = "inet6" } - op, err := client.CreateElasticIP(ctx, elasticIP) - if err != nil { - return err - } + var eipID v3.UUID + { + op, err := client.CreateElasticIP(ctx, elasticIP) + if err != nil { + return err + } - utils.DecorateAsyncOperation("Creating Elastic IP...", func() { - op, err = client.Wait(ctx, op, v3.OperationStateSuccess) - }) - if err != nil { - return err + utils.DecorateAsyncOperation("Creating Elastic IP...", func() { + op, err = client.Wait(ctx, op, v3.OperationStateSuccess) + }) + if err != nil { + return fmt.Errorf("unable to create elastic ip: %w", err) + } + eipID = op.Reference.ID + } + { + op, err := client.UpdateReverseDNSElasticIP( + ctx, + eipID, + v3.UpdateReverseDNSElasticIPRequest{DomainName: c.ReverseDNS}, + ) + utils.DecorateAsyncOperation("Updating Elastic IP reverse dns...", func() { + _, err = client.Wait(ctx, op, v3.OperationStateSuccess) + }) + if err != nil { + return fmt.Errorf("unable to update elastic ip reverse dns: %w", err) + } } return (&elasticIPShowCmd{ CliCommandSettings: c.CliCommandSettings, - ElasticIP: op.Reference.ID.String(), + ElasticIP: eipID.String(), Zone: c.Zone, }).CmdRun(nil, nil) } diff --git a/cmd/compute/elastic_ip/elastic_ip_show.go b/cmd/compute/elastic_ip/elastic_ip_show.go index 1015b0f2b..9fee47b36 100644 --- a/cmd/compute/elastic_ip/elastic_ip_show.go +++ b/cmd/compute/elastic_ip/elastic_ip_show.go @@ -18,24 +18,25 @@ import ( ) type elasticIPShowOutput struct { - ID string `json:"id"` - IPAddress string `json:"ip_address"` - AddressFamily string `json:"address_family"` - CIDR string `json:"cidr"` - Description string `json:"description"` - Zone string `json:"zone"` - Type string `json:"type"` - ReverseDNS string `json:"reverse_dns"` - Instances []string `json:"instances"` - HealthcheckMode string `json:"healthcheck_mode,omitempty"` - HealthcheckPort int64 `json:"healthcheck_port,omitempty"` - HealthcheckURI string `json:"healthcheck_uri,omitempty"` - HealthcheckInterval time.Duration `json:"healthcheck_interval,omitempty"` - HealthcheckTimeout time.Duration `json:"healthcheck_timeout,omitempty"` - HealthcheckStrikesOK int64 `json:"healthcheck_strikes_ok,omitempty"` - HealthcheckStrikesFail int64 `json:"healthcheck_strikes_fail,omitempty"` - HealthcheckTLSSNI string `json:"healthcheck_tls_sni,omitempty"` - HealthcheckTLSSkipVerify *bool `json:"healthcheck_tls_skip_verify,omitempty"` + ID string `json:"id"` + IPAddress string `json:"ip_address"` + AddressFamily string `json:"address_family"` + CIDR string `json:"cidr"` + Description string `json:"description"` + Zone string `json:"zone"` + Type string `json:"type"` + ReverseDNS string `json:"reverse_dns"` + Instances []string `json:"instances"` + HealthcheckMode string `json:"healthcheck_mode,omitempty"` + HealthcheckPort int64 `json:"healthcheck_port,omitempty"` + HealthcheckURI string `json:"healthcheck_uri,omitempty"` + HealthcheckInterval time.Duration `json:"healthcheck_interval,omitempty"` + HealthcheckTimeout time.Duration `json:"healthcheck_timeout,omitempty"` + HealthcheckStrikesOK int64 `json:"healthcheck_strikes_ok,omitempty"` + HealthcheckStrikesFail int64 `json:"healthcheck_strikes_fail,omitempty"` + HealthcheckTLSSNI string `json:"healthcheck_tls_sni,omitempty"` + HealthcheckTLSSkipVerify *bool `json:"healthcheck_tls_skip_verify,omitempty"` + Labels map[string]string `json:"labels"` } func (o *elasticIPShowOutput) ToJSON() { output.JSON(o) } @@ -75,6 +76,18 @@ func (o *elasticIPShowOutput) ToTable() { t.Append([]string{"Healthcheck TLS Skip Verification", fmt.Sprint(o.HealthcheckTLSSkipVerify)}) } } + + var labelsOutput string + if len(o.Labels) > 0 { + var labels []string + for k, v := range o.Labels { + labels = append(labels, fmt.Sprintf("%s:%s", k, v)) + } + labelsOutput = strings.Join(labels, "\n") + } else { + labelsOutput = "n/a" + } + t.Append([]string{"Labels", labelsOutput}) } type elasticIPShowCmd struct { @@ -133,6 +146,7 @@ func (c *elasticIPShowCmd) CmdRun(_ *cobra.Command, _ []string) error { Description: elasticIp.Description, Zone: c.Zone, Type: "manual", + Labels: elasticIp.Labels, } rdns, err := client.GetReverseDNSElasticIP(ctx, elasticIp.ID) From 335de7d3aa9eac873877248d6ac1fceeddc7975b Mon Sep 17 00:00:00 2001 From: Albertone Quentin Date: Fri, 18 Sep 2026 16:23:37 +0200 Subject: [PATCH 2/2] chore: update changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0508340fe..05befb996 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Features + +- EIP: allows labels + reverse dns at creation - #913 + ## 1.101.0 ### Breaking changes