Skip to content

Commit 596bb86

Browse files
authored
Merge branch 'master' into migrate_secret
2 parents 32441ed + 8a8c029 commit 596bb86

File tree

223 files changed

+8811
-4447
lines changed

Some content is hidden

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

223 files changed

+8811
-4447
lines changed

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: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package acctest
22

33
import (
4+
"context"
45
"os"
56
"strconv"
67
"strings"
78
"testing"
89
"time"
910

10-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
11+
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
12+
"github.com/hashicorp/terraform-plugin-mux/tf5muxserver"
1113
"github.com/scaleway/terraform-provider-scaleway/v2/internal/env"
1214
"github.com/scaleway/terraform-provider-scaleway/v2/internal/meta"
1315
"github.com/scaleway/terraform-provider-scaleway/v2/internal/provider"
@@ -20,7 +22,7 @@ func PreCheck(_ *testing.T) {}
2022
type TestTools struct {
2123
T *testing.T
2224
Meta *meta.Meta
23-
ProviderFactories map[string]func() (*schema.Provider, error)
25+
ProviderFactories map[string]func() (tfprotov5.ProviderServer, error)
2426
Cleanup func()
2527
}
2628

@@ -64,9 +66,17 @@ func NewTestTools(t *testing.T) *TestTools {
6466
return &TestTools{
6567
T: t,
6668
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
69+
ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){
70+
"scaleway": func() (tfprotov5.ProviderServer, error) {
71+
ctx := context.Background()
72+
providers := provider.NewProviderList(&provider.Config{Meta: m})
73+
74+
muxServer, err := tf5muxserver.NewMuxServer(ctx, providers...)
75+
if err != nil {
76+
return nil, err
77+
}
78+
79+
return muxServer.ProviderServer(), nil
7080
},
7181
},
7282
Cleanup: cleanup,

internal/acctest/fixtures.go

Lines changed: 13 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/tfprotov5"
7+
"github.com/hashicorp/terraform-plugin-mux/tf5muxserver"
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() (tfprotov5.ProviderServer, error) {
2122
t := tt.T
2223

2324
metaSide, err := meta.NewMeta(ctx, &meta.Config{
@@ -30,9 +31,16 @@ 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() (tfprotov5.ProviderServer, error){
35+
"side": func() (tfprotov5.ProviderServer, error) {
36+
providers := provider.NewProviderList(&provider.Config{Meta: metaSide})
37+
38+
muxServer, err := tf5muxserver.NewMuxServer(ctx, providers...)
39+
if err != nil {
40+
return nil, err
41+
}
42+
43+
return muxServer.ProviderServer(), nil
3644
},
3745
}
3846

internal/provider/provider_mux_test.go

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

internal/provider/providers.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package provider
2+
3+
import (
4+
"github.com/hashicorp/terraform-plugin-framework/providerserver"
5+
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
6+
)
7+
8+
func NewProviderList(config *Config) []func() tfprotov5.ProviderServer {
9+
return []func() tfprotov5.ProviderServer{
10+
// Provider using terraform-plugin-framework
11+
providerserver.NewProtocol5(&ScalewayProvider{}),
12+
13+
// SDKProvider using terraform-plugin-sdk
14+
SDKProvider(config)().GRPCProvider,
15+
}
16+
}
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+
ProtoV5ProviderFactories: 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+
ProtoV5ProviderFactories: 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+
ProtoV5ProviderFactories: 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+
ProtoV5ProviderFactories: 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+
ProtoV5ProviderFactories: 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+
ProtoV5ProviderFactories: 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+
ProtoV5ProviderFactories: tt.ProviderFactories,
64+
CheckDestroy: isProjectDestroyed(tt),
6565
Steps: []resource.TestStep{
6666
{
6767
Config: `

internal/services/applesilicon/server_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ func TestAccServer_Basic(t *testing.T) {
1717
defer tt.Cleanup()
1818

1919
resource.ParallelTest(t, resource.TestCase{
20-
PreCheck: func() { acctest.PreCheck(t) },
21-
ProviderFactories: tt.ProviderFactories,
22-
CheckDestroy: isServerDestroyed(tt),
20+
PreCheck: func() { acctest.PreCheck(t) },
21+
ProtoV5ProviderFactories: tt.ProviderFactories,
22+
CheckDestroy: isServerDestroyed(tt),
2323
Steps: []resource.TestStep{
2424
{
2525
Config: `
@@ -70,9 +70,9 @@ func TestAccServer_EnableDisabledVPC(t *testing.T) {
7070
defer tt.Cleanup()
7171

7272
resource.ParallelTest(t, resource.TestCase{
73-
PreCheck: func() { acctest.PreCheck(t) },
74-
ProviderFactories: tt.ProviderFactories,
75-
CheckDestroy: isServerDestroyed(tt),
73+
PreCheck: func() { acctest.PreCheck(t) },
74+
ProtoV5ProviderFactories: tt.ProviderFactories,
75+
CheckDestroy: isServerDestroyed(tt),
7676
Steps: []resource.TestStep{
7777
{
7878
Config: `
@@ -125,9 +125,9 @@ func TestAccServer_EnableVPC(t *testing.T) {
125125
defer tt.Cleanup()
126126

127127
resource.ParallelTest(t, resource.TestCase{
128-
PreCheck: func() { acctest.PreCheck(t) },
129-
ProviderFactories: tt.ProviderFactories,
130-
CheckDestroy: isServerDestroyed(tt),
128+
PreCheck: func() { acctest.PreCheck(t) },
129+
ProtoV5ProviderFactories: tt.ProviderFactories,
130+
CheckDestroy: isServerDestroyed(tt),
131131
Steps: []resource.TestStep{
132132
{
133133
Config: `
@@ -270,9 +270,9 @@ func TestAccServer_Commitment(t *testing.T) {
270270
defer tt.Cleanup()
271271

272272
resource.ParallelTest(t, resource.TestCase{
273-
PreCheck: func() { acctest.PreCheck(t) },
274-
ProviderFactories: tt.ProviderFactories,
275-
CheckDestroy: isServerDestroyed(tt),
273+
PreCheck: func() { acctest.PreCheck(t) },
274+
ProtoV5ProviderFactories: tt.ProviderFactories,
275+
CheckDestroy: isServerDestroyed(tt),
276276
Steps: []resource.TestStep{
277277
{
278278
Config: `

internal/services/autoscaling/instance_group_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ func TestAccInstanceGroup_Basic(t *testing.T) {
1717
defer tt.Cleanup()
1818

1919
resource.ParallelTest(t, resource.TestCase{
20-
PreCheck: func() { acctest.PreCheck(t) },
21-
ProviderFactories: tt.ProviderFactories,
22-
CheckDestroy: testAccCheckInstanceGroupDestroy(tt),
20+
PreCheck: func() { acctest.PreCheck(t) },
21+
ProtoV5ProviderFactories: tt.ProviderFactories,
22+
CheckDestroy: testAccCheckInstanceGroupDestroy(tt),
2323
Steps: []resource.TestStep{
2424
{
2525
Config: `

0 commit comments

Comments
 (0)