Skip to content

Commit

Permalink
Fix golangci-lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Gogen120 committed Nov 25, 2022
1 parent c24cf36 commit 7506006
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 185 deletions.
9 changes: 9 additions & 0 deletions selectel/dbaas.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ const (
nl1DBaaSV1Endpoint = "https://nl-1.dbaas.selcloud.ru/v1"
)

const (
postgreSQLDatastoreType = "postgresql"
mySQLDatastoreType = "mysql"
mySQLNativeDatastoreType = "mysql_native"
redisDatastoreType = "redis"
)

func getDBaaSV1Endpoint(region string) (endpoint string) {
switch region {
case ru1Region:
Expand Down Expand Up @@ -425,6 +432,7 @@ func containeDatastoreType(expectedTypes []string, datastoreType string) bool {
return true
}
}

return false
}

Expand All @@ -435,6 +443,7 @@ func buildDatastoreTypeErrorMEssage(expectedDatastoreTypeEngines []string, datas
} else {
baseMessage = "Provided datastore type must have an engine "
}

return baseMessage + strings.Join(expectedDatastoreTypeEngines, ", ") + " for this resource. But provided type is " + datastoreTypeEngine
}

Expand Down
4 changes: 2 additions & 2 deletions selectel/import_selectel_dbaas_mysql_datastore_v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func TestAccDBaaSMySQLDatastoreV1ImportBasic(t *testing.T) {
projectName := acctest.RandomWithPrefix("tf-acc")
datastoreName := acctest.RandomWithPrefix("tf-acc-ds")
nodeCount := 1
datastoreTypeEngine := "mysql"
datastoreTypeEngine := mySQLDatastoreType

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccSelectelPreCheck(t) },
Expand All @@ -37,7 +37,7 @@ func TestAccDBaaSMySQLNativeDatastoreV1ImportBasic(t *testing.T) {
projectName := acctest.RandomWithPrefix("tf-acc")
datastoreName := acctest.RandomWithPrefix("tf-acc-ds")
nodeCount := 1
datastoreTypeEngine := "mysql_native"
datastoreTypeEngine := mySQLNativeDatastoreType

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccSelectelPreCheck(t) },
Expand Down
4 changes: 2 additions & 2 deletions selectel/resource_selectel_dbaas_mysql_database_v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestAccDBaaSMySQLDatabaseV1Basic(t *testing.T) {
datastoreName := acctest.RandomWithPrefix("tf-acc-ds")
databaseName := RandomWithPrefix("tf_acc_db")
nodeCount := 1
datastoreTypeEngine := "mysql"
datastoreTypeEngine := mySQLDatastoreType

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccSelectelPreCheck(t) },
Expand Down Expand Up @@ -50,7 +50,7 @@ func TestAccDBaaSMySQLNativeDatabaseV1Basic(t *testing.T) {
datastoreName := acctest.RandomWithPrefix("tf-acc-ds")
databaseName := RandomWithPrefix("tf_acc_db")
nodeCount := 1
datastoreTypeEngine := "mysql_native"
datastoreTypeEngine := mySQLNativeDatastoreType

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccSelectelPreCheck(t) },
Expand Down
2 changes: 1 addition & 1 deletion selectel/resource_selectel_dbaas_mysql_datastore_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func resourceDBaaSMySQLDatastoreV1Create(ctx context.Context, d *schema.Resource
}

typeID := d.Get("type_id").(string)
diagErr = validateDatastoreType(ctx, []string{"mysql", "mysql_native"}, typeID, dbaasClient)
diagErr = validateDatastoreType(ctx, []string{mySQLDatastoreType, mySQLNativeDatastoreType}, typeID, dbaasClient)
if diagErr != nil {
return diagErr
}
Expand Down
223 changes: 45 additions & 178 deletions selectel/resource_selectel_dbaas_mysql_datastore_v1_test.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func resourceDBaaSPostgreSQLDatastoreV1Create(ctx context.Context, d *schema.Res
}

typeID := d.Get("type_id").(string)
diagErr = validateDatastoreType(ctx, []string{"postgresql"}, typeID, dbaasClient)
diagErr = validateDatastoreType(ctx, []string{postgreSQLDatastoreType}, typeID, dbaasClient)
if diagErr != nil {
return diagErr
}
Expand Down
2 changes: 1 addition & 1 deletion selectel/resource_selectel_dbaas_redis_datastore_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func resourceDBaaSRedisDatastoreV1Create(ctx context.Context, d *schema.Resource
flavorID, flavorIDOk := d.GetOk("flavor_id")

typeID := d.Get("type_id").(string)
diagErr = validateDatastoreType(ctx, []string{"redis"}, typeID, dbaasClient)
diagErr = validateDatastoreType(ctx, []string{redisDatastoreType}, typeID, dbaasClient)
if diagErr != nil {
return diagErr
}
Expand Down

0 comments on commit 7506006

Please sign in to comment.