ncloud

package
v0.0.0-...-c3eeba5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2025 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CreateTemplate string
View Source
var DeleteTemplate string
View Source
var ImportStateTemplate string
View Source
var InitialTemplate string
View Source
var ModelTemplate string
View Source
var ReadTemplate string
View Source
var RefreshTemplate string
View Source
var TestTemplate string
View Source
var UpdateTemplate string
View Source
var WaitTemplate string

Functions

func CamelToPascalCase

func CamelToPascalCase(s string) string

func GenArray

func GenArray(d resource.Attributes, pName string) string

func GenObject

func GenObject(d resource.Attributes, pName string) string

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

func NcloudParse(ctx context.Context, document []byte) (util.NcloudSpecification, error)

Parse returns a Specification from the JSON document contents, or any validation errors.

func PascalToSnakeCase

func PascalToSnakeCase(s string) string

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 WriteNcloudResourceRefresh

func WriteNcloudResourceRefresh(resourcesSchema map[string][]byte, spec util.NcloudSpecification, outputDir, packageName string) error

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

func WriteNcloudResources(resourcesSchema map[string][]byte, spec util.NcloudSpecification, outputDir, packageName string, genRefresh bool) error

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 OptionalRequestBody struct {
	Name     string   `json:"name,omitempty"`
	Required []string `json:"required,omitempty"`
	Optional []string `json:"optional,omitempty"`
}

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
}

func (*Template) RenderCreate

func (t *Template) RenderCreate() []byte

func (*Template) RenderDelete

func (t *Template) RenderDelete() []byte

func (*Template) RenderImportState

func (t *Template) RenderImportState() []byte

func (*Template) RenderInitial

func (t *Template) RenderInitial() []byte

func (*Template) RenderModel

func (t *Template) RenderModel() []byte

func (*Template) RenderRead

func (t *Template) RenderRead() []byte

func (*Template) RenderRefresh

func (t *Template) RenderRefresh() []byte

func (*Template) RenderTest

func (t *Template) RenderTest() []byte

func (*Template) RenderUpdate

func (t *Template) RenderUpdate() []byte

func (*Template) RenderWait

func (t *Template) RenderWait() []byte

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL