Documentation ¶
Index ¶
- Variables
- func CamelToPascalCase(s string) string
- func GenArray(d resource.Attributes, pName string) string
- func GenObject(d resource.Attributes, pName string) string
- func Gen_ConvertOAStoTFTypes(data resource.Attributes) (string, string, error)
- func MakeRefreshFromResponse(attr resource.Attributes, resourceName string) string
- func MakeTestTFConfig(requiredCreateParams []*util.RequestParametersInfo, ...) string
- func NcloudParse(ctx context.Context, document []byte) (util.NcloudSpecification, error)
- func PascalToSnakeCase(s string) string
- func WriteNcloudDataSourceTests(dataSourcesSchema map[string][]byte, spec util.NcloudSpecification, ...) error
- func WriteNcloudDataSources(dataSourcesSchema map[string][]byte, spec util.NcloudSpecification, ...) error
- func WriteNcloudResourceRefresh(resourcesSchema map[string][]byte, spec util.NcloudSpecification, ...) error
- func WriteNcloudResourceTests(resourcesSchema map[string][]byte, spec util.NcloudSpecification, ...) error
- func WriteNcloudResources(resourcesSchema map[string][]byte, spec util.NcloudSpecification, ...) error
- type BaseTemplate
- type OptionalRequestBody
- type RequestType
- type Template
- func (t *Template) RenderCreate() []byte
- func (t *Template) RenderDelete() []byte
- func (t *Template) RenderImportState() []byte
- func (t *Template) RenderInitial() []byte
- func (t *Template) RenderModel() []byte
- func (t *Template) RenderRead() []byte
- func (t *Template) RenderRefresh() []byte
- func (t *Template) RenderTest() []byte
- func (t *Template) RenderUpdate() []byte
- func (t *Template) RenderWait() []byte
Constants ¶
This section is empty.
Variables ¶
var CreateTemplate string
var DeleteTemplate string
var ImportStateTemplate string
var InitialTemplate string
var ModelTemplate string
var ReadTemplate string
var RefreshTemplate string
var TestTemplate string
var UpdateTemplate string
var WaitTemplate string
Functions ¶
func CamelToPascalCase ¶
func Gen_ConvertOAStoTFTypes ¶
func Gen_ConvertOAStoTFTypes(data resource.Attributes) (string, string, error)
generate converter that convert openapi.json schema to terraform type
func MakeRefreshFromResponse ¶
func MakeRefreshFromResponse(attr resource.Attributes, resourceName string) string
func MakeTestTFConfig ¶
func MakeTestTFConfig(requiredCreateParams []*util.RequestParametersInfo, createPathParams *util.RequestParameters) string
func NcloudParse ¶
Parse returns a Specification from the JSON document contents, or any validation errors.
func PascalToSnakeCase ¶
func WriteNcloudDataSourceTests ¶
func WriteNcloudDataSourceTests(dataSourcesSchema map[string][]byte, spec util.NcloudSpecification, outputDir, packageName string) error
WriteDataSources uses the packageName to determine whether to create a directory and package per data source. If packageName is an empty string, this indicates that the flag was not set, and the default behaviour is then to create a package and directory per data source. If packageName is set then all generated code is placed into the same directory and package.
func WriteNcloudDataSources ¶
func WriteNcloudDataSources(dataSourcesSchema map[string][]byte, spec util.NcloudSpecification, outputDir, packageName string) error
WriteDataSources uses the packageName to determine whether to create a directory and package per data source. If packageName is an empty string, this indicates that the flag was not set, and the default behaviour is then to create a package and directory per data source. If packageName is set then all generated code is placed into the same directory and package.
func WriteNcloudResourceTests ¶
func WriteNcloudResourceTests(resourcesSchema map[string][]byte, spec util.NcloudSpecification, outputDir, packageName string) error
WriteResources uses the packageName to determine whether to create a directory and package per resource. If packageName is an empty string, this indicates that the flag was not set, and the default behaviour is then to create a package and directory per resource. If packageName is set then all generated code is placed into the same directory and package.
func WriteNcloudResources ¶
Types ¶
type BaseTemplate ¶
type BaseTemplate interface { // RenderInitial generates small code blocks needed initially. RenderInitial() []byte // RenderCreate generates the Create function. RenderCreate() []byte // RenderRead generates the Read function. RenderRead() []byte // RenderUpdate generates the Update function. RenderUpdate() []byte // RenderDelete generates the Delete function. RenderDelete() []byte // RenderModel generates the model. RenderModel() []byte // RenderRefresh generates the Refresh function. RenderRefresh() []byte // RenderWait generates the Waiting Logic. // Will be Rendered in refresh file. RenderWait() []byte // RenderTest generates the Test logic. RenderTest() []byte // RenderImportState generates the ImportState function. RenderImportState() []byte }
To generate actual data, extract data from config.yml and code-spec.json, and render code for each receiver based on that data.
func NewResource ¶
func NewResource(spec util.NcloudSpecification, resourceName, packageName string) BaseTemplate
Extracts the data needed for code generation. Currently, it extracts data from config.yml and code-spec.json, but it is planned to unify everything into code-spec.json in the future.
type OptionalRequestBody ¶
type RequestType ¶
type RequestType struct { Parameters []string `json:"parameters,omitempty"` RequestBody *OptionalRequestBody `json:"request_body,omitempty"` Response string `json:"response,omitempty"` }
type Template ¶
type Template struct {
// contains filtered or unexported fields
}