diff --git a/pkg/apiv1/machines.go b/pkg/apiv1/machines.go index 9470c14..d361147 100644 --- a/pkg/apiv1/machines.go +++ b/pkg/apiv1/machines.go @@ -119,7 +119,7 @@ func NewMachineAPI(httpClient *hreq.Client, endpoint string) *MachineAPI { func (a *MachineAPI) LockMachine(app string, id string, timeout int) (*MachineLease, error) { var res MachineLease - _, err := a.httpClient.R().SetResult(&res).Post(fmt.Sprintf("http://%s/v1/apps/%s/machines/%s/lease/?ttl=%d", a.endpoint, app, id, timeout)) + _, err := a.httpClient.R().SetResult(&res).Post(fmt.Sprintf("https://%s/v1/apps/%s/machines/%s/lease/?ttl=%d", a.endpoint, app, id, timeout)) if err != nil { return nil, err } @@ -127,7 +127,7 @@ func (a *MachineAPI) LockMachine(app string, id string, timeout int) (*MachineLe } func (a *MachineAPI) ReleaseMachine(lease MachineLease, app string, id string) error { - _, err := a.httpClient.R().SetHeader(NonceHeader, lease.Data.Nonce).Delete(fmt.Sprintf("http://%s/v1/apps/%s/machines/%s/lease", a.endpoint, app, id)) + _, err := a.httpClient.R().SetHeader(NonceHeader, lease.Data.Nonce).Delete(fmt.Sprintf("https://%s/v1/apps/%s/machines/%s/lease", a.endpoint, app, id)) if err != nil { return err } @@ -135,7 +135,7 @@ func (a *MachineAPI) ReleaseMachine(lease MachineLease, app string, id string) e } func (a *MachineAPI) WaitForMachine(app string, id string, instanceID string) error { - _, err := a.httpClient.R().Get(fmt.Sprintf("http://%s/v1/apps/%s/machines/%s/wait?instance_id=%s", a.endpoint, app, id, instanceID)) + _, err := a.httpClient.R().Get(fmt.Sprintf("https://%s/v1/apps/%s/machines/%s/wait?instance_id=%s", a.endpoint, app, id, instanceID)) return err } @@ -150,7 +150,7 @@ func (a *MachineAPI) CreateMachine(req MachineCreateOrUpdateRequest, app string, if req.Config.Guest.MemoryMb == 0 { req.Config.Guest.MemoryMb = 256 } - createResponse, err := a.httpClient.R().SetBody(req).SetResult(res).Post(fmt.Sprintf("http://%s/v1/apps/%s/machines", a.endpoint, app)) + createResponse, err := a.httpClient.R().SetBody(req).SetResult(res).Post(fmt.Sprintf("https://%s/v1/apps/%s/machines", a.endpoint, app)) if err != nil { return err @@ -178,7 +178,7 @@ func (a *MachineAPI) UpdateMachine(req MachineCreateOrUpdateRequest, app string, if err != nil { return err } - reqRes, err := a.httpClient.R().SetBody(req).SetResult(res).SetHeader(NonceHeader, lease.Data.Nonce).Post(fmt.Sprintf("http://%s/v1/apps/%s/machines/%s", a.endpoint, app, id)) + reqRes, err := a.httpClient.R().SetBody(req).SetResult(res).SetHeader(NonceHeader, lease.Data.Nonce).Post(fmt.Sprintf("https://%s/v1/apps/%s/machines/%s", a.endpoint, app, id)) if err != nil { return err } @@ -193,27 +193,27 @@ func (a *MachineAPI) UpdateMachine(req MachineCreateOrUpdateRequest, app string, } func (a *MachineAPI) ReadMachine(app string, id string, res *MachineResponse) (*hreq.Response, error) { - return a.httpClient.R().SetResult(res).Get(fmt.Sprintf("http://%s/v1/apps/%s/machines/%s", a.endpoint, app, id)) + return a.httpClient.R().SetResult(res).Get(fmt.Sprintf("https://%s/v1/apps/%s/machines/%s", a.endpoint, app, id)) } func (a *MachineAPI) DeleteMachine(app string, id string, maxRetries int) error { deleted := false for i := 0; i < maxRetries; i++ { var machine MachineResponse - readResponse, err := a.httpClient.R().SetResult(&machine).Get(fmt.Sprintf("http://%s/v1/apps/%s/machines/%s", a.endpoint, app, id)) + readResponse, err := a.httpClient.R().SetResult(&machine).Get(fmt.Sprintf("https://%s/v1/apps/%s/machines/%s", a.endpoint, app, id)) if err != nil { return err } if readResponse.StatusCode == 200 { if machine.State == "started" || machine.State == "starting" || machine.State == "replacing" { - _, _ = a.httpClient.R().Post(fmt.Sprintf("http://%s/v1/apps/%s/machines/%s/stop", a.endpoint, app, id)) + _, _ = a.httpClient.R().Post(fmt.Sprintf("https://%s/v1/apps/%s/machines/%s/stop", a.endpoint, app, id)) } if machine.State == "stopping" || machine.State == "destroying" { time.Sleep(5 * time.Second) } if machine.State == "stopped" || machine.State == "replaced" { - _, err = a.httpClient.R().Delete(fmt.Sprintf("http://%s/v1/apps/%s/machines/%s", a.endpoint, app, id)) + _, err = a.httpClient.R().Delete(fmt.Sprintf("https://%s/v1/apps/%s/machines/%s", a.endpoint, app, id)) if err != nil { return err }