lint

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2023 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Overview

Copyright 2022 Replicated Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2022 Replicated Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotInstaller = fmt.Errorf("object is not an installer")
)

Functions

func ValidInstallerSpecProperties added in v1.2.0

func ValidInstallerSpecProperties() []string

ValidInstallerSpecProperties returns a list of properties known by the installer spec type. Eseentially everything that is marshalable to json.

Types

type AddOn

type AddOn struct {
	Latest   string   `json:"latest"`
	Versions []string `json:"versions"`
}

AddOn holds an add-on and its respective supported versions.

type Linter

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

func New

func New(opts ...Option) *Linter

New returns a new v1beta1.Installer linter. this linter is capable of evaluating if a struct has all its fields properly set, rules in the "rego/" directory are used.

func (*Linter) Validate

func (l *Linter) Validate(ctx context.Context, inst v1beta1.Installer) ([]Output, error)

Validate applies the lint rules on top of the provided Installer object.

func (*Linter) ValidateMarshaledYAML added in v1.0.2

func (l *Linter) ValidateMarshaledYAML(ctx context.Context, data string) ([]Output, error)

ValidateMarshaledYAML verifies if the provided data blob is an installer and applies the lint rules. If you have an already unmarshaled Installer instruct use Validate() instead.

func (*Linter) Versions

func (l *Linter) Versions(ctx context.Context, inst v1beta1.Installer) (map[string]AddOn, error)

Versions return a map containing all supported versions indexed by add-on name. it goes and fetch the versions from a remote endpoint.

type Option

type Option func(*Linter)

Option is a function that sets an option in Linter object.

func WithAPIBaseURL

func WithAPIBaseURL(u *url.URL) Option

WithAPIBaseURL sets a different api base url from where the linter attempts to load known versions for all addons. The default is "https://kurl.sh".

func WithDebug added in v1.0.7

func WithDebug() Option

WithDebug enables debug logging for the linter. debug logs are written to stdout.

func WithInfoSeverity added in v1.2.0

func WithInfoSeverity() Option

WithInfoSeverity enables info severity in the linter. By default this is disabled.

type Output

type Output struct {
	Type     string          `json:"type"`
	Message  string          `json:"message"`
	Severity Severity        `json:"severity"`
	Patch    jsonpatch.Patch `json:"patch,omitempty"`
}

Output holds the outcome of a lint pass on top of a Installer struct.

func (*Output) UnmarshalYAML added in v1.2.0

func (o *Output) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is a helper function that unmarshals a yaml blob into an Output struct. As the Output struct contains a jsonpatch.Patch field and that field contains a property of type json.RawMessage, the default yaml unmarshaller is not able to do the job.

type Severity added in v1.2.0

type Severity string
const (
	SeverityError   Severity = "error"
	SeverityWarning Severity = "warning"
	SeverityInfo    Severity = "info"
)

Jump to

Keyboard shortcuts

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