v1.0.0
This commit is contained in:
@@ -7,16 +7,35 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request struct for redeploy
|
||||
type RedeployRequest struct {
|
||||
// ID of compute instance
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId"`
|
||||
ImageID uint64 `url:"imageId,omitempty"`
|
||||
DiskSize uint64 `url:"diskSize,omitempty"`
|
||||
|
||||
// ID of the new OS image, if image change is required
|
||||
// Required: false
|
||||
ImageID uint64 `url:"imageId,omitempty"`
|
||||
|
||||
// new size for the boot disk in GB, if boot disk size change is required
|
||||
// Required: false
|
||||
DiskSize uint64 `url:"diskSize,omitempty"`
|
||||
|
||||
// How to handle data disks connected to this compute instance,
|
||||
// KEEP, DETACH, DESTROY
|
||||
// Required: false
|
||||
DataDisks string `url:"dataDisks,omitempty"`
|
||||
AutoStart bool `url:"autoStart,omitempty"`
|
||||
ForceStop bool `url:"forceStop,omitempty"`
|
||||
|
||||
// Should the compute be restarted upon successful redeploy
|
||||
// Required: false
|
||||
AutoStart bool `url:"autoStart,omitempty"`
|
||||
|
||||
// Set this flag to True to force stop running compute instance and redeploy next
|
||||
// Required: false
|
||||
ForceStop bool `url:"forceStop,omitempty"`
|
||||
}
|
||||
|
||||
func (crq RedeployRequest) Validate() error {
|
||||
func (crq RedeployRequest) validate() error {
|
||||
if crq.ComputeID == 0 {
|
||||
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||
}
|
||||
@@ -24,8 +43,9 @@ func (crq RedeployRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Redeploy redeploy compute
|
||||
func (c Compute) Redeploy(ctx context.Context, req RedeployRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -41,5 +61,6 @@ func (c Compute) Redeploy(ctx context.Context, req RedeployRequest) (bool, error
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user