k8s

package
v0.0.0-...-f79a1ae Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 53 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSecretUnmanaged = errors.New("secret is not managed by console")

Functions

func Instance

func Instance(pod *corev1.Pod, env string) *model.Instance

func Message

func Message(job *batchv1.Job) string

Types

type Client

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

func New

func New(tenant string, cfg Config, db Database, log logrus.FieldLogger, opts ...Opt) (*Client, error)

func (*Client) App

func (c *Client) App(ctx context.Context, name, team, env string) (*model.App, error)

func (*Client) AppExists

func (c *Client) AppExists(env, team, app string) bool

AppExists returns true if the given app exists in the given environment. The app informer should be synced before calling this function.

func (*Client) Apps

func (c *Client) Apps(ctx context.Context, team string, filter ...EnvFilter) ([]*model.App, error)

func (*Client) AppsUsingSecret

func (c *Client) AppsUsingSecret(ctx context.Context, obj *model.Secret) ([]*model.App, error)

func (*Client) CreateSecret

func (c *Client) CreateSecret(ctx context.Context, name string, team slug.Slug, env string, data []*model.VariableInput) (*model.Secret, error)

func (*Client) DeleteApp

func (c *Client) DeleteApp(ctx context.Context, name, team, env string) error

func (*Client) DeleteJob

func (c *Client) DeleteJob(ctx context.Context, name, team, env string) error

func (*Client) DeleteSecret

func (c *Client) DeleteSecret(ctx context.Context, name string, team slug.Slug, env string) (bool, error)

func (*Client) Informers

func (c *Client) Informers() ClusterInformers

Informers returns a map of informers, keyed by environment

func (*Client) Instances

func (c *Client) Instances(ctx context.Context, team, env, name string) ([]*model.Instance, error)

func (*Client) Log

func (c *Client) Log(ctx context.Context, cluster, namespace, pod, container string, tailLines int64) ([]*model.LogLine, error)

func (*Client) LogStream

func (c *Client) LogStream(ctx context.Context, cluster, namespace, selector, container string, instances []string) (<-chan *model.LogLine, error)

func (*Client) Manifest

func (c *Client) Manifest(ctx context.Context, name, team, env string) (string, error)

func (*Client) NaisJob

func (c *Client) NaisJob(ctx context.Context, name, team, env string) (*model.NaisJob, error)

func (*Client) NaisJobManifest

func (c *Client) NaisJobManifest(ctx context.Context, name, team, env string) (string, error)

func (*Client) NaisJobs

func (c *Client) NaisJobs(ctx context.Context, team string) ([]*model.NaisJob, error)

func (*Client) NaisJobsUsingSecret

func (c *Client) NaisJobsUsingSecret(ctx context.Context, obj *model.Secret) ([]*model.NaisJob, error)

func (*Client) RestartApp

func (c *Client) RestartApp(ctx context.Context, name, team, env string) error

func (*Client) Runs

func (c *Client) Runs(ctx context.Context, team, env, name string) ([]*model.Run, error)

func (*Client) Search

func (c *Client) Search(ctx context.Context, q string, filter *model.SearchFilter) []*search.Result

func (*Client) Secret

func (c *Client) Secret(ctx context.Context, name string, team slug.Slug, env string) (*model.Secret, error)

func (*Client) Secrets

func (c *Client) Secrets(ctx context.Context, team slug.Slug) ([]*model.Secret, error)

Secrets lists all secrets for a given team in all environments

func (*Client) SecretsForApp

func (c *Client) SecretsForApp(ctx context.Context, obj *model.App) ([]*model.Secret, error)

func (*Client) SecretsForEnv

func (c *Client) SecretsForEnv(ctx context.Context, team slug.Slug, env string) ([]*model.Secret, error)

SecretsForEnv lists all secrets for a given team in a specific environment

func (*Client) SecretsForNaisJob

func (c *Client) SecretsForNaisJob(ctx context.Context, obj *model.NaisJob) ([]*model.Secret, error)

func (*Client) ToNaisJob

func (c *Client) ToNaisJob(u *unstructured.Unstructured, env string) (*model.NaisJob, error)

func (*Client) UpdateSecret

func (c *Client) UpdateSecret(ctx context.Context, name string, team slug.Slug, env string, data []*model.VariableInput) (*model.Secret, error)

type ClusterConfigMap

type ClusterConfigMap map[string]rest.Config

func CreateClusterConfigMap

func CreateClusterConfigMap(tenant string, cfg Config) (ClusterConfigMap, error)

type ClusterInformers

type ClusterInformers map[string]*Informers

func (ClusterInformers) Start

type Config

type Config struct {
	Clusters       []string
	StaticClusters []StaticCluster
}

Config is the configuration related to Kubernetes

func (*Config) IsStaticCluster

func (c *Config) IsStaticCluster(cluster string) bool

type Database

type Database interface {
	TeamExists(ctx context.Context, team slug.Slug) (bool, error)
	GetUserTeams(ctx context.Context, userID uuid.UUID) ([]*database.UserTeam, error)
}

type EnvFilter

type EnvFilter = func(string) bool

func WithEnvs

func WithEnvs(envs ...string) EnvFilter

type Informers

type Informers struct {
	AppInformer         informers.GenericInformer
	EventInformer       corev1inf.EventInformer
	JobInformer         batchv1inf.JobInformer
	NaisjobInformer     informers.GenericInformer
	PodInformer         corev1inf.PodInformer
	TopicInformer       informers.GenericInformer
	SqlInstanceInformer informers.GenericInformer
	SqlDatabaseInformer informers.GenericInformer
}

type Opt

type Opt func(*settings)

func WithClientsCreator

func WithClientsCreator(f func(cluster string) (kubernetes.Interface, dynamic.Interface, error)) Opt

type StaticCluster

type StaticCluster struct {
	Name  string
	Host  string
	Token string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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