Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring #414

Merged
merged 2 commits into from
Feb 12, 2024
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
5 changes: 0 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ require (
github.com/hashicorp/terraform v0.14.0
github.com/hashicorp/terraform-plugin-sdk v1.17.2
github.com/nav-inc/datetime v0.1.3
github.com/openlyinc/pointy v1.1.2
github.com/outscale/osc-sdk-go/v2 v2.18.2
github.com/spf13/cast v1.3.1
)
Expand Down Expand Up @@ -60,7 +59,6 @@ require (
github.com/huandu/xstrings v1.3.2 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jstemmer/go-junit-report v0.9.1 // indirect
github.com/klauspost/compress v1.17.1 // indirect
github.com/mattn/go-colorable v0.1.1 // indirect
github.com/mattn/go-isatty v0.0.5 // indirect
Expand All @@ -82,14 +80,11 @@ require (
github.com/zclconf/go-cty-yaml v1.0.2 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.13.0 // indirect
golang.org/x/sync v0.4.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.6.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
google.golang.org/api v0.147.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
Expand Down
37 changes: 4 additions & 33 deletions go.sum

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions outscale/data_source_outscale_access_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

func TestAccOthers_DatasourceAccessKey_basic(t *testing.T) {
t.Parallel()
dataSourceName := "outscale_access_key.outscale_access_key"
dataSourceName := "outscale_access_key.access_key_basic"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -30,7 +30,7 @@ func TestAccOthers_DatasourceAccessKey_basic(t *testing.T) {

func TestAccOthers_AccessKey_withFilters(t *testing.T) {
t.Parallel()
dataSourceName := "outscale_access_key.outscale_access_key"
dataSourceName := "outscale_access_key.keyFilters"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -52,22 +52,22 @@ func TestAccOthers_AccessKey_withFilters(t *testing.T) {

func testAccClientAccessKeyDataSourceBasic() string {
return `
resource "outscale_access_key" "outscale_access_key" {}
resource "outscale_access_key" "access_key_basic" {}

data "outscale_access_key" "outscale_access_key" {
access_key_id = outscale_access_key.outscale_access_key.id
data "outscale_access_key" "access_keyBasic" {
access_key_id = outscale_access_key.access_key_basic.id
}
`
}

func testAccClientAccessKeyDataSourceWithFilters() string {
return `
resource "outscale_access_key" "outscale_access_key" {}
resource "outscale_access_key" "keyFilters" {}

data "outscale_access_key" "outscale_access_key" {
data "outscale_access_key" "access_key_filters" {
filter {
name = "access_key_ids"
values = [outscale_access_key.outscale_access_key.id]
values = [outscale_access_key.keyFilters.id]
}
}
`
Expand Down
37 changes: 5 additions & 32 deletions outscale/data_source_outscale_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,11 @@ func getOApiVMAttributesSchema() map[string]*schema.Schema {
},
"block_device_mappings_created": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"bsu": {
Type: schema.TypeMap,
Optional: true,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand All @@ -322,14 +320,13 @@ func getOApiVMAttributesSchema() map[string]*schema.Schema {
},
"device_name": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
},
},
},
"bsu_optimized": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
"client_token": {
Expand All @@ -342,7 +339,6 @@ func getOApiVMAttributesSchema() map[string]*schema.Schema {
},
"deletion_protection": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
"hypervisor": {
Expand All @@ -351,28 +347,24 @@ func getOApiVMAttributesSchema() map[string]*schema.Schema {
},
"image_id": {
Type: schema.TypeString,
ForceNew: true,
Optional: true,
Computed: true,
},
"is_source_dest_checked": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
"keypair_name": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"security_group_ids": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
outscale-toa marked this conversation as resolved.
Show resolved Hide resolved
Elem: &schema.Schema{Type: schema.TypeString},
},
"security_group_names": {
Type: schema.TypeList,
Optional: true,
outscale-toa marked this conversation as resolved.
Show resolved Hide resolved
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"launch_number": {
Expand Down Expand Up @@ -557,39 +549,32 @@ func getOApiVMAttributesSchema() map[string]*schema.Schema {
},
"nics": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"delete_on_vm_deletion": {
Type: schema.TypeBool,
Computed: true,
Optional: true,
},
"description": {
Type: schema.TypeString,
Computed: true,
Optional: true,
},
"device_number": {
Type: schema.TypeInt,
Computed: true,
Optional: true,
},
"nic_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"private_ips": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"is_primary": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
"link_public_ip": {
Expand Down Expand Up @@ -618,20 +603,17 @@ func getOApiVMAttributesSchema() map[string]*schema.Schema {
},
"private_ip": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
},
},
},
"secondary_private_ip_count": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"security_group_ids": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
Expand All @@ -648,7 +630,6 @@ func getOApiVMAttributesSchema() map[string]*schema.Schema {
"subnet_id": {
Type: schema.TypeString,
Computed: true,
Optional: true,
},
"link_nic": {
Type: schema.TypeList,
Expand Down Expand Up @@ -710,7 +691,6 @@ func getOApiVMAttributesSchema() map[string]*schema.Schema {
},
"security_groups_names": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
Expand Down Expand Up @@ -747,12 +727,10 @@ func getOApiVMAttributesSchema() map[string]*schema.Schema {
},
"placement_subregion_name": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"placement_tenancy": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"private_dns_name": {
Expand Down Expand Up @@ -814,8 +792,6 @@ func getOApiVMAttributesSchema() map[string]*schema.Schema {
},
"subnet_id": {
Type: schema.TypeString,
ForceNew: true,
Optional: true,
Computed: true,
},
"tags": {
Expand All @@ -836,22 +812,19 @@ func getOApiVMAttributesSchema() map[string]*schema.Schema {
},
"user_data": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"vm_id": {
Type: schema.TypeString,
Computed: true,
Optional: true,
Computed: true,
},
"vm_initiated_shutdown_behavior": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"vm_type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"request_id": {
Expand All @@ -860,7 +833,7 @@ func getOApiVMAttributesSchema() map[string]*schema.Schema {
},
"private_ips": {
Type: schema.TypeList,
Optional: true,
Computed: true,
outscale-toa marked this conversation as resolved.
Show resolved Hide resolved
Elem: &schema.Schema{Type: schema.TypeString},
},
}
Expand Down
8 changes: 3 additions & 5 deletions outscale/resource_outscale_ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/openlyinc/pointy"
oscgo "github.com/outscale/osc-sdk-go/v2"
"github.com/spf13/cast"
"github.com/terraform-providers/terraform-provider-outscale/utils"
Expand Down Expand Up @@ -58,8 +57,8 @@ func resourceOutscaleOAPICaCreate(d *schema.ResourceData, meta interface{}) erro
req := oscgo.CreateCaRequest{
CaPem: d.Get("ca_pem").(string),
}
if v, ok := d.GetOk("description"); ok {
req.Description = pointy.String(v.(string))
if _, ok := d.GetOk("description"); ok {
req.SetDescription(d.Get("description").(string))
}

var resp oscgo.CreateCaResponse
Expand Down Expand Up @@ -130,8 +129,7 @@ func resourceOutscaleOAPICaUpdate(d *schema.ResourceData, meta interface{}) erro
}

if d.HasChange("description") {
_, des := d.GetChange("description")
req.Description = pointy.String(des.(string))
req.SetDescription(d.Get("description").(string))
}

var err error
Expand Down
8 changes: 3 additions & 5 deletions outscale/resource_outscale_dhcp_option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"testing"
"time"

"github.com/openlyinc/pointy"
"github.com/terraform-providers/terraform-provider-outscale/utils"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
Expand Down Expand Up @@ -122,10 +121,9 @@ func TestAccNet_withDhcpOptional(t *testing.T) {
domainName := fmt.Sprintf("%s.compute%s.internal", utils.GetRegion(), acctest.RandString(3))
domainServers := []string{"192.168.12.12", "192.168.12.132"}

tags := &oscgo.Tag{
Key: pointy.String(acctest.RandomWithPrefix("name")),
Value: pointy.String(acctest.RandomWithPrefix("test-MZI")),
}
tags := &oscgo.Tag{}
tags.SetKey(acctest.RandomWithPrefix("name"))
tags.SetValue(acctest.RandomWithPrefix("test-MZI"))

domainNameUpdated := fmt.Sprintf("%s.compute%s.internal", utils.GetRegion(), acctest.RandString(3))

Expand Down
27 changes: 15 additions & 12 deletions outscale/resource_outscale_flexible_gpu_link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,22 @@ import (
)

func TestAccVM_withFlexibleGpuLink_basic(t *testing.T) {
omi := os.Getenv("OUTSCALE_IMAGEID")

resource.Test(t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
},
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccOutscaleOAPIFlexibleGpuLinkConfig(omi, "tinav5.c2r2p2", utils.GetRegion()),
if os.Getenv("TEST_QUOTA") == "true" {
omi := os.Getenv("OUTSCALE_IMAGEID")
resource.Test(t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
},
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccOutscaleOAPIFlexibleGpuLinkConfig(omi, "tinav5.c2r2p2", utils.GetRegion()),
},
},
},
})
})
} else {
t.Skip("will be done soon")
}
}

func testAccOutscaleOAPIFlexibleGpuLinkConfig(omi, vmType, region string) string {
Expand Down
7 changes: 2 additions & 5 deletions outscale/resource_outscale_image_export_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"github.com/terraform-providers/terraform-provider-outscale/utils"

"github.com/openlyinc/pointy"
oscgo "github.com/outscale/osc-sdk-go/v2"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
Expand Down Expand Up @@ -146,10 +145,8 @@ func resourceOAPIImageExportTaskCreate(d *schema.ResourceData, meta interface{})
a := v.([]interface{})
if len(a) > 0 {
w := a[0].(map[string]interface{})
et.OsuApiKey = &oscgo.OsuApiKey{
ApiKeyId: pointy.String(w["api_key_id"].(string)),
SecretKey: pointy.String(w["secret_key"].(string)),
}
et.OsuApiKey.SetApiKeyId(w["api_key_id"].(string))
et.OsuApiKey.SetSecretKey(w["secret_key"].(string))
}
}
if v, ok := e["osu_manifest_url"]; ok {
Expand Down
Loading
Loading