app

package
v4.0.0-...-0b0cad2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsCommand

func IsCommand(err error) bool

IsCommand asserts CommandError.

func IsFetch

func IsFetch(err error) bool

IsFetch asserts fetchError.

func IsIO

func IsIO(err error) bool

IsIO asserts ioError.

func IsInvalidConfig

func IsInvalidConfig(err error) bool

IsInvalidConfig asserts invalidConfigError.

func IsInvalidType

func IsInvalidType(err error) bool

IsInvalidType asserts invalidTypeError.

func IsNoResources

func IsNoResources(err error) bool

IsNoResources asserts noResourcesError.

func IsNoSchema

func IsNoSchema(err error) bool

IsNoSchema asserts noSchemaError.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound asserts notFoundError.

func IsOther

func IsOther(err error) bool

IsOther asserts otherError.

func ValidateSchema

func ValidateSchema(valuesSchema string, yamlData map[string]interface{}) (*gojsonschema.Result, error)

Types

type CatalogFetchResult

type CatalogFetchResult struct {
	// contains filtered or unexported fields
}

type ChartVersion

type ChartVersion struct {
	Name        string            `json:"name,omitempty"`
	Version     string            `json:"version,omitempty"`
	Annotations map[string]string `json:"annotations,omitempty"`
	URLs        []string          `json:"urls"`
}

ChartVersion represents a chart entry in the IndexFile

type ChartVersions

type ChartVersions []*ChartVersion

ChartVersions is a list of versioned chart references.

type Config

type Config struct {
	Client k8sclient.Interface
	Logger micrologger.Logger
}

Config represents the values that New() needs in order to create a valid app service.

type IndexFile

type IndexFile struct {
	APIVersion string                   `yaml:"apiVersion"`
	Entries    map[string]ChartVersions `yaml:"entries"`
}

type Interface

type Interface interface {
	Validate(context.Context, ValidateOptions) (ValidationResults, error)
	ValidateApp(context.Context, *applicationv1alpha1.App, string, map[string]interface{}) (string, *gojsonschema.Result, error)
}

Interface represents the contract for the apps service. Using this instead of a regular 'struct' makes mocking the service in tests much simpler.

func New

func New(config Config) (Interface, error)

New returns an app service given a certain Config.

type SchemaFetchResult

type SchemaFetchResult struct {
	// contains filtered or unexported fields
}

type Service

type Service struct {
	Client             client.Client
	AppDataService     appdata.Interface
	CatalogDataService catalogdata.Interface
	HelmbinaryService  helmbinary.Interface
	ValuesService      *values.Values

	CatalogFetchResults map[string]CatalogFetchResult
	SchemaFetchResults  map[string]SchemaFetchResult
}

Service represents an instance of the App service.

func (*Service) Validate

func (s *Service) Validate(ctx context.Context, options ValidateOptions) (ValidationResults, error)

Validate attempts to validate the values of a deployed app (or multiple apps depending on how this command is invoked) against the schema for those values.

func (*Service) ValidateApp

func (s *Service) ValidateApp(ctx context.Context, app *applicationv1alpha1.App, customValuesSchema string, yamlData map[string]interface{}) (string, *gojsonschema.Result, error)

type ValidateOptions

type ValidateOptions struct {
	LabelSelector string
	Name          string
	Namespace     string
	ValuesSchema  string
}

type ValidationResult

type ValidationResult struct {
	App *applicationv1alpha1.App

	// The schema.values.json file, fetched from the
	// 'application.giantswarm.io/values-schema' annotation.
	// Or provided by the -f flag.
	ValuesSchema string

	// An array of validation errors that surfaced after validating the merged
	// values against the schema.values.json file. In the context of this struct,
	// this is the money maker. This is what we really care about, it holds the
	// actual validation errors (if any) that we want to show the user.
	ValidationErrors []gojsonschema.ResultError

	// Any error that occured while attempting to validate the values of this
	// app. This is not a validation error, this is any actual error occured
	// while trying to gather all the files and information required to make a
	// validation pass. An error here means we were not able to validate the app.
	Err error
}

ValidationResult contains everything we need to show information about a validation attempt.

type ValidationResults

type ValidationResults []*ValidationResult

ValidationResults contains multiple validation results. The printer takes this and makes a table out of it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL