Skip to content

Commit b45e49b

Browse files
committed
feat(server): allow specifying user-data for rebuild
1 parent 3871f7c commit b45e49b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

hcloud/schema/server.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ type ServerActionDisableRescueResponse struct {
266266
// ServerActionRebuildRequest defines the schema for the request to
267267
// rebuild a server.
268268
type ServerActionRebuildRequest struct {
269-
Image IDOrName `json:"image"`
269+
Image IDOrName `json:"image"`
270+
UserData *string `json:"user_data"`
270271
}
271272

272273
// ServerActionRebuildResponse defines the schema of the response when

hcloud/server.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,8 @@ func (c *ServerClient) DisableRescue(ctx context.Context, server *Server) (*Acti
727727

728728
// ServerRebuildOpts specifies options for rebuilding a server.
729729
type ServerRebuildOpts struct {
730-
Image *Image
730+
Image *Image
731+
UserData *string
731732
}
732733

733734
// ServerRebuildResult is the result of a create server call.
@@ -754,7 +755,7 @@ func (c *ServerClient) RebuildWithResult(ctx context.Context, server *Server, op
754755

755756
reqPath := fmt.Sprintf(opPath, server.ID)
756757

757-
reqBody := schema.ServerActionRebuildRequest{}
758+
reqBody := schema.ServerActionRebuildRequest{UserData: opts.UserData}
758759
if opts.Image.ID != 0 || opts.Image.Name != "" {
759760
reqBody.Image = schema.IDOrName{ID: opts.Image.ID, Name: opts.Image.Name}
760761
}

0 commit comments

Comments
 (0)