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
8 changes: 8 additions & 0 deletions docs/reference/manual/hcloud_primary-ip_create.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 22 additions & 5 deletions internal/cmd/primaryip/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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
Expand Down
22 changes: 10 additions & 12 deletions internal/cmd/primaryip/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
Loading