README
¶
Component Development
Overview
Components will evolve over time to incorporate more details and in different ways. However, since this is an actively used tool, it should support all valid component schemas, past and present. The way this is accomplished is by abstracting access to specific versions of components to generic interfaces located in versions/base/component.go.
Development
When creating your component struct, place the appropriate YAML tags on the fields as you would normally for the specific version. Now, whenever you unmarshal your data, it will fill all the fields you want for that version.
Now you must implement the interfaces inside your component structs.
In the case that you want to change how much access you want to give externally, you will need to edit the methods on the interfaces
.
Adding A New Version
- Create a folder
versions/X_Y_Z
where theX_Y_Z
is the version in semver notation. - Create your Component struct and any other structs that will implement the different interfaces inside here.
- Add another variable to represent your version inside of
versions/parse.go
- Add a check in the switch-case block for your new version that is represented by the variable created in step 3.
- Follow the same logic seen in the other versions inside the switch-case block.
- Add tests case fixtures with valid and invalid data for your version along with the other fixtures.
- Add those cases to the
versions/parse_test.go
Editing The Interface
- Change the interface(s) inside of interfaces.
- Change the implementations for all the component versions (located in
versions
) to accomodate the interface changes.
For details on the component scheams, consult the schemas repository
tl;dr
All component versions must implement the interface.
Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ComponentV2_0_0 is a semver representation of version 2.0.0 of component.yaml. ComponentV2_0_0 = semver.MustParse("2.0.0") // ComponentV3_0_0 is a semver representation of version 3.0.0 of component.yaml. ComponentV3_0_0 = semver.MustParse("3.0.0") // ComponentV3_1_0 is a semver representation of version 3.1.0 of component.yaml. ComponentV3_1_0 = semver.MustParse("3.1.0") )
Functions ¶
Types ¶
type Base ¶
Base is the bare minimum that every component YAML will have and is used to find the schema version. Complete implementations of component do not need to embed this struct or put it as a field in the component. When this struct is used in the ParseComponent function, it will transfer the version from this struct to the final component struct via SetVersion.
func (*Base) UnmarshalYAML ¶
UnmarshalYAML is a overridden implementation of YAML parsing the component.yaml This method is similar to the one found here: http://choly.ca/post/go-json-marshalling/ This is necessary because we want to have backwards compatibility with parsing the old types of version 2.0 (type =float). To compensate for that, we have to hand roll our own UnmarshalYAML that can decide what to do for parsing the older version of type float and converting it into semver. In addition, we will use this logic to parse strings into semver.
type BaseComponentParseError ¶
type BaseComponentParseError struct {
// contains filtered or unexported fields
}
BaseComponentParseError is the type of error that will be returned if the parsing failed for ONLY the `Base` struct.
func NewComponentParseError ¶
func NewComponentParseError(message string) BaseComponentParseError
NewComponentParseError is a constructor for creating errors of type BaseComponentParseError
func (BaseComponentParseError) Error ¶
func (b BaseComponentParseError) Error() string