Skip to content

Commit 2ed9d05

Browse files
committed
Cleanup schema and add attribute descriptions
1 parent 5160f36 commit 2ed9d05

File tree

6 files changed

+81
-93
lines changed

6 files changed

+81
-93
lines changed

gen/generator.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ var templates = []t{
9595

9696
type YamlConfig struct {
9797
Name string `yaml:"name"`
98-
Model string `yaml:"model"`
9998
RestEndpoint string `yaml:"rest_endpoint"`
10099
GetNoId bool `yaml:"get_no_id"`
101100
NoDelete bool `yaml:"no_delete"`
@@ -118,22 +117,17 @@ type YamlConfigAttribute struct {
118117
ModelName string `yaml:"model_name"`
119118
TfName string `yaml:"tf_name"`
120119
Type string `yaml:"type"`
121-
ModelTypeString bool `yaml:"model_type_string"`
122120
DataPath []string `yaml:"data_path"`
123-
Keys []string `yaml:"keys"`
124121
Id bool `yaml:"id"`
125122
Reference bool `yaml:"reference"`
126123
Mandatory bool `yaml:"mandatory"`
127124
WriteOnly bool `yaml:"write_only"`
128125
WriteChangesOnly bool `yaml:"write_changes_only"`
129-
TfOnly bool `yaml:"tf_only"`
130126
ExcludeTest bool `yaml:"exclude_test"`
131127
ExcludeExample bool `yaml:"exclude_example"`
132-
ExcludeIgnore bool `yaml:"exclude_ignore"`
133128
Description string `yaml:"description"`
134129
Example string `yaml:"example"`
135130
EnumValues []string `yaml:"enum_values"`
136-
IgnoreEnum bool `yaml:"ignore_enum"`
137131
MinList int64 `yaml:"min_list"`
138132
MaxList int64 `yaml:"max_list"`
139133
MinInt int64 `yaml:"min_int"`

gen/schema/schema.yaml

Lines changed: 45 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,48 @@
11
---
2-
name: str()
3-
model: str(required=False)
4-
rest_endpoint: str(required=False)
5-
get_no_id: bool(required=False)
6-
no_delete: bool(required=False)
7-
post_update: bool(required=False)
8-
root_list: bool(required=False)
9-
no_read_prefix: bool(required=False)
10-
id_path: str(required=False)
11-
minimum_version: str(required=False)
12-
ds_description: str(required=False)
13-
res_description: str(required=False)
14-
doc_category: str(required=False)
15-
skip_minimum_test: bool(required=False)
16-
attributes: list(include('attribute'), required=False)
17-
test_tags: list(str(), required=False)
18-
test_prerequisites: str(required=False)
2+
name: str() # Name of the resource
3+
rest_endpoint: str(required=False) # REST endpoint path
4+
get_no_id: bool(required=False) # Set to true if the GET request does not require an ID
5+
no_delete: bool(required=False) # Set to true if the DELETE request is not supported
6+
post_update: bool(required=False) # Set to true if the POST request is used for update
7+
root_list: bool(required=False) # Set to true if the root element of the data structure is a list
8+
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
9+
id_path: str(required=False) # Path to the ID in the response (use "." to access nested elements)
10+
minimum_version: str(required=False) # Define a minimum supported version
11+
ds_description: str(required=False) # Define a data source description
12+
res_description: str(required=False) # Define a resource description
13+
doc_category: str(required=False) # Define a documentation category
14+
skip_minimum_test: bool(required=False) # Do not perform a "minimum" (only mandatory attributes) test
15+
attributes: list(include('attribute'), required=False) # List of attributes
16+
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
17+
test_prerequisites: str(required=False) # HCL code that is included in the acceptance tests to define prerequisites
1918
---
2019
attribute:
21-
model_name: str(required=False)
22-
tf_name: str(required=False)
23-
type: enum('String', 'Int64', 'Bool', 'List', 'Set', 'StringList', required=False)
24-
model_type_string: bool(required=False)
25-
data_path: list(str(), required=False)
26-
keys: list(str(), required=False)
27-
id: bool(required=False)
28-
reference: bool(required=False)
29-
mandatory: bool(required=False)
30-
write_only: bool(required=False)
31-
write_changes_only: bool(required=False)
32-
tf_only: bool(required=False)
33-
exclude_test: bool(required=False)
34-
exclude_example: bool(required=False)
35-
exclude_ignore: bool(required=False)
36-
description: str(required=False)
37-
example: any(str(), int(), bool(), required=False)
38-
enum_values: list(str(), required=False)
39-
ignore_enum: bool(required=False)
40-
min_list: int(required=False)
41-
max_list: int(required=False)
42-
min_int: int(required=False)
43-
max_int: int(required=False)
44-
min_float: num(required=False)
45-
max_float: num(required=False)
46-
string_patterns: list(str(), required=False)
47-
string_min_length: int(required=False)
48-
string_max_length: int(required=False)
49-
default_value: any(str(), int(), bool(), required=False)
50-
value: any(str(), int(), bool(), required=False)
51-
test_value: str(required=False)
52-
minimum_test_value: str(required=False)
53-
test_tags: list(str(), required=False)
54-
attributes: list(include('attribute'), required=False)
20+
model_name: str(required=False) # Name of the attribute in the model (payload)
21+
tf_name: str(required=False) # Name of the attribute in the Terraform resource, by default derived from model_name
22+
type: enum('String', 'Int64', 'Float', 'Bool', 'List', 'Set', 'StringList', required=False) # Type of the attribute
23+
data_path: list(str(), required=False) # Path to the attribute in the model structure
24+
id: bool(required=False) # Set to true if the attribute is part of the ID
25+
reference: bool(required=False) # Set to true if the attribute is a reference being used in the path (URL) of the REST endpoint
26+
mandatory: bool(required=False) # Set to true if the attribute is mandatory
27+
write_only: bool(required=False) # Set to true if the attribute is write-only, meaning we cannot read the value
28+
write_changes_only: bool(required=False) # Set to true if the attribute should only be written (included in PUT payload) if it has changed
29+
exclude_test: bool(required=False) # Exclude attribute from example (documentation) and acceptance test
30+
exclude_example: bool(required=False) # Exclude attribute from acceptance test only (example/documentation is still generated)
31+
description: str(required=False) # Attribute description
32+
example: any(str(), int(), bool(), required=False) # Example value for documentation, also used for acceptance test
33+
enum_values: list(str(), required=False) # List of enum values, only relevant if type is "String"
34+
min_list: int(required=False) # Minimum number of elements in a list, only relevant if type is "List"
35+
max_list: int(required=False) # Maximum number of elements in a list, only relevant if type is "List"
36+
min_int: int(required=False) # Minimum value of an integer, only relevant if type is "Int64"
37+
max_int: int(required=False) # Maximum value of an integer, only relevant if type is "Int64"
38+
min_float: num(required=False) # Minimum value of a float, only relevant if type is "Float"
39+
max_float: num(required=False) # Maximum value of a float, only relevant if type is "Float"
40+
string_patterns: list(str(), required=False) # List of regular expressions that the string must match, only relevant if type is "String"
41+
string_min_length: int(required=False) # Minimum length of a string, only relevant if type is "String"
42+
string_max_length: int(required=False) # Maximum length of a string, only relevant if type is "String"
43+
default_value: any(str(), int(), bool(), required=False) # Default value for the attribute
44+
value: any(str(), int(), bool(), required=False) # Hardcoded value for the attribute
45+
test_value: str(required=False) # Value used for acceptance test
46+
minimum_test_value: str(required=False) # Value used for "minimum" resource acceptance test
47+
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
48+
attributes: list(include('attribute'), required=False) # List of attributes, only relevant if type is "List" or "Set"

gen/templates/data_source_test.go

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)