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{ "databases": schema.ListNestedAttribute{
NestedObject: schema.NestedAttributeObject{ NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{ 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{ "id": schema.Int64Attribute{
Computed: true, Computed: true,
Description: "The id of the database.", Description: "The id of the database.",
@ -169,24 +164,6 @@ func (t DatabasesType) ValueFromObject(ctx context.Context, in basetypes.ObjectV
attributes := in.Attributes() 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"] idAttribute, ok := attributes["id"]
if !ok { if !ok {
@ -246,11 +223,10 @@ func (t DatabasesType) ValueFromObject(ctx context.Context, in basetypes.ObjectV
} }
return DatabasesValue{ return DatabasesValue{
Created: createdVal, Id: idVal,
Id: idVal, Name: nameVal,
Name: nameVal, Owner: ownerVal,
Owner: ownerVal, state: attr.ValueStateKnown,
state: attr.ValueStateKnown,
}, diags }, diags
} }
@ -317,24 +293,6 @@ func NewDatabasesValue(attributeTypes map[string]attr.Type, attributes map[strin
return NewDatabasesValueUnknown(), diags 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"] idAttribute, ok := attributes["id"]
if !ok { if !ok {
@ -394,11 +352,10 @@ func NewDatabasesValue(attributeTypes map[string]attr.Type, attributes map[strin
} }
return DatabasesValue{ return DatabasesValue{
Created: createdVal, Id: idVal,
Id: idVal, Name: nameVal,
Name: nameVal, Owner: ownerVal,
Owner: ownerVal, state: attr.ValueStateKnown,
state: attr.ValueStateKnown,
}, diags }, diags
} }
@ -470,20 +427,18 @@ func (t DatabasesType) ValueType(ctx context.Context) attr.Value {
var _ basetypes.ObjectValuable = DatabasesValue{} var _ basetypes.ObjectValuable = DatabasesValue{}
type DatabasesValue struct { type DatabasesValue struct {
Created basetypes.StringValue `tfsdk:"created"` Id basetypes.Int64Value `tfsdk:"id"`
Id basetypes.Int64Value `tfsdk:"id"` Name basetypes.StringValue `tfsdk:"name"`
Name basetypes.StringValue `tfsdk:"name"` Owner basetypes.StringValue `tfsdk:"owner"`
Owner basetypes.StringValue `tfsdk:"owner"` state attr.ValueState
state attr.ValueState
} }
func (v DatabasesValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) { 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 val tftypes.Value
var err error var err error
attrTypes["created"] = basetypes.StringType{}.TerraformType(ctx)
attrTypes["id"] = basetypes.Int64Type{}.TerraformType(ctx) attrTypes["id"] = basetypes.Int64Type{}.TerraformType(ctx)
attrTypes["name"] = basetypes.StringType{}.TerraformType(ctx) attrTypes["name"] = basetypes.StringType{}.TerraformType(ctx)
attrTypes["owner"] = 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 { switch v.state {
case attr.ValueStateKnown: case attr.ValueStateKnown:
vals := make(map[string]tftypes.Value, 4) vals := make(map[string]tftypes.Value, 3)
val, err = v.Created.ToTerraformValue(ctx)
if err != nil {
return tftypes.NewValue(objectType, tftypes.UnknownValue), err
}
vals["created"] = val
val, err = v.Id.ToTerraformValue(ctx) val, err = v.Id.ToTerraformValue(ctx)
@ -556,10 +503,9 @@ func (v DatabasesValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValu
var diags diag.Diagnostics var diags diag.Diagnostics
attributeTypes := map[string]attr.Type{ attributeTypes := map[string]attr.Type{
"created": basetypes.StringType{}, "id": basetypes.Int64Type{},
"id": basetypes.Int64Type{}, "name": basetypes.StringType{},
"name": basetypes.StringType{}, "owner": basetypes.StringType{},
"owner": basetypes.StringType{},
} }
if v.IsNull() { if v.IsNull() {
@ -573,10 +519,9 @@ func (v DatabasesValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValu
objVal, diags := types.ObjectValue( objVal, diags := types.ObjectValue(
attributeTypes, attributeTypes,
map[string]attr.Value{ map[string]attr.Value{
"created": v.Created, "id": v.Id,
"id": v.Id, "name": v.Name,
"name": v.Name, "owner": v.Owner,
"owner": v.Owner,
}) })
return objVal, diags return objVal, diags
@ -597,10 +542,6 @@ func (v DatabasesValue) Equal(o attr.Value) bool {
return true return true
} }
if !v.Created.Equal(other.Created) {
return false
}
if !v.Id.Equal(other.Id) { if !v.Id.Equal(other.Id) {
return false 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 { func (v DatabasesValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
return map[string]attr.Type{ return map[string]attr.Type{
"created": basetypes.StringType{}, "id": basetypes.Int64Type{},
"id": basetypes.Int64Type{}, "name": basetypes.StringType{},
"name": basetypes.StringType{}, "owner": basetypes.StringType{},
"owner": basetypes.StringType{},
} }
} }

View file

@ -66,8 +66,8 @@ func UserResourceSchema(ctx context.Context) schema.Schema {
"roles": schema.ListAttribute{ "roles": schema.ListAttribute{
ElementType: types.StringType, ElementType: types.StringType,
Required: true, Required: true,
Description: "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.", 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{ "status": schema.StringAttribute{
Computed: true, Computed: true,

View file

@ -66,8 +66,8 @@ func UserResourceSchema(ctx context.Context) schema.Schema {
"roles": schema.ListAttribute{ "roles": schema.ListAttribute{
ElementType: types.StringType, ElementType: types.StringType,
Required: true, Required: true,
Description: "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.", 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{ "status": schema.StringAttribute{
Computed: true, Computed: true,