diff --git a/docs/reference/manual/hcloud_primary-ip_create.md b/docs/reference/manual/hcloud_primary-ip_create.md index 4d0c6aa7c..4369b1db5 100644 --- a/docs/reference/manual/hcloud_primary-ip_create.md +++ b/docs/reference/manual/hcloud_primary-ip_create.md @@ -9,6 +9,14 @@ Create a Primary IP. The --datacenter flag is deprecated. Use --location or --assignee-id instead. See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters. +The --assignee-type flag will be required together with the --assignee-id flag. Using +the default value (server) for the --assignee-type flag is deprecated. Consider +explicitly setting the --assignee-type flag. + +See https://docs.hetzner.cloud/changelog#2026-04-27-primary-ips-will-return-unassigned +and https://docs.hetzner.cloud/changelog#2026-04-27-primary-ips-make-assignee_type-optional. + + ``` hcloud primary-ip create [options] --type --name ``` diff --git a/internal/cmd/primaryip/create.go b/internal/cmd/primaryip/create.go index ca9989e9a..2d2c16753 100644 --- a/internal/cmd/primaryip/create.go +++ b/internal/cmd/primaryip/create.go @@ -22,7 +22,15 @@ var CreateCmd = base.CreateCmd[*hcloud.PrimaryIP]{ Long: `Create a Primary IP. The --datacenter flag is deprecated. Use --location or --assignee-id instead. -See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters.`, +See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters. + +The --assignee-type flag will be required together with the --assignee-id flag. Using +the default value (server) for the --assignee-type flag is deprecated. Consider +explicitly setting the --assignee-type flag. + +See https://docs.hetzner.cloud/changelog#2026-04-27-primary-ips-will-return-unassigned +and https://docs.hetzner.cloud/changelog#2026-04-27-primary-ips-make-assignee_type-optional. +`, TraverseChildren: true, DisableFlagsInUseLine: true, } @@ -71,13 +79,22 @@ See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters.`, } createOpts := hcloud.PrimaryIPCreateOpts{ - Type: hcloud.PrimaryIPType(typ), - Name: name, - AssigneeType: assigneeType, - Labels: labels, + Type: hcloud.PrimaryIPType(typ), + Name: name, + Labels: labels, } if assigneeID != 0 { createOpts.AssigneeID = &assigneeID + if !cmd.Flags().Changed("assignee-type") { + cmd.PrintErrln( + "Warning: " + + "The --assignee-type flag will be required together " + + "with the --assignee-id flag and will no longer default " + + "to 'server'. Consider explicitly setting the " + + "--assignee-type flag.", + ) + } + createOpts.AssigneeType = assigneeType } if cmd.Flags().Changed("auto-delete") { createOpts.AutoDelete = &autoDelete diff --git a/internal/cmd/primaryip/create_test.go b/internal/cmd/primaryip/create_test.go index 2dff3cfc7..99b93141f 100644 --- a/internal/cmd/primaryip/create_test.go +++ b/internal/cmd/primaryip/create_test.go @@ -37,12 +37,11 @@ func TestCreate(t *testing.T) { Create( gomock.Any(), hcloud.PrimaryIPCreateOpts{ - Name: "my-ip", - Type: "ipv4", - Location: "fsn1", - Labels: map[string]string{"foo": "bar"}, - AssigneeType: "server", - AutoDelete: hcloud.Ptr(true), + Name: "my-ip", + Type: "ipv4", + Location: "fsn1", + Labels: map[string]string{"foo": "bar"}, + AutoDelete: hcloud.Ptr(true), }, ). Return( @@ -107,12 +106,11 @@ func TestCreateJSON(t *testing.T) { Create( gomock.Any(), hcloud.PrimaryIPCreateOpts{ - Name: "my-ip", - Type: "ipv4", - Location: "fsn1", - Labels: map[string]string{"foo": "bar"}, - AssigneeType: "server", - AutoDelete: hcloud.Ptr(true), + Name: "my-ip", + Type: "ipv4", + Location: "fsn1", + Labels: map[string]string{"foo": "bar"}, + AutoDelete: hcloud.Ptr(true), }, ). Return(