Documentation ¶
Index ¶
- Constants
- func GetBMHBMCAddress(bmh Document) (string, error)
- func GetBMHBMCCredentials(bmh Document, bundle Bundle) (username string, password string, err error)
- func GetBMHNetworkData(bmh Document, bundle Bundle) (string, error)
- func GetSecretDataKey(cfg Document, key string) (string, error)
- func MakeResMap(fs fs.FileSystem, kfile string) (map[string][]string, error)
- type Bundle
- type BundleFactory
- func (b *BundleFactory) Append(doc Document) error
- func (b *BundleFactory) GetAllDocuments() ([]Document, error)
- func (b *BundleFactory) GetByAnnotation(annotationSelector string) ([]Document, error)
- func (b *BundleFactory) GetByGvk(group, version, kind string) ([]Document, error)
- func (b *BundleFactory) GetByLabel(labelSelector string) ([]Document, error)
- func (b *BundleFactory) GetByName(name string) (Document, error)
- func (b *BundleFactory) GetFileSystem() fs.FileSystem
- func (b *BundleFactory) GetKustomizeBuildOptions() KustomizeBuildOptions
- func (b *BundleFactory) GetKustomizeResourceMap() resmap.ResMap
- func (b *BundleFactory) Select(selector Selector) ([]Document, error)
- func (b *BundleFactory) SelectBundle(selector Selector) (Bundle, error)
- func (b *BundleFactory) SelectByFieldValue(path string, condition func(interface{}) bool) (Bundle, error)
- func (b *BundleFactory) SelectOne(selector Selector) (Document, error)
- func (b *BundleFactory) SetFileSystem(fSys fs.FileSystem) error
- func (b *BundleFactory) SetKustomizeBuildOptions(k KustomizeBuildOptions) error
- func (b *BundleFactory) SetKustomizeResourceMap(r resmap.ResMap) error
- func (b *BundleFactory) Write(out io.Writer) error
- type BundleFactoryFunc
- type DocFactoryFunc
- type Document
- type ErrBadValueFormat
- type ErrDocNotFound
- type ErrDocumentDataKeyNotFound
- type ErrDocumentMalformed
- type ErrMultiDocsFound
- type ErrRuntimeObjectKind
- type Factory
- func (d *Factory) Annotate(newAnnotations map[string]string)
- func (d *Factory) AsYAML() ([]byte, error)
- func (d *Factory) GetBool(path string) (bool, error)
- func (d *Factory) GetFieldValue(path string) (interface{}, error)
- func (d *Factory) GetFloat64(path string) (float64, error)
- func (d *Factory) GetGroup() string
- func (d *Factory) GetInt64(path string) (int64, error)
- func (d *Factory) GetKind() string
- func (d *Factory) GetKustomizeResource() resource.Resource
- func (d *Factory) GetMap(path string) (map[string]interface{}, error)
- func (d *Factory) GetName() string
- func (d *Factory) GetNamespace() string
- func (d *Factory) GetSlice(path string) ([]interface{}, error)
- func (d *Factory) GetString(path string) (string, error)
- func (d *Factory) GetStringMap(path string) (map[string]string, error)
- func (d *Factory) GetStringSlice(path string) ([]string, error)
- func (d *Factory) GetVersion() string
- func (d *Factory) Label(newLabels map[string]string)
- func (d *Factory) MarshalJSON() ([]byte, error)
- func (d *Factory) SetKustomizeResource(r *resource.Resource) error
- func (d *Factory) ToAPIObject(obj runtime.Object, scheme *runtime.Scheme) error
- func (d *Factory) ToObject(obj interface{}) error
- type KustomNode
- type KustomizeBuildOptions
- type Selector
- func NewApplierContainerExecutorSelector() Selector
- func NewBMCCredentialsSelector(name string) Selector
- func NewCRDSelector() Selector
- func NewClusterctlContainerExecutorSelector() Selector
- func NewClusterctlMetadataSelector() Selector
- func NewDeployToK8sSelector() Selector
- func NewEphemeralBMHSelector() Selector
- func NewEphemeralCloudDataSelector() Selector
- func NewNetworkDataSelector(bmhDoc Document) (Selector, error)
- func NewSelector() Selector
- func NewSelectorFromV1Alpha1(selector v1alpha1.Selector) Selector
- func NewValidatorExecutorSelector() Selector
- func (s Selector) ByAnnotation(annotationSelector string) Selector
- func (s Selector) ByGvk(group, version, kind string) Selector
- func (s Selector) ByKind(kind string) Selector
- func (s Selector) ByLabel(labelSelector string) Selector
- func (s Selector) ByName(name string) Selector
- func (s Selector) ByNamespace(namespace string) Selector
- func (s Selector) ByObject(obj runtime.Object, scheme *runtime.Scheme) (Selector, error)
- func (s Selector) ByObjectReference(objRef *corev1.ObjectReference) Selector
- func (s Selector) String() string
Constants ¶
const ( BaseAirshipSelector = "airshipit.org" EphemeralHostSelector = BaseAirshipSelector + "/ephemeral-node in (True, true)" EphemeralUserDataSelector = BaseAirshipSelector + "/ephemeral-user-data in (True, true)" // Please note that by default every document in the manifest is to be deployed to kubernetes cluster. // so this selector simply checks that deploy-k8s label is not equal to false or False (string) DeployToK8sSelector = "airshipit.org/deploy-k8s notin (False, false)" )
Label Selectors
const ( SecretKind = "Secret" BareMetalHostKind = "BareMetalHost" ConfigMapKind = "ConfigMap" ConfigMapVersion = "v1" ClusterctlMetadataKind = "Metadata" ClusterctlMetadataVersion = "v1alpha3" ClusterctlMetadataGroup = "clusterctl.cluster.x-k8s.io" // ValidatorGroup defines Group for document-validation container ValidatorGroup = "airshipit.org" // ValidatorVersion defines Version for document-validation container ValidatorVersion = "v1alpha1" // ValidatorKind defines Kind for document-validation container ValidatorKind = "GenericContainer" // ValidatorName defines Name for document-validation container ValidatorName = "document-validation" // CRDKind is a kind for custom resource definition documents CRDKind = "CustomResourceDefinition" // ClusterctlContainerGroup defines Group for clustertctl container ClusterctlContainerGroup = "airshipit.org" // ClusterctlContainerVersion defines Version for clustertctl container ClusterctlContainerVersion = "v1alpha1" // ClusterctlContainerKind defines Kind for clustertctl container ClusterctlContainerKind = "GenericContainer" // ClusterctlContainerName defines Name for clustertctl container ClusterctlContainerName = "clusterctl" // ApplierContainerGroup defines Group for applier container ApplierContainerGroup = "airshipit.org" // ApplierContainerVersion defines Version for applier container ApplierContainerVersion = "v1alpha1" // ApplierContainerKind defines Kind for applier container ApplierContainerKind = "GenericContainer" // ApplierContainerName defines Name for applier container ApplierContainerName = "applier" )
GVKs
const KustomizationFile = "kustomization.yaml"
KustomizationFile is used for kustomization file
Variables ¶
This section is empty.
Functions ¶
func GetBMHBMCAddress ¶
GetBMHBMCAddress returns the bmc address for a particular the document supplied
func GetBMHBMCCredentials ¶
func GetBMHBMCCredentials(bmh Document, bundle Bundle) (username string, password string, err error)
GetBMHBMCCredentials returns the BMC credentials for the bmh document supplied from the supplied bundle
func GetBMHNetworkData ¶
GetBMHNetworkData retrieves the associated network data string for the bmh document supplied from the bundle supplied
func GetSecretDataKey ¶
GetSecretDataKey understands how to retrieve a specific top level key from a secret that may have the data stored under a data or stringData field in which case the key may be base64 encoded or it may be plain text
it is meant to be used by other high level dochelpers
func MakeResMap ¶
MakeResMap creates resmap based of kustomize types
Types ¶
type Bundle ¶
type Bundle interface { Write(out io.Writer) error SetFileSystem(fs.FileSystem) error GetFileSystem() fs.FileSystem Select(selector Selector) ([]Document, error) SelectOne(selector Selector) (Document, error) SelectBundle(selector Selector) (Bundle, error) SelectByFieldValue(string, func(interface{}) bool) (Bundle, error) GetByGvk(string, string, string) ([]Document, error) GetByName(string) (Document, error) GetByAnnotation(annotationSelector string) ([]Document, error) GetByLabel(labelSelector string) ([]Document, error) GetAllDocuments() ([]Document, error) Append(Document) error }
Bundle interface provides the specification for a bundle implementation
func NewBundle ¶
func NewBundle(fSys fs.FileSystem, kustomizePath string) (Bundle, error)
NewBundle is a convenience function to create a new bundle Over time, it will evolve to support allowing more control for kustomize plugins
func NewBundleByPath ¶
NewBundleByPath is a function which builds new document.Bundle from kustomize rootPath using default FS object example: document.NewBundleByPath("path/to/phase-root")
func NewBundleFromBytes ¶
NewBundleFromBytes is a function which builds new document.Bundle from raw []bytes
type BundleFactory ¶
type BundleFactory struct { KustomizeBuildOptions resmap.ResMap fs.FileSystem }
BundleFactory contains the objects within a bundle
func (*BundleFactory) Append ¶
func (b *BundleFactory) Append(doc Document) error
Append bundle with the document, this only works with document interface implementation that is provided by this package
func (*BundleFactory) GetAllDocuments ¶
func (b *BundleFactory) GetAllDocuments() ([]Document, error)
GetAllDocuments returns all documents in this bundle
func (*BundleFactory) GetByAnnotation ¶
func (b *BundleFactory) GetByAnnotation(annotationSelector string) ([]Document, error)
GetByAnnotation is a convenience method to get documents for a particular annotation
func (*BundleFactory) GetByGvk ¶
func (b *BundleFactory) GetByGvk(group, version, kind string) ([]Document, error)
GetByGvk is a convenience method to get documents for a particular Gvk tuple
func (*BundleFactory) GetByLabel ¶
func (b *BundleFactory) GetByLabel(labelSelector string) ([]Document, error)
GetByLabel is a convenience method to get documents for a particular label
func (*BundleFactory) GetByName ¶
func (b *BundleFactory) GetByName(name string) (Document, error)
GetByName finds a document by name
func (*BundleFactory) GetFileSystem ¶
func (b *BundleFactory) GetFileSystem() fs.FileSystem
GetFileSystem gets the filesystem that will be used by this bundle
func (*BundleFactory) GetKustomizeBuildOptions ¶
func (b *BundleFactory) GetKustomizeBuildOptions() KustomizeBuildOptions
GetKustomizeBuildOptions returns the build options object used to generate the resource map for this bundle
func (*BundleFactory) GetKustomizeResourceMap ¶
func (b *BundleFactory) GetKustomizeResourceMap() resmap.ResMap
GetKustomizeResourceMap returns a Kustomize Resource Map for this bundle
func (*BundleFactory) Select ¶
func (b *BundleFactory) Select(selector Selector) ([]Document, error)
Select offers an interface to pass a Selector, built on top of kustomize Selector to the bundle returning Documents that match the criteria
func (*BundleFactory) SelectBundle ¶
func (b *BundleFactory) SelectBundle(selector Selector) (Bundle, error)
SelectBundle offers an interface to pass a Selector, built on top of kustomize Selector to the bundle returning a new Bundle that matches the criteria. This is useful where you want to actually prune the underlying bundle you are working with rather then getting back the matching documents for scenarios like test cases where you want to pass in custom "filtered" bundles specific to the test case
func (*BundleFactory) SelectByFieldValue ¶
func (b *BundleFactory) SelectByFieldValue(path string, condition func(interface{}) bool) (Bundle, error)
SelectByFieldValue returns new Bundle with filtered resource documents. Method iterates over all resources in the bundle. If resource has field (i.e. key) specified in JSON path, and the comparison function returns 'true' for value referenced by JSON path, then resource is added to resulting bundle. Example: The bundle contains 3 documents
--- apiVersion: v1 kind: DocKind1 metadata: name: doc1 spec: somekey: somefield: "someValue" --- apiVersion: v1 kind: DocKind2 metadata: name: doc2 spec: somekey: somefield: "someValue" --- apiVersion: v1 kind: DocKind1 metadata: name: doc3 spec: somekey: somefield: "someOtherValue"
Execution of bundleInstance.SelectByFieldValue(
"spec.somekey.somefield", func(v interface{}) { return v == "someValue" })
will return a new Bundle instance containing 2 documents:
--- apiVersion: v1 kind: DocKind1 metadata: name: doc1 spec: somekey: somefield: "someValue" --- apiVersion: v1 kind: DocKind2 metadata: name: doc2 spec: somekey: somefield: "someValue"
func (*BundleFactory) SelectOne ¶
func (b *BundleFactory) SelectOne(selector Selector) (Document, error)
SelectOne serves the common use case where you expect one match and only one match to your selector -- in other words, you want to error if you didn't find any documents, and error if you found more than one. This reduces code repetition that would otherwise be scattered around that evaluates the length of the doc set returned for this common case
func (*BundleFactory) SetFileSystem ¶
func (b *BundleFactory) SetFileSystem(fSys fs.FileSystem) error
SetFileSystem sets the filesystem that will be used by this bundle
func (*BundleFactory) SetKustomizeBuildOptions ¶
func (b *BundleFactory) SetKustomizeBuildOptions(k KustomizeBuildOptions) error
SetKustomizeBuildOptions sets the build options to be used for this bundle. In the future, it may perform some basic validations.
func (*BundleFactory) SetKustomizeResourceMap ¶
func (b *BundleFactory) SetKustomizeResourceMap(r resmap.ResMap) error
SetKustomizeResourceMap allows us to set the populated resource map for this bundle. In the future, it may modify it before saving it.
type BundleFactoryFunc ¶
BundleFactoryFunc is a function that returns bundle, can be used to build bundle on demand instead of inplace, useful, when you don't know if bundle will be needed or not, see phase for detail
func BundleFactoryFromBytes ¶
func BundleFactoryFromBytes(data []byte) BundleFactoryFunc
BundleFactoryFromBytes is a function which returns BundleFactoryFunc based on new bundle from bytes
func BundleFactoryFromDocRoot ¶
func BundleFactoryFromDocRoot(docRootFunc func() (string, error)) BundleFactoryFunc
BundleFactoryFromDocRoot is a function which returns BundleFactoryFunc based on new bundle from DocumentRoot path
type DocFactoryFunc ¶
DocFactoryFunc is a type of function which returns (Document, error) and can be used on demand
type Document ¶
type Document interface { Annotate(map[string]string) AsYAML() ([]byte, error) GetAnnotations() map[string]string GetBool(path string) (bool, error) GetFloat64(path string) (float64, error) GetFieldValue(path string) (interface{}, error) GetGroup() string GetInt64(path string) (int64, error) GetKind() string GetLabels() map[string]string GetMap(path string) (map[string]interface{}, error) GetName() string GetNamespace() string GetSlice(path string) ([]interface{}, error) GetString(path string) (string, error) GetStringMap(path string) (map[string]string, error) GetStringSlice(path string) ([]string, error) GetVersion() string Label(map[string]string) MarshalJSON() ([]byte, error) ToObject(interface{}) error ToAPIObject(runtime.Object, *runtime.Scheme) error }
Document interface
func NewDocument ¶
NewDocument is a convenience method to construct a new Document. Although an error is unlikely at this time, this provides some future proofing for when we want more strict airship specific validation of documents getting created as this would be the front door for all Kustomize->Airship documents - e.g. in the future all documents require an airship annotation X
func NewDocumentFromBytes ¶
NewDocumentFromBytes constructs document from bytes
type ErrBadValueFormat ¶
ErrBadValueFormat returned if wrong field type requested
func (ErrBadValueFormat) Error ¶
func (e ErrBadValueFormat) Error() string
type ErrDocNotFound ¶
type ErrDocNotFound struct {
Selector Selector
}
ErrDocNotFound returned if desired document not found by selector
func (ErrDocNotFound) Error ¶
func (e ErrDocNotFound) Error() string
type ErrDocumentDataKeyNotFound ¶
ErrDocumentDataKeyNotFound returned if desired key within a document not found
func (ErrDocumentDataKeyNotFound) Error ¶
func (e ErrDocumentDataKeyNotFound) Error() string
type ErrDocumentMalformed ¶
ErrDocumentMalformed returned if the document is structurally malformed (e.g. missing required low level keys)
func (ErrDocumentMalformed) Error ¶
func (e ErrDocumentMalformed) Error() string
type ErrMultiDocsFound ¶
type ErrMultiDocsFound struct {
Selector Selector
}
ErrMultiDocsFound returned if multiple documents were found by selector
func (ErrMultiDocsFound) Error ¶
func (e ErrMultiDocsFound) Error() string
type ErrRuntimeObjectKind ¶
ErrRuntimeObjectKind returned if runtime object contains either none or more than one Kinds defined in schema
func (ErrRuntimeObjectKind) Error ¶
func (e ErrRuntimeObjectKind) Error() string
type Factory ¶
Factory holds document data
func (*Factory) GetFieldValue ¶
GetFieldValue get object at path
func (*Factory) GetFloat64 ¶
GetFloat64 returns a float64 at path.
func (*Factory) GetKustomizeResource ¶
GetKustomizeResource returns a Kustomize Resource object for this document.
func (*Factory) GetNamespace ¶
GetNamespace returns the namespace the resource thinks it's in.
func (*Factory) GetStringMap ¶
GetStringMap returns a string map at path.
func (*Factory) GetStringSlice ¶
GetStringSlice returns a string slice at path.
func (*Factory) GetVersion ¶
GetVersion returns api version from apiVersion field
func (*Factory) MarshalJSON ¶
MarshalJSON returns the document as JSON.
func (*Factory) SetKustomizeResource ¶
SetKustomizeResource sets a Kustomize Resource object for this document.
func (*Factory) ToAPIObject ¶
ToAPIObject de-serializes a document into a runtime.Object
type KustomNode ¶
type KustomNode struct { Name string // name used for display purposes (cli) Data string // this could be a Kustomization object, or a string containing a file path Children []KustomNode Writer io.Writer }
KustomNode is used to create name and data to display tree structure
func BuildKustomTree ¶
BuildKustomTree creates a tree based on entrypoint
func GetKustomChildren ¶
func GetKustomChildren(k KustomNode) []KustomNode
GetKustomChildren returns children nodes of kustomnode
func (KustomNode) PrintTree ¶
func (k KustomNode) PrintTree(prefix string)
PrintTree prints tree view of phase
type KustomizeBuildOptions ¶
type KustomizeBuildOptions struct { KustomizationPath string LoadRestrictions types.LoadRestrictions }
KustomizeBuildOptions contain the options for running a Kustomize build on a bundle
type Selector ¶
Selector provides abstraction layer in front of kustomize selector
func NewApplierContainerExecutorSelector ¶
func NewApplierContainerExecutorSelector() Selector
NewApplierContainerExecutorSelector returns selector to get executor documents for applier container
func NewBMCCredentialsSelector ¶
NewBMCCredentialsSelector returns selector to get BaremetalHost BMC credentials
func NewCRDSelector ¶
func NewCRDSelector() Selector
NewCRDSelector returns selector to get custom resource definition documents
func NewClusterctlContainerExecutorSelector ¶
func NewClusterctlContainerExecutorSelector() Selector
NewClusterctlContainerExecutorSelector returns selector to get executor documents for clusterctl container
func NewClusterctlMetadataSelector ¶
func NewClusterctlMetadataSelector() Selector
NewClusterctlMetadataSelector returns selector to get clusterctl metadata documents
func NewDeployToK8sSelector ¶
func NewDeployToK8sSelector() Selector
NewDeployToK8sSelector returns a selector to get documents that are to be deployed to kubernetes cluster.
func NewEphemeralBMHSelector ¶
func NewEphemeralBMHSelector() Selector
NewEphemeralBMHSelector returns selector to get BaremetalHost for ephemeral node
func NewEphemeralCloudDataSelector ¶
func NewEphemeralCloudDataSelector() Selector
NewEphemeralCloudDataSelector returns selector to get BaremetalHost for ephemeral node
func NewNetworkDataSelector ¶
NewNetworkDataSelector returns selector that can be used to get secret with network data bmhDoc argument is a document interface, that should hold fields spec.networkData.name and spec.networkData.namespace where to find the secret, if either of these fields are not defined in Document error will be returned
func NewSelectorFromV1Alpha1 ¶
NewSelectorFromV1Alpha1 generates selector object from v1alpha1 analog
func NewValidatorExecutorSelector ¶
func NewValidatorExecutorSelector() Selector
NewValidatorExecutorSelector returns selector to get validator executor documents
func (Selector) ByAnnotation ¶
ByAnnotation select by annotation selector.
func (Selector) ByNamespace ¶
ByNamespace select by namespace
func (Selector) ByObjectReference ¶
func (s Selector) ByObjectReference(objRef *corev1.ObjectReference) Selector
ByObjectReference select by ObjectReference