Skip to content

Commit b823ff1

Browse files
committed
allow to set reverse DNS for cloudVMs
This allows to set a custom reverse DNS entry for cloud VMs.
1 parent 8c8375c commit b823ff1

File tree

7 files changed

+29
-2
lines changed

7 files changed

+29
-2
lines changed

create/cloudvm.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type cloudVMCmd struct {
2121
Location string `default:"nine-es34" help:"Location where the CloudVM instance is created."`
2222
MachineType string `default:"" help:"The machine type defines the sizing for a particular CloudVM."`
2323
Hostname string `default:"" help:"Hostname allows to set the hostname explicitly. If unset, the name of the resource will be used as the hostname. This does not affect the DNS name."`
24+
ReverseDNS string `default:"" help:"Allows to set the reverse DNS of the CloudVM"`
2425
PowerState string `default:"on" help:"Specify the initial power state of the CloudVM. Set to off to create "`
2526
OS string `default:"" help:"OS which should be used to boot the VM. Available options: ${cloudvm_os_flavors}"`
2627
BootDiskSize string `default:"20Gi" help:"Configures the size of the boot disk."`
@@ -90,6 +91,7 @@ func (cmd *cloudVMCmd) newCloudVM(namespace string) (*infrastructure.CloudVirtua
9091
OS: infrastructure.CloudVirtualMachineOS(infrastructure.OperatingSystem(cmd.OS)),
9192
PublicKeys: cmd.PublicKeys,
9293
CloudConfig: cmd.CloudConfig,
94+
ReverseDNS: cmd.ReverseDNS,
9395
},
9496
},
9597
}

create/cloudvm_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ func TestCloudVM(t *testing.T) {
4646
},
4747
},
4848
},
49+
{
50+
name: "reverseDNS",
51+
create: cloudVMCmd{ReverseDNS: "me.example.com"},
52+
want: infrastructure.CloudVirtualMachineParameters{
53+
ReverseDNS: "me.example.com",
54+
},
55+
},
4956
}
5057
for _, tt := range tests {
5158
t.Run(tt.name, func(t *testing.T) {

get/all_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ dev pear Release apps.nine.ch
5959
objects: []client.Object{testApplication("banana", "dev"), testRelease("pear", "dev")},
6060
outputFormat: yamlOut,
6161
projectName: "dev",
62-
output: "apiVersion: apps.nine.ch/v1alpha1\nkind: Application\nmetadata:\n creationTimestamp: null\n name: banana\n namespace: dev\nspec:\n forProvider:\n buildEnv: null\n config:\n env: null\n port: null\n replicas: null\n size: \"\"\n dockerfileBuild:\n enabled: false\n git:\n revision: \"\"\n subPath: \"\"\n url: \"\"\n paused: false\nstatus:\n atProvider:\n defaultURLs: null\n---\napiVersion: apps.nine.ch/v1alpha1\ncreationTimestampNano: 0\nkind: Release\nmetadata:\n creationTimestamp: null\n name: pear\n namespace: dev\nspec:\n forProvider:\n build:\n name: \"\"\n configuration:\n size:\n origin: \"\"\n value: \"\"\n defaultHosts: null\n image: {}\n paused: false\nstatus:\n atProvider:\n owning: false\n",
62+
output: "apiVersion: apps.nine.ch/v1alpha1\nkind: Application\nmetadata:\n creationTimestamp: null\n name: banana\n namespace: dev\nspec:\n forProvider:\n buildEnv: null\n config:\n env: null\n port: null\n replicas: null\n size: \"\"\n dockerfileBuild:\n enabled: false\n git:\n revision: \"\"\n subPath: \"\"\n url: \"\"\n paused: false\nstatus:\n atProvider:\n defaultURLs: null\n---\napiVersion: apps.nine.ch/v1alpha1\ncreationTimestampNano: 0\nkind: Release\nmetadata:\n creationTimestamp: null\n name: pear\n namespace: dev\nspec:\n forProvider:\n build:\n name: \"\"\n configuration:\n size:\n origin: \"\"\n value: \"\"\n defaultHosts: null\n healthProbeConfiguration: null\n image: {}\n paused: false\nstatus:\n atProvider:\n owning: false\n",
6363
},
6464
"all resources from one project, json format": {
6565
projects: test.Projects(organization, "dev", "staging", "prod"),
@@ -122,6 +122,7 @@ dev pear Release apps.nine.ch
122122
}
123123
},
124124
"defaultHosts": null,
125+
"healthProbeConfiguration": null,
125126
"image": {},
126127
"paused": false
127128
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ require (
2626
github.com/mattn/go-isatty v0.0.20
2727
github.com/moby/moby v28.3.3+incompatible
2828
github.com/moby/term v0.5.2
29-
github.com/ninech/apis v0.0.0-20250902105041-acc56447497c
29+
github.com/ninech/apis v0.0.0-20250916133613-3f07ca4fd6e4
3030
github.com/posener/complete v1.2.3
3131
github.com/prometheus/common v0.65.1-0.20250703115700-7f8b2a0d32d3
3232
github.com/stretchr/testify v1.10.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,8 @@ github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+
581581
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
582582
github.com/ninech/apis v0.0.0-20250902105041-acc56447497c h1:ygF81hx5V33abOM5B3OSy6t2hY4TqRtLh5wP2l+yPd4=
583583
github.com/ninech/apis v0.0.0-20250902105041-acc56447497c/go.mod h1:v9N/4IvFju6G/Qp6BPanKG+V6VYsTFiytZs2hktr3Yk=
584+
github.com/ninech/apis v0.0.0-20250916133613-3f07ca4fd6e4 h1:iajGOVRwtmDcMW+BgJo/rRQrjBy5bnqkBPCifWhJH/c=
585+
github.com/ninech/apis v0.0.0-20250916133613-3f07ca4fd6e4/go.mod h1:v9N/4IvFju6G/Qp6BPanKG+V6VYsTFiytZs2hktr3Yk=
584586
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
585587
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
586588
github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4=

update/cloudvm.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type cloudVMCmd struct {
1717
resourceCmd
1818
MachineType string `placeholder:"nine-standard-1" help:"The machine type defines the sizing for a particular CloudVM."`
1919
Hostname string `placeholder:"" help:"Hostname allows to set the hostname explicitly. If unset, the name of the resource will be used as the hostname. This does not affect the DNS name."`
20+
ReverseDNS string `placeholder:"" help:"Allows to set the reverse DNS of the CloudVM"`
2021
OS string `placeholder:"ubuntu22.04" help:"OS which should be used to boot the VM."`
2122
BootDiskSize string `placeholder:"20Gi" help:"Configures the size of the boot disk."`
2223
Disks map[string]string `placeholder:"{}" help:"Disks specifies which additional disks to mount to the machine."`
@@ -123,5 +124,9 @@ func (cmd *cloudVMCmd) applyUpdates(cloudVM *infrastructure.CloudVirtualMachine)
123124
}
124125
}
125126

127+
if cmd.ReverseDNS != "" {
128+
cloudVM.Spec.ForProvider.ReverseDNS = cmd.ReverseDNS
129+
}
130+
126131
return nil
127132
}

update/cloudvm_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ func TestCloudVM(t *testing.T) {
4040
PowerState: infrastructure.VirtualMachinePowerState("on"),
4141
},
4242
},
43+
{
44+
name: "set reverse DNS",
45+
create: infrastructure.CloudVirtualMachineParameters{
46+
ReverseDNS: "",
47+
},
48+
update: cloudVMCmd{ReverseDNS: "me.example.com"},
49+
want: infrastructure.CloudVirtualMachineParameters{
50+
ReverseDNS: "me.example.com",
51+
},
52+
},
4353
}
4454
for _, tt := range tests {
4555
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)