Documentation
¶
Index ¶
- Constants
- func Age(createTime v1.Time) string
- func ConcatURLParams(urlParams map[string]string) string
- func FormatStringSlice(in []string) string
- func GenerateKeycloakAPIURL(codeChallenge string, redirectURI string, state string, ...) (string, error)
- func GenerateKeycloakTokenURL(verrazzanoAPIURL string) (string, error)
- func GenerateRandomCodePair() (string, string, error)
- func GenerateRandomState() (string, error)
- func GenerateRedirectURI(listener net.Listener) string
- func GetCAData(name string) ([]byte, error)
- func GetClientID() string
- func GetCurrentContextFromKubeConfig() (string, error)
- func GetKeycloakURL(verrazzanoAPIURL string) (string, error)
- func GetVerrazzanoAPIURL(name string) (string, error)
- func GetVerrazzanoRealm() string
- func IsLoggedIn() (bool, error)
- func IsLoggedOut() (bool, error)
- func OpenURLInBrowser(url string) error
- func PrintTable(headings []string, data [][]string, w io.Writer) error
- func RemoveAllAuthData() error
- func RemoveClusterFromKubeConfig(name string) error
- func RemoveContextFromKubeConfig(name string) error
- func RemoveUserFromKubeConfig(name string) error
- func ServerSideApply(config *rest.Config, yaml string) error
- func SetClusterInKubeConfig(name string, serverURL string, caData []byte) error
- func SetContextInKubeConfig(name string, clusterName string, userName string) error
- func SetCurrentContextInKubeConfig(name string) error
- func SetUserInKubeConfig(name string, accessToken string, authDetails AuthDetails) error
- func WriteToKubeConfig(kubeConfig Config) error
- type AuthDetails
- type Config
- type Kubernetes
- type NamedKeycloakTokenInfo
- type PrintFlags
- type TokenInfo
Constants ¶
const BufferTime = 10
Assuming that the api call will take place within Buffer seconds from checking validity of token
const KubeConfigKeywordVerrazzano = "verrazzano"
To be used as nick name for Verrazzano related clusters,contexts,users,etc in kubeconfig
const (
NothingFound = "no resources found"
)
Variables ¶
This section is empty.
Functions ¶
func Age ¶
Age takes a Time and returns the length of time from then to now in a compact format like 2d3h
func ConcatURLParams ¶ added in v1.1.0
Accepts url parameters in the form of map[string][string] Returns concatenated list of url parameters Return string of the form `code=xyz&status=abc`
func FormatStringSlice ¶
FormatStringSlice formats a string slice as a comma separated list
func GenerateKeycloakAPIURL ¶ added in v1.1.0
func GenerateKeycloakAPIURL(codeChallenge string, redirectURI string, state string, verrazzanoAPIURL string) (string, error)
Generates the keycloak api url to login Return string of the form `https://keycloak.xyz.io:123/auth/realms/verrazzano-system/protocol/openid-connect/auth?redirect_uri=abc&state=xyz...`
func GenerateKeycloakTokenURL ¶ added in v1.1.0
Gnerates and returns keycloak server api url to get the jwt token Return string of the form `https://keycloak.xyz.io:123/auth/realms/verrazzano-system/protocol/openid-connect/token
func GenerateRandomCodePair ¶ added in v1.1.0
Generates a random code verifier and then produces a code challenge using it. Returns the produced code_verifier and code_challenge pair
func GenerateRandomState ¶ added in v1.1.0
Generates a random string which is used as the state
func GenerateRedirectURI ¶ added in v1.1.0
Generates redirect_uri using the given port number return string of the form `http://localhost:1234`
func GetCAData ¶ added in v1.1.0
Returns the certificate authority data already present in kubeconfig
func GetCurrentContextFromKubeConfig ¶ added in v1.1.0
Returns the current context in kubeconfig
func GetKeycloakURL ¶ added in v1.1.0
Returns the keycloak base url
func GetVerrazzanoAPIURL ¶ added in v1.1.0
Returns the Verrazzano api server url
func GetVerrazzanoRealm ¶ added in v1.1.0
func GetVerrazzanoRealm() string
Returns the realm name the oidc client is part of
func IsLoggedIn ¶ added in v1.1.0
Helper function to find if the user is logged in
func IsLoggedOut ¶ added in v1.1.0
Helper function to find if the user is logged out
func OpenURLInBrowser ¶ added in v1.1.0
Non-blocking browser opener function
func PrintTable ¶
PrintTable will print the data in a well-formatted table with the headings at top
func RemoveAllAuthData ¶ added in v1.1.0
func RemoveAllAuthData() error
Helper function that removes all the user details from kubeconfig
func RemoveClusterFromKubeConfig ¶ added in v1.1.0
Removes a cluster with given name from kubeconfig
func RemoveContextFromKubeConfig ¶ added in v1.1.0
Removes a context with given name from kubeconfig
func RemoveUserFromKubeConfig ¶ added in v1.1.0
Removes a user with given name from kubeconfig
func SetClusterInKubeConfig ¶ added in v1.1.0
Adds a cluster to kubeconfig
func SetContextInKubeConfig ¶ added in v1.1.0
Adds a new context to kubeconfig
func SetCurrentContextInKubeConfig ¶ added in v1.1.0
Changes current cluster to given cluster in kubeconfig
func SetUserInKubeConfig ¶ added in v1.1.0
func SetUserInKubeConfig(name string, accessToken string, authDetails AuthDetails) error
Adds a user to kubeconfig
func WriteToKubeConfig ¶ added in v1.1.0
Writes the given interface map to kubeconfig
Types ¶
type AuthDetails ¶ added in v1.1.0
Struct to store user's authentication data
func GetAuthDetails ¶ added in v1.1.0
func GetAuthDetails(name string) (AuthDetails, error)
Returns tokens and expiration times wrapped up in a struct
type Config ¶ added in v1.1.0
type Config struct { *clientcmdapi.Config `json:",inline"` KeycloakTokenInfos []NamedKeycloakTokenInfo `json:"keycloakTokenInfo,omitempty"` }
func ReadKubeConfig ¶ added in v1.1.0
Reads the kubeconfig into a interface map
type Kubernetes ¶ added in v0.17.0
type Kubernetes interface { GetKubeConfig() (*rest.Config, error) NewClustersClientSet() (clientset.Interface, error) NewProjectClientSet() (projectclientset.Interface, error) NewVerrazzanoClientSet() (verrazzanoclientset.Interface, error) NewClientSet() (kubernetes.Interface, error) }
type NamedKeycloakTokenInfo ¶ added in v1.1.0
type PrintFlags ¶ added in v0.17.0
type PrintFlags struct { JSONYamlPrintFlags *genericclioptions.JSONYamlPrintFlags TemplateFlags *genericclioptions.KubeTemplatePrintFlags OutputFormat *string }
PrintFlags contains all the flags used for output options
func NewGetPrintFlags ¶ added in v0.17.0
func NewGetPrintFlags() *PrintFlags
NewGetPrintFlags returns a new PrintFlags struct for use
func (*PrintFlags) AddFlags ¶ added in v0.17.0
func (f *PrintFlags) AddFlags(cmd *cobra.Command)
AddFlags binds all the required flags for output to the cmd
func (*PrintFlags) AllowedFormats ¶ added in v0.17.0
func (f *PrintFlags) AllowedFormats() []string
AllowedFormats is a list of all the allowed formats for output options
func (*PrintFlags) ToPrinter ¶ added in v0.17.0
func (f *PrintFlags) ToPrinter() (printers.ResourcePrinter, error)
ToPrinter returns an appropriate printer based on the output format or returns an error if there is none
type TokenInfo ¶ added in v1.1.0
type TokenInfo struct { // Refresh token is a jwt token used to refresh the access token // +optional RefreshToken string `json:"refreshToken"` // Time until which access token will be alive // +optional AccessTokenExpTime int64 `json:"accessTokenExpTime"` // Time intil which refresh token will be alive // +optional RefreshTokenExpTime int64 `json:"refreshTokenExpTime"` }