diff --git a/gridscale/config.go b/gridscale/config.go index b8d0000b..59c1828d 100644 --- a/gridscale/config.go +++ b/gridscale/config.go @@ -21,7 +21,6 @@ var marketplaceAppCategories = []string{"CMS", "project management", "Adminpanel var postgreSQLPerformanceClasses = []string{"standard", "high", "insane", "ultra"} var filesystemPerformanceClasses = []string{"standard", "high", "insane", "ultra"} var msSQLServerPerformanceClasses = []string{"standard", "high", "insane", "ultra"} -var mariaDBPerformanceClasses = []string{"standard", "high", "insane", "ultra"} var machineTypes = []string{"i440fx", "q35_bios", "q35_uefi"} var storageDevices = []string{"ide", "sata", "virtio_scsi", "virtio_block"} var usbControllers = []string{"nec_xhci", "piix3_uhci"} diff --git a/gridscale/datasource_gridscale_backup_test.go b/gridscale/datasource_gridscale_backup_test.go index 16784d29..ebe72bae 100644 --- a/gridscale/datasource_gridscale_backup_test.go +++ b/gridscale/datasource_gridscale_backup_test.go @@ -1,7 +1,6 @@ package gridscale import ( - "fmt" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -24,12 +23,12 @@ func TestAccdataSourceGridscaleBackup_basic(t *testing.T) { } func testAccCheckDataSourceBackupConfig_basic() string { - return fmt.Sprintf(` + return ` resource "gridscale_storage" "foo" { name = "storage" capacity = 1 } data "gridscale_backup_list" "foo" { storage_uuid = gridscale_storage.foo.id -}`) +}` } diff --git a/gridscale/datasource_gridscale_objectstorage_test.go b/gridscale/datasource_gridscale_objectstorage_test.go index 28cd00c0..63e618f5 100644 --- a/gridscale/datasource_gridscale_objectstorage_test.go +++ b/gridscale/datasource_gridscale_objectstorage_test.go @@ -1,7 +1,6 @@ package gridscale import ( - "fmt" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -29,12 +28,12 @@ func TestAccdataSourceGridscaleObjectStorage_basic(t *testing.T) { } func testAccCheckDataSourceObjectStorageConfig_basic() string { - return fmt.Sprint(` + return ` resource "gridscale_object_storage_accesskey" "foo" { } data "gridscale_object_storage_accesskey" "foo" { resource_id = "${gridscale_object_storage_accesskey.foo.id}" } -`) +` } diff --git a/gridscale/datasource_gridscale_paas.go b/gridscale/datasource_gridscale_paas.go index f0d33dda..d8796d44 100644 --- a/gridscale/datasource_gridscale_paas.go +++ b/gridscale/datasource_gridscale_paas.go @@ -163,7 +163,7 @@ func dataSourceGridscalePaaSRead(d *schema.ResourceData, meta interface{}) error if err = d.Set("name", props.Name); err != nil { return fmt.Errorf("%s error setting name: %v", errorPrefix, err) } - if creds != nil && len(creds) > 0 { + if len(creds) > 0 { if err = d.Set("username", creds[0].Username); err != nil { return fmt.Errorf("%s error setting username: %v", errorPrefix, err) } @@ -222,6 +222,10 @@ func dataSourceGridscalePaaSRead(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("%s error: %v", errorPrefix, err) } valueInString, err := convInterfaceToString(paramValType, value) + + if err != nil { + return err + } param := map[string]interface{}{ "param": k, "value": valueInString, diff --git a/gridscale/datasource_gridscale_publicnetwork_test.go b/gridscale/datasource_gridscale_publicnetwork_test.go index 0bf3b667..416371cf 100644 --- a/gridscale/datasource_gridscale_publicnetwork_test.go +++ b/gridscale/datasource_gridscale_publicnetwork_test.go @@ -1,7 +1,6 @@ package gridscale import ( - "fmt" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -26,7 +25,7 @@ func TestAccdataSourceGridscalePublicNetwork_basic(t *testing.T) { } func testAccCheckDataSourcePublicNetworkConfig_basic() string { - return fmt.Sprint(` + return ` data "gridscale_public_network" "foo" { -}`) +}` } diff --git a/gridscale/datasource_gridscale_server.go b/gridscale/datasource_gridscale_server.go index a63b36e2..8737d807 100644 --- a/gridscale/datasource_gridscale_server.go +++ b/gridscale/datasource_gridscale_server.go @@ -372,7 +372,7 @@ func dataSourceGridscaleServerRead(d *schema.ResourceData, meta interface{}) err } //Get storages - storages := make([]interface{}, 0) + /*storages := make([]interface{}, 0) for _, value := range server.Properties.Relations.Storages { storage := map[string]interface{}{ "object_uuid": value.ObjectUUID, @@ -389,7 +389,7 @@ func dataSourceGridscaleServerRead(d *schema.ResourceData, meta interface{}) err "capacity": value.Capacity, } storages = append(storages, storage) - } + }*/ // Get hardware_profile_config hardwareProfileConfigList := make([]interface{}, 0) diff --git a/gridscale/resource_gridscale_backup_schedule_test.go b/gridscale/resource_gridscale_backup_schedule_test.go index 7fc543fd..792e0734 100644 --- a/gridscale/resource_gridscale_backup_schedule_test.go +++ b/gridscale/resource_gridscale_backup_schedule_test.go @@ -114,7 +114,7 @@ resource "gridscale_backupschedule" "foo" { } func testAccCheckDataSourceGridscaleBackupScheduleConfig_basic_update() string { - return fmt.Sprintf(` + return ` resource "gridscale_storage" "foo" { name = "storage" capacity = 1 @@ -127,11 +127,11 @@ resource "gridscale_backupschedule" "foo" { next_runtime = "2030-12-30 15:04:05" active = true } -`) +` } func testAccCheckDataSourceGridscaleBackupScheduleConfig_forcenew_update() string { - return fmt.Sprintf(` + return ` resource "gridscale_storage" "new" { name = "storage" capacity = 1 @@ -144,5 +144,5 @@ resource "gridscale_backupschedule" "foo" { next_runtime = "2030-12-30 15:04:05" active = true } -`) +` } diff --git a/gridscale/resource_gridscale_bucket_test.go b/gridscale/resource_gridscale_bucket_test.go index be98840b..a641f5f1 100644 --- a/gridscale/resource_gridscale_bucket_test.go +++ b/gridscale/resource_gridscale_bucket_test.go @@ -1,7 +1,6 @@ package gridscale import ( - "fmt" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -32,7 +31,7 @@ func TestAccResourceGridscaleBucket_Basic(t *testing.T) { } func testAccCheckResourceGridscaleBucketConfig_basic() string { - return fmt.Sprint(` + return ` resource "gridscale_object_storage_accesskey" "test" { timeouts { create="10m" @@ -44,5 +43,5 @@ resource "gridscale_object_storage_bucket" "foo" { secret_key = gridscale_object_storage_accesskey.test.secret_key bucket_name = "myterraformbucket" } -`) +` } diff --git a/gridscale/resource_gridscale_filesystem.go b/gridscale/resource_gridscale_filesystem.go index fbf348ef..bc5108af 100644 --- a/gridscale/resource_gridscale_filesystem.go +++ b/gridscale/resource_gridscale_filesystem.go @@ -54,7 +54,7 @@ func resourceGridscaleFilesystem() *schema.Resource { } } if !isReleaseValid { - return fmt.Errorf("%v is not a valid Filesystem service release. Valid releases are: %v\n", newReleaseVal, strings.Join(releaseList, ", ")) + return fmt.Errorf("%v is not a valid Filesystem service release. Valid releases are: %v", newReleaseVal, strings.Join(releaseList, ", ")) } return nil }), @@ -427,7 +427,7 @@ func getFilesystemTemplateUUID(client *gsclient.Client, release, performanceClas } } if !isReleaseValid { - return "", fmt.Errorf("%v is not a valid Filesystem service release. Valid releases are: %v\n", release, strings.Join(releases, ", ")) + return "", fmt.Errorf("%v is not a valid Filesystem service release. Valid releases are: %v", release, strings.Join(releases, ", ")) } return uTemplate.Properties.ObjectUUID, nil diff --git a/gridscale/resource_gridscale_filesystem_test.go b/gridscale/resource_gridscale_filesystem_test.go index 1487e9fd..9405678e 100644 --- a/gridscale/resource_gridscale_filesystem_test.go +++ b/gridscale/resource_gridscale_filesystem_test.go @@ -59,7 +59,7 @@ resource "gridscale_filesystem" "test" { } func testAccCheckResourceGridscaleFilesystemConfig_basic_update() string { - return fmt.Sprintf(` + return ` resource "gridscale_filesystem" "test" { name = "newname" root_squash = false @@ -68,5 +68,5 @@ resource "gridscale_filesystem" "test" { allowed_ip_ranges = ["192.14.15.15"] labels = ["test"] } -`) +` } diff --git a/gridscale/resource_gridscale_firewall_test.go b/gridscale/resource_gridscale_firewall_test.go index 856aa1e8..a9dce2dc 100644 --- a/gridscale/resource_gridscale_firewall_test.go +++ b/gridscale/resource_gridscale_firewall_test.go @@ -121,7 +121,7 @@ resource "gridscale_firewall" "foo" { } func testAccCheckResourceGridscaleFirewallConfig_basic_update() string { - return fmt.Sprintf(` + return ` resource "gridscale_firewall" "foo" { name = "newname" rules_v4_out { @@ -139,5 +139,5 @@ resource "gridscale_firewall" "foo" { comment = "testv6" } } -`) +` } diff --git a/gridscale/resource_gridscale_ipv4_test.go b/gridscale/resource_gridscale_ipv4_test.go index f422ef6a..866a62a9 100644 --- a/gridscale/resource_gridscale_ipv4_test.go +++ b/gridscale/resource_gridscale_ipv4_test.go @@ -110,11 +110,11 @@ resource "gridscale_ipv4" "foo" { } func testAccCheckResourceGridscaleIpv4Config_basic_update() string { - return fmt.Sprintf(` + return ` resource "gridscale_ipv4" "foo" { name = "newname" failover = true reverse_dns = "test.test" } -`) +` } diff --git a/gridscale/resource_gridscale_ipv6_test.go b/gridscale/resource_gridscale_ipv6_test.go index 98c34a7a..b4d8550e 100644 --- a/gridscale/resource_gridscale_ipv6_test.go +++ b/gridscale/resource_gridscale_ipv6_test.go @@ -110,11 +110,11 @@ resource "gridscale_ipv6" "foo" { } func testAccCheckResourceGridscaleIpv6Config_basic_update() string { - return fmt.Sprintf(` + return ` resource "gridscale_ipv6" "foo" { name = "newname" failover = true reverse_dns = "test.test" } -`) +` } diff --git a/gridscale/resource_gridscale_isoimage_test.go b/gridscale/resource_gridscale_isoimage_test.go index 2ca826e8..a47fd5dd 100644 --- a/gridscale/resource_gridscale_isoimage_test.go +++ b/gridscale/resource_gridscale_isoimage_test.go @@ -114,10 +114,10 @@ resource "gridscale_server" "foo" { } func testAccCheckResourceGridscaleISOImageConfig_basic_update() string { - return fmt.Sprintf(` + return ` resource "gridscale_isoimage" "foo" { name = "newname" source_url = "http://tinycorelinux.net/10.x/x86/release/TinyCore-current.iso" } -`) +` } diff --git a/gridscale/resource_gridscale_k8s.go b/gridscale/resource_gridscale_k8s.go index 8868b82c..b49785c4 100644 --- a/gridscale/resource_gridscale_k8s.go +++ b/gridscale/resource_gridscale_k8s.go @@ -39,10 +39,10 @@ func resourceGridscaleK8s() *schema.Resource { newVersionValInf, isVersionSet := d.GetOk("gsk_version") newVersionVal := newVersionValInf.(string) if !isReleaseSet && !isVersionSet { - return errors.New("either \"release\" or \"gsk_version\" has to be defined.") + return errors.New("either \"release\" or \"gsk_version\" has to be defined") } if isReleaseSet && isVersionSet { - return errors.New("\"release\" and \"gsk_version\" cannot be set at the same time. Only one of them is set at a time.") + return errors.New("\"release\" and \"gsk_version\" cannot be set at the same time. Only one of them is set at a time") } paasTemplates, err := client.GetPaaSTemplateList(ctx) @@ -78,10 +78,10 @@ func resourceGridscaleK8s() *schema.Resource { } } if !isReleaseValid && isReleaseSet { - return fmt.Errorf("%v is an INVALID Kubernetes minor release. Valid releases are: %v\n", newReleaseVal, strings.Join(releaseList, ", ")) + return fmt.Errorf("%v is an INVALID Kubernetes minor release. Valid releases are: %v", newReleaseVal, strings.Join(releaseList, ", ")) } if !isVersionValid && isVersionSet { - return fmt.Errorf("%v is an INVALID gridscale Kubernetes (GSK) version. Valid GSK versions are: %v\n", newVersionVal, strings.Join(versionList, ", ")) + return fmt.Errorf("%v is an INVALID gridscale Kubernetes (GSK) version. Valid GSK versions are: %v", newVersionVal, strings.Join(versionList, ", ")) } return validateK8sParameters(d, chosenTemplate) }, @@ -551,7 +551,7 @@ func getK8sTemplateUUIDFromRelease(client *gsclient.Client, release string) (str } } if !isReleaseValid { - return "", fmt.Errorf("%v is an INVALID Kubernetes minor release. Valid releases are: %v\n", release, strings.Join(releases, ", ")) + return "", fmt.Errorf("%v is an INVALID Kubernetes minor release. Valid releases are: %v", release, strings.Join(releases, ", ")) } return uTemplate.Properties.ObjectUUID, nil @@ -577,7 +577,7 @@ func getK8sTemplateUUIDFromGSKVersion(client *gsclient.Client, version string) ( } } if !isVersionValid { - return "", fmt.Errorf("%v is an INVALID gridscale Kubernetes (GSK) version. Valid GSK versions are: %v\n", version, strings.Join(versions, ", ")) + return "", fmt.Errorf("%v is an INVALID gridscale Kubernetes (GSK) version. Valid GSK versions are: %v", version, strings.Join(versions, ", ")) } return uTemplate.Properties.ObjectUUID, nil @@ -671,7 +671,7 @@ func validateK8sParameters(d *schema.ResourceDiff, template gsclient.PaaSTemplat if cluster_cidr.(string) != "" { _, _, err := net.ParseCIDR(cluster_cidr.(string)) if err != nil { - errorMessages = append(errorMessages, fmt.Sprintf("Invalid value for PaaS template release. Value must be a valid CIDR.\n")) + errorMessages = append(errorMessages, "Invalid value for PaaS template release. Value must be a valid CIDR.\n") } } // if cluster_cidr_template is immutable, return error if it is set during k8s creation diff --git a/gridscale/resource_gridscale_k8s_test.go b/gridscale/resource_gridscale_k8s_test.go index 7ca44d25..8ed62a4b 100644 --- a/gridscale/resource_gridscale_k8s_test.go +++ b/gridscale/resource_gridscale_k8s_test.go @@ -58,7 +58,7 @@ resource "gridscale_k8s" "foopaas" { } func testAccCheckResourceGridscaleK8sConfig_basic_update() string { - return fmt.Sprintf(` + return ` resource "gridscale_k8s" "foopaas" { name = "newname" release = "1.26" @@ -72,5 +72,5 @@ resource "gridscale_k8s" "foopaas" { rocket_storage = 90 } } -`) +` } diff --git a/gridscale/resource_gridscale_loadbalancer.go b/gridscale/resource_gridscale_loadbalancer.go index 495367db..8bebe24f 100644 --- a/gridscale/resource_gridscale_loadbalancer.go +++ b/gridscale/resource_gridscale_loadbalancer.go @@ -321,32 +321,34 @@ func expandLoadbalancerForwardingRules(forwardingRules interface{}) []gsclient.F func flattenLoadbalancerForwardingRules(forwardingRules []gsclient.ForwardingRule) []interface{} { tempForwardingRules := make([]interface{}, 0) - if forwardingRules != nil { - for _, value := range forwardingRules { - forwardingRule := map[string]interface{}{ - "letsencrypt_ssl": value.LetsencryptSSL, - "certificate_uuid": value.CertificateUUID, - "listen_port": value.ListenPort, - "mode": value.Mode, - "target_port": value.TargetPort, - } - tempForwardingRules = append(tempForwardingRules, forwardingRule) + if forwardingRules == nil { + return tempForwardingRules + } + for _, value := range forwardingRules { + forwardingRule := map[string]interface{}{ + "letsencrypt_ssl": value.LetsencryptSSL, + "certificate_uuid": value.CertificateUUID, + "listen_port": value.ListenPort, + "mode": value.Mode, + "target_port": value.TargetPort, } + tempForwardingRules = append(tempForwardingRules, forwardingRule) } return tempForwardingRules } func flattenLoadbalancerBackendServers(backendServers []gsclient.BackendServer) []interface{} { tempBackendServers := make([]interface{}, 0) - if backendServers != nil { - for _, value := range backendServers { - backendServer := map[string]interface{}{ - "weight": value.Weight, - "host": value.Host, - "proxy_protocol": value.ProxyProtocol, - } - tempBackendServers = append(tempBackendServers, backendServer) + if backendServers == nil { + return tempBackendServers + } + for _, value := range backendServers { + backendServer := map[string]interface{}{ + "weight": value.Weight, + "host": value.Host, + "proxy_protocol": value.ProxyProtocol, } + tempBackendServers = append(tempBackendServers, backendServer) } return tempBackendServers } diff --git a/gridscale/resource_gridscale_mariadb.go b/gridscale/resource_gridscale_mariadb.go index 210a89a1..308f0069 100644 --- a/gridscale/resource_gridscale_mariadb.go +++ b/gridscale/resource_gridscale_mariadb.go @@ -524,7 +524,7 @@ func getMariaDBTemplateUUID(client *gsclient.Client, release, performanceClass s } } if !isReleaseValid { - return "", fmt.Errorf("%v is not a valid MariaDB release. Valid releases are: %v\n", release, strings.Join(releases, ", ")) + return "", fmt.Errorf("%v is not a valid MariaDB release. Valid releases are: %v", release, strings.Join(releases, ", ")) } return uTemplate.Properties.ObjectUUID, nil diff --git a/gridscale/resource_gridscale_mariadb_test.go b/gridscale/resource_gridscale_mariadb_test.go index 662cffd2..2b7f5623 100644 --- a/gridscale/resource_gridscale_mariadb_test.go +++ b/gridscale/resource_gridscale_mariadb_test.go @@ -50,7 +50,7 @@ resource "gridscale_mariadb" "test" { } func testAccCheckResourceGridscaleMariaDBConfig_basic_update() string { - return fmt.Sprintf(` + return ` resource "gridscale_mariadb" "test" { name = "newname" release = "10.5" @@ -63,5 +63,5 @@ resource "gridscale_mariadb" "test" { mariadb_server_id = 2 mariadb_binlog_format = "STATEMENT" } -`) +` } diff --git a/gridscale/resource_gridscale_marketplace_app.go b/gridscale/resource_gridscale_marketplace_app.go index 340676fc..8acd3fb1 100644 --- a/gridscale/resource_gridscale_marketplace_app.go +++ b/gridscale/resource_gridscale_marketplace_app.go @@ -314,8 +314,7 @@ func resourceGridscaleMarketplaceApplicationRead(d *schema.ResourceData, meta in func resourceGridscaleMarketplaceApplicationCreate(d *schema.ResourceData, meta interface{}) error { client := meta.(*gsclient.Client) - var publish bool - publish = d.Get("publish").(bool) + publish := d.Get("publish").(bool) requestBody := gsclient.MarketplaceApplicationCreateRequest{ Name: d.Get("name").(string), ObjectStoragePath: d.Get("object_storage_path").(string), @@ -370,9 +369,7 @@ func resourceGridscaleMarketplaceApplicationCreate(d *schema.ResourceData, meta func resourceGridscaleMarketplaceApplicationUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*gsclient.Client) errorPrefix := fmt.Sprintf("update marketplace application (%s) resource -", d.Id()) - - var publish bool - publish = d.Get("publish").(bool) + publish := d.Get("publish").(bool) requestBody := gsclient.MarketplaceApplicationUpdateRequest{ Name: d.Get("name").(string), ObjectStoragePath: d.Get("object_storage_path").(string), diff --git a/gridscale/resource_gridscale_marketplace_app_import_test.go b/gridscale/resource_gridscale_marketplace_app_import_test.go index f9e8afa9..28e8fcbe 100644 --- a/gridscale/resource_gridscale_marketplace_app_import_test.go +++ b/gridscale/resource_gridscale_marketplace_app_import_test.go @@ -115,7 +115,7 @@ resource "gridscale_marketplace_application_import" "foo" { } func testAccCheckResourceGridscaleMarketplaceApplicationImportConfig_basic_update() string { - return fmt.Sprintf(` + return ` resource "gridscale_marketplace_application" "foonew" { name = "newname" object_storage_path = "s3://testsnapshot/test.gz" @@ -127,5 +127,5 @@ resource "gridscale_marketplace_application" "foonew" { resource "gridscale_marketplace_application_import" "foo" { import_unique_hash = gridscale_marketplace_application.foonew.unique_hash } -`) +` } diff --git a/gridscale/resource_gridscale_marketplace_app_test.go b/gridscale/resource_gridscale_marketplace_app_test.go index 34dde392..e16c98f2 100644 --- a/gridscale/resource_gridscale_marketplace_app_test.go +++ b/gridscale/resource_gridscale_marketplace_app_test.go @@ -112,7 +112,7 @@ resource "gridscale_marketplace_application" "foo" { } func testAccCheckResourceGridscaleMarketplaceApplicationConfig_basic_update() string { - return fmt.Sprintf(` + return ` resource "gridscale_marketplace_application" "foo" { name = "newname" object_storage_path = "s3://testsnapshot/test.gz" @@ -122,5 +122,5 @@ resource "gridscale_marketplace_application" "foo" { setup_storage_capacity = 5 meta_components = ["test_component", "test_component1"] } -`) +` } diff --git a/gridscale/resource_gridscale_memcached.go b/gridscale/resource_gridscale_memcached.go index ef266142..d83ff184 100644 --- a/gridscale/resource_gridscale_memcached.go +++ b/gridscale/resource_gridscale_memcached.go @@ -407,7 +407,7 @@ func getMemcachedTemplateUUID(client *gsclient.Client, release, performanceClass } } if !isReleaseValid { - return "", fmt.Errorf("%v is not a valid Memcached release. Valid releases are: %v\n", release, strings.Join(releases, ", ")) + return "", fmt.Errorf("%v is not a valid Memcached release. Valid releases are: %v", release, strings.Join(releases, ", ")) } return uTemplate.Properties.ObjectUUID, nil diff --git a/gridscale/resource_gridscale_mysql.go b/gridscale/resource_gridscale_mysql.go index 7bd508df..4cba7dcf 100644 --- a/gridscale/resource_gridscale_mysql.go +++ b/gridscale/resource_gridscale_mysql.go @@ -524,7 +524,7 @@ func getMySQLTemplateUUID(client *gsclient.Client, release, performanceClass str } } if !isReleaseValid { - return "", fmt.Errorf("%v is not a valid MySQL release. Valid releases are: %v\n", release, strings.Join(releases, ", ")) + return "", fmt.Errorf("%v is not a valid MySQL release. Valid releases are: %v", release, strings.Join(releases, ", ")) } return uTemplate.Properties.ObjectUUID, nil diff --git a/gridscale/resource_gridscale_mysql8_0.go b/gridscale/resource_gridscale_mysql8_0.go index 64a3d60e..896dbab2 100644 --- a/gridscale/resource_gridscale_mysql8_0.go +++ b/gridscale/resource_gridscale_mysql8_0.go @@ -458,7 +458,7 @@ func getMySQL8_0TemplateUUID(client *gsclient.Client, release, performanceClass } } if !isReleaseValid { - return "", fmt.Errorf("%v is not a valid MySQL release. Valid releases are: %v\n", release, strings.Join(releases, ", ")) + return "", fmt.Errorf("%v is not a valid MySQL release. Valid releases are: %v", release, strings.Join(releases, ", ")) } return uTemplate.Properties.ObjectUUID, nil diff --git a/gridscale/resource_gridscale_mysql8_0_test.go b/gridscale/resource_gridscale_mysql8_0_test.go index 8f57f4e0..30b36bb2 100644 --- a/gridscale/resource_gridscale_mysql8_0_test.go +++ b/gridscale/resource_gridscale_mysql8_0_test.go @@ -50,7 +50,7 @@ resource "gridscale_mysql8_0" "test" { } func testAccCheckResourceGridscaleMySQL8_0Config_basic_update() string { - return fmt.Sprintf(` + return ` resource "gridscale_mysql8_0" "test" { name = "newname" release = "8.0" @@ -59,5 +59,5 @@ resource "gridscale_mysql8_0" "test" { mysql_max_connections = 2000 labels = ["test"] } -`) +` } diff --git a/gridscale/resource_gridscale_mysql_test.go b/gridscale/resource_gridscale_mysql_test.go index ca92c05e..7555a555 100644 --- a/gridscale/resource_gridscale_mysql_test.go +++ b/gridscale/resource_gridscale_mysql_test.go @@ -50,7 +50,7 @@ resource "gridscale_mysql" "test" { } func testAccCheckResourceGridscaleMySQLConfig_basic_update() string { - return fmt.Sprintf(` + return ` resource "gridscale_mysql" "test" { name = "newname" release = "5.7" @@ -59,5 +59,5 @@ resource "gridscale_mysql" "test" { mysql_max_connections = 2000 labels = ["test"] } -`) +` } diff --git a/gridscale/resource_gridscale_network_test.go b/gridscale/resource_gridscale_network_test.go index fe38f251..8fa46bcc 100644 --- a/gridscale/resource_gridscale_network_test.go +++ b/gridscale/resource_gridscale_network_test.go @@ -129,7 +129,7 @@ resource "gridscale_network" "foo" { } func testAccCheckResourceGridscaleNetworkConfig_basic_update() string { - return fmt.Sprint(` + return ` resource "gridscale_network" "foo" { name = "newname" l2security = true @@ -139,5 +139,5 @@ resource "gridscale_network" "foo" { dhcp_range = "192.168.122.0/27" dhcp_reserved_subnet = ["192.168.122.0/31"] } -`) +` } diff --git a/gridscale/resource_gridscale_objectstorage_test.go b/gridscale/resource_gridscale_objectstorage_test.go index d6d6ac62..f48669e9 100644 --- a/gridscale/resource_gridscale_objectstorage_test.go +++ b/gridscale/resource_gridscale_objectstorage_test.go @@ -89,8 +89,8 @@ func testAccCheckGridscaleObjectStorageDestroyCheck(s *terraform.State) error { } func testAccCheckResourceGridscaleObjectStorageConfig_basic() string { - return fmt.Sprint(` + return ` resource "gridscale_object_storage_accesskey" "foo" { } -`) +` } diff --git a/gridscale/resource_gridscale_paas.go b/gridscale/resource_gridscale_paas.go index eb52442f..df79967c 100644 --- a/gridscale/resource_gridscale_paas.go +++ b/gridscale/resource_gridscale_paas.go @@ -209,7 +209,7 @@ func resourceGridscalePaaSServiceRead(d *schema.ResourceData, meta interface{}) if err = d.Set("name", props.Name); err != nil { return fmt.Errorf("%s error setting name: %v", errorPrefix, err) } - if creds != nil && len(creds) > 0 { + if len(creds) > 0 { if err = d.Set("username", creds[0].Username); err != nil { return fmt.Errorf("%s error setting username: %v", errorPrefix, err) } @@ -272,6 +272,10 @@ func resourceGridscalePaaSServiceRead(d *schema.ResourceData, meta interface{}) return fmt.Errorf("%s error: %v", errorPrefix, err) } valueInString, err := convInterfaceToString(paramValType, value) + + if err != nil { + return err + } param := map[string]interface{}{ "param": k, "value": valueInString, diff --git a/gridscale/resource_gridscale_paas_test.go b/gridscale/resource_gridscale_paas_test.go index ea9ae487..89f62b83 100644 --- a/gridscale/resource_gridscale_paas_test.go +++ b/gridscale/resource_gridscale_paas_test.go @@ -105,7 +105,7 @@ resource "gridscale_paas" "foopaas" { } func testAccCheckResourceGridscalePaaSConfig_basic_update() string { - return fmt.Sprintf(` + return ` resource "gridscale_paas" "foopaas" { name = "newname" service_template_uuid = "d7a5e8ec-fa78-4d1b-86f9-febe3e16e398" @@ -124,13 +124,13 @@ resource "gridscale_paas" "foopaas" { type = "string" } } -`) +` } // TO DO: update `service_template_uuid` when the backend enables the option to // update `service_template_uuid`. func testAccCheckResourceGridscalePaaSConfig_tmp_update() string { - return fmt.Sprintf(` + return ` resource "gridscale_paas" "foopaas" { name = "newname" service_template_uuid = "d7a5e8ec-fa78-4d1b-86f9-febe3e16e398" @@ -149,5 +149,5 @@ resource "gridscale_paas" "foopaas" { type = "string" } } -`) +` } diff --git a/gridscale/resource_gridscale_postgresql.go b/gridscale/resource_gridscale_postgresql.go index 864815c7..ce5fb88c 100644 --- a/gridscale/resource_gridscale_postgresql.go +++ b/gridscale/resource_gridscale_postgresql.go @@ -18,11 +18,6 @@ import ( const postgresTemplateFlavourName = "postgres" -const ( - postgresReleaseValidationOpt = iota - postgresMaxCoreCountValidationOpt -) - func resourceGridscalePostgreSQL() *schema.Resource { return &schema.Resource{ Create: resourceGridscalePostgreSQLCreate, @@ -59,7 +54,7 @@ func resourceGridscalePostgreSQL() *schema.Resource { } } if !isReleaseValid { - return fmt.Errorf("%v is not a valid PostgreSQL release. Valid releases are: %v\n", newReleaseVal, strings.Join(releaseList, ", ")) + return fmt.Errorf("%v is not a valid PostgreSQL release. Valid releases are: %v", newReleaseVal, strings.Join(releaseList, ", ")) } return nil }), @@ -180,7 +175,7 @@ func resourceGridscalePostgreSQL() *schema.Resource { Computed: true, ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) { if 1 > v.(int) || v.(int) > 32 { - errors = append(errors, fmt.Errorf("%v is not a valid value for number of \"max_core_count\". Valid value should be between 1 and 32\n", v.(int))) + errors = append(errors, fmt.Errorf("%v is not a valid value for number of \"max_core_count\". Valid value should be between 1 and 32", v.(int))) } return }, @@ -429,7 +424,7 @@ func getPostgresTemplateUUID(client *gsclient.Client, release, performanceClass } } if !isReleaseValid { - return "", fmt.Errorf("%v is not a valid PostgreSQL release. Valid releases are: %v\n", release, strings.Join(releases, ", ")) + return "", fmt.Errorf("%v is not a valid PostgreSQL release. Valid releases are: %v", release, strings.Join(releases, ", ")) } return uTemplate.Properties.ObjectUUID, nil diff --git a/gridscale/resource_gridscale_postgresql_test.go b/gridscale/resource_gridscale_postgresql_test.go index fda532f5..d9021760 100644 --- a/gridscale/resource_gridscale_postgresql_test.go +++ b/gridscale/resource_gridscale_postgresql_test.go @@ -50,7 +50,7 @@ resource "gridscale_postgresql" "test" { } func testAccCheckResourceGridscalePostgresConfig_basic_update() string { - return fmt.Sprintf(` + return ` resource "gridscale_postgresql" "test" { name = "newname" release = "13" @@ -58,5 +58,5 @@ resource "gridscale_postgresql" "test" { max_core_count = 20 labels = ["test"] } -`) +` } diff --git a/gridscale/resource_gridscale_redis_cache.go b/gridscale/resource_gridscale_redis_cache.go index d6d89411..2b8ec892 100644 --- a/gridscale/resource_gridscale_redis_cache.go +++ b/gridscale/resource_gridscale_redis_cache.go @@ -368,7 +368,7 @@ func getRedisCacheTemplateUUID(client *gsclient.Client, release, performanceClas } } if !isReleaseValid { - return "", fmt.Errorf("%v is not a valid RedisCache release. Valid releases are: %v\n", release, strings.Join(releases, ", ")) + return "", fmt.Errorf("%v is not a valid RedisCache release. Valid releases are: %v", release, strings.Join(releases, ", ")) } return uTemplate.Properties.ObjectUUID, nil diff --git a/gridscale/resource_gridscale_redis_cache_test.go b/gridscale/resource_gridscale_redis_cache_test.go index b57a77dc..894aa9a4 100644 --- a/gridscale/resource_gridscale_redis_cache_test.go +++ b/gridscale/resource_gridscale_redis_cache_test.go @@ -50,12 +50,12 @@ resource "gridscale_redis_cache" "test" { } func testAccCheckResourceGridscaleRedisCacheConfig_basic_update() string { - return fmt.Sprintf(` + return ` resource "gridscale_redis_cache" "test" { name = "newname" release = "7" performance_class = "standard" labels = ["test"] } -`) +` } diff --git a/gridscale/resource_gridscale_redis_store.go b/gridscale/resource_gridscale_redis_store.go index 7b7703cb..795dc844 100644 --- a/gridscale/resource_gridscale_redis_store.go +++ b/gridscale/resource_gridscale_redis_store.go @@ -368,7 +368,7 @@ func getRedisStoreTemplateUUID(client *gsclient.Client, release, performanceClas } } if !isReleaseValid { - return "", fmt.Errorf("%v is not a valid RedisStore release. Valid releases are: %v\n", release, strings.Join(releases, ", ")) + return "", fmt.Errorf("%v is not a valid RedisStore release. Valid releases are: %v", release, strings.Join(releases, ", ")) } return uTemplate.Properties.ObjectUUID, nil diff --git a/gridscale/resource_gridscale_redis_store_test.go b/gridscale/resource_gridscale_redis_store_test.go index 086ef292..6d5753fc 100644 --- a/gridscale/resource_gridscale_redis_store_test.go +++ b/gridscale/resource_gridscale_redis_store_test.go @@ -50,12 +50,12 @@ resource "gridscale_redis_store" "test" { } func testAccCheckResourceGridscaleRedisStoreConfig_basic_update() string { - return fmt.Sprintf(` + return ` resource "gridscale_redis_store" "test" { name = "newname" release = "7" performance_class = "standard" labels = ["test"] } -`) +` } diff --git a/gridscale/resource_gridscale_securityzone_test.go b/gridscale/resource_gridscale_securityzone_test.go index f155d1a3..22266da7 100644 --- a/gridscale/resource_gridscale_securityzone_test.go +++ b/gridscale/resource_gridscale_securityzone_test.go @@ -96,9 +96,9 @@ resource "gridscale_paas_securityzone" "foo" { } func testAccCheckDataSourceGridscaleSecurityZoneConfig_basic_update() string { - return fmt.Sprintf(` + return ` resource "gridscale_paas_securityzone" "foo" { name = "newname" } -`) +` } diff --git a/gridscale/resource_gridscale_server_test.go b/gridscale/resource_gridscale_server_test.go index fac9e217..f3ea6d77 100644 --- a/gridscale/resource_gridscale_server_test.go +++ b/gridscale/resource_gridscale_server_test.go @@ -159,7 +159,7 @@ resource "gridscale_server" "foo" { } func testAccCheckResourceGridscaleServerConfig_basic_update() string { - return fmt.Sprintf(` + return ` resource "gridscale_ipv4" "foo1" { name = "newname" } @@ -197,5 +197,5 @@ resource "gridscale_server" "foo" { object_uuid = gridscale_storage.foo1.id } } -`) +` } diff --git a/gridscale/resource_gridscale_snapshot_test.go b/gridscale/resource_gridscale_snapshot_test.go index cea3afb1..c59dcfdb 100644 --- a/gridscale/resource_gridscale_snapshot_test.go +++ b/gridscale/resource_gridscale_snapshot_test.go @@ -113,7 +113,7 @@ resource "gridscale_snapshot" "foo" { } func testAccCheckDataSourceGridscaleSnapshotConfig_basic_update() string { - return fmt.Sprintf(` + return ` resource "gridscale_storage" "foo" { name = "storage" capacity = 1 @@ -129,11 +129,11 @@ resource "gridscale_snapshot" "foo" { id = "second" } } -`) +` } func testAccCheckDataSourceGridscaleSnapshotConfig_forcenew_update() string { - return fmt.Sprintf(` + return ` resource "gridscale_storage" "new" { name = "storage" capacity = 1 @@ -142,5 +142,5 @@ resource "gridscale_snapshot" "foo" { name = "newname" storage_uuid = gridscale_storage.new.id } -`) +` } diff --git a/gridscale/resource_gridscale_snapshotschedule_test.go b/gridscale/resource_gridscale_snapshotschedule_test.go index e32fe202..22f888bc 100644 --- a/gridscale/resource_gridscale_snapshotschedule_test.go +++ b/gridscale/resource_gridscale_snapshotschedule_test.go @@ -113,7 +113,7 @@ resource "gridscale_snapshotschedule" "foo" { } func testAccCheckDataSourceGridscaleSnapshotScheduleConfig_basic_update() string { - return fmt.Sprintf(` + return ` resource "gridscale_storage" "foo" { name = "storage" capacity = 1 @@ -125,11 +125,11 @@ resource "gridscale_snapshotschedule" "foo" { keep_snapshots = 1 run_interval = 60 } -`) +` } func testAccCheckDataSourceGridscaleSnapshotScheduleConfig_forcenew_update() string { - return fmt.Sprintf(` + return ` resource "gridscale_storage" "new" { name = "storage" capacity = 1 @@ -140,5 +140,5 @@ resource "gridscale_snapshotschedule" "foo" { keep_snapshots = 1 run_interval = 60 } -`) +` } diff --git a/gridscale/resource_gridscale_sqlserver.go b/gridscale/resource_gridscale_sqlserver.go index 234a07d0..be37400f 100644 --- a/gridscale/resource_gridscale_sqlserver.go +++ b/gridscale/resource_gridscale_sqlserver.go @@ -163,7 +163,7 @@ func resourceGridscaleMSSQLServer() *schema.Resource { Default: defaultBackupServerURL, ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) { if v.(string) != defaultBackupServerURL { - errors = append(errors, fmt.Errorf("Currently, only %s is supported", defaultBackupServerURL)) + errors = append(errors, fmt.Errorf("currently, only %s is supported", defaultBackupServerURL)) } return }, @@ -466,7 +466,7 @@ func getMSSQLTemplateUUID(client *gsclient.Client, release, performanceClass str } } if !isReleaseValid { - return "", fmt.Errorf("%v is not a valid MS SQL Server release. Valid releases are: %v\n", release, strings.Join(releases, ", ")) + return "", fmt.Errorf("%v is not a valid MS SQL Server release. Valid releases are: %v", release, strings.Join(releases, ", ")) } return uTemplate.Properties.ObjectUUID, nil diff --git a/gridscale/resource_gridscale_sqlserver_test.go b/gridscale/resource_gridscale_sqlserver_test.go index b29b0e0f..c7a8d30e 100644 --- a/gridscale/resource_gridscale_sqlserver_test.go +++ b/gridscale/resource_gridscale_sqlserver_test.go @@ -50,12 +50,12 @@ resource "gridscale_sqlserver" "test" { } func testAccCheckResourceGridscaleMSSQLServerConfig_basic_update() string { - return fmt.Sprintf(` + return ` resource "gridscale_sqlserver" "test" { name = "newname" release = "2019" performance_class = "standard" labels = ["test"] } -`) +` } diff --git a/gridscale/resource_gridscale_sshkey_test.go b/gridscale/resource_gridscale_sshkey_test.go index aa5ddece..f5da47fb 100644 --- a/gridscale/resource_gridscale_sshkey_test.go +++ b/gridscale/resource_gridscale_sshkey_test.go @@ -111,10 +111,10 @@ resource "gridscale_sshkey" "foo" { } func testAccCheckResourceGridscaleSshkeyConfig_basic_update() string { - return fmt.Sprintf(` + return ` resource "gridscale_sshkey" "foo" { name = "newname" sshkey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCvOYJ3xXtPXaPOacFQ97+nGq5QDkl17/JeTaY36RLPKgYBt2Z5YSPSROdzh/5GgZ0p6E3W84gKNaedUo3v+zvgmdGZeDFk+cxlC0HtXwQN87GQRtYTMsucbI6OJT7p4qntl70MIBzvIrmheGZqXnpeRxA7PjVcjkA3nxps3XJsuMDd0Ft0Ue3j0lmOno779mfgg34VeTgE2GZlH31gFqxWz3fXUgaZoLdO7HbLKu4ybfFWdCzqBt4B8RG9xMq0220gJR6ZwAaiMc1CGIknK7C6EKeCx9LOWDjCaHg6pA2iPAb/PoxDuiqbUIzfRmkgMf0lYmrf0kqx529ALm92ulSx root@33c294c5235e" } -`) +` } diff --git a/gridscale/resource_gridscale_storage_clone_test.go b/gridscale/resource_gridscale_storage_clone_test.go index 85668575..b3f2499d 100644 --- a/gridscale/resource_gridscale_storage_clone_test.go +++ b/gridscale/resource_gridscale_storage_clone_test.go @@ -1,13 +1,9 @@ package gridscale import ( - "context" - "fmt" "testing" - "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/gridscale/gsclient-go/v3" ) @@ -43,7 +39,7 @@ func TestAccResourceGridscaleStorageClone_Basic(t *testing.T) { }) } -func testAccCheckGridscaleStorageCloneDestroyCheck(s *terraform.State) error { +/*func testAccCheckGridscaleStorageCloneDestroyCheck(s *terraform.State) error { client := testAccProvider.Meta().(*gsclient.Client) for _, rs := range s.RootModule().Resources { if rs.Type != "gridscale_storage_clone" { @@ -68,10 +64,10 @@ func testAccCheckGridscaleStorageCloneDestroyCheck(s *terraform.State) error { } return nil -} +}*/ func testAccCheckResourceGridscaleStorageCloneConfig_basic() string { - return fmt.Sprint(` + return ` resource "gridscale_storage" "foo" { name = "test" capacity = 1 @@ -82,11 +78,11 @@ resource "gridscale_storage_clone" "foo" { name = "desired_name" storage_type = "storage_high" } -`) +` } func testAccCheckResourceGridscaleStorageCloneConfig_basic_update() string { - return fmt.Sprint(` + return ` resource "gridscale_storage" "foo" { name = "test" capacity = 1 @@ -98,5 +94,5 @@ resource "gridscale_storage_clone" "foo" { capacity = 2 storage_type = "storage_insane" } -`) +` } diff --git a/gridscale/resource_gridscale_storage_test.go b/gridscale/resource_gridscale_storage_test.go index efaf475f..3e624a33 100644 --- a/gridscale/resource_gridscale_storage_test.go +++ b/gridscale/resource_gridscale_storage_test.go @@ -138,12 +138,12 @@ resource "gridscale_storage" "foo" { } func testAccCheckResourceGridscaleStorageConfig_basic_update() string { - return fmt.Sprintf(` + return ` resource "gridscale_storage" "foo" { name = "newname" capacity = 1 } -`) +` } func testAccCheckResourceGridscaleStorageConfig_advanced(name string) string { diff --git a/gridscale/resource_gridscale_template_test.go b/gridscale/resource_gridscale_template_test.go index 77899618..8fa82429 100644 --- a/gridscale/resource_gridscale_template_test.go +++ b/gridscale/resource_gridscale_template_test.go @@ -117,7 +117,7 @@ resource "gridscale_template" "foo" { } func testAccCheckResourceGridscaleTemplateConfig_basic_update() string { - return fmt.Sprintf(` + return ` resource "gridscale_storage" "foo" { name = "newname" capacity = 1 @@ -133,5 +133,5 @@ resource "gridscale_template" "foo" { labels = ["test"] snapshot_uuid = gridscale_snapshot.foo.id } -`) +` }