Skip to content

Commit

Permalink
Change id in datasources
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbyiliev committed Dec 6, 2023
1 parent c12c6b7 commit f4f015a
Show file tree
Hide file tree
Showing 17 changed files with 30 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pkg/datasources/datasource_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func clusterRead(ctx context.Context, d *schema.ResourceData, meta interface{})
for _, p := range dataSource {
clusterMap := map[string]interface{}{}

clusterMap["id"] = p.ClusterId.String
clusterMap["id"] = utils.TransformIdWithRegion(p.ClusterId.String)
clusterMap["name"] = p.ClusterName.String
clusterMap["managed"] = p.Managed.Bool
clusterMap["size"] = p.Size.String
Expand Down
2 changes: 1 addition & 1 deletion pkg/datasources/datasource_cluster_replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func clusterReplicaRead(ctx context.Context, d *schema.ResourceData, meta interf
for _, p := range dataSource {
clusterReplicaMap := map[string]interface{}{}

clusterReplicaMap["id"] = p.ReplicaId.String
clusterReplicaMap["id"] = utils.TransformIdWithRegion(p.ReplicaId.String)
clusterReplicaMap["name"] = p.ReplicaName.String
clusterReplicaMap["cluster"] = p.ClusterName.String
clusterReplicaMap["size"] = p.Size.String
Expand Down
3 changes: 2 additions & 1 deletion pkg/datasources/datasource_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize"
"github.com/MaterializeInc/terraform-provider-materialize/pkg/utils"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -73,7 +74,7 @@ func connectionRead(ctx context.Context, d *schema.ResourceData, meta interface{
for _, p := range dataSource {
connectionMap := map[string]interface{}{}

connectionMap["id"] = p.ConnectionId.String
connectionMap["id"] = utils.TransformIdWithRegion(p.ConnectionId.String)
connectionMap["name"] = p.ConnectionName.String
connectionMap["schema_name"] = p.SchemaName.String
connectionMap["database_name"] = p.DatabaseName.String
Expand Down
3 changes: 2 additions & 1 deletion pkg/datasources/datasource_current_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package datasources
import (
"context"

"github.com/MaterializeInc/terraform-provider-materialize/pkg/utils"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/jmoiron/sqlx"
Expand All @@ -28,7 +29,7 @@ func currentClusterRead(ctx context.Context, d *schema.ResourceData, meta interf
conn.QueryRow("SHOW CLUSTER;").Scan(&name)

d.Set("name", name)
d.SetId("current_cluster")
d.SetId(utils.TransformIdWithRegion("current_cluster"))

return diags
}
3 changes: 2 additions & 1 deletion pkg/datasources/datasource_current_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package datasources
import (
"context"

"github.com/MaterializeInc/terraform-provider-materialize/pkg/utils"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/jmoiron/sqlx"
Expand All @@ -28,7 +29,7 @@ func currentDatabaseRead(ctx context.Context, d *schema.ResourceData, meta inter
conn.QueryRow("SHOW DATABASE;").Scan(&name)

d.Set("name", name)
d.SetId("current_database")
d.SetId(utils.TransformIdWithRegion("current_database"))

return diags
}
2 changes: 1 addition & 1 deletion pkg/datasources/datasource_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func databaseRead(ctx context.Context, d *schema.ResourceData, meta interface{})
for _, p := range dataSource {
databaseMap := map[string]interface{}{}

databaseMap["id"] = p.DatabaseId.String
databaseMap["id"] = utils.TransformIdWithRegion(p.DatabaseId.String)
databaseMap["name"] = p.DatabaseName.String

databaseFormats = append(databaseFormats, databaseMap)
Expand Down
3 changes: 2 additions & 1 deletion pkg/datasources/datasource_egress_ips.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"log"

"github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize"
"github.com/MaterializeInc/terraform-provider-materialize/pkg/utils"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/jmoiron/sqlx"
Expand Down Expand Up @@ -64,7 +65,7 @@ func EgressIpsRead(ctx context.Context, d *schema.ResourceData, meta interface{}
return diag.FromErr(err)
}

d.SetId("egress_ips")
d.SetId(utils.TransformIdWithRegion("egress_ips"))

return diags
}
3 changes: 2 additions & 1 deletion pkg/datasources/datasource_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize"
"github.com/MaterializeInc/terraform-provider-materialize/pkg/utils"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -73,7 +74,7 @@ func indexRead(ctx context.Context, d *schema.ResourceData, meta interface{}) di
for _, p := range dataSource {
indexMap := map[string]interface{}{}

indexMap["id"] = p.IndexId.String
indexMap["id"] = utils.TransformIdWithRegion(p.IndexId.String)
indexMap["name"] = p.IndexName.String
indexMap["obj_name"] = p.ObjectName.String
indexMap["obj_schema"] = p.ObjectSchemaName.String
Expand Down
3 changes: 2 additions & 1 deletion pkg/datasources/datasource_materialized_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize"
"github.com/MaterializeInc/terraform-provider-materialize/pkg/utils"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -69,7 +70,7 @@ func materializedViewRead(ctx context.Context, d *schema.ResourceData, meta inte
for _, p := range dataSource {
materizliedViewMap := map[string]interface{}{}

materizliedViewMap["id"] = p.MaterializedViewId.String
materizliedViewMap["id"] = utils.TransformIdWithRegion(p.MaterializedViewId.String)
materizliedViewMap["name"] = p.MaterializedViewName.String
materizliedViewMap["schema_name"] = p.SchemaName.String
materizliedViewMap["database_name"] = p.DatabaseName.String
Expand Down
3 changes: 2 additions & 1 deletion pkg/datasources/datasource_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize"
"github.com/MaterializeInc/terraform-provider-materialize/pkg/utils"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -57,6 +58,6 @@ func roleRead(ctx context.Context, d *schema.ResourceData, meta interface{}) dia
return diag.FromErr(err)
}

d.SetId("roles")
d.SetId(utils.TransformIdWithRegion("roles"))
return diags
}
2 changes: 1 addition & 1 deletion pkg/datasources/datasource_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func schemaRead(ctx context.Context, d *schema.ResourceData, meta interface{}) d
for _, p := range dataSource {
schemaMap := map[string]interface{}{}

schemaMap["id"] = p.SchemaId.String
schemaMap["id"] = utils.TransformIdWithRegion(p.SchemaId.String)
schemaMap["name"] = p.SchemaName.String
schemaMap["database_name"] = p.DatabaseName.String

Expand Down
3 changes: 2 additions & 1 deletion pkg/datasources/datasource_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize"
"github.com/MaterializeInc/terraform-provider-materialize/pkg/utils"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -69,7 +70,7 @@ func secretRead(ctx context.Context, d *schema.ResourceData, meta interface{}) d
for _, p := range dataSource {
secretMap := map[string]interface{}{}

secretMap["id"] = p.SecretId.String
secretMap["id"] = utils.TransformIdWithRegion(p.SecretId.String)
secretMap["name"] = p.SecretName.String
secretMap["schema_name"] = p.SchemaName.String
secretMap["database_name"] = p.DatabaseName.String
Expand Down
3 changes: 2 additions & 1 deletion pkg/datasources/datasource_sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize"
"github.com/MaterializeInc/terraform-provider-materialize/pkg/utils"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -89,7 +90,7 @@ func sinkRead(ctx context.Context, d *schema.ResourceData, meta interface{}) dia
for _, p := range dataSource {
sinkMap := map[string]interface{}{}

sinkMap["id"] = p.SinkId.String
sinkMap["id"] = utils.TransformIdWithRegion(p.SinkId.String)
sinkMap["name"] = p.SinkName.String
sinkMap["schema_name"] = p.SchemaName.String
sinkMap["database_name"] = p.DatabaseName.String
Expand Down
3 changes: 2 additions & 1 deletion pkg/datasources/datasource_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize"
"github.com/MaterializeInc/terraform-provider-materialize/pkg/utils"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -89,7 +90,7 @@ func sourceRead(ctx context.Context, d *schema.ResourceData, meta interface{}) d
for _, p := range dataSource {
sourceMap := map[string]interface{}{}

sourceMap["id"] = p.SourceId.String
sourceMap["id"] = utils.TransformIdWithRegion(p.SourceId.String)
sourceMap["name"] = p.SourceName.String
sourceMap["schema_name"] = p.SchemaName.String
sourceMap["database_name"] = p.DatabaseName.String
Expand Down
3 changes: 2 additions & 1 deletion pkg/datasources/datasource_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize"
"github.com/MaterializeInc/terraform-provider-materialize/pkg/utils"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -69,7 +70,7 @@ func tableRead(ctx context.Context, d *schema.ResourceData, meta interface{}) di
for _, p := range dataSource {
tableMap := map[string]interface{}{}

tableMap["id"] = p.TableId.String
tableMap["id"] = utils.TransformIdWithRegion(p.TableId.String)
tableMap["name"] = p.TableName.String
tableMap["schema_name"] = p.SchemaName.String
tableMap["database_name"] = p.DatabaseName.String
Expand Down
3 changes: 2 additions & 1 deletion pkg/datasources/datasource_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize"
"github.com/MaterializeInc/terraform-provider-materialize/pkg/utils"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -73,7 +74,7 @@ func typeRead(ctx context.Context, d *schema.ResourceData, meta interface{}) dia
for _, p := range dataSource {
typeMap := map[string]interface{}{}

typeMap["id"] = p.TypeId.String
typeMap["id"] = utils.TransformIdWithRegion(p.TypeId.String)
typeMap["name"] = p.TypeName.String
typeMap["schema_name"] = p.SchemaName.String
typeMap["database_name"] = p.DatabaseName.String
Expand Down
3 changes: 2 additions & 1 deletion pkg/datasources/datasource_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"github.com/MaterializeInc/terraform-provider-materialize/pkg/materialize"
"github.com/MaterializeInc/terraform-provider-materialize/pkg/utils"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -69,7 +70,7 @@ func viewRead(ctx context.Context, d *schema.ResourceData, meta interface{}) dia
for _, p := range dataSource {
viewMap := map[string]interface{}{}

viewMap["id"] = p.ViewId.String
viewMap["id"] = utils.TransformIdWithRegion(p.ViewId.String)
viewMap["name"] = p.ViewName.String
viewMap["schema_name"] = p.SchemaName.String
viewMap["database_name"] = p.DatabaseName.String
Expand Down

0 comments on commit f4f015a

Please sign in to comment.