Documentation ¶
Index ¶
- func LoadSwagger(swaggerURI string) (*openapispec.Swagger, error)
- func NormalizeFileRef(ref *openapispec.Ref, relativeBase string) *openapispec.Ref
- type SWGGrant
- type SWGPropertyCoverageStore
- func (store *SWGPropertyCoverageStore) Add(propAddr propertyaddr.SwaggerPropertyAddr, prop SWGSchemaProperty) error
- func (store *SWGPropertyCoverageStore) FindCoverage(propAddr propertyaddr.SwaggerPropertyAddr) (covered, total int, ok bool)
- func (store *SWGPropertyCoverageStore) SchemaCoverage() (covered, total int)
- type SWGSchema
- func (s *SWGSchema) AddTFLink(swgPropAddr propertyaddr.SwaggerPropertyAddr, ...) error
- func (s *SWGSchema) CalcCoverage() error
- func (s *SWGSchema) ExpandPropertyOneLevelDeep(addr propertyaddr.SwaggerPropertyAddr) error
- func (s *SWGSchema) FindCoverage(propAddr propertyaddr.SwaggerPropertyAddr) (covered, total int, ok bool)
- func (s *SWGSchema) SchemaCoverage() (covered, total int)
- type SWGSchemaAddr
- type SWGSchemaCollector
- type SWGSchemaGrant
- type SWGSchemaProperties
- type SWGSchemaProperty
- type SWGSchemas
- func (c *SWGSchemas) Get(addr SWGSchemaAddr) *SWGSchema
- func (c *SWGSchemas) GetAll() map[SWGSchemaAddr]*SWGSchema
- func (c *SWGSchemas) Grant(grant SWGGrant) error
- func (c *SWGSchemas) LinkSWGSchema(swaggerBasePath, swaggerRelPath string, ...) error
- func (c *SWGSchemas) Lock()
- func (c *SWGSchemas) Set(addr SWGSchemaAddr, schema *SWGSchema)
- func (c *SWGSchemas) Unlock()
- type SwaggerCache
- type SwaggerLink
- type TFLink
- type TFLinks
- type TFSchema
- type TFSchemaPropertyLinks
- type TerraformAttribute
- type TerraformBlock
- type TerraformNestedBlock
- type TerraformProvider
- type TerraformProviderSchemas
- type TerraformSchema
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadSwagger ¶
func LoadSwagger(swaggerURI string) (*openapispec.Swagger, error)
LoadSwagger load a certain swagger spec (document) from either file or http
func NormalizeFileRef ¶
func NormalizeFileRef(ref *openapispec.Ref, relativeBase string) *openapispec.Ref
relativeBase could be an ABSOLUTE file path or an ABSOLUTE URL
Types ¶
type SWGGrant ¶
type SWGGrant map[SWGSchemaAddr]SWGSchemaGrant
func NewSWGGrantFromFiles ¶
NewSWGGrantFromFiles construct a SWGGrant from a grantBaseDir which contains the folder layout as defined by the SWGSchemaAddr.
type SWGPropertyCoverageStore ¶
type SWGPropertyCoverageStore struct {
// contains filtered or unexported fields
}
func NewSWGPropertyCoverageStore ¶
func NewSWGPropertyCoverageStore() SWGPropertyCoverageStore
func (*SWGPropertyCoverageStore) Add ¶
func (store *SWGPropertyCoverageStore) Add(propAddr propertyaddr.SwaggerPropertyAddr, prop SWGSchemaProperty) error
Add adds a SWGSchemaProperty and record the coverage state in each property level. If a property is added more than once, an error will be returned. NOTE: The granted property will be ignored
func (*SWGPropertyCoverageStore) FindCoverage ¶
func (store *SWGPropertyCoverageStore) FindCoverage(propAddr propertyaddr.SwaggerPropertyAddr) (covered, total int, ok bool)
func (*SWGPropertyCoverageStore) SchemaCoverage ¶
func (store *SWGPropertyCoverageStore) SchemaCoverage() (covered, total int)
type SWGSchema ¶
type SWGSchema struct { SwaggerRelPath string Name string Properties SWGSchemaProperties // Whether this property is granted to be not to implement in Terraform IsGranted bool `json:",omitempty"` GrantComment string `json:",omitempty"` // contains filtered or unexported fields }
func CollectSWGSchemas ¶
func CollectSWGSchemas(swaggerBaseURL, swaggerRelPath string, collector SWGSchemaCollector) ([]SWGSchema, error)
CollectSWGSchemas collects the schemas from a swagger spec
func NewSWGSchema ¶
func (*SWGSchema) AddTFLink ¶
func (s *SWGSchema) AddTFLink(swgPropAddr propertyaddr.SwaggerPropertyAddr, tfPropAddr propertyaddr.TerraformPropertyAddr) error
func (*SWGSchema) CalcCoverage ¶
CalcCoverage calculates the property coverage (<=1) of the schema/property, and fill in the SWGSchema. Those granted properties are not counted during the calculation.
func (*SWGSchema) ExpandPropertyOneLevelDeep ¶
func (s *SWGSchema) ExpandPropertyOneLevelDeep(addr propertyaddr.SwaggerPropertyAddr) error
ExpandPropertyOneLevelDeep expand the specified swagger schemas property one level deep, with any allOf and $ref taken into consideration.
func (*SWGSchema) FindCoverage ¶
func (s *SWGSchema) FindCoverage(propAddr propertyaddr.SwaggerPropertyAddr) (covered, total int, ok bool)
func (*SWGSchema) SchemaCoverage ¶
type SWGSchemaAddr ¶
type SWGSchemaAddr string
func NewSWGSchemaAddr ¶
func NewSWGSchemaAddr(swaggerRelPath, schemaName string) SWGSchemaAddr
func (SWGSchemaAddr) SchemaName ¶
func (addr SWGSchemaAddr) SchemaName() string
func (SWGSchemaAddr) SwaggerRelPath ¶
func (addr SWGSchemaAddr) SwaggerRelPath() string
type SWGSchemaCollector ¶
type SWGSchemaCollector func(swagger *openapispec.Swagger) (schemaNames []string)
type SWGSchemaGrant ¶
type SWGSchemaGrant struct { // The grant comment why the schema is granted. Comment string `json:",omitempty"` // Property grant map, whose key is the propertyaddr, whose value is the grant comment. Properties map[string]string `json:",omitempty"` }
func (SWGSchemaGrant) IsSchemaGranted ¶
func (g SWGSchemaGrant) IsSchemaGranted() bool
type SWGSchemaProperties ¶
type SWGSchemaProperties map[string]*SWGSchemaProperty // the key is swagger schemas relative property addr
func NewSWGSchemaProperties ¶
func NewSWGSchemaProperties() SWGSchemaProperties
func (SWGSchemaProperties) Add ¶
func (p SWGSchemaProperties) Add(o SWGSchemaProperties)
type SWGSchemaProperty ¶
type SWGSchemaProperty struct { // Terraform property addresses TFLinks TFLinks `json:",omitempty"` // Whether this property is granted to be not to implement in Terraform IsGranted bool `json:",omitempty"` GrantComment string `json:",omitempty"` // contains filtered or unexported fields }
func NewSWGSchemaProperty ¶
func NewSWGSchemaProperty(schema openapispec.Schema, tflinks []TFLink, resolvedRefs map[string]interface{}, schemaURI string) *SWGSchemaProperty
type SWGSchemas ¶
SWGSchemas caches the SWGSchema using swagger + schemas as key. During each link operation from terraform schemas to swagger schemas, it will manipulate one of the SWGSchema. Afterwards, this type contains all the mapping info from swagger to terraform.
func NewSGWSchemas ¶
func NewSGWSchemas() *SWGSchemas
func NewSWGSchemasFromTerraformSchema ¶
func NewSWGSchemasFromTerraformSchema(swaggerBasePath, tfSchemaDir, swaggerGrantBaseDir string) (*SWGSchemas, error)
Build SWGSchemas by processing on Terraform schema files (which resides in the tfSchemaDir) and the Swagger specs (which resides in the swaggerBaseDir, can be either a local path or an http URI) Optionally, users can specify the swaggerGrantDir which contains the grants for those non-terraform appropriate swagger schema/properties.
func (*SWGSchemas) Get ¶
func (c *SWGSchemas) Get(addr SWGSchemaAddr) *SWGSchema
func (*SWGSchemas) GetAll ¶
func (c *SWGSchemas) GetAll() map[SWGSchemaAddr]*SWGSchema
GetSWGSchema get all SWGSchema from cache.
func (*SWGSchemas) Grant ¶
func (c *SWGSchemas) Grant(grant SWGGrant) error
Grant inquiries the SWGGrant to add the granting information onto the SWGSchemas
func (*SWGSchemas) LinkSWGSchema ¶
func (c *SWGSchemas) LinkSWGSchema(swaggerBasePath, swaggerRelPath string, swgPropAddr propertyaddr.SwaggerPropertyAddr, tfPropAddr propertyaddr.TerraformPropertyAddr) error
func (*SWGSchemas) Lock ¶
func (c *SWGSchemas) Lock()
func (*SWGSchemas) Set ¶
func (c *SWGSchemas) Set(addr SWGSchemaAddr, schema *SWGSchema)
func (*SWGSchemas) Unlock ¶
func (c *SWGSchemas) Unlock()
type SwaggerCache ¶
type SwaggerLink ¶
type SwaggerLink struct { Spec *string `json:"swagger,omitempty"` // swagger spec relative path that this propertyaddr resides in, this overrides the global swagger scope SchemaProp propertyaddr.SwaggerPropertyAddr `json:"prop"` // dot-separated swagger schemas propertyaddr, starting from the schemas used as the PUT body parameter }
type TFLink ¶
type TFLink struct {
Prop propertyaddr.TerraformPropertyAddr
}
type TFSchema ¶
type TFSchema struct { Name string SwaggerSpec string `json:"swagger"` // swagger spec relative path path that all the linked swagger property resides in by default PropertyLinks TFSchemaPropertyLinks }
func NewSchemaScaffoldFromTerraformBlock ¶
func NewSchemaScaffoldFromTerraformBlock(name string, block *TerraformBlock) *TFSchema
NewSchemaScaffoldFromTerraformBlock construct the TFSchema for a certain resource from the terraform resource block derived from `terraform providers schema -json`.
func UpdateSchemaScaffoldFromTerraformBlock ¶
func UpdateSchemaScaffoldFromTerraformBlock(name string, block *TerraformBlock, oldSchema *TFSchema) (*TFSchema, error)
UpdateSchemaScaffoldFromTerraformBlock is similart to NewSchemaScaffoldFromTerraformBlock, except it will update the constrcutred TFSchema with the existing TFSchema.
func (TFSchema) LinkSwagger ¶
func (schema TFSchema) LinkSwagger(swgSchemaCache *SWGSchemas, swaggerBasePath string) error
type TFSchemaPropertyLinks ¶
type TFSchemaPropertyLinks map[string][]SwaggerLink
type TerraformAttribute ¶
type TerraformBlock ¶
type TerraformBlock struct { Attributes map[string]*TerraformAttribute `json:"attributes"` BlockTypes map[string]*TerraformNestedBlock `json:"block_types"` }
type TerraformNestedBlock ¶
type TerraformNestedBlock struct {
TerraformBlock `json:"block"`
}
type TerraformProvider ¶
type TerraformProvider struct { ResourceSchemas map[string]*TerraformSchema `json:"resource_schemas,omitempty"` DataSourceSchemas map[string]*TerraformSchema `json:"data_source_schemas,omitempty"` }
type TerraformProviderSchemas ¶
type TerraformProviderSchemas struct { FormatVersion string `json:"format_version"` Schemas map[string]TerraformProvider `json:"provider_schemas"` }
type TerraformSchema ¶
type TerraformSchema struct {
Block *TerraformBlock `json:"block,omitempty"`
}