backend

package
v0.0.0-...-5ccf328 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const PluginIDSeparator = "|"

Variables

View Source
var (
	DefaultMaxCount uint = 100
	MaxMaxCount     uint = 1_000
)

Functions

func ApplyWindow

func ApplyWindow[E any](list []E, window Window) []E

func EscapePatternRE

func EscapePatternRE(s string) string

func IDMatchesPattern

func IDMatchesPattern(s string, pattern string) bool

func IDMatchesPatterns

func IDMatchesPatterns(id string, patterns []string) bool

func IDPatternRE

func IDPatternRE(pattern string) string

func IsBadArgumentError

func IsBadArgumentError(err error) bool

func IsBusyError

func IsBusyError(err error) bool

func IsNotDoneError

func IsNotDoneError(err error) bool

func IsNotFoundError

func IsNotFoundError(err error) bool

func IsNotImplementedError

func IsNotImplementedError(err error) bool

func IsTimeoutError

func IsTimeoutError(err error) bool

func MatchesPattern

func MatchesPattern(s string, pattern string) bool

func MetadataMatchesPatterns

func MetadataMatchesPatterns(metadata map[string]string, patterns map[string]string) bool

func NewID

func NewID() string

func PatternRE

func PatternRE(pattern string) string

func SortDeploymentInfos

func SortDeploymentInfos(deploymentInfos []DeploymentInfo)

func SortPlugins

func SortPlugins(plugins []Plugin)

func SortSiteInfos

func SortSiteInfos(siteInfos []SiteInfo)

func SortTemplateInfos

func SortTemplateInfos(templateInfos []TemplateInfo)

Types

type Backend

type Backend interface {
	Connect(context contextpkg.Context) error
	Release(context contextpkg.Context) error
	String() string

	// Owns and may change the contents of the template argument.
	// Ignores template DeploymentIDs.
	// Can return BadArgumentError, NotDoneError.
	SetTemplate(context contextpkg.Context, template *Template) error

	// Can return BadArgumentError, NotFoundError.
	GetTemplate(context contextpkg.Context, templateId string) (*Template, error)

	// Does *not* delete associated deployments, but removes associations.
	// Can return BadArgumentError, NotFoundError, NotDoneError.
	DeleteTemplate(context contextpkg.Context, templateId string) error

	// Can return BadArgumentError.
	ListTemplates(context contextpkg.Context, selectTemplates SelectTemplates, window Window) (util.Results[TemplateInfo], error)

	// Does *not* delete associated deployments, but removes associations.
	// Can return BadArgumentError, NotDoneError.
	PurgeTemplates(context contextpkg.Context, selectTemplates SelectTemplates) error

	// Owns and may change the contents of the site argument.
	// Ignores site DeploymentIDs.
	// Can return BadArgumentError, NotDoneError.
	SetSite(context contextpkg.Context, site *Site) error

	// Can return BadArgumentError, NotFoundError.
	GetSite(context contextpkg.Context, siteId string) (*Site, error)

	// Does *not* delete associated deployments, but removes association.
	// Can return BadArgumentError, NotFoundError, NotDoneError.
	DeleteSite(context contextpkg.Context, siteId string) error

	// Can return BadArgumentError.
	ListSites(context contextpkg.Context, selectSites SelectSites, window Window) (util.Results[SiteInfo], error)

	// Does *not* delete associated deployments, but removes association.
	// Can return BadArgumentError, NotDoneError.
	PurgeSites(context contextpkg.Context, selectSites SelectSites) error

	// Owns and may change the contents of the deployment argument.
	// Can return BadArgumentError, NotDoneError.
	CreateDeployment(context contextpkg.Context, deployment *Deployment) error

	// Can return BadArgumentError, NotFoundError.
	GetDeployment(context contextpkg.Context, deploymentId string) (*Deployment, error)

	// Does *not* delete child deployments, but orphans them.
	// Can return BadArgumentError, NotFoundError, NotDoneError.
	DeleteDeployment(context contextpkg.Context, deploymentId string) error

	// Can return BadArgumentError.
	ListDeployments(context contextpkg.Context, selectDeployments SelectDeployments, window Window) (util.Results[DeploymentInfo], error)

	// Does *not* delete child deployments, but orphans them.
	// Can return BadArgumentError, NotDoneError.
	PurgeDeployments(context contextpkg.Context, selectDeployments SelectDeployments) error

	// Can return BadArgumentError, NotFoundError, NotDoneError, BusyError.
	StartDeploymentModification(context contextpkg.Context, deploymentId string) (string, *Deployment, error)

	// Owns and may change the contents of the package argument.
	// May change TemplateID, SiteID, Prepared, Approved.
	// Does *not* modify Metadata, even if modified package indicate a change.
	// If validation is not nil, should validate the modification. If the deployment is prepared, it should be complete validation.
	// Can return BadArgumentError, NotFoundError, NotDoneError, TimeoutError.
	EndDeploymentModification(context contextpkg.Context, modificationToken string, package_ tkoutil.Package, validation *validationpkg.Validation) (string, error)

	// Can return BadArgumentError, NotFoundError, NotDoneError.
	CancelDeploymentModification(context contextpkg.Context, modificationToken string) error

	// Owns and may change the contents of the plugin argument.
	// Can return BadArgumentError, NotDoneError.
	SetPlugin(context contextpkg.Context, plugin *Plugin) error

	// Can return BadArgumentError, NotFoundError.
	GetPlugin(context contextpkg.Context, pluginId PluginID) (*Plugin, error)

	// Can return BadArgumentError, NotFoundError, NotDoneError.
	DeletePlugin(context contextpkg.Context, pluginId PluginID) error

	// Can return BadArgumentError.
	ListPlugins(context contextpkg.Context, selectPlugins SelectPlugins, window Window) (util.Results[Plugin], error)

	// Can return BadArgumentError, NotDoneError.
	PurgePlugins(context contextpkg.Context, selectPlugins SelectPlugins) error
}

type BadArgumentError

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

func NewBadArgumentError

func NewBadArgumentError(message string) *BadArgumentError

func NewBadArgumentErrorf

func NewBadArgumentErrorf(format string, a ...any) *BadArgumentError

func WrapBadArgumentError

func WrapBadArgumentError(err error) *BadArgumentError

func (*BadArgumentError) Error

func (self *BadArgumentError) Error() string

(error interface)

type BusyError

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

func NewBusyError

func NewBusyError(message string) *BusyError

func NewBusyErrorf

func NewBusyErrorf(format string, a ...any) *BusyError

func (*BusyError) Error

func (self *BusyError) Error() string

(error interface)

type Deployment

type Deployment struct {
	DeploymentInfo
	Package util.Package
}

func NewDeploymentFromBytes

func NewDeploymentFromBytes(parentDemploymentId string, templateId string, siteId string, metadata map[string]string, prepared bool, approved bool, packageFormat string, package_ []byte) (*Deployment, error)

func (*Deployment) Clone

func (self *Deployment) Clone(withPackage bool) *Deployment

func (*Deployment) EncodePackage

func (self *Deployment) EncodePackage(format string) ([]byte, error)

func (*Deployment) MergeDeploymentResource

func (self *Deployment) MergeDeploymentResource()

func (*Deployment) MergeTemplate

func (self *Deployment) MergeTemplate(template *Template)

func (*Deployment) UpdateFromPackage

func (self *Deployment) UpdateFromPackage(withMetadata bool)

type DeploymentInfo

type DeploymentInfo struct {
	DeploymentID       string
	ParentDeploymentID string
	TemplateID         string
	SiteID             string
	Metadata           map[string]string
	Created            time.Time // millisecond precision
	Updated            time.Time // millisecond precision
	Prepared           bool
	Approved           bool
}

func (*DeploymentInfo) Clone

func (self *DeploymentInfo) Clone() DeploymentInfo

func (*DeploymentInfo) MergeTemplateInfo

func (self *DeploymentInfo) MergeTemplateInfo(templateInfo *TemplateInfo)

func (*DeploymentInfo) NewDeploymentResource

func (self *DeploymentInfo) NewDeploymentResource() util.Resource

func (*DeploymentInfo) UpdateFromPackage

func (self *DeploymentInfo) UpdateFromPackage(package_ util.Package, withMetadata bool)

type NotDoneError

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

func NewNotDoneError

func NewNotDoneError(message string) *NotDoneError

func NewNotDoneErrorf

func NewNotDoneErrorf(format string, a ...any) *NotDoneError

func (*NotDoneError) Error

func (self *NotDoneError) Error() string

(error interface)

type NotFoundError

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

func NewNotFoundError

func NewNotFoundError(message string) *NotFoundError

func NewNotFoundErrorf

func NewNotFoundErrorf(format string, a ...any) *NotFoundError

func (*NotFoundError) Error

func (self *NotFoundError) Error() string

(error interface)

type NotImplementedError

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

func NewNotImplementedError

func NewNotImplementedError(feature string) *NotImplementedError

func (*NotImplementedError) Error

func (self *NotImplementedError) Error() string

(error interface)

type Plugin

type Plugin struct {
	PluginID
	Executor   string
	Arguments  []string
	Properties map[string]string
	Triggers   []util.GVK
}

func NewPlugin

func NewPlugin(type_ string, name string, executor string, arguments []string, properties map[string]string, triggers []util.GVK) *Plugin

func (*Plugin) AddTrigger

func (self *Plugin) AddTrigger(group string, version string, kind string)

func (*Plugin) Clone

func (self *Plugin) Clone() *Plugin

func (*Plugin) TriggersAsStrings

func (self *Plugin) TriggersAsStrings() []string

type PluginID

type PluginID struct {
	Type string
	Name string
}

func NewPluginID

func NewPluginID(type_ string, name string) PluginID

func ParsePluginID

func ParsePluginID(id string) (PluginID, bool)

func (*PluginID) String

func (self *PluginID) String() string

(fmt.Stringer interface)

type SelectDeployments

type SelectDeployments struct {
	ParentDeploymentID       *string
	TemplateIDPatterns       []string
	TemplateMetadataPatterns map[string]string
	SiteIDPatterns           []string
	SiteMetadataPatterns     map[string]string
	MetadataPatterns         map[string]string
	Prepared                 *bool
	Approved                 *bool
}

type SelectPlugins

type SelectPlugins struct {
	Type         *string
	NamePatterns []string
	Executor     *string
	Trigger      *util.GVK
}

type SelectSites

type SelectSites struct {
	SiteIDPatterns     []string
	TemplateIDPatterns []string
	MetadataPatterns   map[string]string
}

type SelectTemplates

type SelectTemplates struct {
	TemplateIDPatterns []string
	MetadataPatterns   map[string]string
}

type Site

type Site struct {
	SiteInfo
	Package util.Package
}

func NewSiteFromBytes

func NewSiteFromBytes(siteId string, templateId string, metadata map[string]string, packageFormat string, package_ []byte) (*Site, error)

func (*Site) AddDeployment

func (self *Site) AddDeployment(deploymentId string) bool

func (*Site) Clone

func (self *Site) Clone(withDeployments bool) *Site

func (*Site) EncodePackage

func (self *Site) EncodePackage(format string) ([]byte, error)

func (*Site) MergeTemplate

func (self *Site) MergeTemplate(template *Template)

func (*Site) RemoveDeployment

func (self *Site) RemoveDeployment(deploymentId string) bool

func (*Site) UpdateFromPackage

func (self *Site) UpdateFromPackage()

type SiteInfo

type SiteInfo struct {
	SiteID        string
	TemplateID    string
	Metadata      map[string]string
	Updated       time.Time // millisecond precision
	DeploymentIDs []string
}

func (*SiteInfo) Clone

func (self *SiteInfo) Clone(withDeployments bool) SiteInfo

func (*SiteInfo) MergeTemplateInfo

func (self *SiteInfo) MergeTemplateInfo(templateInfo *TemplateInfo)

func (*SiteInfo) UpdateFromPackage

func (self *SiteInfo) UpdateFromPackage(package_ util.Package)

type Template

type Template struct {
	TemplateInfo
	Package util.Package
}

func NewTemplateFromBytes

func NewTemplateFromBytes(templateId string, metadata map[string]string, packageFormat string, package_ []byte) (*Template, error)

func (*Template) AddDeployment

func (self *Template) AddDeployment(deploymentId string) bool

func (*Template) Clone

func (self *Template) Clone(withDeployments bool) *Template

func (*Template) EncodePackage

func (self *Template) EncodePackage(format string) ([]byte, error)

func (*Template) RemoveDeployment

func (self *Template) RemoveDeployment(deploymentId string) bool

func (*Template) UpdateFromPackage

func (self *Template) UpdateFromPackage()

type TemplateInfo

type TemplateInfo struct {
	TemplateID    string
	Metadata      map[string]string
	Updated       time.Time // millisecond precision
	DeploymentIDs []string
}

func (*TemplateInfo) Clone

func (self *TemplateInfo) Clone(withDeployments bool) TemplateInfo

func (*TemplateInfo) UpdateFromPackage

func (self *TemplateInfo) UpdateFromPackage(package_ util.Package)

type TimeoutError

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

func NewTimeoutError

func NewTimeoutError(message string) *TimeoutError

func NewTimeoutErrorf

func NewTimeoutErrorf(format string, a ...any) *TimeoutError

func (*TimeoutError) Error

func (self *TimeoutError) Error() string

(error interface)

type Window

type Window struct {
	Offset   uint
	MaxCount int // <0 for maximum number of results
}

func (Window) End

func (self Window) End() uint

func (Window) Limit

func (self Window) Limit() uint

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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