Skip to content

Commit b404a8c

Browse files
authored
Add custom type handling for collection elements and object attribute types (#9)
* Incorporating usage of spec element type * Adding tests for custom types on elements * Updating ci-go.yml to use token for pulling modules from codegen-spec (private repo) * Linting * Using latest version of main and calling spec.Parse for validation and spec generation * Switching to using HasImport available in spec * Add handling of element type and attribute type into provider and resource * Add handling of default and plan modifier imports into resources * Switching to using HasImport() helper method * Removing unused function * Wiring-up addition of imports into schema template for provider and resources * Removing unneeded schemaImport inclusion in import generation as the import is included in the top-level schema.gotmpl * Moving commands to separate directory * Adding new line when object contains more than one attribute type * Adding copyright headers * Handling custom type in schema generation for collection elements and object attribute types * Amending golangci configuration to skip output directory * Refactoring to used shared functions for spec schema ElementType and ObjectAttributeType * Updating package names to match module name * Removing unneeded import from schema.gotmpl for data source, provider and resource * Adding nil check in template for custom field in plan modifier * Adding nil check in template for custom field in validator * DRYing up usage of WriteString() * Adding comment about the usage specschema types * Using string quoting within fmt.Sprintf()
1 parent 13f3105 commit b404a8c

File tree

213 files changed

+19360
-3642
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

213 files changed

+19360
-3642
lines changed

.golangci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@ linters:
2626

2727
run:
2828
# Prevent false positive timeouts in CI
29-
timeout: 5m
29+
timeout: 5m
30+
skip-dirs:
31+
- output

README.md

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ facilitate the chaining together of CLI commands.
88
The following is a contrived example:
99

1010
```shell
11-
cat examples/ir.json | go run . schema
11+
cat examples/ir.json | go run . all
1212
```
1313

1414
An alternative is to use the `-input` flag to specify a file from which the IR can be read.
1515

1616
For example:
1717

1818
```shell
19-
go run . schema -input examples/ir.json
19+
go run . all -input examples/ir.json
2020
```
2121

2222
Both cases will process `ir.json`.
@@ -51,27 +51,6 @@ The general flow is as follows:
5151
* Write the formatted Go code, one file per data source, provider or resource, into
5252
`generator/output`.
5353

54-
Currently, the only command that has been implemented is `schema`. This is a bit of a misnomer
55-
as the `schema` command generates schema, models and model helper functions but _only_ for data
56-
sources currently.
57-
58-
## Further Considerations
59-
60-
### Input
61-
62-
* Do we want to have the default for input for both the IR and the IR schema be stdin?
63-
64-
### Validate
65-
66-
* Do we want to improve the detail of the error messages that are generated when the IR is
67-
not valid JSON or is this considered outside the scope of the IR2FCG?
68-
69-
### Generate
70-
71-
* Go code generation is leveraging [text/template](https://pkg.go.dev/text/template). Currently,
72-
testing of the code generation is using files which contain a textual representation of the
73-
expected generated code. This is quite difficult to visually inspect as no syntax highlighting
74-
is provided by an IDE. Perhaps there's a better/easier way to handle this process?
75-
* The templates that are used for generating Go code are `*.gotmpl` files which do not benefit
76-
from Go syntax highlighting via an IDE. Again, perhaps there's a better/easier way to deal
77-
with the templates.
54+
Currently, the only command that has been implemented is `all`. This is a bit of a misnomer
55+
as the `all` command only generates schema for data sources, provider and resources at
56+
present.

0 commit comments

Comments
 (0)