Move internal packages into internal folder (#33)

* Move internal packages into internal folder

* Fix testutil imports
This commit is contained in:
João Palet 2023-09-26 19:44:16 +02:00 committed by GitHub
parent 46be7cfafd
commit f8c9e4c0af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
83 changed files with 148 additions and 148 deletions

View file

@ -1,62 +0,0 @@
package core
import (
"context"
"fmt"
"net/http"
"strings"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-log/tflog"
)
// Separator used for concatenation of TF-internal resource ID
const Separator = ","
type ProviderData struct {
RoundTripper http.RoundTripper
ServiceAccountEmail string
Region string
DnsCustomEndpoint string
PostgreSQLCustomEndpoint string
PostgresFlexCustomEndpoint string
LogMeCustomEndpoint string
RabbitMQCustomEndpoint string
MariaDBCustomEndpoint string
OpenSearchCustomEndpoint string
RedisCustomEndpoint string
ArgusCustomEndpoint string
SKECustomEndpoint string
ResourceManagerCustomEndpoint string
}
// DiagsToError Converts TF diagnostics' errors into an error with a human-readable description.
// If there are no errors, the output is nil
func DiagsToError(diags diag.Diagnostics) error {
if !diags.HasError() {
return nil
}
diagsError := diags.Errors()
diagsStrings := make([]string, 0)
for _, diagnostic := range diagsError {
diagsStrings = append(diagsStrings, fmt.Sprintf(
"(%s) %s",
diagnostic.Summary(),
diagnostic.Detail(),
))
}
return fmt.Errorf("%s", strings.Join(diagsStrings, ";"))
}
// LogAndAddError Logs the error and adds it to the diags
func LogAndAddError(ctx context.Context, diags *diag.Diagnostics, summary, detail string) {
tflog.Error(ctx, summary)
diags.AddError(summary, detail)
}
// LogAndAddWarning Logs the warning and adds it to the diags
func LogAndAddWarning(ctx context.Context, diags *diag.Diagnostics, summary, detail string) {
tflog.Warn(ctx, summary)
diags.AddWarning(summary, detail)
}