cli

package
v1.0.0-rc7 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OperatorEqual    = "=="
	OperatorNotEqual = "!="
)
View Source
const (
	InClusterCAFile   string = "ca.crt"
	InClusterCertFile string = "tls.crt"
)
View Source
const (
	DefaultDashboardNamespace     = "cosmo-system"
	DefaultDashboardPort          = 8443
	DefaultDashboardInclusterPort = 8080
)
View Source
const (
	ENV_CONFIG        = "COSMOCTL_CONFIG"
	ENV_DASHBOARD_URL = "COSMOCTL_DASHBOARD_URL"
)
View Source
const (
	ServiceAccountTokenFile = "/var/run/secrets/kubernetes.io/serviceaccount/token"
)

Variables

View Source
var (
	InClusterDashboardURL = inClusterDashboardURL()
)

Functions

func AskInput

func AskInput(prompt string, silent bool) (string, error)

func ConnectErrorHandler

func ConnectErrorHandler(rcmd RunCommand) func(*cobra.Command, []string) error

func DoFilter

func DoFilter[T any](objects []T, objectFilterKeyFunc func(T) []string, f Filter) []T

func ExtractSessionToken

func ExtractSessionToken(res *connect.Response[dashv1alpha1.LoginResponse]) string

func GetCurrentWorkspaceName

func GetCurrentWorkspaceName() string

GetCurrentWorkspaceName returns current workspace name. If running in Workspace pod, hostname is like `$INSTANCE-deploy-podsufix`(e.g.`ws1-workspace-575db4c9cd-h558m`) the first part is workspace name prefixed by cosmo.

func InClusterHTTPClient

func InClusterHTTPClient(ca []byte) (*http.Client, error)

func NewRequestWithToken

func NewRequestWithToken[T any](message *T, cfg *Config) *connect.Request[T]

func OutputTable

func OutputTable(output io.Writer, headers []string, data [][]string)

func ReadFromPipedStdin

func ReadFromPipedStdin() (string, error)

func ServiceAccountLogin

func ServiceAccountLogin(ctx context.Context, cfg *Config) error

func UseServiceAccount

func UseServiceAccount(cfg *Config) bool

Types

type Config

type Config struct {
	Endpoint          string `json:"endpoint"`
	Token             string `json:"token"`
	User              string `json:"user"`
	UseServiceAccount bool   `json:"useServiceAccount,omitempty"`
	CACert            string `json:"cacert,omitempty"`
	// contains filtered or unexported fields
}

func NewOrLoadConfigFile

func NewOrLoadConfigFile(path string) (*Config, error)

func (*Config) GetCACert

func (c *Config) GetCACert() []byte

func (*Config) Save

func (c *Config) Save() error

func (*Config) SetCACert

func (c *Config) SetCACert(ca []byte)

func (*Config) SetPath

func (c *Config) SetPath(path string)

type CosmoDashClient

type CosmoDashClient struct {
	AuthServiceClient      dashboardv1alpha1connect.AuthServiceClient
	UserServiceClient      dashboardv1alpha1connect.UserServiceClient
	WorkspaceServiceClient dashboardv1alpha1connect.WorkspaceServiceClient
	TemplateServiceClient  dashboardv1alpha1connect.TemplateServiceClient
	WebAuthnServiceClient  dashboardv1alpha1connect.WebAuthnServiceClient
}

func NewCosmoDashClient

func NewCosmoDashClient(httpClient connect.HTTPClient, baseURL string) (*CosmoDashClient, error)

type Filter

type Filter struct {
	Key      string
	Value    string
	Operator string
}

func ParseFilters

func ParseFilters(filterExpressions []string) ([]Filter, error)

type RootOptions

type RootOptions struct {
	UseKubeAPI               bool
	KubeConfigPath           string
	KubeContext              string
	DashboardURL             string
	ConfigPath               string
	LogLevel                 int
	DisableUseServiceAccount bool

	Versions        VersionInfo
	Ctx             context.Context
	Logr            *clog.Logger
	KosmoClient     *kosmo.Client
	CosmoDashClient *CosmoDashClient
	CliConfig       *Config
}

func NewRootOptions

func NewRootOptions() *RootOptions

func (*RootOptions) AddFlags

func (o *RootOptions) AddFlags(cmd *cobra.Command)

func (*RootOptions) Complete

func (o *RootOptions) Complete(cmd *cobra.Command, args []string) error

func (*RootOptions) CompleteWithoutClient

func (o *RootOptions) CompleteWithoutClient(cmd *cobra.Command, args []string) error

func (*RootOptions) GetConfigFilePath

func (o *RootOptions) GetConfigFilePath() (string, error)

func (*RootOptions) GetDashboardURL

func (o *RootOptions) GetDashboardURL() string

func (*RootOptions) Logger

func (o *RootOptions) Logger() *clog.Logger

func (*RootOptions) Validate

func (o *RootOptions) Validate(cmd *cobra.Command, args []string) error

type RunCommand

type RunCommand interface {
	RunE(*cobra.Command, []string) error
	Logger() *clog.Logger
}

type VersionInfo

type VersionInfo struct {
	Version string
	Commit  string
	Date    string
}

Jump to

Keyboard shortcuts

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