Skip to content

Commit f8ba78c

Browse files
committed
feat(apple-silicon): manage runner on server
1 parent 65a9760 commit f8ba78c

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

internal/services/applesilicon/server.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ func ResourceServer() *schema.Resource {
6161
Description: "The commitment period of the server",
6262
ValidateDiagFunc: verify.ValidateEnum[applesilicon.CommitmentType](),
6363
},
64+
"runner_ids": {
65+
Type: schema.TypeList,
66+
Optional: true,
67+
Computed: true,
68+
Elem: &schema.Schema{
69+
Type: schema.TypeString,
70+
ValidateDiagFunc: verify.IsUUIDorUUIDWithLocality(),
71+
},
72+
Description: "List of runner ids attach to the server",
73+
},
6474
"public_bandwidth": {
6575
Type: schema.TypeInt,
6676
Optional: true,
@@ -207,6 +217,10 @@ func ResourceAppleSiliconServerCreate(ctx context.Context, d *schema.ResourceDat
207217
Zone: zone,
208218
}
209219

220+
if runnerIDs, ok := d.GetOk("runner_ids"); ok {
221+
createReq.AppliedRunnerConfigurations.RunnerConfigurationIDs = runnerIDs.([]string)
222+
}
223+
210224
if bandwidth, ok := d.GetOk("public_bandwidth"); ok {
211225
createReq.PublicBandwidthBps = *types.ExpandUint64Ptr(bandwidth)
212226
}
@@ -283,6 +297,7 @@ func ResourceAppleSiliconServerRead(ctx context.Context, d *schema.ResourceData,
283297
_ = d.Set("username", res.SSHUsername)
284298
_ = d.Set("public_bandwidth", int(res.PublicBandwidthBps))
285299
_ = d.Set("zone", res.Zone)
300+
_ = d.Set("runner_ids", res.AppliedRunnerConfigurationIDs)
286301

287302
listPrivateNetworks, err := privateNetworkAPI.ListServerPrivateNetworks(&applesilicon.PrivateNetworkAPIListServerPrivateNetworksRequest{
288303
Zone: res.Zone,
@@ -385,6 +400,10 @@ func ResourceAppleSiliconServerUpdate(ctx context.Context, d *schema.ResourceDat
385400
req.PublicBandwidthBps = publicBandwidth
386401
}
387402

403+
if d.HasChange("runner_ids") {
404+
req.AppliedRunnerConfigurations.RunnerConfigurationIDs = d.Get("runner_ids").([]string)
405+
}
406+
388407
_, err = asAPI.UpdateServer(req, scw.WithContext(ctx))
389408
if err != nil {
390409
return diag.FromErr(err)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
version: 2
3+
interactions: []

0 commit comments

Comments
 (0)