Skip to content

Commit

Permalink
Cleanup schema and add attribute descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
danischm committed Oct 3, 2023
1 parent 5160f36 commit 2ed9d05
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 93 deletions.
6 changes: 0 additions & 6 deletions gen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ var templates = []t{

type YamlConfig struct {
Name string `yaml:"name"`
Model string `yaml:"model"`
RestEndpoint string `yaml:"rest_endpoint"`
GetNoId bool `yaml:"get_no_id"`
NoDelete bool `yaml:"no_delete"`
Expand All @@ -118,22 +117,17 @@ type YamlConfigAttribute struct {
ModelName string `yaml:"model_name"`
TfName string `yaml:"tf_name"`
Type string `yaml:"type"`
ModelTypeString bool `yaml:"model_type_string"`
DataPath []string `yaml:"data_path"`
Keys []string `yaml:"keys"`
Id bool `yaml:"id"`
Reference bool `yaml:"reference"`
Mandatory bool `yaml:"mandatory"`
WriteOnly bool `yaml:"write_only"`
WriteChangesOnly bool `yaml:"write_changes_only"`
TfOnly bool `yaml:"tf_only"`
ExcludeTest bool `yaml:"exclude_test"`
ExcludeExample bool `yaml:"exclude_example"`
ExcludeIgnore bool `yaml:"exclude_ignore"`
Description string `yaml:"description"`
Example string `yaml:"example"`
EnumValues []string `yaml:"enum_values"`
IgnoreEnum bool `yaml:"ignore_enum"`
MinList int64 `yaml:"min_list"`
MaxList int64 `yaml:"max_list"`
MinInt int64 `yaml:"min_int"`
Expand Down
96 changes: 45 additions & 51 deletions gen/schema/schema.yaml
Original file line number Diff line number Diff line change
@@ -1,54 +1,48 @@
---
name: str()
model: str(required=False)
rest_endpoint: str(required=False)
get_no_id: bool(required=False)
no_delete: bool(required=False)
post_update: bool(required=False)
root_list: bool(required=False)
no_read_prefix: bool(required=False)
id_path: str(required=False)
minimum_version: str(required=False)
ds_description: str(required=False)
res_description: str(required=False)
doc_category: str(required=False)
skip_minimum_test: bool(required=False)
attributes: list(include('attribute'), required=False)
test_tags: list(str(), required=False)
test_prerequisites: str(required=False)
name: str() # Name of the resource
rest_endpoint: str(required=False) # REST endpoint path
get_no_id: bool(required=False) # Set to true if the GET request does not require an ID
no_delete: bool(required=False) # Set to true if the DELETE request is not supported
post_update: bool(required=False) # Set to true if the POST request is used for update
root_list: bool(required=False) # Set to true if the root element of the data structure is a list
no_read_prefix: bool(required=False) # Set to true if it is an Open API endpoint put the response is not embeeded into a "response" element
id_path: str(required=False) # Path to the ID in the response (use "." to access nested elements)
minimum_version: str(required=False) # Define a minimum supported version
ds_description: str(required=False) # Define a data source description
res_description: str(required=False) # Define a resource description
doc_category: str(required=False) # Define a documentation category
skip_minimum_test: bool(required=False) # Do not perform a "minimum" (only mandatory attributes) test
attributes: list(include('attribute'), required=False) # List of attributes
test_tags: list(str(), required=False) # List of test tags, tests are only executed if an environment variable with one of these tags is configured
test_prerequisites: str(required=False) # HCL code that is included in the acceptance tests to define prerequisites
---
attribute:
model_name: str(required=False)
tf_name: str(required=False)
type: enum('String', 'Int64', 'Bool', 'List', 'Set', 'StringList', required=False)
model_type_string: bool(required=False)
data_path: list(str(), required=False)
keys: list(str(), required=False)
id: bool(required=False)
reference: bool(required=False)
mandatory: bool(required=False)
write_only: bool(required=False)
write_changes_only: bool(required=False)
tf_only: bool(required=False)
exclude_test: bool(required=False)
exclude_example: bool(required=False)
exclude_ignore: bool(required=False)
description: str(required=False)
example: any(str(), int(), bool(), required=False)
enum_values: list(str(), required=False)
ignore_enum: bool(required=False)
min_list: int(required=False)
max_list: int(required=False)
min_int: int(required=False)
max_int: int(required=False)
min_float: num(required=False)
max_float: num(required=False)
string_patterns: list(str(), required=False)
string_min_length: int(required=False)
string_max_length: int(required=False)
default_value: any(str(), int(), bool(), required=False)
value: any(str(), int(), bool(), required=False)
test_value: str(required=False)
minimum_test_value: str(required=False)
test_tags: list(str(), required=False)
attributes: list(include('attribute'), required=False)
model_name: str(required=False) # Name of the attribute in the model (payload)
tf_name: str(required=False) # Name of the attribute in the Terraform resource, by default derived from model_name
type: enum('String', 'Int64', 'Float', 'Bool', 'List', 'Set', 'StringList', required=False) # Type of the attribute
data_path: list(str(), required=False) # Path to the attribute in the model structure
id: bool(required=False) # Set to true if the attribute is part of the ID
reference: bool(required=False) # Set to true if the attribute is a reference being used in the path (URL) of the REST endpoint
mandatory: bool(required=False) # Set to true if the attribute is mandatory
write_only: bool(required=False) # Set to true if the attribute is write-only, meaning we cannot read the value
write_changes_only: bool(required=False) # Set to true if the attribute should only be written (included in PUT payload) if it has changed
exclude_test: bool(required=False) # Exclude attribute from example (documentation) and acceptance test
exclude_example: bool(required=False) # Exclude attribute from acceptance test only (example/documentation is still generated)
description: str(required=False) # Attribute description
example: any(str(), int(), bool(), required=False) # Example value for documentation, also used for acceptance test
enum_values: list(str(), required=False) # List of enum values, only relevant if type is "String"
min_list: int(required=False) # Minimum number of elements in a list, only relevant if type is "List"
max_list: int(required=False) # Maximum number of elements in a list, only relevant if type is "List"
min_int: int(required=False) # Minimum value of an integer, only relevant if type is "Int64"
max_int: int(required=False) # Maximum value of an integer, only relevant if type is "Int64"
min_float: num(required=False) # Minimum value of a float, only relevant if type is "Float"
max_float: num(required=False) # Maximum value of a float, only relevant if type is "Float"
string_patterns: list(str(), required=False) # List of regular expressions that the string must match, only relevant if type is "String"
string_min_length: int(required=False) # Minimum length of a string, only relevant if type is "String"
string_max_length: int(required=False) # Maximum length of a string, only relevant if type is "String"
default_value: any(str(), int(), bool(), required=False) # Default value for the attribute
value: any(str(), int(), bool(), required=False) # Hardcoded value for the attribute
test_value: str(required=False) # Value used for acceptance test
minimum_test_value: str(required=False) # Value used for "minimum" resource acceptance test
test_tags: list(str(), required=False) # List of test tags, attribute is only included in acceptance tests if an environment variable with one of these tags is configured
attributes: list(include('attribute'), required=False) # List of attributes, only relevant if type is "List" or "Set"
16 changes: 8 additions & 8 deletions gen/templates/data_source_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2ed9d05

Please sign in to comment.