Documentation
¶
Index ¶
- Variables
- func AddKubeaddFlags(cmd *cobra.Command, config *Config) *cobra.Command
- func Contains(key string, patterns []string) bool
- func NewKubeCheckerImpl() *kubeCheckerImpl
- func RegexMatch(s string, pattern string) bool
- func RegisterArrayUniqueItemsChecker(fn SliceUniqueItemsChecker)
- func VisitJSON(schema *openapi3.Schema, value interface{}, settings SchemaSettings) openapi3.MultiError
- type Cluster
- type Config
- type GroupVersions
- type KindInfo
- type KubeChecker
- type OutputManager
- type STDOutputManager
- func (s *STDOutputManager) DeprecationTableBodyOutput(results []ValidationResult, currentVersion bool)
- func (s *STDOutputManager) Flush() error
- func (s *STDOutputManager) Put(result ValidationResult) error
- func (s *STDOutputManager) PutBulk(results []ValidationResult) error
- func (s *STDOutputManager) SummaryTableBodyOutput(results []ValidationResult)
- func (s *STDOutputManager) ValidationErrorTableBodyOutput(results []ValidationResult, currentVersion bool)
- type SchemaError
- type SchemaSettings
- type SliceUniqueItemsChecker
- type ValidFormat
- type ValidationResult
Constants ¶
This section is empty.
Variables ¶
var SchemaErrorDetailsDisabled = true
Functions ¶
func AddKubeaddFlags ¶
AddKubeaddFlags adds the default flags for kubedd to cmd
func NewKubeCheckerImpl ¶
func NewKubeCheckerImpl() *kubeCheckerImpl
func RegexMatch ¶
func RegisterArrayUniqueItemsChecker ¶
func RegisterArrayUniqueItemsChecker(fn SliceUniqueItemsChecker)
RegisterArrayUniqueItemsChecker is used to register a customized function used to check if JSON array have unique items.
func VisitJSON ¶
func VisitJSON(schema *openapi3.Schema, value interface{}, settings SchemaSettings) openapi3.MultiError
Types ¶
type Cluster ¶
func NewCluster ¶
func (*Cluster) FetchK8sObjects ¶
func (c *Cluster) FetchK8sObjects(gvks []schema.GroupVersionKind, conf *Config) []unstructured.Unstructured
func (*Cluster) ServerVersion ¶
type Config ¶
type Config struct {
// DefaultNamespace is the namespace to assume in resources
// if no namespace is set in `metadata:namespace` (as used with
// `kubectl apply --namespace ...` or `helm install --namespace ...`,
// for example)
DefaultNamespace string
// TargetKubernetesVersion represents the version of Kubernetes
// to which we want to migrate
TargetKubernetesVersion string
// SourceKubernetesVersion represents the version of Kubernetes
// on which kubernetes objects are running currently
SourceKubernetesVersion string
// TargetSchemaLocation is the base URL of target kubernetes version.
// It can be either a remote location or a local directory
TargetSchemaLocation string
// SourceSchemaLocation is the base URL of source kubernetes versions.
// It can be either a remote location or a local directory
SourceSchemaLocation string
// AdditionalSchemaLocations is a list of alternative base URLs from
// which to search for schemas, given that the desired schema was not
// found at TargetSchemaLocation
AdditionalSchemaLocations []string
// Strict tells kubedd whether to prohibit properties not in
// the schema. The API allows them, but kubectl does not
Strict bool
// IgnoreMissingSchemas tells kubedd whether to skip validation
// for resource definitions without an available schema
IgnoreMissingSchemas bool
// ExitOnError tells kubedd whether to halt processing upon the
// first error encountered or to continue, aggregating all errors
ExitOnError bool
// FileName is the name to be displayed when testing manifests read from stdin
FileName string
// OutputFormat is the name of the output formatter which will be used when
// reporting results to the user.
OutputFormat string
// Quiet indicates whether non-results output should be emitted to the applications
// log.
Quiet bool
// InsecureSkipTLSVerify controls whether to skip TLS certificate validation
// when retrieving schema content over HTTPS
InsecureSkipTLSVerify bool
// IgnoreKeysFromDeprecation is the list of keys to be skipped for depreciation check
IgnoreKeysFromDeprecation []string
// IgnoreKeysFromValidation is the list of keys to be skipped for validation check
IgnoreKeysFromValidation []string
// SelectNamespaces is the list of namespaces to be validated, by default all namespaces are validated
SelectNamespaces []string
// IgnoreNamespaces is the list of namespaces to be skipped for validation, by default none are skipped
IgnoreNamespaces []string
// SelectKinds is the list of kinds to be validated, by default all kinds are validated
SelectKinds []string
// IgnoreKinds is the list of kinds to be skipped for validation, by default none are skipped
IgnoreKinds []string
// IgnoreNullErrors is the flag to ignore null value errors
IgnoreNullErrors bool
}
A Config object contains various configuration data for kubedd
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
NewDefaultConfig creates a Config with default values
type GroupVersions ¶
type KubeChecker ¶
type KubeChecker interface {
IsVersionSupported(releaseVersion, apiVersion, kind string) bool
LoadFromUrl(releaseVersion string, force bool) error
LoadFromPath(releaseVersion string, filePath string, force bool) error
ValidateJson(spec string, releaseVersion string) (ValidationResult, error)
ValidateYaml(spec string, releaseVersion string) (ValidationResult, error)
ValidateObject(spec map[string]interface{}, releaseVersion string) (ValidationResult, error)
GetKinds(releaseVersion string) ([]schema.GroupVersionKind, error)
}
type OutputManager ¶
type OutputManager interface {
PutBulk(r []ValidationResult) error
Put(r ValidationResult) error
Flush() error
}
OutputManager controls how results of the `kubedd` evaluation will be recorded and reported to the end user. This interface is kept private to ensure all implementations are closed within this package.
func GetOutputManager ¶
func GetOutputManager(outFmt string) OutputManager
type STDOutputManager ¶
type STDOutputManager struct {
}
STDOutputManager reports `kubedd` results to stdout.
func (*STDOutputManager) DeprecationTableBodyOutput ¶
func (s *STDOutputManager) DeprecationTableBodyOutput(results []ValidationResult, currentVersion bool)
func (*STDOutputManager) Flush ¶
func (s *STDOutputManager) Flush() error
func (*STDOutputManager) Put ¶
func (s *STDOutputManager) Put(result ValidationResult) error
func (*STDOutputManager) PutBulk ¶
func (s *STDOutputManager) PutBulk(results []ValidationResult) error
func (*STDOutputManager) SummaryTableBodyOutput ¶
func (s *STDOutputManager) SummaryTableBodyOutput(results []ValidationResult)
func (*STDOutputManager) ValidationErrorTableBodyOutput ¶
func (s *STDOutputManager) ValidationErrorTableBodyOutput(results []ValidationResult, currentVersion bool)
type SchemaError ¶
type SchemaError struct {
Value interface{}
Schema *openapi3.Schema
SchemaField string
Reason string
Origin error
// contains filtered or unexported fields
}
func (*SchemaError) Error ¶
func (err *SchemaError) Error() string
func (*SchemaError) JSONPointer ¶
func (err *SchemaError) JSONPointer() []string
type SchemaSettings ¶
type SchemaSettings struct {
MultiError bool
}
type SliceUniqueItemsChecker ¶
type SliceUniqueItemsChecker func(items []interface{}) bool
SliceUniqueItemsChecker is an function used to check if an given slice have unique items.
type ValidFormat ¶
type ValidFormat struct{}
ValidFormat is a type for quickly forcing new formats on the gojsonschema loader
func (ValidFormat) IsFormat ¶
func (f ValidFormat) IsFormat(input interface{}) bool
IsFormat always returns true and meets the gojsonschema.FormatChecker interface
type ValidationResult ¶
type ValidationResult struct {
FileName string
Kind string
APIVersion string
ValidatedAgainstSchema bool
Errors []gojsonschema.ResultError
ErrorsForOriginal []*openapi3.SchemaError
ErrorsForLatest []*openapi3.SchemaError
DeprecationForOriginal []*SchemaError
DeprecationForLatest []*SchemaError
ResourceName string
ResourceNamespace string
Deleted bool
Deprecated bool
LatestAPIVersion string
IsVersionSupported int
}
ValidationResult contains the details from validating a given Kubernetes resource
func (*ValidationResult) QualifiedName ¶
func (v *ValidationResult) QualifiedName() string
QualifiedName returns a string of the [namespace.]name of the k8s resource
func (*ValidationResult) VersionKind ¶
func (v *ValidationResult) VersionKind() string
VersionKind returns a string representation of this result's apiVersion and kind