config

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: Apache-2.0 Imports: 29 Imported by: 1

Documentation

Overview

Package config provides utilities to get configuration.

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultCluster the default cluster name
	DefaultCluster = "kwok"

	// WorkDir is the directory of the work spaces.
	WorkDir = envs.GetEnvWithPrefix("WORKDIR", path.WorkDir())

	// ClustersDir is the directory of the clusters.
	ClustersDir = path.Join(WorkDir, "clusters")

	// GOOS is the operating system target for which the code is compiled.
	GOOS = runtime.GOOS

	// GOARCH is the architecture target for which the code is compiled.
	GOARCH = runtime.GOARCH
)

Functions

func ClusterName

func ClusterName(name string) string

ClusterName returns the cluster name.

func FilterWithType

func FilterWithType[T InternalObject](objs []InternalObject) (out []T)

FilterWithType returns a list of objects with the given type.

func FilterWithTypeFromContext

func FilterWithTypeFromContext[T metav1.Object](ctx context.Context) (out []T)

FilterWithTypeFromContext returns all objects of the given type from the context.

func GetKwokConfiguration

func GetKwokConfiguration(ctx context.Context) (conf *internalversion.KwokConfiguration)

GetKwokConfiguration get the configuration of the kwok.

func GetKwokctlConfiguration

func GetKwokctlConfiguration(ctx context.Context) (conf *internalversion.KwokctlConfiguration)

GetKwokctlConfiguration get the configuration of the kwokctl.

func InitFlags

func InitFlags(ctx context.Context, flags *pflag.FlagSet) (context.Context, error)

InitFlags initializes the flags for the configuration.

func Marshal added in v0.4.0

func Marshal(obj InternalObject) ([]byte, error)

Marshal marshals the given internal object into a raw message.

func Save

func Save(ctx context.Context, dist string, objs []InternalObject) error

Save saves the given objects to the given path.

func SaveTo added in v0.4.0

func SaveTo(ctx context.Context, w io.Writer, objs []InternalObject) error

SaveTo saves the given objects to the given writer.

func UnmarshalWithType added in v0.4.0

func UnmarshalWithType[T InternalObject, D string | []byte](raw D) (t T, err error)

UnmarshalWithType unmarshals the given raw message into the internal object.

Types

type InternalObject added in v0.2.0

type InternalObject interface {
	GetNamespace() string
	GetName() string
}

InternalObject is an object that is internal to the kwok project.

func FilterWithoutType

func FilterWithoutType[T InternalObject](objs []InternalObject) (out []InternalObject)

FilterWithoutType filters out objects of the given type.

func FilterWithoutTypeFromContext

func FilterWithoutTypeFromContext[T InternalObject](ctx context.Context) (out []InternalObject)

FilterWithoutTypeFromContext returns all objects from the context that are not of the given type.

func GetFromContext added in v0.4.0

func GetFromContext(ctx context.Context) []InternalObject

GetFromContext returns the objects from the context.

func Load

func Load(ctx context.Context, src ...string) ([]InternalObject, error)

Load loads the given path into the context.

func LoadUnstructured added in v0.6.0

func LoadUnstructured(src ...string) ([]InternalObject, error)

LoadUnstructured loads the given path into the context.

func Unmarshal added in v0.4.0

func Unmarshal[D string | []byte](d D) (InternalObject, error)

Unmarshal unmarshals the given raw message into the internal object.

Directories

Path Synopsis
Package resources contains utility functions for serving resources.
Package resources contains utility functions for serving resources.

Jump to

Keyboard shortcuts

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