cluster

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache implements a simple caching layer, for the loaded manifest files. The goal of the caching layer is to return the manifests faster to the user.

type Cluster

type Cluster struct {
	// contains filtered or unexported fields
}

Cluster is a Kubernetes cluster. It contains all required fields to interact with the cluster and it's services.

func NewCluster

func NewCluster(name string, restConfig *rest.Config) (*Cluster, error)

NewCluster returns a new cluster. Each cluster must have a unique name and a client to make requests against the Kubernetes API server of this cluster. When a cluster was successfully created we call the loadCRDs function to get all CRDs for this cluster.

func (*Cluster) GetApplication

func (c *Cluster) GetApplication(ctx context.Context, namespace, name string) (*applicationProto.Application, error)

GetApplication returns a application for the given namespace and name. After the application is retrieved we replace, the cluster, namespace and name in the spec of the Application CR. This is needed, so that the user doesn't have to, provide these fields.

func (*Cluster) GetApplications

func (c *Cluster) GetApplications(ctx context.Context, namespace string) ([]*applicationProto.Application, error)

GetApplications returns a list of applications gor the given namespace. It also adds the cluster, namespace and application name to the application CR, so that this information must not be specified by the user in the CR.

func (*Cluster) GetCRDs

func (c *Cluster) GetCRDs() []*clustersProto.CRD

GetCRDs returns all CRDs of the cluster.

func (*Cluster) GetLogs added in v0.2.0

func (c *Cluster) GetLogs(ctx context.Context, namespace, name, container, regex string, since int64, previous bool) ([]string, error)

GetLogs returns the logs for a Pod. The Pod is identified by the namespace and name. Before we return the logs, we filter them by the provided regular expression. Before we check each log line against the regular expression provided by a user, we check that a regular expression was provided. If not we just return the logs from the Kubernetes API request splitted by the newline character. If a regular expression was provided, we compile it and then loop through all lines and check each line against the regex. When a line matches the regex it is added to the slice of log lines, which are returned then.

func (*Cluster) GetName

func (c *Cluster) GetName() string

GetName returns the name of the cluster.

func (*Cluster) GetNamespaces

func (c *Cluster) GetNamespaces(ctx context.Context, cacheDuration time.Duration) ([]string, error)

GetNamespaces returns all namespaces for the cluster. To reduce the latency and the number of API calls, we are "caching" the namespaces. This means that if a new namespace is created in a cluster, this namespaces is only shown after the configured cache duration.

func (*Cluster) GetResources

func (c *Cluster) GetResources(ctx context.Context, namespace, path, resource, paramName, param string) (string, error)

GetResources returns a list for the given resource in the given namespace. The resource is identified by the Kubernetes API path and the name of the resource.

func (*Cluster) GetTeam added in v0.2.0

func (c *Cluster) GetTeam(ctx context.Context, namespace, name string) (*teamProto.Team, error)

GetTeam returns a team for the given namespace and name. After the team is retrieved we replace the cluster, namespace and name in the spec of the Team CR. This is needed, so that the user doesn't have to provide the name field and we can find the team later again.

func (*Cluster) GetTeams added in v0.2.0

func (c *Cluster) GetTeams(ctx context.Context) ([]*teamProto.Team, error)

GetTeams returns a list of teams. Since teams must be unique accross clusters and namespace, we ignore the namespace parameter in the request and always request all teams in the cluster.

func (*Cluster) GetTemplates added in v0.3.0

func (c *Cluster) GetTemplates(ctx context.Context) ([]*templateProto.Template, error)

GetTemplates returns a list of templates.

Jump to

Keyboard shortcuts

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