Documentation
¶
Overview ¶
Package api provides the Kubernetes client and configuration for the nine.ch API.
Index ¶
- Constants
- func GetToken(ctx context.Context, issuerURL, clientID string, usePKCE bool, out io.Writer) error
- func GetTokenFromConfig(ctx context.Context, cfg *rest.Config) (string, error)
- func GetTokenFromExecConfig(ctx context.Context, execConfig *api.ExecConfig) (string, error)
- func IsManagedBy(annotations map[string]string) bool
- func LoadingRules() (*clientcmd.ClientConfigLoadingRules, error)
- func NamespacedName(name, project string) types.NamespacedName
- func NewScheme() (*runtime.Scheme, error)
- func ObjectName(obj runtimeclient.Object) types.NamespacedName
- type ApplyResult
- type Client
- func (c *Client) ApplyManifest(ctx context.Context, r io.Reader) (*unstructured.Unstructured, ApplyResult, error)
- func (c *Client) ConnectionSecretData(ctx context.Context, mg resource.Managed) (map[string][]byte, error)
- func (c *Client) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error
- func (c *Client) CreateManifest(ctx context.Context, r io.Reader) (*unstructured.Unstructured, error)
- func (c *Client) DeleteManifest(ctx context.Context, r io.Reader) (*unstructured.Unstructured, error)
- func (c *Client) DeploioRuntimeClient(ctx context.Context, scheme *runtime.Scheme) (runtimeclient.Client, error)
- func (c *Client) DeploioRuntimeConfig(ctx context.Context) (*rest.Config, error)
- func (c *Client) GetConnectionSecret(ctx context.Context, mg resource.Managed) (*corev1.Secret, error)
- func (c *Client) GetObject(ctx context.Context, name string, obj runtimeclient.Object) error
- func (c *Client) ListObjects(ctx context.Context, list runtimeclient.ObjectList, options ...ListOpt) error
- func (c *Client) Name(name string) types.NamespacedName
- func (c *Client) Organization() (string, error)
- func (c *Client) Projects(ctx context.Context, onlyName string) ([]management.Project, error)
- func (c *Client) RotateCredentials(ctx context.Context, mg resource.Managed) (types.UID, error)
- func (c *Client) Token(ctx context.Context) string
- func (c *Client) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error
- type ClientOpt
- type DefaultTokenGetter
- type ListOpt
- type ListOpts
- type TokenGetter
- type UserInfo
- type WatchFunc
Constants ¶
const ( // ManagedByAnnotation is the annotation key marking objects that nctl created or updated. ManagedByAnnotation = "app.kubernetes.io/managed-by" // Name is the name of the CLI and the value of ManagedByAnnotation on objects managed by it. Name = cli.Name // RotateCredentialsAnnotation is the annotation key nctl sets to the time // it reset the credentials of a resource, // which makes the controller reconcile the resource. RotateCredentialsAnnotation = "nine.ch/rotate-credentials" )
const ( DefaultTokenCachePath = ".kube/cache/oidc-login" IssuerURLArg = "--issuer-url=" ClientIDArg = "--client-id=" ClientSecretArg = "--client-secret=" TokenURLArg = "--token-url=" UsePKCEArg = "--use-pkce" CustomersPrefix = "/Customers/" AuthCmdName = "auth" ClientCredentialsCmdName = "client-credentials" OIDCCmdName = "oidc" )
Variables ¶
This section is empty.
Functions ¶
func GetToken ¶ added in v1.1.0
GetToken executes the OIDC login flow using the kubelogin with the provided OIDC parameters writes the raw JSON ExecCredential result to out.
func GetTokenFromConfig ¶ added in v1.1.0
GetTokenFromConfig takes a rest.Config and returns a valid OIDC access token or the static bearer token if it's set in the config.
func GetTokenFromExecConfig ¶ added in v1.1.0
GetTokenFromExecConfig takes the provided execConfig, parses out the args and gets the token by executing the login flow.
func IsManagedBy ¶ added in v1.21.0
IsManagedBy reports whether the annotations mark an object as managed by nctl.
func LoadingRules ¶
func LoadingRules() (*clientcmd.ClientConfigLoadingRules, error)
func NamespacedName ¶ added in v1.1.0
func NamespacedName(name, project string) types.NamespacedName
func ObjectName ¶ added in v1.0.1
func ObjectName(obj runtimeclient.Object) types.NamespacedName
Types ¶
type ApplyResult ¶ added in v1.21.0
type ApplyResult string
ApplyResult tells what Client.ApplyManifest did with the object of the manifest.
const ( ApplyResultCreated ApplyResult = "created" ApplyResultUpdated ApplyResult = "updated" )
type Client ¶
type Client struct {
runtimeclient.WithWatch
Config *rest.Config
KubeconfigPath string
Project string
Log *log.Client
KubeconfigContext string
// contains filtered or unexported fields
}
func New ¶
func New(ctx context.Context, apiClusterContext, project string, opts ...ClientOpt) (*Client, error)
New returns a new Client by loading a kubeconfig with the supplied context and project. The kubeconfig is discovered like this: * KUBECONFIG environment variable pointing at a file * $HOME/.kube/config if exists
func (*Client) ApplyManifest ¶ added in v1.21.0
func (c *Client) ApplyManifest(ctx context.Context, r io.Reader) (*unstructured.Unstructured, ApplyResult, error)
ApplyManifest creates the object described by the YAML or JSON manifest read from r, or updates it if it already exists, and returns it along with what happened.
func (*Client) ConnectionSecretData ¶ added in v1.21.0
func (c *Client) ConnectionSecretData(ctx context.Context, mg resource.Managed) (map[string][]byte, error)
ConnectionSecretData returns the data of the connection secret referenced by mg.
func (*Client) Create ¶ added in v1.14.0
Create saves the object obj in the Kubernetes cluster. obj must be a struct pointer so that obj can be updated with the content returned by the Server.
func (*Client) CreateManifest ¶ added in v1.21.0
func (c *Client) CreateManifest(ctx context.Context, r io.Reader) (*unstructured.Unstructured, error)
CreateManifest creates the object described by the YAML or JSON manifest read from r and returns it.
func (*Client) DeleteManifest ¶ added in v1.21.0
func (c *Client) DeleteManifest(ctx context.Context, r io.Reader) (*unstructured.Unstructured, error)
DeleteManifest deletes the object described by the YAML or JSON manifest read from r and returns it.
func (*Client) DeploioRuntimeClient ¶ added in v1.8.0
func (*Client) DeploioRuntimeConfig ¶ added in v1.8.0
func (*Client) GetConnectionSecret ¶
func (*Client) GetObject ¶ added in v1.8.4
GetObject gets the object in the current client project with some ux-improvements like hinting when the object has been found in a different project of the same organization.
func (*Client) ListObjects ¶ added in v1.8.4
func (c *Client) ListObjects(ctx context.Context, list runtimeclient.ObjectList, options ...ListOpt) error
ListObjects lists objects in the current client project with some ux-improvements like hinting when a resource has been found in a different project of the same organization.
func (*Client) Organization ¶ added in v1.8.2
func (*Client) Projects ¶ added in v1.8.4
Projects returns either all existing Projects or only the specific project identified by the "onlyName" parameter
func (*Client) RotateCredentials ¶ added in v1.21.0
RotateCredentials makes the controller of mg generate new credentials and write them to a new connection secret. It deletes the connection secret of mg and then sets RotateCredentialsAnnotation on mg to the current time, like kubectl rollout restart does.
It returns the UID of the deleted secret, which is empty if the secret was missing already.
type ClientOpt ¶ added in v1.1.0
func DefaultAnnotations ¶ added in v1.14.0
DefaultAnnotations configures the client to set default annotations on all resources created or updated.
func StaticToken ¶ added in v1.7.1
StaticToken configures the client to get a bearer token once and then set it statically in the client config. This means the client will not automatically renew the token when it expires.
type DefaultTokenGetter ¶ added in v1.2.0
type DefaultTokenGetter struct{}
func (*DefaultTokenGetter) GetTokenString ¶ added in v1.2.0
type ListOpt ¶ added in v1.8.4
type ListOpt func(opts *ListOpts)
func AllNamespaces ¶ added in v1.8.4
func AllNamespaces() ListOpt
func AllProjects ¶ added in v1.8.4
func AllProjects() ListOpt
func MatchLabel ¶ added in v1.8.4
type TokenGetter ¶ added in v1.2.0
type UserInfo ¶ added in v1.2.0
func GetUserInfoFromToken ¶ added in v1.2.0
type WatchFunc ¶ added in v1.11.0
type WatchFunc func(list runtimeclient.ObjectList) error
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package config provides the nctl specific configuration stored in the kubeconfig.
|
Package config provides the nctl specific configuration stored in the kubeconfig. |
|
Package gitinfo provides a client to interact with the git information service to retrieve metadata about git repositories.
|
Package gitinfo provides a client to interact with the git information service to retrieve metadata about git repositories. |
|
Package log provides functionality to interact with the Nine logging API.
|
Package log provides functionality to interact with the Nine logging API. |
|
login
module
|