Skip to content

Commit

Permalink
Merge pull request #21 from aep-dev/documentation
Browse files Browse the repository at this point in the history
Fix documentation and required attributes
  • Loading branch information
rambleraptor authored Jan 25, 2025
2 parents 1fdd7f9 + 4b11a3b commit ec122dc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (

require (
github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect
github.com/aep-dev/aep-lib-go v0.0.0-20241214201740-a1e57b9a0273 // indirect
github.com/aep-dev/aep-lib-go v0.0.0-20250121233519-8bc026ce637e // indirect
github.com/agext/levenshtein v1.2.2 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ github.com/ProtonMail/go-crypto v1.1.0-alpha.2 h1:bkyFVUP+ROOARdgCiJzNQo2V2kiB97
github.com/ProtonMail/go-crypto v1.1.0-alpha.2/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
github.com/aep-dev/aep-lib-go v0.0.0-20241214201740-a1e57b9a0273 h1:Ti/n7Xko9nrr731O0f7iUewiTL1fiPA93A4/iSazW6M=
github.com/aep-dev/aep-lib-go v0.0.0-20241214201740-a1e57b9a0273/go.mod h1:M+h1D6T2uIUPelmaEsJbjR6JhqKsTlPX3lxp25zQQsk=
github.com/aep-dev/aep-lib-go v0.0.0-20250121233519-8bc026ce637e h1:fwCEENQV0LVH/HEkn6Egznu9FzsifNwnIW7qoYvs5jw=
github.com/aep-dev/aep-lib-go v0.0.0-20250121233519-8bc026ce637e/go.mod h1:M+h1D6T2uIUPelmaEsJbjR6JhqKsTlPX3lxp25zQQsk=
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=
Expand Down
35 changes: 23 additions & 12 deletions internal/provider/example_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,41 +58,52 @@ func (r *ExampleResource) Schema(ctx context.Context, req resource.SchemaRequest
}
}

func checkIfRequired(requiredProps []string, propName string) bool {
for _, prop := range requiredProps {
if prop == propName {
return true
}
return false
}

}

Check failure on line 69 in internal/provider/example_resource.go

View workflow job for this annotation

GitHub Actions / Build

missing return

Check failure on line 69 in internal/provider/example_resource.go

View workflow job for this annotation

GitHub Actions / generate

missing return

func (r *ExampleResource) schemaAttributes() map[string]schema.Attribute {
m := make(map[string]schema.Attribute)
for name, prop := range r.resource.Schema.Properties {
required := checkIfRequired(r.resource.Schema.Required, name)
var a schema.Attribute
switch prop.Type {
case "number":
a = schema.NumberAttribute{
MarkdownDescription: "",
MarkdownDescription: prop.Description,
Computed: prop.ReadOnly,
Required: false,
Optional: true,
Required: required,
Optional: !required,
}
m[name] = a
case "string":
a = schema.StringAttribute{
MarkdownDescription: "",
MarkdownDescription: prop.Description,
Computed: prop.ReadOnly,
Required: false,
Optional: true,
Optional: !required,
Required: required,
}
m[name] = a
case "boolean":
a = schema.BoolAttribute{
MarkdownDescription: "",
MarkdownDescription: prop.Description,
Computed: prop.ReadOnly,
Required: false,
Optional: true,
Required: required,
Optional: !required,
}
m[name] = a
case "integer":
a = schema.Int64Attribute{
MarkdownDescription: "",
MarkdownDescription: prop.Description,
Computed: prop.ReadOnly,
Required: false,
Optional: true,
Required: required,
Optional: !required,
}
m[name] = a
}
Expand Down

0 comments on commit ec122dc

Please sign in to comment.