From ce93fd06dbeab0536adfaaa636bbba9d895d6364 Mon Sep 17 00:00:00 2001 From: Yaroslav Erokhin <43792992+yaroslaver@users.noreply.github.com> Date: Mon, 19 Feb 2024 17:57:42 +0300 Subject: [PATCH] Add userdata for create nodegroup operation (#73) * add userdata for create nodegroup operation * docs: expand the description of user data --- pkg/testutils/ptr.go | 5 +++++ pkg/v1/nodegroup/requests_opts.go | 3 +++ pkg/v1/nodegroup/testing/fixtures.go | 4 +++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/testutils/ptr.go b/pkg/testutils/ptr.go index 6dd7052..d99b0d7 100644 --- a/pkg/testutils/ptr.go +++ b/pkg/testutils/ptr.go @@ -9,3 +9,8 @@ func BoolToPtr(v bool) *bool { func IntToPtr(v int) *int { return &v } + +// StringToPtr can be used to convert string value to string pointer. +func StringToPtr(v string) *string { + return &v +} diff --git a/pkg/v1/nodegroup/requests_opts.go b/pkg/v1/nodegroup/requests_opts.go index cb79283..16d807d 100644 --- a/pkg/v1/nodegroup/requests_opts.go +++ b/pkg/v1/nodegroup/requests_opts.go @@ -53,6 +53,9 @@ type CreateOpts struct { // AutoscaleMaxNodes represents maximum possible number of worker nodes in the nodegroup. AutoscaleMaxNodes *int `json:"autoscale_max_nodes,omitempty"` + + // UserData represents base64 data which is used to pass a script that worker nodes run on boot. + UserData *string `json:"user_data,omitempty"` } // ResizeOpts represents options for the nodegroup Resize request. diff --git a/pkg/v1/nodegroup/testing/fixtures.go b/pkg/v1/nodegroup/testing/fixtures.go index c163801..694e35f 100644 --- a/pkg/v1/nodegroup/testing/fixtures.go +++ b/pkg/v1/nodegroup/testing/fixtures.go @@ -197,7 +197,8 @@ const testCreateNodegroupOptsRaw = ` ], "enable_autoscale": true, "autoscale_min_nodes": 1, - "autoscale_max_nodes": 10 + "autoscale_max_nodes": 10, + "user_data": "cGFja2FnZSBtYWluCgppbXBvcnQgImZtdCIKCmZ1bmMgbWFpbigpIHsKCWZtdC5QcmludGxuKCJIZWxsbyIpCn0=" } } ` @@ -224,6 +225,7 @@ var testCreateNodegroupOpts = &nodegroup.CreateOpts{ EnableAutoscale: testutils.BoolToPtr(true), AutoscaleMinNodes: testutils.IntToPtr(1), AutoscaleMaxNodes: testutils.IntToPtr(10), + UserData: testutils.StringToPtr("cGFja2FnZSBtYWluCgppbXBvcnQgImZtdCIKCmZ1bmMgbWFpbigpIHsKCWZtdC5QcmludGxuKCJIZWxsbyIpCn0="), } // testUpdateNodegroupOptsRaw represents marshalled options for the Update request.