Skip to content

Commit 65a9760

Browse files
committed
add skip test security
1 parent acc37ce commit 65a9760

File tree

5 files changed

+30
-53
lines changed

5 files changed

+30
-53
lines changed

docs/resources/apple_silicon_runner.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ resource "scaleway_apple_silicon_runner" "main" {
1515
ci_provider = "github"
1616
url = "https://github.com/my-org/my-repo"
1717
token = "my-token"
18-
labels = ["updated"]
1918
}
2019
```
2120

@@ -24,7 +23,6 @@ resource "scaleway_apple_silicon_runner" "main" {
2423
- `ci_provider` - (Required) The CI/CD provider for the runner. Must be either 'github' or 'gitlab'
2524
- `token` - (Required) The token used to authenticate the runner to run
2625
- `url` - (Required) The URL of the runner to run
27-
- `labels` - (Optional) A list of labels that should be applied to the runner. Only for github provider
2826
- `name` - (Optional) The name of the runner
2927
- `project_id` - (Optional) The project_id you want to attach the resource to
3028
- `zone` - (Optional) The zone of the runner
@@ -33,11 +31,13 @@ resource "scaleway_apple_silicon_runner" "main" {
3331

3432
- `id` - The ID of the runner.
3533
- `status` - The status of the runner
34+
- `labels` - A list of labels applied to the runner. Only for github provider
35+
- `error_message` - The error message if the runner is in error state
3636

3737
## Import
3838

3939
Runner can be imported using the `{zone}/{id}`, e.g.
4040

4141
```bash
4242
terraform import scaleway_apple_silicon_runner.main fr-par-1/11111111-1111-1111-1111-111111111111
43-
```
43+
```

internal/services/applesilicon/runner.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ func ResourceRunner() *schema.Resource {
5858
Elem: &schema.Schema{
5959
Type: schema.TypeString,
6060
},
61-
Optional: true,
6261
Computed: true,
6362
Description: "A list of labels that should be applied to the runner.",
6463
},
@@ -67,6 +66,11 @@ func ResourceRunner() *schema.Resource {
6766
Computed: true,
6867
Description: "The status of the runner",
6968
},
69+
"error_message": {
70+
Type: schema.TypeString,
71+
Computed: true,
72+
Description: "The error message of the runner",
73+
},
7074
"zone": zonal.Schema(),
7175
"project_id": account.ProjectIDSchema(),
7276
},
@@ -92,7 +96,7 @@ func ResourceAppleSiliconRunnerCreate(ctx context.Context, d *schema.ResourceDat
9296
runnerConfig.GithubConfiguration = &applesilicon.GithubRunnerConfiguration{
9397
URL: d.Get("url").(string),
9498
Token: d.Get("token").(string),
95-
Labels: types.ExpandStrings(d.Get("labels")),
99+
Labels: nil,
96100
}
97101
}
98102

@@ -138,17 +142,20 @@ func ResourceAppleSiliconRunnerRead(ctx context.Context, d *schema.ResourceData,
138142
return diag.FromErr(err)
139143
}
140144

141-
_ = d.Set("name", runner.ID)
142145
_ = d.Set("name", runner.Configuration.Name)
143146
_ = d.Set("ci_provider", runner.Configuration.Provider)
144147
_ = d.Set("status", runner.Status)
148+
_ = d.Set("error_message", runner.ErrorMessage)
145149

146150
if runner.Configuration.Provider == "github" {
147-
_ = d.Set("token", runner.Configuration.GithubConfiguration.Token)
148151
_ = d.Set("url", runner.Configuration.GithubConfiguration.URL)
149152
_ = d.Set("labels", runner.Configuration.GithubConfiguration.Labels)
150153
}
151154

155+
if runner.Configuration.Provider == "gitlab" {
156+
_ = d.Set("url", runner.Configuration.GitlabConfiguration.URL)
157+
}
158+
152159
return nil
153160
}
154161

@@ -206,7 +213,7 @@ func ResourceAppleSiliconRunnerDelete(ctx context.Context, d *schema.ResourceDat
206213
RunnerID: ID,
207214
}
208215
err = asAPI.DeleteRunner(runnerDeleteReq, scw.WithContext(ctx))
209-
if err != nil && !httperrors.Is404(err) {
216+
if err != nil && !httperrors.Is403(err) {
210217
return diag.FromErr(err)
211218
}
212219
return nil

internal/services/applesilicon/runner_test.go

Lines changed: 11 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package applesilicon_test
22

33
import (
44
"fmt"
5+
"os"
56
"testing"
67

78
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
@@ -15,77 +16,45 @@ import (
1516
func TestAccRunner_BasicGithub(t *testing.T) {
1617
tt := acctest.NewTestTools(t)
1718
defer tt.Cleanup()
19+
t.Skip("can not register this cassette for security issue")
20+
var githubUrl = os.Getenv("GITHUB_URL_AS")
21+
var githubToken = os.Getenv("GITHUB_TOKEN_AS")
1822

1923
resource.ParallelTest(t, resource.TestCase{
2024
ProtoV6ProviderFactories: tt.ProviderFactories,
2125
CheckDestroy: isRunnerDestroyed(tt),
2226
Steps: []resource.TestStep{
2327
{
24-
Config: `
28+
Config: fmt.Sprintf(`
2529
resource "scaleway_apple_silicon_runner" "main" {
2630
name = "TestAccRunnerGithub"
2731
ci_provider = "github"
2832
url = "%s"
2933
token = "%s"
30-
labels = ["ci", "macos"]
3134
}
32-
`,
35+
`, githubUrl, githubToken),
3336
Check: resource.ComposeTestCheckFunc(
3437
isRunnerPresent(tt, "scaleway_apple_silicon_runner.main"),
3538
resource.TestCheckResourceAttr("scaleway_apple_silicon_runner.main", "name", "TestAccRunnerGithub"),
36-
resource.TestCheckResourceAttr("scaleway_apple_silicon_runner.main", "provider", "github"),
37-
resource.TestCheckResourceAttr("scaleway_apple_silicon_runner.main", "url", "https://github.com/my-org/repo"),
38-
resource.TestCheckResourceAttr("scaleway_apple_silicon_runner.main", "labels.#", "2"),
39+
resource.TestCheckResourceAttr("scaleway_apple_silicon_runner.main", "ci_provider", "github"),
40+
resource.TestCheckResourceAttr("scaleway_apple_silicon_runner.main", "url", githubUrl),
3941

4042
// Computed
4143
resource.TestCheckResourceAttrSet("scaleway_apple_silicon_runner.main", "status"),
4244
),
4345
},
4446
{
45-
Config: `
47+
Config: fmt.Sprintf(`
4648
resource "scaleway_apple_silicon_runner" "main" {
4749
name = "TestAccRunnerGithubUpdated"
4850
ci_provider = "github"
4951
url = "%s"
5052
token = "%s"
51-
labels = ["updated"]
5253
}
53-
`,
54+
`, githubUrl, githubToken),
5455
Check: resource.ComposeTestCheckFunc(
5556
isRunnerPresent(tt, "scaleway_apple_silicon_runner.main"),
5657
resource.TestCheckResourceAttr("scaleway_apple_silicon_runner.main", "name", "TestAccRunnerGithubUpdated"),
57-
resource.TestCheckResourceAttr("scaleway_apple_silicon_runner.main", "labels.#", "1"),
58-
),
59-
},
60-
},
61-
})
62-
}
63-
64-
func TestAccRunner_BasicGitlab(t *testing.T) {
65-
tt := acctest.NewTestTools(t)
66-
defer tt.Cleanup()
67-
68-
resource.ParallelTest(t, resource.TestCase{
69-
ProtoV6ProviderFactories: tt.ProviderFactories,
70-
CheckDestroy: isRunnerDestroyed(tt),
71-
Steps: []resource.TestStep{
72-
{
73-
Config: `
74-
resource "scaleway_apple_silicon_runner" "main" {
75-
name = "TestAccRunnerGitlab"
76-
ci_provider = "gitlab"
77-
url = "https://gitlab.com"
78-
token = "gitlab-token"
79-
}
80-
`,
81-
Check: resource.ComposeTestCheckFunc(
82-
isRunnerPresent(tt, "scaleway_apple_silicon_runner.main"),
83-
resource.TestCheckResourceAttr("scaleway_apple_silicon_runner.main", "name", "TestAccRunnerGitlab"),
84-
resource.TestCheckResourceAttr("scaleway_apple_silicon_runner.main", "provider", "gitlab"),
85-
resource.TestCheckResourceAttr("scaleway_apple_silicon_runner.main", "url", "https://gitlab.com"),
86-
87-
// Computed
88-
resource.TestCheckResourceAttrSet("scaleway_apple_silicon_runner.main", "status"),
8958
),
9059
},
9160
},
@@ -134,7 +103,7 @@ func isRunnerDestroyed(tt *acctest.TestTools) resource.TestCheckFunc {
134103
return fmt.Errorf("runner still exists: %s", rs.Primary.ID)
135104
}
136105

137-
if !httperrors.Is404(err) {
106+
if !httperrors.Is403(err) {
138107
return fmt.Errorf("unexpected error: %s", err)
139108
}
140109
}

provider/sdkv2.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ func SDKProvider(config *Config) plugin.ProviderFunc {
130130
"scaleway_account_project": account.ResourceProject(),
131131
"scaleway_account_ssh_key": iam.ResourceSSKKey(),
132132
"scaleway_apple_silicon_server": applesilicon.ResourceServer(),
133+
"scaleway_apple_silicon_runner": applesilicon.ResourceRunner(),
133134
"scaleway_autoscaling_instance_group": autoscaling.ResourceInstanceGroup(),
134135
"scaleway_autoscaling_instance_policy": autoscaling.ResourceInstancePolicy(),
135136
"scaleway_autoscaling_instance_template": autoscaling.ResourceInstanceTemplate(),

templates/resources/apple_silicon_runner.md.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ resource "scaleway_apple_silicon_runner" "main" {
1616
ci_provider = "github"
1717
url = "https://github.com/my-org/my-repo"
1818
token = "my-token"
19-
labels = ["updated"]
2019
}
2120
```
2221

@@ -25,7 +24,6 @@ resource "scaleway_apple_silicon_runner" "main" {
2524
- `ci_provider` - (Required) The CI/CD provider for the runner. Must be either 'github' or 'gitlab'
2625
- `token` - (Required) The token used to authenticate the runner to run
2726
- `url` - (Required) The URL of the runner to run
28-
- `labels` - (Optional) A list of labels that should be applied to the runner. Only for github provider
2927
- `name` - (Optional) The name of the runner
3028
- `project_id` - (Optional) The project_id you want to attach the resource to
3129
- `zone` - (Optional) The zone of the runner
@@ -34,11 +32,13 @@ resource "scaleway_apple_silicon_runner" "main" {
3432

3533
- `id` - The ID of the runner.
3634
- `status` - The status of the runner
35+
- `labels` - A list of labels applied to the runner. Only for github provider
36+
- `error_message` - The error message if the runner is in error state
3737

3838
## Import
3939

4040
Runner can be imported using the `{zone}/{id}`, e.g.
4141

4242
```bash
4343
terraform import scaleway_apple_silicon_runner.main fr-par-1/11111111-1111-1111-1111-111111111111
44-
```
44+
```

0 commit comments

Comments
 (0)