status

package
v1.1.87-nightly Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2025 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	K3sServerNotReady = "k3s server is not ready, please wait"
)

Variables

View Source
var Cmd = &cobra.Command{
	Use:   "status",
	Short: "get status of your current context (user, team, environment, vpn status)",
	Run: func(cmd *cobra.Command, _ []string) {
		apic := clients.Api
		fc := clients.File

		if u, err := apic.GetCurrentUser(); err == nil {
			fn.Logf("\nLogged in as %s (%s)\n",
				text.Blue(u.Name),
				text.Blue(u.Email),
			)
		}

		var team string
		team, err := fc.GetDirTeam()
		if err == nil {
			fn.Log(fmt.Sprint(text.Bold(text.Blue("Team: ")), team))
		}

		func() {
			if team == "" {
				return
			}

			e, err := apic.EnsureEnv()
			selectedEnv := ""
			if err == nil {
				selectedEnv = e
			}

			ev, err := apic.GetEnvironment(team, selectedEnv)
			if err == nil {
				r := text.Yellow("offline")
				if ev.ClusterName != "" {
					if ev.IsArchived {
						r = text.Yellow("archived")
					} else {
						cluster, err := apic.GetCluster(team, ev.ClusterName)
						if err != nil {
							fn.PrintError(err)
							return
						}
						if time.Since(cluster.LastOnlineAt) < time.Minute {
							r = text.Green("online")
						}
						if ev.Spec.Suspend {
							r = text.Yellow("suspended")
						}
					}
					fn.Log(text.Bold(text.Blue("Environment: ")), selectedEnv, fmt.Sprintf("(%s)", r))
				}
			} else if selectedEnv != "" {
				fn.Log(text.Bold(text.Blue("Environment: ")), selectedEnv)
			}
		}()

		return

	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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