util

package
v1.20.0-rc.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// ConfigManagementName is the name of the ConfigManagement object.
	ConfigManagementName = "config-management"
	// ConfigManagementResource is the config management resource
	ConfigManagementResource = "configmanagements"
	// ConfigManagementVersionName is the field name that indicates the ConfigManagement version.
	ConfigManagementVersionName = "configManagementVersion"
	// ACMOperatorDeployment is the name of ACM Operator Deployment
	ACMOperatorDeployment = "config-management-operator"
	// ConfigManagementCRDName is the name of the ConfigManagement CustomResourceDefinition
	ConfigManagementCRDName = "configmanagements.configmanagement.gke.io"
	// ConfigSyncName is the name of the ConfigSync object for OSS installation.
	ConfigSyncName = "config-sync"
	// ReconcilerManagerName is the name of reconciler-manger
	ReconcilerManagerName = "reconciler-manager"
	// ManagedByHubAnnotationKey is the annotation key set by Hub
	ManagedByHubAnnotationKey = "configmanagement.gke.io/managed-by-hub"
	// ManagedByHubAnnotationValue is the annotation value set by Hub
	ManagedByHubAnnotationValue = "true"
)
View Source
const (
	// Indent is the extra spaces for indentation.
	Indent = "  "
	// Separator is the delimiter before each cluster.
	Separator = "--------------------"
	// Bullet is the separator before each bullet item.
	Bullet = "- "

	// ColorDefault is the default color code
	ColorDefault = "\033[0m"
	// ColorRed is the red color code
	ColorRed = "\033[31m"
	// ColorGreen is the green color code
	ColorGreen = "\033[32m"
	// ColorYellow is the yellow color code
	ColorYellow = "\033[33m"
	// ColorCyan is the cyan color code
	ColorCyan = "\033[36m"
)
View Source
const (
	// ErrorMsg indicates that an error has occurred when retrieving or calculating a field value.
	ErrorMsg = "ERROR"
	// NotInstalledMsg indicates that ACM is not installed on a cluster.
	NotInstalledMsg = "NOT INSTALLED"
	// NotRunningMsg indicates that ACM is installed but not running on a cluster.
	NotRunningMsg = "NOT RUNNING"
	// NotConfiguredMsg indicates that ACM is installed but not configured for a cluster.
	NotConfiguredMsg = "NOT CONFIGURED"
	// UnknownMsg indicates that a field's value is unknown or unavailable.
	UnknownMsg = "UNKNOWN"
	// OSSMsg indicates OSS installation
	OSSMsg = "OSS Installation"
)

Status enums shared across nomos subcommands.

View Source
const (
	// FieldManager is the field manager name used by the nomos CLI.
	// This avoids conflicts with the reconciler and reconciler-manager.
	FieldManager = configsync.ConfigSyncPrefix + "nomos-cli"
)

Variables

View Source
var DynamicClient = func(config *rest.Config) (dynamic.Interface, error) {
	return dynamic.NewForConfig(config)
}

DynamicClient obtains a client based on the supplied REST config. Returns dynamic.Interface to be overridden in tests.

Functions

func IsOssInstallation added in v1.15.1

func IsOssInstallation(ctx context.Context, c *ConfigManagementClient, cl client.Client, ck *kubernetes.Clientset) (bool, error)

IsOssInstallation will check for the existence of ConfigManagement object, Operator deployment, and RootSync CRD If RootSync CRD exist but ConfigManagement and Operator doesn't, it indicates an OSS installation

func MonoRepoNotice

func MonoRepoNotice(writer io.Writer, monoRepoClusters ...string)

MonoRepoNotice logs a notice for the clusters that are running in the legacy mode.

func MustFprintf added in v1.19.0

func MustFprintf(w io.Writer, format string, a ...any)

MustFprintf prints a formatted string to the writer and panics on error.

func NewWriter

func NewWriter(out io.Writer) *tabwriter.Writer

NewWriter returns a standardized writer for the CLI for writing tabular output to the console.

func PrintErr

func PrintErr(err error) error

PrintErr attempts to print an error to STDERR.

func PrintErrOrDie

func PrintErrOrDie(err error)

PrintErrOrDie attempts to print an error to STDERR, and panics if it is unable to.

func WriteObject

func WriteObject(printer printers.ResourcePrinter, dir string, object ast.FileObject) error

WriteObject writes a FileObject to a file using the provided ResourcePrinter. Writes to the file at object.OSPath(), overwriting if one exists.

Types

type ConfigManagementClient

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

ConfigManagementClient wraps a dynamic resource interface for reading ConfigManagement resources.

func NewConfigManagementClient

func NewConfigManagementClient(cfg *rest.Config) (*ConfigManagementClient, error)

NewConfigManagementClient returns a new ConfigManagementClient.

func (*ConfigManagementClient) EnableMultiRepo

EnableMultiRepo removes the spec.git field and sets spec.enableMultiRepo to true. It returns both the original and the updated ConfigManagement objects.

func (*ConfigManagementClient) IsHNCEnabled

func (c *ConfigManagementClient) IsHNCEnabled(ctx context.Context) (bool, error)

IsHNCEnabled returns if the ConfigManagement object has HNC enabled.

func (*ConfigManagementClient) IsManagedByHub added in v1.19.0

func (c *ConfigManagementClient) IsManagedByHub(ctx context.Context) (bool, error)

IsManagedByHub returns if the ConfigManagement object is managed by Hub.

func (*ConfigManagementClient) IsMultiRepo

func (c *ConfigManagementClient) IsMultiRepo(ctx context.Context) (*bool, error)

IsMultiRepo returns if the enableMultiRepoMode is true in the ConfigManagement objects.

func (*ConfigManagementClient) NestedBool

func (c *ConfigManagementClient) NestedBool(ctx context.Context, fields ...string) (bool, error)

NestedBool returns the boolean value specified by the given path of field names. Returns false if a value is not found and an error if value is not a bool.

func (*ConfigManagementClient) NestedInt

func (c *ConfigManagementClient) NestedInt(ctx context.Context, fields ...string) (int, error)

NestedInt returns the integer value specified by the given path of field names. Returns false if a value is not found and an error if value is not a bool.

func (*ConfigManagementClient) NestedString

func (c *ConfigManagementClient) NestedString(ctx context.Context, fields ...string) (string, error)

NestedString returns the string value specified by the given path of field names. Returns empty string if a value is not found and an error if value is not a string.

func (*ConfigManagementClient) NestedStringSlice

func (c *ConfigManagementClient) NestedStringSlice(ctx context.Context, fields ...string) ([]string, error)

NestedStringSlice returns the string slice specified by the given path of field names. Returns nil if a value is not found and an error if value is not a string slice.

func (*ConfigManagementClient) RemoveFinalizers added in v1.19.0

func (c *ConfigManagementClient) RemoveFinalizers(ctx context.Context) error

RemoveFinalizers removes all finalizers from the ConfigManagement object

func (*ConfigManagementClient) UpdateConfigManagement

func (c *ConfigManagementClient) UpdateConfigManagement(ctx context.Context, obj *unstructured.Unstructured) error

UpdateConfigManagement updates the ConfigManagement object in the API server.

func (*ConfigManagementClient) Version

func (c *ConfigManagementClient) Version(ctx context.Context) (string, error)

Version returns the version of the ConfigManagement objects.

Jump to

Keyboard shortcuts

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