Documentation
¶
Index ¶
- Constants
- func AreVariablesSameType(expected interface{}, actual interface{}) bool
- func IndentStringStructure(input string) string
- func ListVariableType(listVar interface{}) string
- func MapVariableType(mapVar interface{}) string
- func NewCloneyUserVariablesFromFile(filePath string) (map[string]interface{}, error)
- func NewCloneyUserVariablesFromRawYAML(rawYAML string) (map[string]interface{}, error)
- func VariableType(variable interface{}) string
- func VariableValue(value interface{}) string
- type CloneyMetadata
- type CloneyMetadataConfiguration
- type CloneyMetadataVariable
Constants ¶
const ( STRING_VARIABLE_TYPE = "string" INTEGER_VARIABLE_TYPE = "integer" DECIMAL_VARIABLE_TYPE = "decimal" BOOLEAN_VARIABLE_TYPE = "boolean" LIST_VARIABLE_TYPE = "list" MAP_VARIABLE_TYPE = "map" UNKNOWN_VARIABLE_TYPE = "unknown" )
Constants for variable types.
Variables ¶
This section is empty.
Functions ¶
func AreVariablesSameType ¶
func AreVariablesSameType(expected interface{}, actual interface{}) bool
AreVariablesSameType checks if two variables are of the same type.
func IndentStringStructure ¶
IndentStringStructure indents the structure of a string (list or map-like structure). Used for formatting maps and lists.
func ListVariableType ¶
func ListVariableType(listVar interface{}) string
ListVariableType returns a string representation of the type of a list variable.
func MapVariableType ¶
func MapVariableType(mapVar interface{}) string
MapVariableType returns a string representation of the type of a map variable.
func NewCloneyUserVariablesFromFile ¶
NewCloneyUserVariablesFromFile reads a file and returns a map of variables defined in it. Supported file extensions: '.yaml' or '.yml'.
func NewCloneyUserVariablesFromRawYAML ¶
NewCloneyUserVariablesFromRawYAML returns a map of variables defined in the given raw YAML string.
func VariableType ¶
func VariableType(variable interface{}) string
VariableType returns the type of a variable as a string.
func VariableValue ¶
func VariableValue(value interface{}) string
VariableValue returns the value of a variable as a string.
Types ¶
type CloneyMetadata ¶
type CloneyMetadata struct {
// Name is the template repository name.
Name string `yaml:"name" validate:"required"`
// Description is the template repository description.
Description string `yaml:"description"`
// TemplateVersion is the version of the template repository.
TemplateVersion string `yaml:"template_version" validate:"required,semver"`
// ManifestVersion is the version of the manifest file.
ManifestVersion string `yaml:"manifest_version" validate:"required"`
// Authors is the list of authors of the template repository.
Authors []string `yaml:"authors"`
// License is the license of the template repository.
License string `yaml:"license"`
// Configuration is the configuration of the template repository.
Configuration CloneyMetadataConfiguration `yaml:"configuration"`
// Variables is the list of variables of the template repository.
Variables []CloneyMetadataVariable `yaml:"variables"`
}
CloneyMetadata represents the metadata file of a Cloney template repository.
func NewCloneyMetadataFromRawYAML ¶
func NewCloneyMetadataFromRawYAML(rawYAML string, supportedManifestVersions []string) (*CloneyMetadata, error)
NewCloneyMetadataFromRawYAML creates a new CloneyMetadata struct from a YAML string. It also validates the manifest version and the metadata structure.
func (*CloneyMetadata) GetGeneralInfo ¶
func (m *CloneyMetadata) GetGeneralInfo() string
GetGeneralInfo returns the general information of the Cloney template repository as a string.
func (*CloneyMetadata) GetVariables ¶
func (m *CloneyMetadata) GetVariables() string
GetVariables returns the variables of the Cloney template repository as a string.
func (*CloneyMetadata) MatchUserVariables ¶
func (m *CloneyMetadata) MatchUserVariables(userVariables map[string]interface{}) (map[string]interface{}, error)
MatchUserVariables validates if a given map of variables matches the variables defined in the template repository metadata file. It also adds the default values of the variables to the user variables if they are not defined.
func (*CloneyMetadata) String ¶
func (m *CloneyMetadata) String() string
String returns the string representation of the CloneyMetadata struct.
type CloneyMetadataConfiguration ¶
type CloneyMetadataConfiguration struct {
// IgnorePaths is the list of paths to ignore when cloning the template repository.
IgnorePaths []string `yaml:"ignore_paths"`
}
CloneyMetadataConfiguration represents the configuration of a Cloney template repository.
type CloneyMetadataVariable ¶
type CloneyMetadataVariable struct {
// Name is the variable name.
Name string `yaml:"name" validate:"required"`
// Description is the variable description.
Description string `yaml:"description"`
// Default is the default value of the variable.
Default interface{} `yaml:"default"`
// Example is an example value of the variable.
Example interface{} `yaml:"example" validate:"required"`
// Validate specifies if the variable should be validated.
// It is a pointer to a bool because if the field is not defined in the YAML file,
// the default value should be true.
Validate *bool `yaml:"validate"`
}
CloneyMetadataVariable represents a variable in a Cloney template repository.