instance

package
v0.1.0-beta.4 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Copyright © 2021 Loft Orbital

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

View Source
const (
	Kind     = "Instance"
	Group    = "cuebe.loftorbital.com"
	Version  = "v1alpha1"
	Resource = "instances"
)

Variables

This section is empty.

Functions

func InstallCRD

func InstallCRD(ctx context.Context, config *utils.K8sConfig, opts utils.CommonMetaOptions) error

InstallCRD install the cuebe instance custom definition to the cluster.

Types

type Instance

type Instance interface {
	fmt.Stringer

	// Commit applies the instance remotely.
	Commit(ctx context.Context, config *utils.K8sConfig, opts utils.CommonMetaOptions) error
	// Delete deletes the instance from the cluster.
	Delete(ctx context.Context, config *utils.K8sConfig, opts utils.CommonMetaOptions) error

	// Add adds a Manifest to the instance.
	//
	// It does not commit changes remotely, use Commit for that.
	Add(m manifest.Manifest)
	// Remove removes a Manifest from the instance
	//
	// It does not commit changes remotely, use Commit for that.
	Remove(m manifest.Manifest)
	// Manifests returns the instance manifests.
	Manifests() []manifest.Manifest
}

func Split

func Split(manifests []manifest.Manifest) []Instance

Split groups manifest by instance and returns the instances. Manifests that do not belong to an instance will be added to the orphan instance.

type InstanceSpec

type InstanceSpec struct {
	Resources []manifest.Id `json:"resources,omitempty"`
}

InstanceSpec contains the ids of the manifests this instance manage.

type Named

type Named struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec InstanceSpec `json:"spec,omitempty"`
	// contains filtered or unexported fields
}

Named represents a named instance.

func NewNamed

func NewNamed(name string) *Named

NewNamed creates a new named instance.

func (*Named) Add

func (i *Named) Add(m manifest.Manifest)

Add adds a manifest to the instance. It's thread safe.

func (*Named) Commit

func (i *Named) Commit(ctx context.Context, config *utils.K8sConfig, opts utils.CommonMetaOptions) error

Commit applies the instance remotely.

func (*Named) Delete

func (i *Named) Delete(ctx context.Context, config *utils.K8sConfig, opts utils.CommonMetaOptions) error

Delete deletes the instance from the cluster.

func (*Named) Id

func (n *Named) Id() manifest.Id

Id returns the instance id as a manifest.Id. Mostly useful for test or debug purposes.

func (*Named) Manifests

func (i *Named) Manifests() []manifest.Manifest

Manifests returns the instance manifests.

func (*Named) Marshal

func (i *Named) Marshal() ([]byte, error)

Marshal encode the instance.

func (*Named) OwnerReference

func (i *Named) OwnerReference() metav1.OwnerReference

OwnerReference returns a metav1.OwnerReference to be used for managed resources.

func (*Named) Remove

func (i *Named) Remove(m manifest.Manifest)

Remove deletes a manifest from the instance. It's thread safe.

func (*Named) String

func (i *Named) String() string

func (*Named) Sync

func (i *Named) Sync(ctx context.Context, config *utils.K8sConfig, opts utils.CommonMetaOptions) error

func (*Named) Unmarshal

func (i *Named) Unmarshal(b []byte) error

Unmarshal decode the instance inplace.

type Orphan

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

func NewOrphan

func NewOrphan() *Orphan

NewOrphan creates a new Orphan instance.

func (*Orphan) Add

func (o *Orphan) Add(m manifest.Manifest)

Add adds a Manifest to the instance.

It does not commit changes remotely, use Commit for that.

func (*Orphan) Commit

func (o *Orphan) Commit(ctx context.Context, config *utils.K8sConfig, opts utils.CommonMetaOptions) error

Commit applies the instance remotely.

func (*Orphan) Delete

func (o *Orphan) Delete(ctx context.Context, config *utils.K8sConfig, opts utils.CommonMetaOptions) error

Delete deletes the instance from the cluster.

func (*Orphan) Manifests

func (o *Orphan) Manifests() []manifest.Manifest

Manifests returns the instance manifests.

func (*Orphan) Remove

func (o *Orphan) Remove(m manifest.Manifest)

Remove removes a Manifest from the instance

It does not commit changes remotely, use Commit for that.

func (*Orphan) String

func (o *Orphan) String() string

Jump to

Keyboard shortcuts

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