diff --git a/hcloud/schema/server.go b/hcloud/schema/server.go index 9aaa8e2f..f80345da 100644 --- a/hcloud/schema/server.go +++ b/hcloud/schema/server.go @@ -266,7 +266,8 @@ type ServerActionDisableRescueResponse struct { // ServerActionRebuildRequest defines the schema for the request to // rebuild a server. type ServerActionRebuildRequest struct { - Image IDOrName `json:"image"` + Image IDOrName `json:"image"` + UserData *string `json:"user_data,omitempty"` } // ServerActionRebuildResponse defines the schema of the response when diff --git a/hcloud/server.go b/hcloud/server.go index 7e2eb7c9..f8bea7e6 100644 --- a/hcloud/server.go +++ b/hcloud/server.go @@ -727,7 +727,8 @@ func (c *ServerClient) DisableRescue(ctx context.Context, server *Server) (*Acti // ServerRebuildOpts specifies options for rebuilding a server. type ServerRebuildOpts struct { - Image *Image + Image *Image + UserData *string } // ServerRebuildResult is the result of a create server call. @@ -754,7 +755,7 @@ func (c *ServerClient) RebuildWithResult(ctx context.Context, server *Server, op reqPath := fmt.Sprintf(opPath, server.ID) - reqBody := schema.ServerActionRebuildRequest{} + reqBody := schema.ServerActionRebuildRequest{UserData: opts.UserData} if opts.Image.ID != 0 || opts.Image.Name != "" { reqBody.Image = schema.IDOrName{ID: opts.Image.ID, Name: opts.Image.Name} }