Help us shape the future of Go! Take the 2026 Go Developer Survey

status

package
v1.23.3 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Overview

Package status contains logic for the nomos status CLI command.

Index

Constants

View Source
const (
	// ACMOperatorLabelSelector is the label selector for the ACM operator Pod.
	ACMOperatorLabelSelector = "k8s-app=config-management-operator"
)

Variables

View Source
var (
	// ErrNoRootSyncsFound is the error returned when no RootSyncs are found on a cluster
	ErrNoRootSyncsFound = errors.New("No RootSync resources found")
	// ErrNoRepoSyncsFound is the error returned when no RepoSyncs are found on a cluster
	ErrNoRepoSyncsFound = errors.New("No RepoSync resources found")
	// ErrMonoRepoFound is the error returned when mono-repo mode is detected on a cluster
	ErrMonoRepoFound = errors.New("This cluster is running in legacy mono-repo mode, which is no longer supported")
)
View Source
var Cmd = &cobra.Command{
	Use: "status",

	Short: `Prints the status of all clusters with Configuration Management installed.`,
	RunE: func(cmd *cobra.Command, _ []string) error {

		cmd.SilenceUsage = true

		fmt.Println("Connecting to clusters...")

		clientMap, err := ClusterClients(cmd.Context(), flags.Contexts)
		if err != nil {
			if errors.Is(err, os.ErrNotExist) {
				return fmt.Errorf("failed to create client configs: %w", err)
			}

			klog.Fatalf("Failed to get clients: %v", err)
		}
		if len(clientMap) == 0 {
			return errors.New("no clusters found")
		}

		names := clusterNames(clientMap)

		writer := util.NewWriter(os.Stdout)
		if pollingInterval > 0 {
			for {
				printStatus(cmd.Context(), writer, clientMap, names)
				time.Sleep(pollingInterval)
			}
		} else {
			printStatus(cmd.Context(), writer, clientMap, names)
		}
		return nil
	},
}

Cmd runs a loop that fetches ACM objects from all available clusters and prints a summary of the status of Config Management for each cluster.

Functions

func ClusterClients

func ClusterClients(ctx context.Context, contexts []string) (map[string]*ClusterClient, error)

ClusterClients returns a map of of typed clients keyed by the name of the kubeconfig context they are initialized from.

func HasRunningPod

func HasRunningPod(pods []corev1.Pod) bool

HasRunningPod returns true if there is a Pod whose phase is running.

func SaveToTempFile

func SaveToTempFile(ctx context.Context, contexts []string) (*os.File, error)

SaveToTempFile writes the `nomos status` output into a temporary file, and opens the file for reading. It returns the file descriptor with read_only permission. Using the temp file instead of os.Pipe is to avoid the hanging issue caused by the os.Pipe buffer limit: 64k. This function is only used in `nomos bugreport` for the `nomos status` output.

Types

type ClusterClient

type ClusterClient struct {
	// Client performs CRUD operations on Kubernetes objects.
	Client client.Client

	// K8sClient contains the clients for groups.
	K8sClient        kubernetes.Interface
	ConfigManagement *util.ConfigManagementClient
	// contains filtered or unexported fields
}

ClusterClient is the client that talks to the cluster.

func (*ClusterClient) IsConfigured

func (c *ClusterClient) IsConfigured(ctx context.Context, cs *ClusterState) bool

IsConfigured returns true if the ClusterClient is connected to a cluster where Config Sync is configured. Updates the given ClusterState with status info if Config Sync is not configured.

func (*ClusterClient) IsInstalled

func (c *ClusterClient) IsInstalled(ctx context.Context, cs *ClusterState) bool

IsInstalled returns true if the ClusterClient is connected to a cluster where Config Sync is installed (ACM operator Pod is running). Updates the given ClusterState with status info if Config Sync is not installed.

type ClusterState

type ClusterState struct {
	// Ref is the current cluster context
	Ref string

	// Error represents the sync errors
	Error string
	// contains filtered or unexported fields
}

ClusterState represents the sync status of all repos on a cluster.

type RepoState

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

RepoState represents the sync status of a single repo on a cluster.

func RootRepoStatus

func RootRepoStatus(rs *v1beta1.RootSync, rg *kptv1alpha1.ResourceGroup, syncingConditionSupported bool) *RepoState

RootRepoStatus converts the given RootSync into a RepoState.

func (*RepoState) GetCommit

func (r *RepoState) GetCommit() string

GetCommit returns RepoState's commit

func (*RepoState) GetErrorSummary

func (r *RepoState) GetErrorSummary() *v1beta1.ErrorSummary

GetErrorSummary returns RepoState's ErrorSummary

func (*RepoState) GetStatus

func (r *RepoState) GetStatus() string

GetStatus returns RepoState's status

Jump to

Keyboard shortcuts

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