Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
Fix accidental ignore of region
Browse files Browse the repository at this point in the history
  • Loading branch information
DAlperin committed May 27, 2022
1 parent 38c01d1 commit 294bc70
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions internal/provider/machine_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type MachineConfig struct {

type CreateOrUpdateMachineRequest struct {
Name string `json:"name"`
Region string `json:"region"`
Config MachineConfig `json:"config"`
Guest *GuestConfig `json:"guest,omitempty"`
}
Expand Down Expand Up @@ -309,7 +310,8 @@ func (mr flyMachineResource) Create(ctx context.Context, req tfsdk.CreateResourc
services := TfServicesToServices(data.Services)

createReq := CreateOrUpdateMachineRequest{
Name: data.Name.Value,
Name: data.Name.Value,
Region: data.Region.Value,
Config: MachineConfig{
Image: data.Image.Value,
Services: services,
Expand All @@ -330,7 +332,7 @@ func (mr flyMachineResource) Create(ctx context.Context, req tfsdk.CreateResourc
data.Env.ElementsAs(context.Background(), &env, false)
createReq.Config.Env = env
}

tflog.Info(ctx, fmt.Sprintf("%+v", createReq))
body, _ := json.Marshal(createReq)
createResponse, err := mr.http.Post(fmt.Sprintf("http://127.0.0.1:4280/v1/apps/%s/machines", data.App.Value), "application/json", bytes.NewBuffer(body))
if err != nil {
Expand Down Expand Up @@ -474,7 +476,8 @@ func (mr flyMachineResource) Update(ctx context.Context, req tfsdk.UpdateResourc
services := TfServicesToServices(plan.Services)

updateReq := CreateOrUpdateMachineRequest{
Name: plan.Name.Value,
Name: plan.Name.Value,
Region: state.Region.Value,
Config: MachineConfig{
Image: plan.Image.Value,
Services: services,
Expand Down

0 comments on commit 294bc70

Please sign in to comment.