Documentation
¶
Overview ¶
Package types provides shared types used by multiple packages in the "bicep-docs" application.
It also provides custom UnmarshalJSON and Sort functions for some of those types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Metadata ¶
Metadata is a struct that contains the metadata part of a parameter, an output, or the template itself. The metadata part consists of two optional fields: name and description.
A name can be either a metadata item (metadata name = '...') for the template, or a parameter/output name.
A description can be either an annotation (@description('...') | @sys.description('...')) or a metadata item (metadata description = '...').
type Module ¶
Module is a struct that contains the information about a module. A module has a symbolic name, a source, and an optional description.
The symbolic name is the name of the module that is used to reference the module. The source is either the path to the module file or the URL of the remote module. The description is an optional description of the module.
Example: module network './modules/network/main.bicep'
In the example above, the symbolic name is "network" and the source is "./modules/network/main.bicep".
type Output ¶
type Output struct { Name string `json:"-"` Type string `json:"-"` Nullable bool `json:"nullable"` Metadata *Metadata `json:"metadata"` }
Output is a struct that contains the information about an output. An output has a name, type, nullable flag, and an optional metadata part.
The name is the name of the output. The type is the type of the output (e.g. "string"). The nullable flag indicates if the output can be null. The metadata part is the optional metadata part of the output (just the description).
func (*Output) UnmarshalJSON ¶
UnmarshalJSON unmarshals a JSON object into an Output. The type field can be either a type or a $ref.
type Parameter ¶
type Parameter struct { Name string `json:"-"` Type string `json:"-"` DefaultValue any `json:"defaultValue"` Nullable bool `json:"nullable"` Metadata *Metadata `json:"metadata"` }
Parameter is a struct that contains the information about a parameter. A parameter has a name, type, an optional default value, nullable flag, and an optional metadata part.
The name is the name of the parameter. The type is the type of the parameter (e.g. "string" or even a user defined type). The default value is the optional default value of the parameter. The nullable flag indicates if the parameter can be null. The metadata part is the optional metadata part of the parameter (just the description).
func (*Parameter) UnmarshalJSON ¶
UnmarshalJSON unmarshals a JSON object into a Parameter. The type field can be either a type or a $ref.
type Resource ¶
Resource is a struct that contains the information about a resource. A resource has a symbolic name, a type, and an optional description.
The symbolic name is the name of the resource that is used to reference the resource. The type is the type of the resource (e.g. "Microsoft.Network/virtualNetworks"). The description is an optional description of the resource.
type Section ¶
type Section string
Section is an enum that represents the different sections of the generated Markdown file.
const ( DescriptionSection Section = "description" UsageSection Section = "usage" ModulesSection Section = "modules" ResourcesSection Section = "resources" ParametersSection Section = "parameters" UserDefinedDataTypesSection Section = "uddts" UserDefinedFunctionsSection Section = "udfs" VariablesSection Section = "variables" OutputsSection Section = "outputs" )
func ParseSectionFromString ¶
ParseSectionFromString converts a string to its corresponding Section enum value.
type Template ¶
type Template struct { FileName string `json:"-"` Modules []Module `json:"-"` Resources []Resource `json:"-"` Parameters []Parameter `json:"-"` UserDefinedDataTypes []UserDefinedDataType `json:"-"` UserDefinedFunctions []UserDefinedFunction `json:"-"` Variables []Variable `json:"-"` Outputs []Output `json:"-"` Metadata *Metadata `json:"metadata"` }
Template is a struct that contains the information about a Bicep template.
A template has a list of: modules, resources, parameters, user defined data types, user defined functions, variables, outputs and an optional metadata part.
func (*Template) Sort ¶
func (t *Template) Sort()
Sort sorts the template's parameters, user defined data types, variables, outputs and user defined functions by name.
func (*Template) UnmarshalJSON ¶
UnmarshalJSON unmarshals a JSON object into a Template.
The parameters, data types, variables, outputs, and functions are unmarshalled into slices of Parameter, UserDefinedDataType, Variable, Output, and UserDefinedFunction, respectively.
The slices are then sorted by name.
type UserDefinedDataType ¶
type UserDefinedDataType struct { Name string `json:"-"` Type string `json:"-"` Nullable bool `json:"nullable"` Properties []UserDefinedDataTypeProperty `json:"-"` Metadata *Metadata `json:"metadata"` }
UserDefinedDataType (UDDT) is a struct that contains the information about a user defined data type. A user defined data type has a name, type, nullable flag, list of properties, and an optional metadata part.
The name is the name of the user defined data type. The type is the type of the user defined data type (e.g. "object" or even including other user defined types). The nullable flag indicates if the user defined data type can be null. The properties are the properties of the user defined data type (e.g. fields in an object). The metadata part is the optional metadata part of the user defined data type (just the description).
func (*UserDefinedDataType) UnmarshalJSON ¶
func (u *UserDefinedDataType) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals a JSON object into a UserDefinedDataType. The type field can be either a type or a $ref.
type UserDefinedDataTypeProperty ¶
type UserDefinedDataTypeProperty struct { Name string `json:"-"` Type string `json:"-"` Nullable bool `json:"nullable"` Metadata *Metadata `json:"metadata"` }
UserDefinedDataTypeProperty is a struct that contains the information about a property of a user defined data type. A property has a name, type, nullable flag, and an optional metadata part.
The name is the name of the property. The type is the type of the property (e.g. "string" or even a user defined type). The nullable flag indicates if the property can be null. The metadata part is the optional metadata part of the property (just the description).
func (*UserDefinedDataTypeProperty) UnmarshalJSON ¶
func (p *UserDefinedDataTypeProperty) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals a JSON object into a UserDefinedDataTypeProperty. The type field can be either a type or a $ref.
type UserDefinedFunction ¶
type UserDefinedFunction struct { Name string `json:"-"` Parameters []Parameter `json:"parameters"` Output Output `json:"output"` Metadata *Metadata `json:"metadata"` }
UserDefinedFunction (UDF) is a struct that contains the information about a user defined function. A user defined function has a name, a list of parameters, an output and an optional metadata part.
The name is the name of the user defined function. The parameters are the parameters of the user defined function. The output is the output of the user defined function. The metadata part is the optional metadata part of the user defined function (just the description).