resources

package
v0.0.0-...-3bfe646 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: Apache-2.0 Imports: 40 Imported by: 5

Documentation

Overview

+groupName=gravitational.io

Index

Constants

View Source
const (
	// KindResourceFile represents a generic Kubernetes resource spec file.
	KindResourceFile = "Resource file"
	// KindManifestFile represents a cluster/app image manifest file.
	KindManifestFile = "Manifest file"
	// KindHelmTemplate represents a Helm template file.
	KindHelmTemplate = "Helm template"
)

Variables

This section is empty.

Functions

func Encode

func Encode(objects []runtime.Object, encoding encoding, w io.Writer) error

Encode encodes the specified objects into the given writer

func ForEachObject

func ForEachObject(reader io.Reader, fn ResourceFunc) error

ForEachObject decodes Kubernetes objects from the provided reader and calls the provided function for each of them

func ForEachObjectInFile

func ForEachObjectInFile(path string, fn ResourceFunc) error

ForEachObjectInFile decodes the file at specified path as Kubernetes spec and calls the provided function for each of the decoded objects

func UpdateSecurityContext

func UpdateSecurityContext(pod *v1.PodSpec, serviceUser systeminfo.User) (updated bool)

UpdateSecurityContext updates the security context for the given Pod (including security contexts of all containers) using the specified service user. Only the security contexts using a special defaults.PlaceholderServiceUserID are updated.

func UpdateSecurityContextInDir

func UpdateSecurityContextInDir(dir string, serviceUser systeminfo.User) error

UpdateSecurityContextInDir updates all application resources in the specified directory with securityContext using the given service user

Types

type DecodeOption

type DecodeOption func(*universalDecoder)

DecodeOption is a functional argument for decoding

type ExtractedImages

type ExtractedImages struct {
	// Images contains extracted image names
	Images []string
	// UnrecognizedObjects contains objects which could not be recognized
	UnrecognizedObjects []runtime.Object
}

ExtractedImages is the results of image extraction from a list of objects

type ManifestRewriteFunc

type ManifestRewriteFunc func(context.Context, *schema.Manifest) error

ManifestRewriteFunc defines an interface for functions that can update parts of an application manifest

type Resource

type Resource struct {
	Objects []runtime.Object
	// contains filtered or unexported fields
}

Resource combines a set of kubernetes resources and a means to serialize them in the original format (JSON or YAML)

func Decode

func Decode(r io.Reader, options ...DecodeOption) (resource *Resource, err error)

Decode decodes kubernetes resources from the specified io.Reader

func NewResource

func NewResource(objects ...runtime.Object) Resource

NewResource creates a new resource object that can encode objects it was initialized with in YAML format

func (*Resource) DeepCopy

func (in *Resource) DeepCopy() *Resource

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Resource.

func (*Resource) DeepCopyInto

func (in *Resource) DeepCopyInto(out *Resource)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (Resource) Encode

func (r Resource) Encode(w io.Writer) error

Encode encodes contained resources in the original format (JSON or YAML)

type ResourceFile

type ResourceFile struct {
	Resource
	// contains filtered or unexported fields
}

ResourceFile represents a file with resources to process

func NewResourceFile

func NewResourceFile(path string) (*ResourceFile, error)

NewResourceFile parses the file at path and returns all kubernetes objects as a single ResourceFile instance. The object can then serialize itself to the original location.

func NewResourceFileObject

func NewResourceFileObject(path, kind string, resource Resource) ResourceFile

NewResourceFileObject returns new resource file created from resource

func (*ResourceFile) DeepCopy

func (in *ResourceFile) DeepCopy() *ResourceFile

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceFile.

func (*ResourceFile) DeepCopyInto

func (in *ResourceFile) DeepCopyInto(out *ResourceFile)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (ResourceFile) Images

func (r ResourceFile) Images() (*ExtractedImages, error)

Images returns a list of Docker images in this resource file

func (ResourceFile) Kind

func (r ResourceFile) Kind() string

Kind returns the kind of the resource this file represents.

func (ResourceFile) Path

func (r ResourceFile) Path() string

Path returns path to resource

func (ResourceFile) String

func (r ResourceFile) String() string

String implements fmt.Stringer for this resource file

type ResourceFiles

type ResourceFiles []ResourceFile

ResourceFiles is a collection of resource files

func (ResourceFiles) Images

func (r ResourceFiles) Images() ([]string, error)

Images accumulates container image references over the specified range of resource files and returns them as a flat list w/o duplicates.

func (*ResourceFiles) RewriteImages

func (r *ResourceFiles) RewriteImages(rewriteFunc func(string) string) error

RewriteImages rewrites container image references in all resource files part of this collection using the specified imageService.

func (*ResourceFiles) RewriteManifest

func (r *ResourceFiles) RewriteManifest(ctx context.Context, rewrites ...ManifestRewriteFunc) error

RewriteManifest rewrites parts of the application manifest resources by application of the specified set of rewrite functions

func (ResourceFiles) Write

func (r ResourceFiles) Write() (err error)

Write serializes the resource files to disk back to the locations they were read from.

type ResourceFunc

type ResourceFunc func(object runtime.Object) error

ResourceFunc is the function that operates on an arbitrary Kubernetes object

type Resources

type Resources []Resource

Resources is a list of resource objects

func (Resources) Images

func (resources Resources) Images() ([]string, error)

Images returns images found in resources

type Unknown

type Unknown struct {
	Raw json.RawMessage `json:",inline"`
	// contains filtered or unexported fields
}

Unknown represents an unparsed Kubernetes resource with an interpreted TypeMeta and ObjectMeta fields which are used for type recognition. +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

func ToUnknown

func ToUnknown(object runtime.Object) (*Unknown, error)

ToUnknown attempts to convert the provided generic object to an unknown resource.

func (*Unknown) DeepCopy

func (in *Unknown) DeepCopy() *Unknown

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Unknown.

func (*Unknown) DeepCopyInto

func (in *Unknown) DeepCopyInto(out *Unknown)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*Unknown) DeepCopyObject

func (in *Unknown) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

func (*Unknown) GetObjectKind

func (r *Unknown) GetObjectKind() schema.ObjectKind

GetObjectKind returns the ObjectKind for this Unknown. Implements runtime.Object

func (*Unknown) MarshalJSON

func (r *Unknown) MarshalJSON() ([]byte, error)

MarshalJSON returns the raw message

func (*Unknown) UnmarshalJSON

func (r *Unknown) UnmarshalJSON(data []byte) error

UnmarshalJSON consumes the specified data as a binary blob w/o interpreting it

Jump to

Keyboard shortcuts

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