Documentation ¶
Index ¶
- Constants
- Variables
- func AddKubernetesContext(name, namespace, buildkitURL string)
- func AddOktetoContext(name string, u *types.User, namespace, personalNamespace string)
- func AddOktetoCredentialsToCfg(cfg *clientcmdapi.Config, cred *types.Credential, namespace, userName string, ...) error
- func AddSchema(oCtx string) string
- func ContextExists() bool
- func GetContextCertificate() (*x509.Certificate, error)
- func GetContextCertificateStateless(certB64 string) (*x509.Certificate, error)
- func GetDiscoveryClient() (discovery.DiscoveryInterface, *rest.Config, error)
- func GetDynamicClient() (dynamic.Interface, *rest.Config, error)
- func GetExternalRegistryCredentials(registryOrImage string) (string, string, error)
- func GetExternalRegistryCredentialsStateless(registryOrImage string, isOkteto bool, c *Client) (string, string, error)
- func GetExternalRegistryCredentialsWithContext(ctx context.Context, registryOrImage string) (string, string, error)
- func GetExternalRegistryCredentialsWithContextStateless(ctx context.Context, registryOrImage string, isOkteto bool, c *Client) (string, string, error)
- func GetK8sClient() (*kubernetes.Clientset, *rest.Config, error)
- func GetK8sClientWithLogger(oktetoK8sLogger *io.K8sLogger) (*kubernetes.Clientset, *rest.Config, error)
- func GetKubernetesTimeout() time.Duration
- func GetSanitizedUsername() string
- func GetServerNameOverride() string
- func GetSubdomain() string
- func HasBeenLogged(oktetoURL string) bool
- func InDevContainer() bool
- func InitContextWithDeprecatedToken()
- func IsContextInitialized() bool
- func IsErrGithubMissingBusinessEmail(err error) bool
- func IsInsecureSkipTLSVerifyPolicy() bool
- func IsOkteto() bool
- func IsOktetoCloud() bool
- func IsOktetoContext(contextName string) bool
- func K8sContextToOktetoUrl(ctx context.Context, k8sContext, k8sNamespace string, ...) string
- func RemoveSchema(uri string) string
- func SetInsecureSkipTLSVerifyPolicy(isInsecure bool)
- func SetServerNameOverride(serverNameOverride string)
- func TranslateAuthError(err error) error
- func UrlToKubernetesContext(uri string) string
- type Client
- func (c *Client) Auth(ctx context.Context, code string) (*types.User, error)
- func (c *Client) Endpoint() types.EndpointClientInterface
- func (c *Client) Kubetoken() types.KubetokenInterface
- func (c *Client) Namespaces() types.NamespaceInterface
- func (c *Client) Pipeline() types.PipelineInterface
- func (c *Client) Previews() types.PreviewInterface
- func (c *Client) Stream() types.StreamInterface
- func (c *Client) User() types.UserInterface
- type ClientCfg
- type ClientProvider
- type Component
- type Config
- func (Config) GetContextCertificate() (*x509.Certificate, error)
- func (Config) GetContextName() string
- func (Config) GetExternalRegistryCredentials(registryHost string) (string, string, error)
- func (Config) GetGlobalNamespace() string
- func (Config) GetNamespace() string
- func (Config) GetRegistryURL() string
- func (Config) GetServerNameOverride() string
- func (Config) GetToken() string
- func (Config) GetUserID() string
- func (Config) IsInsecureSkipTLSVerifyPolicy() bool
- func (Config) IsOktetoCluster() bool
- type ConfigStateless
- func (c ConfigStateless) GetContextCertificate() (*x509.Certificate, error)
- func (c ConfigStateless) GetContextName() string
- func (c ConfigStateless) GetExternalRegistryCredentials(registryHost string) (string, string, error)
- func (c ConfigStateless) GetGlobalNamespace() string
- func (c ConfigStateless) GetNamespace() string
- func (c ConfigStateless) GetRegistryURL() string
- func (ConfigStateless) GetServerNameOverride() string
- func (c ConfigStateless) GetToken() string
- func (c ConfigStateless) GetUserID() string
- func (c ConfigStateless) IsInsecureSkipTLSVerifyPolicy() bool
- func (c ConfigStateless) IsOktetoCluster() bool
- type Context
- type ContextConfigWriter
- type ContextConfigWriterInterface
- type ContextInterface
- type ContextStateless
- func (oc *ContextStateless) ExistsContext() bool
- func (oc *ContextStateless) GetCurrentBuilder() string
- func (oc *ContextStateless) GetCurrentCertStr() string
- func (oc *ContextStateless) GetCurrentCfg() *clientcmdapi.Config
- func (oc *ContextStateless) GetCurrentName() string
- func (oc *ContextStateless) GetCurrentNamespace() string
- func (oc *ContextStateless) GetCurrentRegister() string
- func (oc *ContextStateless) GetCurrentToken() string
- func (oc *ContextStateless) GetCurrentUser() string
- func (oc *ContextStateless) GetGlobalNamespace() string
- func (oc *ContextStateless) GetTokenByContextName(name string) (string, error)
- func (oc *ContextStateless) IsInsecure() bool
- func (oc *ContextStateless) IsOkteto() bool
- func (oc *ContextStateless) SetCurrentCfg(cfg *clientcmdapi.Config)
- func (oc *ContextStateless) SetGlobalNamespace(globalNamespace string)
- func (oc *ContextStateless) UseContextByBuilder()
- type ContextStore
- type ContextViewer
- type EndpointInfo
- type InputVariable
- type K8sClient
- func (*K8sClient) GetIngressClient() (*ingresses.Client, error)
- func (k *K8sClient) Provide(clientApiConfig *clientcmdapi.Config) (kubernetes.Interface, *rest.Config, error)
- func (*K8sClient) ProvideWithLogger(clientApiConfig *clientcmdapi.Config, k8sLogger *ioCtrl.K8sLogger) (kubernetes.Interface, *rest.Config, error)
- type K8sClientProvider
- type K8sClientProviderWithLogger
- type Option
- type PreviewEnv
- type PreviewScope
- type Space
- type SpaceQuery
- type Token
Constants ¶
const ( // CloudURL is the default URL of okteto CloudURL = "https://cloud.okteto.com" // CloudRegistryURL is the default URL of okteto registry CloudRegistryURL = "registry.cloud.okteto.net" // CloudBuildKitURL is the default URL of okteto buildkit CloudBuildKitURL = "tcp://buildkit.cloud.okteto.net:1234" // CloudBuildKitCert is the default certificate of okteto buildkit CloudBuildKitCert = `` /* 1950-byte string literal not displayed */ // StagingURL is the default URL of okteto StagingURL = "https://staging.okteto.dev" )
const ( // Deployment k8s deployemnt kind Deployment = "Deployment" // StatefulSet k8s statefulset kind StatefulSet = "StatefulSet" // Job k8s Job kind Job = "job" // CronJob k8s CronJob kind CronJob = "CronJob" )
const ( RunningStatus = "running" NotRunningStatus = "not-running" CompletedStatus = "completed" PullingStatus = "pulling" ProgressingStatus = "progressing" BootingStatus = "booting" ErrorStatus = "error" )
Variables ¶
var ( // ErrGithubMissingBusinessEmail is raised when the user does not have a business email ErrGithubMissingBusinessEmail = errors.New("github-missing-business-email") ErrUnauthorizedGlobalCreation = errors.New("you are not authorized to create a global preview env") )
var ( ErrDeployPipelineLabelsFeatureNotSupported = oktetoErrors.UserError{ E: errors.New(`deploying a preview environments with labels requires a more recent version of Okteto. Consider removing the "--label" flag, or please upgrade to the latest version`), Hint: "For more information and upgrade instructions, please visit our docs at https://www.okteto.com/docs or contact your system administrator.", } )
var ( errors.New("k8s unauthorized error") )ErrK8sUnauthorised =
var (
ErrLabelsFeatureNotSupported = fmt.Errorf(`Filtering preview environments by label requires a more recent version of Okteto.
Consider removing the "--label" flag, or please upgrade to the latest version.
For more information and upgrade instructions, please visit our docs at https://www.okteto.com/docs or contact your system administrator.`)
)
var TransitionStatus = map[string]bool{ BootingStatus: true, ProgressingStatus: true, PullingStatus: true, }
Functions ¶
func AddKubernetesContext ¶
func AddKubernetesContext(name, namespace, buildkitURL string)
func AddOktetoContext ¶
func AddOktetoCredentialsToCfg ¶
func AddOktetoCredentialsToCfg(cfg *clientcmdapi.Config, cred *types.Credential, namespace, userName string, oktetoContext Context) error
AddOktetoCredentialsToCfg populates the provided kubernetes config using the provided credentials obtained from the Okteto API
func ContextExists ¶
func ContextExists() bool
ContextExists checks if an okteto context has been created
func GetContextCertificate ¶
func GetContextCertificate() (*x509.Certificate, error)
func GetContextCertificateStateless ¶
func GetContextCertificateStateless(certB64 string) (*x509.Certificate, error)
func GetDiscoveryClient ¶
func GetDiscoveryClient() (discovery.DiscoveryInterface, *rest.Config, error)
GetDiscoveryClient return a kubernetes discovery client for the current okteto context
func GetDynamicClient ¶
GetDynamicClient returns a kubernetes dynamic client for the current okteto context
func GetExternalRegistryCredentials ¶
GetExternalRegistryCredentials returns registry credentials for a registry defined in okteto without rely on an okteto context global var. This function is mostly executed by internal libraries (registry, docker credentials helpers, etc) and we need to respect this signature. For this reason, context is managed internally by the function.
func GetExternalRegistryCredentialsStateless ¶
func GetExternalRegistryCredentialsStateless(registryOrImage string, isOkteto bool, c *Client) (string, string, error)
GetExternalRegistryCredentialsStateless returns registry credentials for a registry defined in okteto. This function is mostly executed by internal libraries (registry, docker credentials helpers, etc) and we need to respect this signature. For this reason, context is managed internally by the function.
func GetK8sClient ¶
func GetK8sClient() (*kubernetes.Clientset, *rest.Config, error)
GetK8sClient returns a kubernetes client for the current okteto context and a kubernetes config object
func GetK8sClientWithLogger ¶
func GetK8sClientWithLogger(oktetoK8sLogger *io.K8sLogger) (*kubernetes.Clientset, *rest.Config, error)
GetK8sClientWithLogger returns a kubernetes client for the current okteto context and a kubernetes config object
func GetKubernetesTimeout ¶
func GetSanitizedUsername ¶
func GetSanitizedUsername() string
GetSanitizedUsername returns the username of the authenticated user sanitized to be DNS compatible
func GetServerNameOverride ¶
func GetServerNameOverride() string
func GetSubdomain ¶
func GetSubdomain() string
func HasBeenLogged ¶
func InDevContainer ¶
func InDevContainer() bool
InDevContainer returns true if running in an okteto dev container
func InitContextWithDeprecatedToken ¶
func InitContextWithDeprecatedToken()
InitContextWithDeprecatedToken initializes the okteto context if an old fashion exists and it matches the current kubernetes context this function is to make "okteto context" transparent to current Okteto Enterprise users, but it can be removed when people upgrade
func IsContextInitialized ¶
func IsContextInitialized() bool
func IsErrGithubMissingBusinessEmail ¶
IsErrGithubMissingBusinessEmail returns true if the error is ErrGithubMissingBusinessEmail
func IsInsecureSkipTLSVerifyPolicy ¶
func IsInsecureSkipTLSVerifyPolicy() bool
func IsOktetoCloud ¶
func IsOktetoCloud() bool
func IsOktetoContext ¶
IsOktetoContext returns if the contextName param is Okteto
func K8sContextToOktetoUrl ¶
func K8sContextToOktetoUrl(ctx context.Context, k8sContext, k8sNamespace string, clientProvider K8sClientProvider) string
K8sContextToOktetoUrl translates k8s contexts like cloud_okteto_com to hettps://cloud.okteto.com
func RemoveSchema ¶
func SetInsecureSkipTLSVerifyPolicy ¶
func SetInsecureSkipTLSVerifyPolicy(isInsecure bool)
func SetServerNameOverride ¶
func SetServerNameOverride(serverNameOverride string)
func TranslateAuthError ¶
TranslateAuthError returns a legible error text depending if is custom error
func UrlToKubernetesContext ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implementation to connect to Okteto API
func NewOktetoClient ¶
NewOktetoClient creates a new client to connect with Okteto API
func NewOktetoClientFromUrl ¶
NewOktetoClientFromUrl creates a new client to connect with Okteto API provided an url
func NewOktetoClientFromUrlAndToken ¶
NewOktetoClientFromUrlAndToken creates a new client to connect with Okteto API provided url and token
func NewOktetoClientStateless ¶
NewOktetoClientStateless creates a new client to connect with Okteto API
func (*Client) Endpoint ¶
func (c *Client) Endpoint() types.EndpointClientInterface
Endpoint retrieves the Endpoint client
func (*Client) Kubetoken ¶
func (c *Client) Kubetoken() types.KubetokenInterface
Kubetoken retrieves the Kubetoken client
func (*Client) Namespaces ¶
func (c *Client) Namespaces() types.NamespaceInterface
Namespaces retrieves the NamespaceClient
func (*Client) Pipeline ¶
func (c *Client) Pipeline() types.PipelineInterface
Pipeline retrieves the Pipeline client
func (*Client) Previews ¶
func (c *Client) Previews() types.PreviewInterface
Previews retrieves the Previews client
func (*Client) Stream ¶
func (c *Client) Stream() types.StreamInterface
Stream retrieves the Stream client
type ClientProvider ¶
type ClientProvider struct{}
func NewOktetoClientProvider ¶
func NewOktetoClientProvider() *ClientProvider
func (*ClientProvider) Provide ¶
func (*ClientProvider) Provide(opts ...Option) (types.OktetoInterface, error)
type Component ¶
type Component struct { DeployedBy graphql.String Endpoints []EndpointInfo }
type Config ¶
type Config struct{}
func (Config) GetContextCertificate ¶
func (Config) GetContextCertificate() (*x509.Certificate, error)
func (Config) GetContextName ¶
func (Config) GetExternalRegistryCredentials ¶
func (Config) GetGlobalNamespace ¶
func (Config) GetNamespace ¶
func (Config) GetRegistryURL ¶
func (Config) GetServerNameOverride ¶
func (Config) IsInsecureSkipTLSVerifyPolicy ¶
func (Config) IsOktetoCluster ¶
type ConfigStateless ¶
type ConfigStateless struct { GetTokenFn func(string) (string, error) GlobalNamespace string Namespace string RegistryUrl string UserId string Token string Cert string ServerNameOverride string ContextName string InsecureSkipTLSVerifyPolicy bool IsOkteto bool }
func (ConfigStateless) GetContextCertificate ¶
func (c ConfigStateless) GetContextCertificate() (*x509.Certificate, error)
func (ConfigStateless) GetContextName ¶
func (c ConfigStateless) GetContextName() string
func (ConfigStateless) GetExternalRegistryCredentials ¶
func (c ConfigStateless) GetExternalRegistryCredentials(registryHost string) (string, string, error)
func (ConfigStateless) GetGlobalNamespace ¶
func (c ConfigStateless) GetGlobalNamespace() string
func (ConfigStateless) GetNamespace ¶
func (c ConfigStateless) GetNamespace() string
func (ConfigStateless) GetRegistryURL ¶
func (c ConfigStateless) GetRegistryURL() string
func (ConfigStateless) GetServerNameOverride ¶
func (ConfigStateless) GetServerNameOverride() string
func (ConfigStateless) GetToken ¶
func (c ConfigStateless) GetToken() string
func (ConfigStateless) GetUserID ¶
func (c ConfigStateless) GetUserID() string
func (ConfigStateless) IsInsecureSkipTLSVerifyPolicy ¶
func (c ConfigStateless) IsInsecureSkipTLSVerifyPolicy() bool
func (ConfigStateless) IsOktetoCluster ¶
func (c ConfigStateless) IsOktetoCluster() bool
type Context ¶
type Context struct { Cfg *clientcmdapi.Config `json:"-" yaml:"-"` Name string `json:"name" yaml:"name,omitempty"` UserID string `json:"id,omitempty" yaml:"id,omitempty"` Username string `json:"username,omitempty" yaml:"username,omitempty"` Token string `json:"token,omitempty" yaml:"token,omitempty"` Namespace string `json:"namespace" yaml:"namespace,omitempty"` Builder string `json:"builder,omitempty" yaml:"builder,omitempty"` Registry string `json:"registry,omitempty" yaml:"registry,omitempty"` Certificate string `json:"certificate,omitempty" yaml:"certificate,omitempty"` PersonalNamespace string `json:"personalNamespace,omitempty" yaml:"personalNamespace,omitempty"` GlobalNamespace string `json:"-" yaml:"-"` ClusterType string `json:"-" yaml:"-"` CompanyName string `json:"-" yaml:"-"` IsOkteto bool `json:"isOkteto,omitempty" yaml:"isOkteto,omitempty"` IsStoredAsInsecure bool `json:"isInsecure,omitempty" yaml:"isInsecure,omitempty"` IsInsecure bool `json:"-" yaml:"-"` Analytics bool `json:"-" yaml:"-"` IsTrial bool `json:"-" yaml:"-"` }
Context contains the information related to an okteto context
func GetContext ¶
func GetContext() *Context
func (*Context) SetClusterType ¶
func (*Context) ToViewer ¶
func (c *Context) ToViewer() *ContextViewer
ToViewer transforms to a viewer struct
type ContextConfigWriter ¶
type ContextConfigWriter struct{}
ContextConfigWriter writes the information about the context config into stdout
func NewContextConfigWriter ¶
func NewContextConfigWriter() *ContextConfigWriter
func (*ContextConfigWriter) Write ¶
func (*ContextConfigWriter) Write() error
type ContextConfigWriterInterface ¶
type ContextConfigWriterInterface interface {
Write() error
}
type ContextInterface ¶
type ContextInterface interface { GetCurrentName() string GetCurrentCfg() *clientcmdapi.Config GetCurrentNamespace() string GetGlobalNamespace() string GetCurrentBuilder() string GetCurrentCertStr() string GetCurrentToken() string GetCurrentUser() string GetCurrentRegister() string ExistsContext() bool IsOkteto() bool IsInsecure() bool UseContextByBuilder() GetTokenByContextName(name string) (string, error) }
type ContextStateless ¶
type ContextStateless struct {
Store *ContextStore
}
func (*ContextStateless) ExistsContext ¶
func (oc *ContextStateless) ExistsContext() bool
func (*ContextStateless) GetCurrentBuilder ¶
func (oc *ContextStateless) GetCurrentBuilder() string
func (*ContextStateless) GetCurrentCertStr ¶
func (oc *ContextStateless) GetCurrentCertStr() string
func (*ContextStateless) GetCurrentCfg ¶
func (oc *ContextStateless) GetCurrentCfg() *clientcmdapi.Config
func (*ContextStateless) GetCurrentName ¶
func (oc *ContextStateless) GetCurrentName() string
func (*ContextStateless) GetCurrentNamespace ¶
func (oc *ContextStateless) GetCurrentNamespace() string
func (*ContextStateless) GetCurrentRegister ¶
func (oc *ContextStateless) GetCurrentRegister() string
func (*ContextStateless) GetCurrentToken ¶
func (oc *ContextStateless) GetCurrentToken() string
func (*ContextStateless) GetCurrentUser ¶
func (oc *ContextStateless) GetCurrentUser() string
func (*ContextStateless) GetGlobalNamespace ¶
func (oc *ContextStateless) GetGlobalNamespace() string
func (*ContextStateless) GetTokenByContextName ¶
func (oc *ContextStateless) GetTokenByContextName(name string) (string, error)
func (*ContextStateless) IsInsecure ¶
func (oc *ContextStateless) IsInsecure() bool
func (*ContextStateless) IsOkteto ¶
func (oc *ContextStateless) IsOkteto() bool
func (*ContextStateless) SetCurrentCfg ¶
func (oc *ContextStateless) SetCurrentCfg(cfg *clientcmdapi.Config)
func (*ContextStateless) SetGlobalNamespace ¶
func (oc *ContextStateless) SetGlobalNamespace(globalNamespace string)
func (*ContextStateless) UseContextByBuilder ¶
func (oc *ContextStateless) UseContextByBuilder()
type ContextStore ¶
type ContextStore struct { Contexts map[string]*Context `json:"contexts"` CurrentContext string `json:"current-context"` }
var (
CurrentStore *ContextStore
)
func GetContextStore ¶
func GetContextStore() *ContextStore
func GetContextStoreFromStorePath ¶
func GetContextStoreFromStorePath() *ContextStore
type ContextViewer ¶
type ContextViewer struct { Name string `json:"name" yaml:"name,omitempty"` Namespace string `json:"namespace" yaml:"namespace,omitempty"` Builder string `json:"builder,omitempty" yaml:"builder,omitempty"` Registry string `json:"registry,omitempty" yaml:"registry,omitempty"` Current bool `json:"current" yaml:"current"` }
ContextViewer contains info to show
type EndpointInfo ¶
type InputVariable ¶
type K8sClient ¶
type K8sClient struct {
// contains filtered or unexported fields
}
func NewK8sClientProvider ¶
func NewK8sClientProvider() *K8sClient
NewK8sClientProvider returns new K8sClient
func NewK8sClientProviderWithLogger ¶
NewK8sClientProviderWithLogger returns new K8sClient that logs all requests to k8s
func (*K8sClient) GetIngressClient ¶
func (*K8sClient) Provide ¶
func (k *K8sClient) Provide(clientApiConfig *clientcmdapi.Config) (kubernetes.Interface, *rest.Config, error)
func (*K8sClient) ProvideWithLogger ¶
func (*K8sClient) ProvideWithLogger(clientApiConfig *clientcmdapi.Config, k8sLogger *ioCtrl.K8sLogger) (kubernetes.Interface, *rest.Config, error)
type K8sClientProvider ¶
type K8sClientProvider interface {
Provide(clientApiConfig *clientcmdapi.Config) (kubernetes.Interface, *rest.Config, error)
}
type K8sClientProviderWithLogger ¶
type K8sClientProviderWithLogger interface {
ProvideWithLogger(clientApiConfig *clientcmdapi.Config, k8sLogger *ioCtrl.K8sLogger) (kubernetes.Interface, *rest.Config, error)
}
type PreviewEnv ¶
type PreviewEnv struct { ID string `json:"id" yaml:"id"` Job string `json:"job" yaml:"job"` Scope string `json:"scope" yaml:"scope"` Sleeping bool `json:"sleeping" yaml:"sleeping"` }
PreviewEnv represents an Okteto preview environment
type PreviewScope ¶
type SpaceQuery ¶
type SpaceQuery struct {
Response Space `graphql:"space(id: $id)"`
}
type Token ¶
type Token struct { URL string `json:"URL"` Buildkit string `json:"Buildkit"` Registry string `json:"Registry"` ID string `json:"ID"` Username string `json:"Username"` Token string `json:"Token"` MachineID string `json:"MachineID"` }
Token contains the auth token and the URL it belongs to