Skip to content

Commit 82860c4

Browse files
committed
feat(apple-silicon): add support vpc
1 parent 83cfa19 commit 82860c4

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ require (
3030
github.com/nats-io/jwt/v2 v2.7.3
3131
github.com/nats-io/nats.go v1.37.0
3232
github.com/robfig/cron/v3 v3.0.1
33-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241129094524-023aa8142bc1
33+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20250115101541-adcf20ac0a4e
3434
github.com/stretchr/testify v1.9.0
3535
golang.org/x/crypto v0.31.0
3636
gopkg.in/dnaeon/go-vcr.v3 v3.2.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,8 @@ github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
282282
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
283283
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241129094524-023aa8142bc1 h1:0OKzyRfLH+dWSPOBvwbhNcBTbEiuNkv8mdYGev1+/1g=
284284
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241129094524-023aa8142bc1/go.mod h1:kAoejOVBg1E/aVAR6IwKWEmbLCEg2IXklzPAkxzAaXA=
285+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20250115101541-adcf20ac0a4e h1:jkaT8NRDr9XNOtXVF743DPgOpp50xDEIwR/S1AWQCWk=
286+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20250115101541-adcf20ac0a4e/go.mod h1:kzh+BSAvpoyHHdHBCDhmSWtBc1NbLMZ2lWHqnBoxFks=
285287
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
286288
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
287289
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=

internal/services/applesilicon/server.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ func ResourceServer() *schema.Resource {
4141
Required: true,
4242
ForceNew: true,
4343
},
44+
"enable_vpc": {
45+
Type: schema.TypeBool,
46+
Optional: true,
47+
Default: false,
48+
Description: "Whether or not to enable VPC access",
49+
},
4450
// Computed
4551
"ip": {
4652
Type: schema.TypeString,
@@ -72,6 +78,11 @@ func ResourceServer() *schema.Resource {
7278
Computed: true,
7379
Description: "The minimal date and time on which you can delete this server due to Apple licence",
7480
},
81+
"vpc_status": {
82+
Type: schema.TypeString,
83+
Computed: true,
84+
Description: "The VPC status of the server",
85+
},
7586

7687
// Common
7788
"zone": zonal.Schema(),
@@ -91,6 +102,7 @@ func ResourceAppleSiliconServerCreate(ctx context.Context, d *schema.ResourceDat
91102
Name: types.ExpandOrGenerateString(d.Get("name"), "m1"),
92103
Type: d.Get("type").(string),
93104
ProjectID: d.Get("project_id").(string),
105+
EnableVpc: d.Get("enable_vpc").(bool),
94106
}
95107

96108
res, err := asAPI.CreateServer(createReq, scw.WithContext(ctx))
@@ -134,6 +146,7 @@ func ResourceAppleSiliconServerRead(ctx context.Context, d *schema.ResourceData,
134146
_ = d.Set("deletable_at", res.DeletableAt.Format(time.RFC3339))
135147
_ = d.Set("ip", res.IP.String())
136148
_ = d.Set("vnc_url", res.VncURL)
149+
_ = d.Set("vpc_status", res.VpcStatus)
137150

138151
_ = d.Set("zone", res.Zone.String())
139152
_ = d.Set("organization_id", res.OrganizationID)
@@ -157,6 +170,11 @@ func ResourceAppleSiliconServerUpdate(ctx context.Context, d *schema.ResourceDat
157170
req.Name = types.ExpandStringPtr(d.Get("name"))
158171
}
159172

173+
if d.HasChange("enable_vpc") {
174+
enableVpc := d.Get("enable_vpc").(bool)
175+
req.EnableVpc = &enableVpc
176+
}
177+
160178
_, err = asAPI.UpdateServer(req, scw.WithContext(ctx))
161179
if err != nil {
162180
return diag.FromErr(err)

0 commit comments

Comments
 (0)