Skip to content

Commit

Permalink
checking user is a string
Browse files Browse the repository at this point in the history
  • Loading branch information
simisoft-exo committed Nov 21, 2024
1 parent b63fc93 commit c44e254
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions pkg/resources/database/datasource_uri.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,13 @@ func (d *DataSourceURI) Read(ctx context.Context, req datasource.ReadRequest, re
)
return
}
if user == "" {
resp.Diagnostics.AddError(
"Client Error",
"Database Service Kafka user is empty",
)
return
}

creds, err := client.RevealDBAASMysqlUserPassword(ctx, data.Name.ValueString(), user)
if err != nil {
Expand Down Expand Up @@ -320,6 +327,13 @@ func (d *DataSourceURI) Read(ctx context.Context, req datasource.ReadRequest, re
)
return
}
if user == "" {
resp.Diagnostics.AddError(
"Client Error",
"Database Service MySQL user is empty",
)
return
}
data.Schema = types.StringValue("mysql")

creds, err := client.RevealDBAASMysqlUserPassword(ctx, data.Name.ValueString(), user)
Expand Down Expand Up @@ -367,6 +381,13 @@ func (d *DataSourceURI) Read(ctx context.Context, req datasource.ReadRequest, re
)
return
}
if user == "" {
resp.Diagnostics.AddError(
"Client Error",
"Database Service Postgres user is empty",
)
return
}
data.Schema = types.StringValue("postgres")

creds, err := client.RevealDBAASPostgresUserPassword(ctx, data.Name.ValueString(), user)
Expand All @@ -385,6 +406,7 @@ func (d *DataSourceURI) Read(ctx context.Context, req datasource.ReadRequest, re
)
return
}

params["password"] = creds.Password
case "redis":
res, err := waitForDBAASService(
Expand Down Expand Up @@ -413,6 +435,13 @@ func (d *DataSourceURI) Read(ctx context.Context, req datasource.ReadRequest, re
)
return
}
if user == "" {
resp.Diagnostics.AddError(
"Client Error",
"Database Service Redis user is empty",
)
return
}
data.Schema = types.StringValue("rediss")

creds, err := client.RevealDBAASRedisUserPassword(ctx, data.Name.ValueString(), user)
Expand Down Expand Up @@ -459,6 +488,13 @@ func (d *DataSourceURI) Read(ctx context.Context, req datasource.ReadRequest, re
)
return
}
if user == "" {
resp.Diagnostics.AddError(
"Client Error",
"Database Service Opensearch user is empty",
)
return
}
data.Schema = types.StringValue("https")

creds, err := client.RevealDBAASOpensearchUserPassword(ctx, data.Name.ValueString(), user)
Expand Down Expand Up @@ -507,6 +543,13 @@ func (d *DataSourceURI) Read(ctx context.Context, req datasource.ReadRequest, re
)
return
}
if user == "" {
resp.Diagnostics.AddError(
"Client Error",
"Database Service Grafana user is empty",
)
return
}
data.Schema = types.StringValue("https")

creds, err := client.RevealDBAASGrafanaUserPassword(ctx, data.Name.ValueString(), user)
Expand Down

0 comments on commit c44e254

Please sign in to comment.