Move functions to conversion pkg (#123)
This commit is contained in:
parent
71bf63cbc9
commit
03d0e28016
22 changed files with 237 additions and 221 deletions
|
|
@ -7,7 +7,6 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-framework/diag"
|
||||
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
|
||||
"github.com/hashicorp/terraform-plugin-log/tflog"
|
||||
)
|
||||
|
||||
|
|
@ -65,33 +64,3 @@ func LogAndAddWarning(ctx context.Context, diags *diag.Diagnostics, summary, det
|
|||
tflog.Warn(ctx, fmt.Sprintf("%s | %s", summary, detail))
|
||||
diags.AddWarning(summary, detail)
|
||||
}
|
||||
|
||||
// StringValueToPointer converts basetypes.StringValue to a pointer to string.
|
||||
// It returns nil if the value is null or unknown.
|
||||
func StringValueToPointer(s basetypes.StringValue) *string {
|
||||
if s.IsNull() || s.IsUnknown() {
|
||||
return nil
|
||||
}
|
||||
value := s.ValueString()
|
||||
return &value
|
||||
}
|
||||
|
||||
// Int64ValueToPointer converts basetypes.Int64Value to a pointer to int64.
|
||||
// It returns nil if the value is null or unknown.
|
||||
func Int64ValueToPointer(s basetypes.Int64Value) *int64 {
|
||||
if s.IsNull() || s.IsUnknown() {
|
||||
return nil
|
||||
}
|
||||
value := s.ValueInt64()
|
||||
return &value
|
||||
}
|
||||
|
||||
// BoolValueToPointer converts basetypes.BoolValue to a pointer to bool.
|
||||
// It returns nil if the value is null or unknown.
|
||||
func BoolValueToPointer(s basetypes.BoolValue) *bool {
|
||||
if s.IsNull() || s.IsUnknown() {
|
||||
return nil
|
||||
}
|
||||
value := s.ValueBool()
|
||||
return &value
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue