cluster

package
v0.0.0-...-987a61a Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultClusterName = "default_cluster"
View Source
const TokenFilePath = "/var/run/secrets/kubernetes.io/serviceaccount/token"

Variables

This section is empty.

Functions

func BuildEnvironmentIdentifer

func BuildEnvironmentIdentifer(clusterName string, namespace string) string

Types

type ClusterBean

type ClusterBean struct {
	Id                      int                        `json:"id,omitempty" validate:"number"`
	ClusterName             string                     `json:"cluster_name,omitempty" validate:"required"`
	ServerUrl               string                     `json:"server_url,omitempty" validate:"url,required"`
	PrometheusUrl           string                     `json:"prometheus_url,omitempty" validate:"validate-non-empty-url"`
	Active                  bool                       `json:"active"`
	Config                  map[string]string          `json:"config,omitempty" validate:"required"`
	PrometheusAuth          *PrometheusAuth            `json:"prometheusAuth,omitempty"`
	DefaultClusterComponent []*DefaultClusterComponent `json:"defaultClusterComponent"`
	AgentInstallationStage  int                        `json:"agentInstallationStage,notnull"` // -1=external, 0=not triggered, 1=progressing, 2=success, 3=fails
	K8sVersion              string                     `json:"k8sVersion"`
	HasConfigOrUrlChanged   bool                       `json:"-"`
}

type ClusterEnvDto

type ClusterEnvDto struct {
	ClusterId    int       `json:"clusterId"`
	ClusterName  string    `json:"clusterName,omitempty"`
	Environments []*EnvDto `json:"environments,omitempty"`
}

type ClusterService

type ClusterService interface {
	Save(parent context.Context, bean *ClusterBean, userId int32) (*ClusterBean, error)
	FindOne(clusterName string) (*ClusterBean, error)
	FindOneActive(clusterName string) (*ClusterBean, error)
	FindAll() ([]*ClusterBean, error)
	FindAllActive() ([]ClusterBean, error)
	DeleteFromDb(bean *ClusterBean, userId int32) error

	FindById(id int) (*ClusterBean, error)
	FindByIds(id []int) ([]ClusterBean, error)
	Update(ctx context.Context, bean *ClusterBean, userId int32) (*ClusterBean, error)
	Delete(bean *ClusterBean, userId int32) error

	FindAllForAutoComplete() ([]ClusterBean, error)
	CreateGrafanaDataSource(clusterBean *ClusterBean, env *repository.Environment) (int, error)
	GetClusterConfig(cluster *ClusterBean) (*util.ClusterConfig, error)
}

type ClusterServiceImpl

type ClusterServiceImpl struct {
	K8sUtil            *util.K8sUtil
	K8sInformerFactory informer.K8sInformerFactory
	// contains filtered or unexported fields
}

func NewClusterServiceImpl

func NewClusterServiceImpl(repository repository.ClusterRepository, logger *zap.SugaredLogger,
	K8sUtil *util.K8sUtil, K8sInformerFactory informer.K8sInformerFactory) *ClusterServiceImpl

func (*ClusterServiceImpl) CreateGrafanaDataSource

func (impl *ClusterServiceImpl) CreateGrafanaDataSource(clusterBean *ClusterBean, env *repository.Environment) (int, error)

func (*ClusterServiceImpl) Delete

func (impl *ClusterServiceImpl) Delete(bean *ClusterBean, userId int32) error

func (ClusterServiceImpl) DeleteFromDb

func (impl ClusterServiceImpl) DeleteFromDb(bean *ClusterBean, userId int32) error

func (*ClusterServiceImpl) FindAll

func (impl *ClusterServiceImpl) FindAll() ([]*ClusterBean, error)

func (*ClusterServiceImpl) FindAllActive

func (impl *ClusterServiceImpl) FindAllActive() ([]ClusterBean, error)

func (*ClusterServiceImpl) FindAllForAutoComplete

func (impl *ClusterServiceImpl) FindAllForAutoComplete() ([]ClusterBean, error)

func (*ClusterServiceImpl) FindById

func (impl *ClusterServiceImpl) FindById(id int) (*ClusterBean, error)

func (*ClusterServiceImpl) FindByIds

func (impl *ClusterServiceImpl) FindByIds(ids []int) ([]ClusterBean, error)

func (*ClusterServiceImpl) FindOne

func (impl *ClusterServiceImpl) FindOne(clusterName string) (*ClusterBean, error)

func (*ClusterServiceImpl) FindOneActive

func (impl *ClusterServiceImpl) FindOneActive(clusterName string) (*ClusterBean, error)

func (*ClusterServiceImpl) GetClusterConfig

func (impl *ClusterServiceImpl) GetClusterConfig(cluster *ClusterBean) (*util.ClusterConfig, error)

func (*ClusterServiceImpl) Save

func (impl *ClusterServiceImpl) Save(parent context.Context, bean *ClusterBean, userId int32) (*ClusterBean, error)

func (*ClusterServiceImpl) SyncNsInformer

func (impl *ClusterServiceImpl) SyncNsInformer(bean *ClusterBean)

func (*ClusterServiceImpl) Update

func (impl *ClusterServiceImpl) Update(ctx context.Context, bean *ClusterBean, userId int32) (*ClusterBean, error)

type ClusterServiceImplExtended

type ClusterServiceImplExtended struct {
	K8sInformerFactory informer.K8sInformerFactory
	*ClusterServiceImpl
	// contains filtered or unexported fields
}

extends ClusterServiceImpl and enhances method of ClusterService with full mode specific errors

func NewClusterServiceImplExtended

func NewClusterServiceImplExtended(repository repository.ClusterRepository, environmentRepository repository.EnvironmentRepository,
	grafanaClient grafana.GrafanaClient, logger *zap.SugaredLogger, installedAppRepository repository2.InstalledAppRepository,
	K8sUtil *util.K8sUtil,
	clusterServiceCD cluster2.ServiceClient, K8sInformerFactory informer.K8sInformerFactory) *ClusterServiceImplExtended

func (*ClusterServiceImplExtended) CreateGrafanaDataSource

func (impl *ClusterServiceImplExtended) CreateGrafanaDataSource(clusterBean *ClusterBean, env *repository.Environment) (int, error)

func (ClusterServiceImplExtended) DeleteFromDb

func (impl ClusterServiceImplExtended) DeleteFromDb(bean *ClusterBean, userId int32) error

func (*ClusterServiceImplExtended) FindAll

func (impl *ClusterServiceImplExtended) FindAll() ([]*ClusterBean, error)

func (*ClusterServiceImplExtended) Save

func (impl *ClusterServiceImplExtended) Save(ctx context.Context, bean *ClusterBean, userId int32) (*ClusterBean, error)

func (*ClusterServiceImplExtended) Update

func (impl *ClusterServiceImplExtended) Update(ctx context.Context, bean *ClusterBean, userId int32) (*ClusterBean, error)

type DefaultClusterComponent

type DefaultClusterComponent struct {
	ComponentName  string `json:"name"`
	AppId          int    `json:"appId"`
	InstalledAppId int    `json:"installedAppId,omitempty"`
	EnvId          int    `json:"envId"`
	EnvName        string `json:"envName"`
	Status         string `json:"status"`
}

type EnvDto

type EnvDto struct {
	EnvironmentId         int    `json:"environmentId" validate:"number"`
	EnvironmentName       string `json:"environmentName,omitempty" validate:"max=50"`
	Namespace             string `json:"namespace,omitempty" validate:"max=50"`
	EnvironmentIdentifier string `json:"environmentIdentifier,omitempty"`
}

type EnvironmentBean

type EnvironmentBean struct {
	Id                    int    `json:"id,omitempty" validate:"number"`
	Environment           string `json:"environment_name,omitempty" validate:"required,max=50"`
	ClusterId             int    `json:"cluster_id,omitempty" validate:"number,required"`
	ClusterName           string `json:"cluster_name,omitempty"`
	Active                bool   `json:"active"`
	Default               bool   `json:"default"`
	PrometheusEndpoint    string `json:"prometheus_endpoint,omitempty"`
	Namespace             string `json:"namespace,omitempty" validate:"max=50"`
	CdArgoSetup           bool   `json:"isClusterCdActive"`
	EnvironmentIdentifier string `json:"environmentIdentifier"`
}

type EnvironmentService

type EnvironmentService interface {
	FindOne(environment string) (*EnvironmentBean, error)
	Create(mappings *EnvironmentBean, userId int32) (*EnvironmentBean, error)
	GetAll() ([]EnvironmentBean, error)
	GetAllActive() ([]EnvironmentBean, error)
	Delete(deleteReq *EnvironmentBean, userId int32) error

	FindById(id int) (*EnvironmentBean, error)
	Update(mappings *EnvironmentBean, userId int32) (*EnvironmentBean, error)
	FindClusterByEnvId(id int) (*ClusterBean, error)
	GetEnvironmentListForAutocomplete() ([]EnvironmentBean, error)
	FindByIds(ids []*int) ([]*EnvironmentBean, error)
	FindByNamespaceAndClusterName(namespaces string, clusterName string) (*repository.Environment, error)
	GetByClusterId(id int) ([]*EnvironmentBean, error)
	GetCombinedEnvironmentListForDropDown(token string, isActionUserSuperAdmin bool, auth func(token string, object string) bool) ([]*ClusterEnvDto, error)
	GetCombinedEnvironmentListForDropDownByClusterIds(token string, clusterIds []int, auth func(token string, object string) bool) ([]*ClusterEnvDto, error)
}

type EnvironmentServiceImpl

type EnvironmentServiceImpl struct {
	K8sUtil *util.K8sUtil
	// contains filtered or unexported fields
}

func NewEnvironmentServiceImpl

func NewEnvironmentServiceImpl(environmentRepository repository.EnvironmentRepository,
	clusterService ClusterService, logger *zap.SugaredLogger,
	K8sUtil *util.K8sUtil, k8sInformerFactory informer.K8sInformerFactory,

	userAuthService user.UserAuthService) *EnvironmentServiceImpl

func (EnvironmentServiceImpl) Create

func (impl EnvironmentServiceImpl) Create(mappings *EnvironmentBean, userId int32) (*EnvironmentBean, error)

func (EnvironmentServiceImpl) Delete

func (impl EnvironmentServiceImpl) Delete(deleteReq *EnvironmentBean, userId int32) error

func (EnvironmentServiceImpl) FindById

func (impl EnvironmentServiceImpl) FindById(id int) (*EnvironmentBean, error)

func (EnvironmentServiceImpl) FindByIds

func (impl EnvironmentServiceImpl) FindByIds(ids []*int) ([]*EnvironmentBean, error)

func (EnvironmentServiceImpl) FindByNamespaceAndClusterName

func (impl EnvironmentServiceImpl) FindByNamespaceAndClusterName(namespaces string, clusterName string) (*repository.Environment, error)

func (EnvironmentServiceImpl) FindClusterByEnvId

func (impl EnvironmentServiceImpl) FindClusterByEnvId(id int) (*ClusterBean, error)

func (EnvironmentServiceImpl) FindOne

func (impl EnvironmentServiceImpl) FindOne(environment string) (*EnvironmentBean, error)

func (EnvironmentServiceImpl) GetAll

func (impl EnvironmentServiceImpl) GetAll() ([]EnvironmentBean, error)

func (EnvironmentServiceImpl) GetAllActive

func (impl EnvironmentServiceImpl) GetAllActive() ([]EnvironmentBean, error)

func (EnvironmentServiceImpl) GetByClusterId

func (impl EnvironmentServiceImpl) GetByClusterId(id int) ([]*EnvironmentBean, error)

func (EnvironmentServiceImpl) GetCombinedEnvironmentListForDropDown

func (impl EnvironmentServiceImpl) GetCombinedEnvironmentListForDropDown(token string, isActionUserSuperAdmin bool, auth func(token string, object string) bool) ([]*ClusterEnvDto, error)

func (EnvironmentServiceImpl) GetCombinedEnvironmentListForDropDownByClusterIds

func (impl EnvironmentServiceImpl) GetCombinedEnvironmentListForDropDownByClusterIds(token string, clusterIds []int, auth func(token string, object string) bool) ([]*ClusterEnvDto, error)

func (EnvironmentServiceImpl) GetEnvironmentListForAutocomplete

func (impl EnvironmentServiceImpl) GetEnvironmentListForAutocomplete() ([]EnvironmentBean, error)

func (EnvironmentServiceImpl) Update

func (impl EnvironmentServiceImpl) Update(mappings *EnvironmentBean, userId int32) (*EnvironmentBean, error)

type PrometheusAuth

type PrometheusAuth struct {
	UserName      string `json:"userName,omitempty"`
	Password      string `json:"password,omitempty"`
	TlsClientCert string `json:"tlsClientCert,omitempty"`
	TlsClientKey  string `json:"tlsClientKey,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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