manifest

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: 15 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.

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.

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 (
	DeletionPolicyAbandon    = "abandon"
	InstanceLabel            = "instance.cuebe.loftorbital.com/name"
	DeletionPolicyAnnotation = "instance.cuebe.loftorbital.com/deletion-policy"
)
View Source
const FieldManager = "cuebe"

Variables

This section is empty.

Functions

func IsManifest

func IsManifest(v cue.Value) bool

IsManifest returns true if the cue.Value "looks like" a Manifest. For now that means it has a 'kind' and 'apiVersion', both being strings.

Types

type Id

type Id struct {
	Group     string `json:"group" protobuf:"bytes,1,opt,name=group"`
	Version   string `json:"version" protobuf:"bytes,2,opt,name=version"`
	Kind      string `json:"kind" protobuf:"bytes,3,opt,name=kind"`
	Namespace string `json:"namespace,omitempty" protobuf:"bytes,3,opt,name=namespace"`
	Name      string `json:"name,omitempty" protobuf:"bytes,3,opt,name=name"`
}

Id contains the necessary fields to identify a Manifest

func (Id) GroupKind

func (id Id) GroupKind() schema.GroupKind

func (Id) Manifest

func (id Id) Manifest(ctx context.Context, rm meta.RESTMapper, client dynamic.Interface, opts metav1.GetOptions) (Manifest, error)

Manifest retrieves the manifest matching this id in the given cluster.

func (Id) RESTMapping

func (id Id) RESTMapping(rm meta.RESTMapper) (*meta.RESTMapping, error)

RESTMapping returns the rest mapping for this id.

func (Id) ResourceInterface

func (id Id) ResourceInterface(rm meta.RESTMapper, client dynamic.Interface) (resource dynamic.ResourceInterface, err error)

ResourceInterface returns the dynamic resource interface for this id.

func (Id) String

func (id Id) String() string

type Manifest

type Manifest struct {
	*unstructured.Unstructured
}

Manifest is a wrapper around *unstructured.Unstructured.

func Decode

func Decode(v cue.Value) (Manifest, error)

Decode converts a cue.Value into a Manifest or returns an error if the value is not compatible with a k8s object.

func Extract

func Extract(v cue.Value, paths ...cue.Path) ([]Manifest, error)

Extract extracts all Manifests recursively starting from every paths. Recursion is stopped on `ignore` cue.Attribute or when a Manifest has been decoded. That means nested Manifests are not possible.

func New

New creates a new Manifest from an *unstructured.Unstructured object.

func (Manifest) Delete

func (m Manifest) Delete(ctx context.Context, konfig *utils.K8sConfig, opts utils.CommonMetaOptions) error

Delete deletes the Manifest from the cluster. If deletion policy is set to abandon, the resource is not deleted, but will be patched with an empty instance.

func (Manifest) GetDeletionPolicy

func (m Manifest) GetDeletionPolicy() string

GetDeletionPolicy returns the deletion policy of this Manifest.

func (Manifest) GetInstance

func (m Manifest) GetInstance() string

GetInstance retrieve the instance this Manifest belongs to, or an empty string if not belonging to any instance.

func (Manifest) Hash

func (m Manifest) Hash() ([]byte, error)

Hash returns the hash of a Manifest.

func (Manifest) Id

func (m Manifest) Id() Id

Id returns the Id of the Manifest m.

func (Manifest) IsRemote

func (m Manifest) IsRemote() bool

IsRemote returns true if the manifest has an uuid set. TODO: this is weak, get rid of using that asap.

func (Manifest) Patch

func (m Manifest) Patch(ctx context.Context, konfig *utils.K8sConfig, opts utils.CommonMetaOptions) (Manifest, error)

Patch does a server-side apply patch of the Manifest.

func (Manifest) WithDeletionPolicy

func (m Manifest) WithDeletionPolicy(policy string) Manifest

WithDeletionPolicy sets the manifest deletion policy and returns the modified manifest.

func (Manifest) WithInstance

func (m Manifest) WithInstance(name string) Manifest

WithInstance sets the manifest instance and returns the modified manifest.

Jump to

Keyboard shortcuts

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