Documentation
¶
Overview ¶
Package configschema implements a way to specify configuration attributes for Juju configuration.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SampleYAML ¶
SampleYAML writes YAML output to w, indented by indent spaces that holds the attributes in attrs with descriptions found in the given fields. An entry for any attribute in fields not in attrs will be generated but commented out.
Types ¶
type Attr ¶
type Attr struct { // Description holds a human-readable description // of the attribute. Description string `json:"description"` // Type holds the type of the attribute value. Type FieldType `json:"type"` // Group holds the group that the attribute belongs to. // All attributes within a Fields that have the same Group // attribute are considered to be part of the same group. Group Group `json:"group"` // Immutable specifies whether the attribute cannot // be changed once set. Immutable bool // Mandatory specifies whether the attribute // must be provided. Mandatory bool `json:"mandatory,omitempty"` // Secret specifies whether the attribute should be // considered secret. Secret bool `json:"is-secret,omitempty"` // EnvVar holds the environment variable // that will be used to obtain the default value // if it isn't specified. EnvVar string `json:"env-var,omitempty"` // EnvVars holds additional environment // variables to be used if the value in EnvVar is // not available, from highest to lowest priority. EnvVars []string `json:"env-vars,omitempty"` // Example holds an example value for the attribute // that can be used to produce a plausible-looking // entry for the attribute without necessarily using // it as a default value. // // TODO if the example holds some special values, use // it as a template to generate initial random values // (for example for admin-password) ? Example interface{} `json:"example,omitempty"` // Values holds the set of all possible values of the attribute. Values []interface{} `json:"values,omitempty"` // Documentation holds the longform documentation for this option. // This may include markdown. Documentation string }
type FieldType ¶
type FieldType string
FieldType describes the type of an attribute value.
const ( // Tstring represents a string type. Its canonical Go type is string. Tstring FieldType = "string" // Tbool represents a boolean type. Its canonical Go type is bool. Tbool FieldType = "bool" // Tint represents an integer type. Its canonical Go type is int. Tint FieldType = "int" // Tattrs represents an attribute map. Its canonical Go type is // map[string]string. Tattrs FieldType = "attrs" // Tlist represents an list of strings. Its canonical Go type is []string Tlist FieldType = "list" )
The following constants are the possible type values. The "canonical Go type" is the type that the will be the result of a successful Coerce call.
type Fields ¶
Fields holds a map from attribute name to information about that attribute.
func (Fields) ExampleYAML ¶
ExampleYAML returns the fields formatted as a YAML example, with non-mandatory fields commented out, like the providers do currently.
func (Fields) ValidationSchema ¶
ValidationSchema returns values suitable for passing to schema.FieldMap to create a schema.Checker that will validate the given fields. It will return an error if the fields are invalid.
The Defaults return value will contain entries for all non-mandatory attributes set to schema.Omit. It is the responsibility of the client to set any actual default values as required.
type Group ¶
type Group string
Group describes the grouping of attributes.
const ( // JujuGroup groups attributes defined by Juju that may // not be specified by a user. JujuGroup Group = "juju" // EnvironGroup groups attributes that are defined across all // possible Juju environments. EnvironGroup Group = "environ" // AccountGroup groups attributes that define a user account // used by a provider. AccountGroup Group = "account" // ProviderGroup groups attributes defined by the provider // that are not account credentials. This is also the default // group. ProviderGroup Group = "" )
The following constants are the initially defined group values.