Add validation phases
This patch introduces ability to validate phases using kubeval. Appropriate functionality was embedded into phase/plan validate command. Change-Id: I1e1ccae2b7e4948bdc97a199c96c07a3eb7292b2 Signed-off-by: Ruslan Aliev <raliev@mirantis.com> Relates-To: #503 Closes: #2 Closes: #19
This commit is contained in:
@@ -59,10 +59,31 @@ type Bundle interface {
|
||||
Append(Document) error
|
||||
}
|
||||
|
||||
// DocFactoryFunc is a type of function which returns (Document, error) and can be used on demand
|
||||
type DocFactoryFunc func() (Document, error)
|
||||
|
||||
// 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
|
||||
type BundleFactoryFunc func() (Bundle, error)
|
||||
|
||||
// BundleFactoryFromBytes is a function which returns BundleFactoryFunc based on new bundle from bytes
|
||||
func BundleFactoryFromBytes(data []byte) BundleFactoryFunc {
|
||||
return func() (Bundle, error) {
|
||||
return NewBundleFromBytes(data)
|
||||
}
|
||||
}
|
||||
|
||||
// BundleFactoryFromDocRoot is a function which returns BundleFactoryFunc based on new bundle from DocumentRoot path
|
||||
func BundleFactoryFromDocRoot(docRootFunc func() (string, error)) BundleFactoryFunc {
|
||||
return func() (Bundle, error) {
|
||||
path, err := docRootFunc()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return NewBundleByPath(path)
|
||||
}
|
||||
}
|
||||
|
||||
// NewBundleByPath is a function which builds new document.Bundle from kustomize rootPath using default FS object
|
||||
// example: document.NewBundleByPath("path/to/phase-root")
|
||||
func NewBundleByPath(rootPath string) (Bundle, error) {
|
||||
|
||||
@@ -36,6 +36,15 @@ const (
|
||||
ClusterctlMetadataKind = "Metadata"
|
||||
ClusterctlMetadataVersion = "v1alpha3"
|
||||
ClusterctlMetadataGroup = "clusterctl.cluster.x-k8s.io"
|
||||
|
||||
// DocumentValidationGroup defines Group for document-validation container
|
||||
DocumentValidationGroup = "airshipit.org"
|
||||
// DocumentValidationVersion defines Version for document-validation container
|
||||
DocumentValidationVersion = "v1alpha1"
|
||||
// DocumentValidationKind defines Kind for document-validation container
|
||||
DocumentValidationKind = "GenericContainer"
|
||||
// DocumentValidationName defines Name for document-validation container
|
||||
DocumentValidationName = "document-validation"
|
||||
)
|
||||
|
||||
// KustomizationFile is used for kustomization file
|
||||
|
||||
@@ -190,6 +190,14 @@ func NewClusterctlMetadataSelector() Selector {
|
||||
ClusterctlMetadataKind)
|
||||
}
|
||||
|
||||
// NewValidatorExecutorSelector returns selector to get validator executor documents
|
||||
func NewValidatorExecutorSelector() Selector {
|
||||
return NewSelector().ByGvk(DocumentValidationGroup,
|
||||
DocumentValidationVersion,
|
||||
DocumentValidationKind).
|
||||
ByName(DocumentValidationName)
|
||||
}
|
||||
|
||||
//GetSecretData returns data located with a given key of a given document
|
||||
func GetSecretData(docBundle Bundle, apiSelector types.Selector, key string) ([]byte, error) {
|
||||
s := NewSelector()
|
||||
|
||||
Reference in New Issue
Block a user