Skip to content

fix(apple-silicon): remove cumbersome validate func #2293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions docs/resources/apple_silicon.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ In addition to all above arguments, the following attributes are exported:

~> **Important:** Apple Silicon servers' IDs are [zoned](../guides/regions_and_zones.md#resource-ids), which means they are of the form `{zone}/{id}`, e.g. `fr-par-1/11111111-1111-1111-1111-111111111111`

- `state` - The state of the server. Check the possible values on
our [sdk](https://github.com/scaleway/scaleway-sdk-go/blob/master/api/applesilicon/v1alpha1/applesilicon_sdk.go#L103).
- `state` - The state of the server.
- `ip` - IPv4 address of the server (IPv4 address).
- `vnc_url` - URL of the VNC.
- `created_at` - The date and time of the creation of the Apple Silicon server.
Expand All @@ -57,5 +56,5 @@ In addition to all above arguments, the following attributes are exported:
Instance servers can be imported using the `{zone}/{id}`, e.g.

```bash
$ terraform import scaleway_apple_silicon.server fr-par-1/11111111-1111-1111-1111-111111111111
$ terraform import scaleway_apple_silicon_server.main fr-par-1/11111111-1111-1111-1111-111111111111
```
4 changes: 0 additions & 4 deletions scaleway/helpers_apple_silicon.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ const (
defaultAppleSiliconServerRetryInterval = 5 * time.Second
)

const (
AppleSiliconM1Type = "M1-M"
)

// asAPIWithZone returns a new apple silicon API and the zone
func asAPIWithZone(d *schema.ResourceData, m interface{}) (*applesilicon.API, scw.Zone, error) {
meta := m.(*Meta)
Expand Down
4 changes: 0 additions & 4 deletions scaleway/resource_apple_silicon_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
applesilicon "github.com/scaleway/scaleway-sdk-go/api/applesilicon/v1alpha1"
"github.com/scaleway/scaleway-sdk-go/scw"
)
Expand Down Expand Up @@ -37,9 +36,6 @@ func resourceScalewayAppleSiliconServer() *schema.Resource {
Description: "Type of the server",
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
AppleSiliconM1Type,
}, false),
},
// Computed
"ip": {
Expand Down
2 changes: 1 addition & 1 deletion scaleway/resource_apple_silicon_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestAccScalewayAppleSiliconServer_Basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckScalewayAppleSiliconExists(tt, "scaleway_apple_silicon_server.main"),
resource.TestCheckResourceAttr("scaleway_apple_silicon_server.main", "name", "test-m1"),
resource.TestCheckResourceAttr("scaleway_apple_silicon_server.main", "type", AppleSiliconM1Type),
resource.TestCheckResourceAttr("scaleway_apple_silicon_server.main", "type", "M1-M"),
// Computed
resource.TestCheckResourceAttrSet("scaleway_apple_silicon_server.main", "ip"),
resource.TestCheckResourceAttrSet("scaleway_apple_silicon_server.main", "vnc_url"),
Expand Down