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
7 changes: 7 additions & 0 deletions bootstrap/api/v1beta1/rke2config_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,15 @@ func DefaultRKE2ConfigSpec(spec *RKE2ConfigSpec) {
}
}

var ignoredCloudInitFields = []string{"write_files", "ntp", "runcmd"}

// CorrectArbitraryData makes individual corrections to data and makes it YAML compliant.
func CorrectArbitraryData(arbitraryData map[string]string) error {
// Remove ignored fields from the map
for _, key := range ignoredCloudInitFields {
delete(arbitraryData, key)
}

// Make individual corrections to each value
for k, v := range arbitraryData {
b := bytes.Buffer{}
Expand Down
1 change: 0 additions & 1 deletion bootstrap/api/v1beta1/rke2config_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ func Test_correctArbitraryData(t *testing.T) {
},
want: map[string]string{
"bootcmd": "\n- touch /bootcmd.sentinel\n- echo 192.168.1.130 us.archive.ubuntu.com > /etc/hosts\n- - cloud-init-per\n - once\n - mymkfs\n - mkfs\n - /dev/vdb\n",
"ntp": "\n enabled: true\n ntp_client: chrony\n ",
"device_aliases:": "\n my_alias: /dev/sdb\n swap_disk: /dev/sdc\n ",
"resize_rootfs": "noblock",
"users": "\n- name: capv\n ssh_authorized_keys:\n - ssh-rsa ABCDEFGHIJKLMNOPQRSTUVWXYZ [email protected]\n - ssh-rsa ABCDEFGHIJKLMNOPQRSTUVWXYZ [email protected]\n sudo: ALL=(ALL) NOPASSWD:ALL\n",
Expand Down
2 changes: 2 additions & 0 deletions bootstrap/api/v1beta1/rke2configtemplate_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ func (r *RKE2ConfigTemplateCustomDefaulter) Default(_ context.Context, obj runti

rke2ConfigTemplateLogger.Info("defaulting", "RKE2ConfigTemplate", klog.KObj(rct))

DefaultRKE2ConfigSpec(&rct.Spec.Template.Spec)

return nil
}

Expand Down
5 changes: 0 additions & 5 deletions bootstrap/internal/cloudinit/cloudinit.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,6 @@ func cleanupAdditionalCloudInit(cloudInitData string) (string, error) {
}

func cleanupArbitraryData(arbitraryData map[string]string) error {
// Remove ignored fields from the map
for _, field := range ignoredCloudInitFields {
delete(arbitraryData, field)
}

if len(arbitraryData) == 0 {
return nil
}
Expand Down
1 change: 0 additions & 1 deletion bootstrap/internal/cloudinit/cloudinit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ runcmd:
arbitraryData = map[string]string{
"disk_setup": "\n ephemeral0:\n layout: false\n overwrite: false\n table_type: mbr\n ",
"device_aliases": "\n ephemeral0: /dev/vdb\n ",
"runcmd": "\n- print hello world\n",
"users": "\n- name: capv\n sudo: ALL=(ALL) NOPASSWD:ALL\n",
"list": "\n- data\n",
}
Expand Down
Loading