Skip to content

Commit 60ddebf

Browse files
authored
Merge branch 'main' into kms-beta
2 parents 070d21d + a2d59a5 commit 60ddebf

File tree

7 files changed

+415
-9
lines changed

7 files changed

+415
-9
lines changed

.github/workflows/renovate.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Checkout
1414
uses: actions/checkout@v5
1515
- name: Self-hosted Renovate
16-
uses: renovatebot/github-action@v43.0.12
16+
uses: renovatebot/github-action@v43.0.13
1717
with:
1818
configurationFile: .github/renovate.json
1919
token: ${{ secrets.RENOVATE_TOKEN }}

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ require (
4343
)
4444

4545
require (
46-
golang.org/x/net v0.43.0 // indirect
46+
golang.org/x/net v0.44.0 // indirect
4747
golang.org/x/time v0.11.0 // indirect
4848
gopkg.in/inf.v0 v0.9.1 // indirect
4949
)
@@ -209,7 +209,8 @@ require (
209209
go.yaml.in/yaml/v3 v3.0.4 // indirect
210210
golang.org/x/exp/typeparams v0.0.0-20250210185358-939b2ce775ac // indirect
211211
golang.org/x/sync v0.17.0 // indirect
212-
golang.org/x/tools v0.36.0 // indirect
212+
golang.org/x/telemetry v0.0.0-20250908211612-aef8a434d053 // indirect
213+
golang.org/x/tools v0.37.0 // indirect
213214
golang.org/x/tools/go/expect v0.1.1-deprecated // indirect
214215
golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated // indirect
215216
google.golang.org/protobuf v1.36.6 // indirect

go.sum

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -799,8 +799,8 @@ golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
799799
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
800800
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
801801
golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
802-
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
803-
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
802+
golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I=
803+
golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY=
804804
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
805805
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
806806
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -879,6 +879,8 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
879879
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
880880
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
881881
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
882+
golang.org/x/telemetry v0.0.0-20250908211612-aef8a434d053 h1:dHQOQddU4YHS5gY33/6klKjq7Gp3WwMyOXGNp5nzRj8=
883+
golang.org/x/telemetry v0.0.0-20250908211612-aef8a434d053/go.mod h1:+nZKN+XVh4LCiA9DV3ywrzN4gumyCnKjau3NGb9SGoE=
882884
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
883885
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
884886
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
@@ -966,8 +968,8 @@ golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
966968
golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s=
967969
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
968970
golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg=
969-
golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg=
970-
golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s=
971+
golang.org/x/tools v0.37.0 h1:DVSRzp7FwePZW356yEAChSdNcQo6Nsp+fex1SUW09lE=
972+
golang.org/x/tools v0.37.0/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w=
971973
golang.org/x/tools/go/expect v0.1.1-deprecated h1:jpBZDwmgPhXsKZC6WhL20P4b/wmnpsEAGHaNy0n/rJM=
972974
golang.org/x/tools/go/expect v0.1.1-deprecated/go.mod h1:eihoPOH+FgIqa3FpoTwguz/bVUSGBlGQU67vpBeOrBY=
973975
golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated h1:1h2MnaIAIXISqTFKdENegdpAgUXz6NrPEsbIeWaBRvM=

internal/cmd/server/describe/describe.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,12 @@ func outputResult(p *print.Printer, outputFormat string, server *iaas.Server) er
118118

119119
return nil
120120
case print.YAMLOutputFormat:
121-
details, err := yaml.MarshalWithOptions(server, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
121+
// This is a temporary workaround to get the desired base64 encoded yaml output for userdata
122+
// and will be replaced by a fix in the Go-SDK
123+
// ref: https://jira.schwarz/browse/STACKITSDK-246
124+
patchedServer := utils.ConvertToBase64PatchedServer(server)
125+
126+
details, err := yaml.MarshalWithOptions(patchedServer, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
122127
if err != nil {
123128
return fmt.Errorf("marshal server: %w", err)
124129
}

internal/cmd/server/list/list.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,12 @@ func outputResult(p *print.Printer, outputFormat string, servers []iaas.Server)
158158

159159
return nil
160160
case print.YAMLOutputFormat:
161-
details, err := yaml.MarshalWithOptions(servers, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
161+
// This is a temporary workaround to get the desired base64 encoded yaml output for userdata
162+
// and will be replaced by a fix in the Go-SDK
163+
// ref: https://jira.schwarz/browse/STACKITSDK-246
164+
patchedServers := utils.ConvertToBase64PatchedServers(servers)
165+
166+
details, err := yaml.MarshalWithOptions(patchedServers, yaml.IndentSequence(true), yaml.UseJSONMarshaler())
162167
if err != nil {
163168
return fmt.Errorf("marshal server: %w", err)
164169
}

internal/pkg/utils/utils.go

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/spf13/viper"
1414
"github.com/stackitcloud/stackit-cli/internal/pkg/config"
1515
sdkConfig "github.com/stackitcloud/stackit-sdk-go/core/config"
16+
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
1617
)
1718

1819
// Ptr Returns the pointer to any type T
@@ -153,3 +154,99 @@ func ConvertStringMapToInterfaceMap(m *map[string]string) *map[string]interface{
153154
}
154155
return &result
155156
}
157+
158+
// Base64Bytes implements yaml.Marshaler to convert []byte to base64 strings
159+
// ref: https://carlosbecker.com/posts/go-custom-marshaling
160+
type Base64Bytes []byte
161+
162+
// MarshalYAML implements yaml.Marshaler
163+
func (b Base64Bytes) MarshalYAML() (interface{}, error) {
164+
if len(b) == 0 {
165+
return "", nil
166+
}
167+
return base64.StdEncoding.EncodeToString(b), nil
168+
}
169+
170+
type Base64PatchedServer struct {
171+
Id *string `json:"id,omitempty"`
172+
Name *string `json:"name,omitempty"`
173+
Status *string `json:"status,omitempty"`
174+
AvailabilityZone *string `json:"availabilityZone,omitempty"`
175+
BootVolume *iaas.CreateServerPayloadBootVolume `json:"bootVolume,omitempty"`
176+
CreatedAt *time.Time `json:"createdAt,omitempty"`
177+
ErrorMessage *string `json:"errorMessage,omitempty"`
178+
PowerStatus *string `json:"powerStatus,omitempty"`
179+
AffinityGroup *string `json:"affinityGroup,omitempty"`
180+
ImageId *string `json:"imageId,omitempty"`
181+
KeypairName *string `json:"keypairName,omitempty"`
182+
MachineType *string `json:"machineType,omitempty"`
183+
Labels *map[string]interface{} `json:"labels,omitempty"`
184+
LaunchedAt *time.Time `json:"launchedAt,omitempty"`
185+
MaintenanceWindow *iaas.ServerMaintenance `json:"maintenanceWindow,omitempty"`
186+
Metadata *map[string]interface{} `json:"metadata,omitempty"`
187+
Networking *iaas.CreateServerPayloadNetworking `json:"networking,omitempty"`
188+
Nics *[]iaas.ServerNetwork `json:"nics,omitempty"`
189+
SecurityGroups *[]string `json:"securityGroups,omitempty"`
190+
ServiceAccountMails *[]string `json:"serviceAccountMails,omitempty"`
191+
UpdatedAt *time.Time `json:"updatedAt,omitempty"`
192+
UserData *Base64Bytes `json:"userData,omitempty"`
193+
Volumes *[]string `json:"volumes,omitempty"`
194+
}
195+
196+
// ConvertToBase64PatchedServer converts an iaas.Server to Base64PatchedServer
197+
// This is a temporary workaround to get the desired base64 encoded yaml output for userdata
198+
// and will be replaced by a fix in the Go-SDK
199+
// ref: https://jira.schwarz/browse/STACKITSDK-246
200+
func ConvertToBase64PatchedServer(server *iaas.Server) *Base64PatchedServer {
201+
if server == nil {
202+
return nil
203+
}
204+
205+
var userData *Base64Bytes
206+
if server.UserData != nil {
207+
userData = Ptr(Base64Bytes(*server.UserData))
208+
}
209+
210+
return &Base64PatchedServer{
211+
Id: server.Id,
212+
Name: server.Name,
213+
Status: server.Status,
214+
AvailabilityZone: server.AvailabilityZone,
215+
BootVolume: server.BootVolume,
216+
CreatedAt: server.CreatedAt,
217+
ErrorMessage: server.ErrorMessage,
218+
PowerStatus: server.PowerStatus,
219+
AffinityGroup: server.AffinityGroup,
220+
ImageId: server.ImageId,
221+
KeypairName: server.KeypairName,
222+
MachineType: server.MachineType,
223+
Labels: server.Labels,
224+
LaunchedAt: server.LaunchedAt,
225+
MaintenanceWindow: server.MaintenanceWindow,
226+
Metadata: server.Metadata,
227+
Networking: server.Networking,
228+
Nics: server.Nics,
229+
SecurityGroups: server.SecurityGroups,
230+
ServiceAccountMails: server.ServiceAccountMails,
231+
UpdatedAt: server.UpdatedAt,
232+
UserData: userData,
233+
Volumes: server.Volumes,
234+
}
235+
}
236+
237+
// ConvertToBase64PatchedServers converts a slice of iaas.Server to a slice of Base64PatchedServer
238+
// This is a temporary workaround to get the desired base64 encoded yaml output for userdata
239+
// and will be replaced by a fix in the Go-SDK
240+
// ref: https://jira.schwarz/browse/STACKITSDK-246
241+
func ConvertToBase64PatchedServers(servers []iaas.Server) []Base64PatchedServer {
242+
if servers == nil {
243+
return nil
244+
}
245+
246+
result := make([]Base64PatchedServer, len(servers))
247+
for i := range servers {
248+
result[i] = *ConvertToBase64PatchedServer(&servers[i])
249+
}
250+
251+
return result
252+
}

0 commit comments

Comments
 (0)