-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Terraform] Scalar support for models and datasources #497
base: main
Are you sure you want to change the base?
[Terraform] Scalar support for models and datasources #497
Conversation
Note: in addition to the changes introduced by this PR, the diff includes unreleased changes living in
grafana-foundation-sdk@next+cog-v0.0.x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the internal/jennies/terraform/templates/types/foo.tmpl
file?
TemporaryScalarPlaceholder types.Bool // @TODO Remove this once non-scalars are implemented | ||
} | ||
|
||
func (m {{ .Name | formatObjectName }}DataSourceModel) GetAttrRefresh() interface{} { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks very specific to the dashboard's refresh field 🤔
var scalarType string | ||
|
||
switch tt.ScalarKind { | ||
case ast.KindString, ast.KindBytes: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't KindBytes be generated as []byte
?
case ast.KindFloat32: | ||
scalarType = "float64" | ||
case ast.KindFloat64: | ||
scalarType = "float64" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why number precision is ignored?
} | ||
return scalarType | ||
} | ||
return "types.Any" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does types.Any
refer to?
return "ValueAny()" | ||
} | ||
|
||
func formatTypeValueNoPointers(dflt any, t ast.Type) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does dflt
mean?
Aim: full working support for scalar values. All that remains is support for schemas, then this should be in place.