Skip to content

Commit 8893a6a

Browse files
committed
return correct services
1 parent 047d1d1 commit 8893a6a

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

instance/instance.go

+10
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,11 @@ func (i *Instance) AddService(consulClient *consul.Client, service, config strin
301301
return nil, errors.New("Could not set service config")
302302
}
303303

304+
i, err = i.GetInstance(consulClient)
305+
if err != nil {
306+
return nil, err
307+
}
308+
304309
return i, nil
305310
}
306311

@@ -403,5 +408,10 @@ func (i *Instance) RemoveService(consulClient *consul.Client, service string) (*
403408
return nil, errors.New("Could not remove service")
404409
}
405410

411+
i, err = i.GetInstance(consulClient)
412+
if err != nil {
413+
return nil, err
414+
}
415+
406416
return i, nil
407417
}

packet.go

+10-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"encoding/json"
55
"errors"
6+
"io/ioutil"
67
"os"
78

89
"github.com/google/uuid"
@@ -48,7 +49,7 @@ func CreatePacketInstance(consulClient *consul.Client, in *pb.CreateInstanceRequ
4849
instance, err := instance.CreateInstance(consulClient, instance.CreateInstanceRequest{
4950
ID: id.String(),
5051
Owner: projID,
51-
Device: "",
52+
Device: "", // can't set this yet because we don't know what the device ID is until it's provisioned
5253
Provider: "PACKET",
5354
})
5455
if err != nil {
@@ -73,7 +74,12 @@ func CreatePacketInstance(consulClient *consul.Client, in *pb.CreateInstanceRequ
7374
},
7475
}
7576

76-
customDataJSONString, err := json.Marshal(customData)
77+
customDataJSON, err := json.Marshal(customData)
78+
if err != nil {
79+
return nil, err
80+
}
81+
82+
userDataString, err := ioutil.ReadFile("./assets/packet.userdata.sh")
7783
if err != nil {
7884
return nil, err
7985
}
@@ -85,7 +91,8 @@ func CreatePacketInstance(consulClient *consul.Client, in *pb.CreateInstanceRequ
8591
Plan: "baremetal_2",
8692
OS: "ubuntu_16_04",
8793
BillingCycle: "hourly",
88-
CustomData: string(customDataJSONString),
94+
CustomData: string(customDataJSON),
95+
UserData: string(userDataString),
8996
}
9097
device, _, err := packetClient.Devices.Create(&createReq)
9198
if err != nil {

0 commit comments

Comments
 (0)