Skip to content

Commit 490856e

Browse files
authored
chore: add tfproviderlint workflow (#592)
1 parent 8fbdf3f commit 490856e

9 files changed

+48
-17
lines changed

.github/workflows/tfproviderlint.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Run tfproviderlint
2+
3+
on: [pull_request, push]
4+
5+
jobs:
6+
tfproviderlint:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/[email protected]
10+
- uses: bflad/tfproviderlint-github-action@master
11+
with:
12+
args: ./...

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/google/go-cmp v0.5.2
77
github.com/hashicorp/go-retryablehttp v0.6.7
88
github.com/hashicorp/terraform-plugin-sdk/v2 v2.2.0
9-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20201106174615-fd524d38cee8
9+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20201109203223-9446a84bfb2a
1010
github.com/stretchr/testify v1.6.1
1111
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a // indirect
1212
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,8 @@ github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20201012095732-98ec365545de
301301
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20201012095732-98ec365545de/go.mod h1:CJJ5VAbozOl0yEw7nHB9+7BXTJbIn6h7W+f6Gau5IP8=
302302
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20201106174615-fd524d38cee8 h1:OUM8gK4Frdx3yhDJWQSToADtrvCTGaZXYrm6O3j3JaQ=
303303
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20201106174615-fd524d38cee8/go.mod h1:CJJ5VAbozOl0yEw7nHB9+7BXTJbIn6h7W+f6Gau5IP8=
304+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20201109203223-9446a84bfb2a h1:bcVe/pXc4HWi8RwkiiYOdIjYWjQvR5eeMRaepXGW298=
305+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20201109203223-9446a84bfb2a/go.mod h1:CJJ5VAbozOl0yEw7nHB9+7BXTJbIn6h7W+f6Gau5IP8=
304306
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
305307
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
306308
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=

scaleway/data_source_helpers.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ func datasourceSchemaFromResourceSchema(rs map[string]*schema.Schema) map[string
4242
dv := &schema.Schema{
4343
Computed: true,
4444
ForceNew: false,
45-
Required: false,
4645
Description: v.Description,
4746
Type: v.Type,
4847
}

scaleway/data_source_marketplace_image_beta.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
package scaleway
22

33
import (
4+
"context"
5+
6+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
47
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
58
"github.com/scaleway/scaleway-sdk-go/api/marketplace/v1"
9+
"github.com/scaleway/scaleway-sdk-go/scw"
610
)
711

812
func dataSourceScalewayMarketplaceImageBeta() *schema.Resource {
913
return &schema.Resource{
10-
Read: dataSourceScalewayMarketplaceImageReadBeta,
14+
ReadContext: dataSourceScalewayMarketplaceImageReadBeta,
1115

1216
Schema: map[string]*schema.Schema{
1317
"label": {
@@ -26,21 +30,19 @@ func dataSourceScalewayMarketplaceImageBeta() *schema.Resource {
2630
}
2731
}
2832

29-
func dataSourceScalewayMarketplaceImageReadBeta(d *schema.ResourceData, m interface{}) error {
30-
meta := m.(*Meta)
31-
marketplaceAPI := marketplace.NewAPI(meta.scwClient)
32-
zone, err := extractZone(d, meta)
33+
func dataSourceScalewayMarketplaceImageReadBeta(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
34+
marketplaceAPI, zone, err := marketplaceAPIWithZone(d, m)
3335
if err != nil {
34-
return err
36+
return diag.FromErr(err)
3537
}
3638

3739
imageID, err := marketplaceAPI.GetLocalImageIDByLabel(&marketplace.GetLocalImageIDByLabelRequest{
3840
ImageLabel: d.Get("label").(string),
3941
CommercialType: d.Get("instance_type").(string),
4042
Zone: zone,
41-
})
43+
}, scw.WithContext(ctx))
4244
if err != nil {
43-
return err
45+
return diag.FromErr(err)
4446
}
4547

4648
zonedID := datasourceNewZonedID(imageID, zone)

scaleway/data_source_registry_image_beta.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ func dataSourceScalewayRegistryImageBeta() *schema.Resource {
5757
}
5858
}
5959

60-
func dataSourceScalewayRegistryImageBetaRead(d *schema.ResourceData, m interface{}) error {
61-
api, region, err := registryAPIWithRegion(d, m)
60+
func dataSourceScalewayRegistryImageBetaRead(d *schema.ResourceData, meta interface{}) error {
61+
api, region, err := registryAPIWithRegion(d, meta)
6262
if err != nil {
6363
return err
6464
}

scaleway/helpers.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ func newTemplateFunc(tplStr string) func(data interface{}) string {
284284
buffer := bytes.Buffer{}
285285
err := t.Execute(&buffer, tplParams)
286286
if err != nil {
287-
panic(err)
287+
panic(err) // lintignore:R009
288288
}
289289
return buffer.String()
290290
}
@@ -329,7 +329,7 @@ func expandDuration(data interface{}) *time.Duration {
329329
d, err := time.ParseDuration(data.(string))
330330
if err != nil {
331331
// We panic as this should never happened. Data from state should be validate using a validate func
332-
panic(err)
332+
panic(err) // lintignore:R009
333333
}
334334
return &d
335335
}
@@ -422,7 +422,7 @@ func expandIPNet(raw string) scw.IPNet {
422422
err := json.Unmarshal([]byte(raw), &ipNet)
423423
if err != nil {
424424
// We panic as this should never happen. Data from state should be validate using a validate func
425-
panic(fmt.Errorf("%s could not be marshaled: %v", raw, err))
425+
panic(fmt.Errorf("%s could not be marshaled: %v", raw, err)) // lintignore:R009
426426
}
427427

428428
return ipNet
@@ -432,7 +432,7 @@ func flattenIPNet(ipNet scw.IPNet) string {
432432
raw, err := json.Marshal(ipNet)
433433
if err != nil {
434434
// We panic as this should never happen.
435-
panic(err)
435+
panic(err) // lintignore:R009
436436
}
437437
return string(raw[1 : len(raw)-1])
438438
}

scaleway/helpers_marketplace.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package scaleway
2+
3+
import (
4+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
5+
"github.com/scaleway/scaleway-sdk-go/api/marketplace/v1"
6+
"github.com/scaleway/scaleway-sdk-go/scw"
7+
)
8+
9+
// marketplaceAPIWithZone returns a new marketplace API and the zone for a Create request
10+
func marketplaceAPIWithZone(d *schema.ResourceData, m interface{}) (*marketplace.API, scw.Zone, error) {
11+
meta := m.(*Meta)
12+
marketplaceAPI := marketplace.NewAPI(meta.scwClient)
13+
14+
zone, err := extractZone(d, meta)
15+
return marketplaceAPI, zone, err
16+
}

scaleway/resource_rdb_instance_beta.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ func resourceScalewayRdbInstanceBetaUpdate(ctx context.Context, d *schema.Resour
274274
}
275275

276276
// Wait for the instance to settle after upgrading
277-
time.Sleep(30 * time.Second)
277+
time.Sleep(30 * time.Second) // lintignore:R018
278278
}
279279

280280
if d.HasChange("password") {

0 commit comments

Comments
 (0)