Skip to content

Commit d7e3e86

Browse files
committed
Merge branch 'master' into fix/mongodb-snapshot-expiration-dates
2 parents c8a9ae1 + ad603e9 commit d7e3e86

File tree

229 files changed

+9129
-10335
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

229 files changed

+9129
-10335
lines changed

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,18 @@
1010

1111
## Requirements
1212

13-
- [Terraform](https://www.terraform.io/downloads.html) 0.10.x
14-
- [Go](https://golang.org/doc/install) 1.11 (to build the provider plugin)
13+
- [Terraform](https://www.terraform.io/downloads.html) 1.0
14+
- [Go](https://golang.org/doc/install) 1.25 (to build the provider plugin)
1515

1616
## Building The Provider
1717

18-
Clone repository to: `$GOPATH/src/github.com/scaleway/terraform-provider-scaleway`
19-
2018
```sh
21-
$ mkdir -p $GOPATH/src/github.com/scaleway; cd $GOPATH/src/github.com/scaleway
2219
$ git clone [email protected]:scaleway/terraform-provider-scaleway.git
2320
```
2421

2522
Enter the provider directory and build the provider
2623

2724
```sh
28-
$ cd $GOPATH/src/github.com/scaleway/terraform-provider-scaleway
2925
$ make build
3026
```
3127

docs/resources/instance_image.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ resource "scaleway_instance_snapshot" "server_snapshot" {
6969
resource "scaleway_instance_image" "image" {
7070
name = "image_with_extra_volumes"
7171
root_volume_id = scaleway_instance_snapshot.server_snapshot.id
72-
additional_volumes = [
72+
additional_volume_ids = [
7373
scaleway_instance_snapshot.volume_snapshot.id
7474
]
7575
}
@@ -83,9 +83,6 @@ The following arguments are supported:
8383
- `name` - (Optional) The name of the image. If not provided it will be randomly generated.
8484
- `architecture` - (Optional, default `x86_64`) The architecture the image is compatible with. Possible values are: `x86_64` or `arm`.
8585
- `additional_volume_ids` - (Optional) List of IDs of the snapshots of the additional volumes to be attached to the image.
86-
87-
-> **Important:** For now it is only possible to have 1 additional_volume.
88-
8986
- `tags` - (Optional) A list of tags to apply to the image.
9087
- `public` - (Optional) Set to `true` if the image is public.
9188
- `zone` - (Defaults to provider `zone`) The [zone](../guides/regions_and_zones.md#zones) in which the image should be created.
@@ -104,26 +101,27 @@ In addition to all arguments above, the following attributes are exported:
104101
- `from_server_id` - ID of the server the image is based on (in case it is a backup).
105102
- `state` - State of the image. Possible values are: `available`, `creating` or `error`.
106103
- `organization_id` - The organization ID the image is associated with.
104+
- `root_volume` - The description of the root volume attached to the image.
105+
106+
-> The `root_volume` block contains :
107+
- `id` - The ID of the volume.
108+
- `name` - The name of the volume.
109+
- `size` - The size of the volume.
110+
- `volume_type` - The type of volume, possible values are `l_ssd` and `sbs_snapshot`.
111+
107112
- `additional_volumes` - The description of the extra volumes attached to the image.
108113

109114
-> The `additional_volumes` block contains :
110115
- `id` - The ID of the volume.
111116
- `name` - The name of the volume.
112-
- `export_uri` - The export URI of the volume.
113117
- `size` - The size of the volume.
114-
- `volume_type` - The type of volume, possible values are `l_ssd` and `b_ssd`.
115-
- `creation_date` - Date of the volume creation.
116-
- `modification_date` - Date of volume latest update.
117-
- `organization` - The organization ID the volume is associated with.
118-
- `project` - ID of the project the volume is associated with
118+
- `volume_type` - The type of volume, possible values are `l_ssd` and `sbs_snapshot`.
119119
- `tags` - List of tags associated with the volume.
120-
- `state` - State of the volume.
121-
- `zone` - The [zone](../guides/regions_and_zones.md#zones) in which the volume is.
122120
- `server` - Description of the server containing the volume (in case the image is a backup from a server).
123121

124-
-> The `server` block contains :
125-
- `id` - ID of the server containing the volume.
126-
- `name` - Name of the server containing the volume.
122+
-> The `server` block contains :
123+
- `id` - ID of the server containing the volume.
124+
- `name` - Name of the server containing the volume.
127125

128126
## Import
129127

internal/acctest/acctest.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import (
77
"testing"
88
"time"
99

10-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
10+
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
11+
"github.com/hashicorp/terraform-plugin-mux/tf6muxserver"
1112
"github.com/scaleway/terraform-provider-scaleway/v2/internal/env"
1213
"github.com/scaleway/terraform-provider-scaleway/v2/internal/meta"
1314
"github.com/scaleway/terraform-provider-scaleway/v2/internal/provider"
@@ -20,7 +21,7 @@ func PreCheck(_ *testing.T) {}
2021
type TestTools struct {
2122
T *testing.T
2223
Meta *meta.Meta
23-
ProviderFactories map[string]func() (*schema.Provider, error)
24+
ProviderFactories map[string]func() (tfprotov6.ProviderServer, error)
2425
Cleanup func()
2526
}
2627

@@ -64,9 +65,19 @@ func NewTestTools(t *testing.T) *TestTools {
6465
return &TestTools{
6566
T: t,
6667
Meta: m,
67-
ProviderFactories: map[string]func() (*schema.Provider, error){
68-
"scaleway": func() (*schema.Provider, error) {
69-
return provider.SDKProvider(&provider.Config{Meta: m})(), nil
68+
ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){
69+
"scaleway": func() (tfprotov6.ProviderServer, error) {
70+
providers, errProvider := provider.NewProviderList(ctx, &provider.Config{Meta: m})
71+
if errProvider != nil {
72+
return nil, errProvider
73+
}
74+
75+
muxServer, errMux := tf6muxserver.NewMuxServer(ctx, providers...)
76+
if errMux != nil {
77+
return nil, errMux
78+
}
79+
80+
return muxServer.ProviderServer(), nil
7081
},
7182
},
7283
Cleanup: cleanup,

internal/acctest/fixtures.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ package acctest
33
import (
44
"context"
55

6-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
6+
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
7+
"github.com/hashicorp/terraform-plugin-mux/tf6muxserver"
78
sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
89
"github.com/scaleway/scaleway-sdk-go/api/account/v3"
910
iam "github.com/scaleway/scaleway-sdk-go/api/iam/v1alpha1"
@@ -17,7 +18,7 @@ import (
1718
// given project and API key as default profile configuration.
1819
//
1920
// This is useful to test resources that need to create resources in another project.
20-
func FakeSideProjectProviders(ctx context.Context, tt *TestTools, project *account.Project, iamAPIKey *iam.APIKey) map[string]func() (*schema.Provider, error) {
21+
func FakeSideProjectProviders(ctx context.Context, tt *TestTools, project *account.Project, iamAPIKey *iam.APIKey) map[string]func() (tfprotov6.ProviderServer, error) {
2122
t := tt.T
2223

2324
metaSide, err := meta.NewMeta(ctx, &meta.Config{
@@ -30,9 +31,19 @@ func FakeSideProjectProviders(ctx context.Context, tt *TestTools, project *accou
3031
})
3132
require.NoError(t, err)
3233

33-
providers := map[string]func() (*schema.Provider, error){
34-
"side": func() (*schema.Provider, error) {
35-
return provider.SDKProvider(&provider.Config{Meta: metaSide})(), nil
34+
providers := map[string]func() (tfprotov6.ProviderServer, error){
35+
"side": func() (tfprotov6.ProviderServer, error) {
36+
providers, errProvider := provider.NewProviderList(ctx, &provider.Config{Meta: metaSide})
37+
if errProvider != nil {
38+
return nil, errProvider
39+
}
40+
41+
muxServer, errMux := tf6muxserver.NewMuxServer(ctx, providers...)
42+
if errMux != nil {
43+
return nil, errMux
44+
}
45+
46+
return muxServer.ProviderServer(), nil
3647
},
3748
}
3849

internal/provider/provider_mux_test.go

Lines changed: 0 additions & 47 deletions
This file was deleted.

internal/provider/provider_sdkv2.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ func SDKProvider(config *Config) plugin.ProviderFunc {
354354
terraformVersion := p.TerraformVersion
355355

356356
// If we provide meta in config use it. This is useful for tests
357-
if config.Meta != nil {
357+
if config != nil && config.Meta != nil {
358358
return config.Meta, nil
359359
}
360360

internal/provider/providers.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package provider
2+
3+
import (
4+
"context"
5+
6+
"github.com/hashicorp/terraform-plugin-framework/providerserver"
7+
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
8+
"github.com/hashicorp/terraform-plugin-mux/tf5to6server"
9+
)
10+
11+
func NewProviderList(ctx context.Context, config *Config) ([]func() tfprotov6.ProviderServer, error) {
12+
// SDKProvider using terraform-plugin-sdk
13+
upgradedSdkProvider, err := tf5to6server.UpgradeServer(
14+
ctx,
15+
SDKProvider(config)().GRPCProvider,
16+
)
17+
if err != nil {
18+
return nil, err
19+
}
20+
21+
return []func() tfprotov6.ProviderServer{
22+
// Provider using terraform-plugin-framework
23+
providerserver.NewProtocol6(&ScalewayProvider{}),
24+
25+
func() tfprotov6.ProviderServer {
26+
return upgradedSdkProvider
27+
},
28+
}, nil
29+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package provider_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
7+
"github.com/scaleway/terraform-provider-scaleway/v2/internal/acctest"
8+
instancechecks "github.com/scaleway/terraform-provider-scaleway/v2/internal/services/instance/testfuncs"
9+
)
10+
11+
func TestMuxServer(t *testing.T) {
12+
tt := acctest.NewTestTools(t)
13+
defer tt.Cleanup()
14+
15+
resource.Test(t, resource.TestCase{
16+
ProtoV6ProviderFactories: tt.ProviderFactories,
17+
Steps: []resource.TestStep{
18+
{
19+
Config: `
20+
resource scaleway_instance_ip main {}`,
21+
Check: resource.ComposeTestCheckFunc(
22+
instancechecks.CheckIPExists(tt, "scaleway_instance_ip.main"),
23+
),
24+
},
25+
},
26+
})
27+
}

internal/services/account/project_data_source_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ func TestAccDataSourceProject_Basic(t *testing.T) {
2020
}
2121

2222
resource.ParallelTest(t, resource.TestCase{
23-
PreCheck: func() { acctest.PreCheck(t) },
24-
ProviderFactories: tt.ProviderFactories,
23+
PreCheck: func() { acctest.PreCheck(t) },
24+
ProtoV6ProviderFactories: tt.ProviderFactories,
2525
CheckDestroy: resource.ComposeTestCheckFunc(
2626
isProjectDestroyed(tt),
2727
),
@@ -61,8 +61,8 @@ func TestAccDataSourceProject_Default(t *testing.T) {
6161
}
6262

6363
resource.ParallelTest(t, resource.TestCase{
64-
PreCheck: func() { acctest.PreCheck(t) },
65-
ProviderFactories: tt.ProviderFactories,
64+
PreCheck: func() { acctest.PreCheck(t) },
65+
ProtoV6ProviderFactories: tt.ProviderFactories,
6666
Steps: []resource.TestStep{
6767
{
6868
Config: fmt.Sprintf(`
@@ -105,8 +105,8 @@ func TestAccDataSourceProject_Extract(t *testing.T) {
105105
}
106106

107107
resource.ParallelTest(t, resource.TestCase{
108-
PreCheck: func() { acctest.PreCheck(t) },
109-
ProviderFactories: tt.ProviderFactories,
108+
PreCheck: func() { acctest.PreCheck(t) },
109+
ProtoV6ProviderFactories: tt.ProviderFactories,
110110
Steps: []resource.TestStep{
111111
{
112112
Config: `data scaleway_account_project "project" {}`,
@@ -129,8 +129,8 @@ func TestAccDataSourceProject_List(t *testing.T) {
129129
}
130130

131131
resource.ParallelTest(t, resource.TestCase{
132-
PreCheck: func() { acctest.PreCheck(t) },
133-
ProviderFactories: tt.ProviderFactories,
132+
PreCheck: func() { acctest.PreCheck(t) },
133+
ProtoV6ProviderFactories: tt.ProviderFactories,
134134
CheckDestroy: resource.ComposeTestCheckFunc(
135135
isProjectDestroyed(tt),
136136
),

internal/services/account/project_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ func TestAccProject_Basic(t *testing.T) {
2222
defer tt.Cleanup()
2323

2424
resource.ParallelTest(t, resource.TestCase{
25-
ProviderFactories: tt.ProviderFactories,
26-
CheckDestroy: isProjectDestroyed(tt),
25+
ProtoV6ProviderFactories: tt.ProviderFactories,
26+
CheckDestroy: isProjectDestroyed(tt),
2727
Steps: []resource.TestStep{
2828
{
2929
Config: `
@@ -60,8 +60,8 @@ func TestAccProject_NoUpdate(t *testing.T) {
6060
defer tt.Cleanup()
6161

6262
resource.ParallelTest(t, resource.TestCase{
63-
ProviderFactories: tt.ProviderFactories,
64-
CheckDestroy: isProjectDestroyed(tt),
63+
ProtoV6ProviderFactories: tt.ProviderFactories,
64+
CheckDestroy: isProjectDestroyed(tt),
6565
Steps: []resource.TestStep{
6666
{
6767
Config: `

0 commit comments

Comments
 (0)