upbound

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UserAgent is the default user agent to use to make requests to the
	// Upbound API.
	UserAgent = "up-cli"
	// CookieName is the default cookie name used to identify a session token.
	CookieName = "SID"
)

Variables

This section is empty.

Functions

func GetOrganization added in v0.29.0

func GetOrganization(ctx context.Context, ac *accounts.Client, account string) (*accounts.AccountResponse, error)

func JSON added in v0.25.0

func JSON(base, overlay io.Reader) (kong.Resolver, error)

JSON returns a Resolver that retrieves values from a JSON source. Based slightly off of https://github.com/alecthomas/kong/blob/f48da244f54370c0cb63e22b0e500e5459a491bf/resolver.go#L33-L60 Hyphens in flag names are replaced with underscores.

Types

type Context

type Context struct {
	// Profile fields
	ProfileName string
	Profile     profile.Profile
	Token       string
	Cfg         *config.Config
	CfgSrc      config.Source
	Account     string

	// Kubeconfig fields
	Kubecfg clientcmd.ClientConfig

	// Upbound API connection URLs
	Domain                *url.URL
	APIEndpoint           *url.URL
	AuthEndpoint          *url.URL
	ProxyEndpoint         *url.URL
	RegistryEndpoint      *url.URL
	InsecureSkipTLSVerify bool

	// Debugging
	DebugLevel    int
	WrapTransport func(rt http.RoundTripper) http.RoundTripper
	// contains filtered or unexported fields
}

Context includes common data that Upbound consumers may utilize.

func NewFromFlags added in v0.25.0

func NewFromFlags(f Flags, opts ...Option) (*Context, error)

NewFromFlags constructs a new context from flags.

func (*Context) BuildCloudSpaceClientConfig added in v0.29.0

func (c *Context) BuildCloudSpaceClientConfig(ctx context.Context, spaceName, organization string) (clientcmd.ClientConfig, error)

BuildCloudSpaceClientConfig builds a Kubeconfig pointed at an Upbound cloud-hosted space. Uses the space name as the current context

func (*Context) BuildCloudSpaceRestConfig added in v0.29.0

func (c *Context) BuildCloudSpaceRestConfig(ctx context.Context, spaceName, profileName string) (*rest.Config, error)

BuildCloudSpaceRestConfig builds a REST config pointed at an Upbound cloud-hosted space suitable for usage with any K8s controller-runtime client.

func (*Context) BuildControllerClientConfig added in v0.29.0

func (c *Context) BuildControllerClientConfig() (*rest.Config, error)

BuildControllerClientConfig builds a REST config suitable for usage with any K8s controller-runtime client.

func (*Context) BuildCurrentContextClient added in v0.29.0

func (c *Context) BuildCurrentContextClient() (client.Client, error)

BuildCurrentContextClient creates a K8s client using the current Kubeconfig defaulting to the current Kubecontext

func (*Context) BuildSDKAuthConfig added in v0.29.0

func (c *Context) BuildSDKAuthConfig() (*up.Config, error)

BuildSDKAuthConfig builds an Upbound SDK config pointed at the Upbound auth endpoint.

func (*Context) BuildSDKConfig added in v0.25.0

func (c *Context) BuildSDKConfig() (*up.Config, error)

BuildSDKConfig builds an Upbound SDK config suitable for usage with any service client.

func (*Context) GetCurrentContext added in v0.29.0

func (c *Context) GetCurrentContext() (context *clientcmdapi.Context, cluster *clientcmdapi.Cluster, auth *clientcmdapi.AuthInfo, exists bool)

func (*Context) GetCurrentSpaceContextScope added in v0.29.0

func (c *Context) GetCurrentSpaceContextScope() (string, types.NamespacedName, bool)

func (*Context) HasValidContext added in v0.29.0

func (c *Context) HasValidContext() bool

HasValidContext returns true if the kube configuration attached to the context is valid and usable.

type Flags added in v0.25.0

type Flags struct {
	// Optional
	Domain  *url.URL `env:"UP_DOMAIN" default:"https://upbound.io" help:"Root Upbound domain." json:"domain,omitempty"`
	Profile string   `env:"UP_PROFILE" help:"Profile used to execute command." predictor:"profiles" json:"profile,omitempty"`
	Account string   `short:"a" env:"UP_ACCOUNT" help:"Account used to execute command." json:"account,omitempty"`

	// Insecure
	InsecureSkipTLSVerify bool `env:"UP_INSECURE_SKIP_TLS_VERIFY" help:"[INSECURE] Skip verifying TLS certificates." json:"insecureSkipTLSVerify,omitempty"`
	Debug                 int  `` /* 199-byte string literal not displayed */

	// Hidden
	APIEndpoint      *url.URL `` /* 138-byte string literal not displayed */
	AuthEndpoint     *url.URL `` /* 142-byte string literal not displayed */
	ProxyEndpoint    *url.URL `` /* 146-byte string literal not displayed */
	RegistryEndpoint *url.URL `` /* 158-byte string literal not displayed */
}

Flags are common flags used by commands that interact with Upbound.

func (Flags) MarshalJSON added in v0.25.0

func (f Flags) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Flags struct, converting the url.URL to strings.

type KubeFlags added in v0.25.0

type KubeFlags struct {
	// Kubeconfig is the kubeconfig file path to read. If empty, it refers to
	// client-go's default kubeconfig location.
	Kubeconfig string `type:"existingfile" help:"Override default kubeconfig path."`
	// Context is the context within Kubeconfig to read. If empty, it refers
	// to the default context.
	Context string `name:"kubecontext" help:"Override default kubeconfig context."`
	// contains filtered or unexported fields
}

func (*KubeFlags) AfterApply added in v0.25.0

func (f *KubeFlags) AfterApply() error

func (*KubeFlags) GetConfig added in v0.25.0

func (f *KubeFlags) GetConfig() *rest.Config

GetConfig returns the *rest.Config from KubeFlags. Returns nil unless AfterApply has been called.

func (*KubeFlags) GetContext added in v0.25.0

func (f *KubeFlags) GetContext() string

GetContext returns the kubeconfig context from KubeFlags. Returns empty string unless AfterApply has been called. Returns KubeFlags.Context if it's defined, otherwise the name of the default context in the config resolved from KubeFlags.Kubeconfig. NOTE(branden): This ensures that a profile created from this context will continue to work with the same cluster if the kubeconfig's default context is changed.

func (*KubeFlags) Namespace added in v0.25.0

func (f *KubeFlags) Namespace() string

type Option added in v0.25.0

type Option func(*Context)

Option modifies a Context

func AllowMissingProfile added in v0.25.0

func AllowMissingProfile() Option

AllowMissingProfile indicates that Context should still be returned even if a profile name is supplied and it does not exist in config.

type TokenFile added in v0.25.0

type TokenFile struct {
	AccessID string `json:"accessId"`
	Token    string `json:"token"`
}

TokenFile is the format in which Upbound tokens are stored on disk.

func TokenFromPath added in v0.25.0

func TokenFromPath(path string, opts ...TokenOption) (TokenFile, error)

TokenFromPath extracts a token from the provided path.

type TokenOption added in v0.25.0

type TokenOption func(conf *tokenConf)

TokenOption modifies how a token is obtained.

Jump to

Keyboard shortcuts

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