Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ jobs:
- name: golangci-lint
uses: golangci/[email protected]
with:
version: v2.3.0
version: v2.5.0
args: --timeout 5m
8 changes: 4 additions & 4 deletions internal/locality/regional/ids.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,22 @@ func NewIDString(region scw.Region, id string) string {
func ParseNestedID(regionalNestedID string) (region scw.Region, outerID, innerID string, err error) {
loc, innerID, outerID, err := locality.ParseLocalizedNestedID(regionalNestedID)
if err != nil {
return
return region, outerID, innerID, err
}

region, err = scw.ParseRegion(loc)

return
return region, outerID, innerID, err
}

// ParseID parses a regionalID and extracts the resource region and id.
func ParseID(regionalID string) (region scw.Region, id string, err error) {
loc, id, err := locality.ParseLocalizedID(regionalID)
if err != nil {
return
return region, id, err
}

region, err = scw.ParseRegion(loc)

return
return region, id, err
}
6 changes: 3 additions & 3 deletions internal/locality/zonal/ids.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,17 @@ func ParseID(zonedID string) (zone scw.Zone, id string, err error) {

zone, err = scw.ParseZone(rawZone)

return
return zone, id, err
}

// ParseNestedID parses a zonedNestedID and extracts the resource zone ,inner and outer ID.
func ParseNestedID(zonedNestedID string) (zone scw.Zone, outerID, innerID string, err error) {
rawZone, innerID, outerID, err := locality.ParseLocalizedNestedID(zonedNestedID)
if err != nil {
return
return zone, outerID, innerID, err
}

zone, err = scw.ParseZone(rawZone)

return
return zone, outerID, innerID, err
}
2 changes: 1 addition & 1 deletion internal/services/iam/group_membership.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func ExpandGroupMembershipID(id string) (groupID string, userID string, applicat
applicationID = elems[2]
}

return
return groupID, userID, applicationID, err
}

func MakeGroupRequest(ctx context.Context, api *iam.API, request any) (*iam.Group, error) {
Expand Down
3 changes: 3 additions & 0 deletions internal/services/instance/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2023,6 +2023,7 @@ func TestAccServer_PrivateNetworkMissingPNIC(t *testing.T) {
ImportState: true,
ImportStateIdFunc: func(state *terraform.State) (string, error) {
serverID := state.RootModule().Resources["scaleway_instance_server.main"].Primary.ID

pnicID, exists := state.RootModule().Resources["scaleway_instance_server.main"].Primary.Attributes["private_network.0.pnic_id"]
if !exists {
return "", errors.New("private_network.0.pnic_id not found")
Expand Down Expand Up @@ -2066,7 +2067,9 @@ func TestAccServer_PrivateNetworkMissingPNIC(t *testing.T) {
if !exists {
return errors.New("private_network.0.pnic_id not found")
}

localizedPNICID := state.RootModule().Resources["scaleway_instance_private_nic.pnic"].Primary.ID

_, pnicID, _, err := zonal.ParseNestedID(localizedPNICID)
if err != nil {
return err
Expand Down
5 changes: 5 additions & 0 deletions internal/services/k8s/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ func ResourceCluster() *schema.Resource {
if okAutoUpgradeEnable && autoUpgradeEnable.(bool) && !versionIsOnlyMinor {
return errors.New("only minor version x.y can be used with auto upgrade enabled")
}

if versionIsOnlyMinor && !autoUpgradeEnable.(bool) {
return errors.New("minor version x.y must only be used with auto upgrade enabled")
}
Expand All @@ -257,11 +258,13 @@ func ResourceCluster() *schema.Resource {
// If no private network has been set yet, migrate the cluster in the Update function
return nil
}

if planned != "" {
_, plannedPNID, err := locality.ParseLocalizedID(planned.(string))
if err != nil {
return err
}

if plannedPNID == actual {
// If the private network ID is the same, do nothing
return nil
Expand All @@ -283,6 +286,7 @@ func ResourceCluster() *schema.Resource {
if err != nil {
return err
}

possibleTypes, err := k8sAPI.ListClusterAvailableTypes(&k8s.ListClusterAvailableTypesRequest{
Region: region,
ClusterID: clusterID,
Expand All @@ -297,6 +301,7 @@ func ResourceCluster() *schema.Resource {
return nil
}
}

err = diff.ForceNew("type")
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions internal/services/lb/backends_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func DataSourceBackends() *schema.Resource {
Computed: true,
Description: func() string {
var t lb.ForwardPortAlgorithm

values := t.Values()

return fmt.Sprintf("Load balancing algorithm to be used when determining which backend server to forward new traffic to. Possible values are: %s", values)
Expand Down
2 changes: 2 additions & 0 deletions internal/services/lb/lb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ func TestAccLB_Migrate(t *testing.T) {
if !ok {
return fmt.Errorf("resource not found: %s", "scaleway_lb.main")
}

lbID = rs.Primary.ID

return nil
Expand Down Expand Up @@ -310,6 +311,7 @@ func TestAccLB_Migrate(t *testing.T) {
if !ok {
return fmt.Errorf("resource not found: %s", "scaleway_lb.main")
}

if rs.Primary.ID != lbID {
return errors.New("LB id has changed")
}
Expand Down
1 change: 1 addition & 0 deletions internal/services/lb/lbs_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ func DataSourceLbs() *schema.Resource {
Computed: true,
Description: func() string {
var t lb.SSLCompatibilityLevel

values := t.Values()

return fmt.Sprintf("SSL compatibility level possible values are %s", values)
Expand Down
1 change: 1 addition & 0 deletions internal/services/mnq/sns_topic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func TestAccSNSTopic_Basic(t *testing.T) {
if !exists {
return errors.New("failed to find resource")
}

name, exists := topic.Primary.Attributes["name"]
if !exists {
return errors.New("failed to find atttribute")
Expand Down
1 change: 1 addition & 0 deletions internal/services/mongodb/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ func ResourceInstance() *schema.Resource {
func(ctx context.Context, d *schema.ResourceDiff, meta any) error {
if d.HasChange("version") {
v := d.Get("version").(string)

parts := strings.Split(v, ".")
if len(parts) > 2 {
majorMinor := parts[0] + "." + parts[1]
Expand Down
1 change: 1 addition & 0 deletions internal/services/mongodb/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func ResourceUser() *schema.Resource {
if databaseName != "" && anyDatabase {
return errors.New("database_name and any_database are mutually exclusive")
}

if databaseName == "" && !anyDatabase {
return errors.New("either database_name or any_database must be specified")
}
Expand Down
6 changes: 6 additions & 0 deletions internal/services/scwconfig/scw_config_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ func TestAccDataSourceConfig_ActiveProfile(t *testing.T) {
PreCheck: func() { acctest.PreCheck(t) },
ProviderFactories: func() map[string]func() (*schema.Provider, error) {
_ = os.Unsetenv("SCW_PROFILE")

t.Setenv("SCW_CONFIG_PATH", "./testfixture/test_config.yaml")

metaDefault, err := meta.NewMeta(ctx, &meta.Config{
TerraformVersion: "terraform-tests",
HTTPClient: tt.Meta.HTTPClient(),
Expand Down Expand Up @@ -81,8 +83,10 @@ func TestAccDataSourceConfig_OtherProfile(t *testing.T) {
PreCheck: func() { acctest.PreCheck(t) },
ProviderFactories: func() map[string]func() (*schema.Provider, error) {
_ = os.Unsetenv("SCW_PROFILE")

t.Setenv("SCW_CONFIG_PATH", "./testfixture/test_config.yaml")
t.Setenv("SCW_PROFILE", "other")

metaOther, err := meta.NewMeta(ctx, &meta.Config{
TerraformVersion: "terraform-tests",
HTTPClient: tt.Meta.HTTPClient(),
Expand Down Expand Up @@ -134,9 +138,11 @@ func TestAccDataSourceConfig_MixedProfile(t *testing.T) {
PreCheck: func() { acctest.PreCheck(t) },
ProviderFactories: func() map[string]func() (*schema.Provider, error) {
_ = os.Unsetenv("SCW_PROFILE")

t.Setenv("SCW_CONFIG_PATH", "./testfixture/test_config.yaml")
t.Setenv("SCW_PROFILE", "incomplete")
t.Setenv("SCW_DEFAULT_PROJECT_ID", "77777777-7777-7777-7777-777777777777")

metaMixed, err := meta.NewMeta(ctx, &meta.Config{
TerraformVersion: "terraform-tests",
HTTPClient: tt.Meta.HTTPClient(),
Expand Down
1 change: 1 addition & 0 deletions internal/services/secret/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func ResourceSecret() *schema.Resource {
Type: schema.TypeString,
Description: func() string {
var t secret.SecretType

secretTypes := t.Values()

return fmt.Sprintf("Type of the secret could be any value among: %s", secretTypes)
Expand Down
2 changes: 1 addition & 1 deletion internal/services/vpc/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func expandSubnets(d *schema.ResourceData) (ipv4Subnets []scw.IPNet, ipv6Subnets
}
}

return
return ipv4Subnets, ipv6Subnets, err
}

func FlattenAndSortSubnets(sub any) (any, any) {
Expand Down
Loading