fix: remove unused 'created' attribute from databases and update user roles description

This commit is contained in:
Andre_Harms 2026-02-11 15:42:43 +01:00
parent 119356d8cb
commit be5c3b5430
3 changed files with 27 additions and 87 deletions

View file

@ -23,11 +23,6 @@ func DatabasesDataSourceSchema(ctx context.Context) schema.Schema {
"databases": schema.ListNestedAttribute{
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"created": schema.StringAttribute{
Computed: true,
Description: "The data when the database was created in RFC3339 format.",
MarkdownDescription: "The data when the database was created in RFC3339 format.",
},
"id": schema.Int64Attribute{
Computed: true,
Description: "The id of the database.",
@ -169,24 +164,6 @@ func (t DatabasesType) ValueFromObject(ctx context.Context, in basetypes.ObjectV
attributes := in.Attributes()
createdAttribute, ok := attributes["created"]
if !ok {
diags.AddError(
"Attribute Missing",
`created is missing from object`)
return nil, diags
}
createdVal, ok := createdAttribute.(basetypes.StringValue)
if !ok {
diags.AddError(
"Attribute Wrong Type",
fmt.Sprintf(`created expected to be basetypes.StringValue, was: %T`, createdAttribute))
}
idAttribute, ok := attributes["id"]
if !ok {
@ -246,11 +223,10 @@ func (t DatabasesType) ValueFromObject(ctx context.Context, in basetypes.ObjectV
}
return DatabasesValue{
Created: createdVal,
Id: idVal,
Name: nameVal,
Owner: ownerVal,
state: attr.ValueStateKnown,
Id: idVal,
Name: nameVal,
Owner: ownerVal,
state: attr.ValueStateKnown,
}, diags
}
@ -317,24 +293,6 @@ func NewDatabasesValue(attributeTypes map[string]attr.Type, attributes map[strin
return NewDatabasesValueUnknown(), diags
}
createdAttribute, ok := attributes["created"]
if !ok {
diags.AddError(
"Attribute Missing",
`created is missing from object`)
return NewDatabasesValueUnknown(), diags
}
createdVal, ok := createdAttribute.(basetypes.StringValue)
if !ok {
diags.AddError(
"Attribute Wrong Type",
fmt.Sprintf(`created expected to be basetypes.StringValue, was: %T`, createdAttribute))
}
idAttribute, ok := attributes["id"]
if !ok {
@ -394,11 +352,10 @@ func NewDatabasesValue(attributeTypes map[string]attr.Type, attributes map[strin
}
return DatabasesValue{
Created: createdVal,
Id: idVal,
Name: nameVal,
Owner: ownerVal,
state: attr.ValueStateKnown,
Id: idVal,
Name: nameVal,
Owner: ownerVal,
state: attr.ValueStateKnown,
}, diags
}
@ -470,20 +427,18 @@ func (t DatabasesType) ValueType(ctx context.Context) attr.Value {
var _ basetypes.ObjectValuable = DatabasesValue{}
type DatabasesValue struct {
Created basetypes.StringValue `tfsdk:"created"`
Id basetypes.Int64Value `tfsdk:"id"`
Name basetypes.StringValue `tfsdk:"name"`
Owner basetypes.StringValue `tfsdk:"owner"`
state attr.ValueState
Id basetypes.Int64Value `tfsdk:"id"`
Name basetypes.StringValue `tfsdk:"name"`
Owner basetypes.StringValue `tfsdk:"owner"`
state attr.ValueState
}
func (v DatabasesValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
attrTypes := make(map[string]tftypes.Type, 4)
attrTypes := make(map[string]tftypes.Type, 3)
var val tftypes.Value
var err error
attrTypes["created"] = basetypes.StringType{}.TerraformType(ctx)
attrTypes["id"] = basetypes.Int64Type{}.TerraformType(ctx)
attrTypes["name"] = basetypes.StringType{}.TerraformType(ctx)
attrTypes["owner"] = basetypes.StringType{}.TerraformType(ctx)
@ -492,15 +447,7 @@ func (v DatabasesValue) ToTerraformValue(ctx context.Context) (tftypes.Value, er
switch v.state {
case attr.ValueStateKnown:
vals := make(map[string]tftypes.Value, 4)
val, err = v.Created.ToTerraformValue(ctx)
if err != nil {
return tftypes.NewValue(objectType, tftypes.UnknownValue), err
}
vals["created"] = val
vals := make(map[string]tftypes.Value, 3)
val, err = v.Id.ToTerraformValue(ctx)
@ -556,10 +503,9 @@ func (v DatabasesValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValu
var diags diag.Diagnostics
attributeTypes := map[string]attr.Type{
"created": basetypes.StringType{},
"id": basetypes.Int64Type{},
"name": basetypes.StringType{},
"owner": basetypes.StringType{},
"id": basetypes.Int64Type{},
"name": basetypes.StringType{},
"owner": basetypes.StringType{},
}
if v.IsNull() {
@ -573,10 +519,9 @@ func (v DatabasesValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValu
objVal, diags := types.ObjectValue(
attributeTypes,
map[string]attr.Value{
"created": v.Created,
"id": v.Id,
"name": v.Name,
"owner": v.Owner,
"id": v.Id,
"name": v.Name,
"owner": v.Owner,
})
return objVal, diags
@ -597,10 +542,6 @@ func (v DatabasesValue) Equal(o attr.Value) bool {
return true
}
if !v.Created.Equal(other.Created) {
return false
}
if !v.Id.Equal(other.Id) {
return false
}
@ -626,10 +567,9 @@ func (v DatabasesValue) Type(ctx context.Context) attr.Type {
func (v DatabasesValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
return map[string]attr.Type{
"created": basetypes.StringType{},
"id": basetypes.Int64Type{},
"name": basetypes.StringType{},
"owner": basetypes.StringType{},
"id": basetypes.Int64Type{},
"name": basetypes.StringType{},
"owner": basetypes.StringType{},
}
}

View file

@ -66,8 +66,8 @@ func UserResourceSchema(ctx context.Context) schema.Schema {
"roles": schema.ListAttribute{
ElementType: types.StringType,
Required: true,
Description: "A list containing the user roles for the instance.",
MarkdownDescription: "A list containing the user roles for the instance.",
Description: "A list containing the user roles for the instance. A list with the valid user roles can be retrieved using the List Roles endpoint.",
MarkdownDescription: "A list containing the user roles for the instance. A list with the valid user roles can be retrieved using the List Roles endpoint.",
},
"status": schema.StringAttribute{
Computed: true,

View file

@ -66,8 +66,8 @@ func UserResourceSchema(ctx context.Context) schema.Schema {
"roles": schema.ListAttribute{
ElementType: types.StringType,
Required: true,
Description: "A list containing the user roles for the instance.",
MarkdownDescription: "A list containing the user roles for the instance.",
Description: "A list containing the user roles for the instance. A list with the valid user roles can be retrieved using the List Roles endpoint.",
MarkdownDescription: "A list containing the user roles for the instance. A list with the valid user roles can be retrieved using the List Roles endpoint.",
},
"status": schema.StringAttribute{
Computed: true,