manifest

package
v0.63.2 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: MPL-2.0 Imports: 4 Imported by: 1

Documentation

Overview

Package manifest defines the basic primitives for Nobl9 objects schema.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidKind = fmt.Errorf("not a valid Kind, try [%s]", strings.Join(_KindNames, ", "))
View Source
var ErrInvalidObjectFormat = fmt.Errorf("not a valid ObjectFormat, try [%s]", strings.Join(_ObjectFormatNames, ", "))
View Source
var ErrInvalidVersion = fmt.Errorf("not a valid Version, try [%s]", strings.Join(_VersionNames, ", "))

Functions

func FilterByKind added in v0.28.0

func FilterByKind[T Object](objects []Object) []T

FilterByKind filters Object slice and returns its subset matching the type constraint.

func KindNames added in v0.20.0

func KindNames() []string

KindNames returns a list of possible string values of Kind.

func ObjectFormatNames added in v0.28.0

func ObjectFormatNames() []string

ObjectFormatNames returns a list of possible string values of ObjectFormat.

func Validate added in v0.28.0

func Validate(objects []Object) []error

Validate performs validation of all the provided objects. It aggregates the results into a single error.

func VersionNames added in v0.28.0

func VersionNames() []string

VersionNames returns a list of possible string values of Version.

Types

type Kind added in v0.20.0

type Kind int

Kind represents all the object kinds available in the API to perform operations on.

ENUM(

SLO = 1 Service Agent AlertPolicy AlertSilence Alert Project AlertMethod Direct DataExport RoleBinding Annotation UserGroup )

const (
	// KindSLO is a Kind of type SLO.
	KindSLO Kind = iota + 1
	// KindService is a Kind of type Service.
	KindService
	// KindAgent is a Kind of type Agent.
	KindAgent
	// KindAlertPolicy is a Kind of type AlertPolicy.
	KindAlertPolicy
	// KindAlertSilence is a Kind of type AlertSilence.
	KindAlertSilence
	// KindAlert is a Kind of type Alert.
	KindAlert
	// KindProject is a Kind of type Project.
	KindProject
	// KindAlertMethod is a Kind of type AlertMethod.
	KindAlertMethod
	// KindDirect is a Kind of type Direct.
	KindDirect
	// KindDataExport is a Kind of type DataExport.
	KindDataExport
	// KindRoleBinding is a Kind of type RoleBinding.
	KindRoleBinding
	// KindAnnotation is a Kind of type Annotation.
	KindAnnotation
	// KindUserGroup is a Kind of type UserGroup.
	KindUserGroup
)

func ApplicableKinds added in v0.20.0

func ApplicableKinds() []Kind

ApplicableKinds returns all the Kind instances which can be applied or deleted by the user.

func KindValues added in v0.20.0

func KindValues() []Kind

KindValues returns a list of the values for Kind

func ParseKind added in v0.20.0

func ParseKind(name string) (Kind, error)

ParseKind attempts to convert a string to a Kind.

func (Kind) Applicable added in v0.20.0

func (k Kind) Applicable() bool

Applicable returns true if the Kind can be applied or deleted by the user. In other words, it informs whether the Kind's lifecycle is managed by the user.

func (Kind) Equals added in v0.20.0

func (k Kind) Equals(s string) bool

Equals returns true if the Kind is equal to the given string. The comparison is case-insensitive.

func (Kind) IsValid added in v0.20.0

func (x Kind) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (Kind) MarshalText added in v0.20.0

func (k Kind) MarshalText() ([]byte, error)

MarshalText implements the text encoding.TextMarshaler interface.

func (Kind) String added in v0.20.0

func (x Kind) String() string

String implements the Stringer interface.

func (Kind) ToLower added in v0.20.0

func (k Kind) ToLower() string

ToLower converts the Kind to a lower case string.

func (*Kind) UnmarshalText added in v0.20.0

func (k *Kind) UnmarshalText(text []byte) error

UnmarshalText implements the text encoding.TextUnmarshaler interface.

type Object added in v0.28.0

type Object interface {
	// GetVersion returns the API version of the Object.
	GetVersion() string
	// GetKind returns the Kind of the Object.
	GetKind() Kind
	// GetName returns the name of the Object (RFC 1123 compliant DNS).
	GetName() string
	// Validate performs static validation of the Object.
	Validate() error
	// GetManifestSource returns the source of the Object's manifest.
	GetManifestSource() string
	// SetManifestSource sets the source of the Object's manifest.
	SetManifestSource(src string) Object
}

Object represents a generic Nobl9 object definition. All Nobl9 objects implement this interface.

func SetDefaultProject added in v0.28.0

func SetDefaultProject(objects []Object, project string) []Object

SetDefaultProject sets the default project for each object only if the object is ProjectScopedObject, and it does not yet have project assigned to it.

type ObjectFormat added in v0.28.0

type ObjectFormat int

ObjectFormat represents the format of Object data representation. ENUM(JSON = 1, YAML)

const (
	// ObjectFormatJSON is a ObjectFormat of type JSON.
	ObjectFormatJSON ObjectFormat = iota + 1
	// ObjectFormatYAML is a ObjectFormat of type YAML.
	ObjectFormatYAML
)

func ParseObjectFormat added in v0.28.0

func ParseObjectFormat(name string) (ObjectFormat, error)

ParseObjectFormat attempts to convert a string to a ObjectFormat.

func (ObjectFormat) IsValid added in v0.28.0

func (x ObjectFormat) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (ObjectFormat) String added in v0.28.0

func (x ObjectFormat) String() string

String implements the Stringer interface.

type ProjectScopedObject added in v0.28.0

type ProjectScopedObject interface {
	Object
	// GetProject returns the name of the project which the ProjectScopedObject belongs to.
	GetProject() string
	// SetProject sets the name of the project which the ProjectScopedObject should belong to.
	// It returns the copy of the Object with the updated Project.
	SetProject(project string) Object
}

ProjectScopedObject an Object which is tied to a specific KindProject. Example of such an object is v1alpha.SLO. On the other hand v1alpha.RoleBinding is an example of organization scoped Object which is not tied to any KindProject.

type Version added in v0.28.0

type Version string

Version represents the specific version of the manifest. ENUM(v1alpha = n9/v1alpha)

const (
	// VersionV1alpha is a Version of type v1alpha.
	VersionV1alpha Version = "n9/v1alpha"
)

func ParseVersion added in v0.28.0

func ParseVersion(name string) (Version, error)

ParseVersion attempts to convert a string to a Version.

func VersionValues added in v0.28.0

func VersionValues() []Version

VersionValues returns a list of the values for Version

func (Version) IsValid added in v0.28.0

func (x Version) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (Version) MarshalText added in v0.28.0

func (x Version) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (Version) String added in v0.28.0

func (x Version) String() string

String implements the Stringer interface.

func (*Version) UnmarshalText added in v0.28.0

func (x *Version) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

Directories

Path Synopsis
Package v1alpha represents objects available in API n9/v1alpha
Package v1alpha represents objects available in API n9/v1alpha
annotation
Package annotation defines Annotation object definitions.
Package annotation defines Annotation object definitions.
parser
Package parser provides parsing methods for v1alpha objects.
Package parser provides parsing methods for v1alpha objects.
project
Package project defines Project object definitions.
Package project defines Project object definitions.
rolebinding
Package rolebinding defines RoleBinding object definitions.
Package rolebinding defines RoleBinding object definitions.
service
Package service defines Service object definitions.
Package service defines Service object definitions.
slo
Package slo defines SLO object definitions.
Package slo defines SLO object definitions.
twindow
Package twindow provides enums and functions to operate with resources related to Time Windows
Package twindow provides enums and functions to operate with resources related to Time Windows
usergroup
Package usergroup defines UserGroup object definitions.
Package usergroup defines UserGroup object definitions.

Jump to

Keyboard shortcuts

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