cluster

package
v0.6.18-rc.2 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: Apache-2.0 Imports: 41 Imported by: 28

Documentation

Index

Constants

View Source
const (
	DEFAULT_CLUSTER                  = "default_cluster"
	DEFAULT_NAMESPACE                = "default"
	CLUSTER_MODIFY_EVENT_SECRET_TYPE = "cluster.request/modify"
	CLUSTER_ACTION_ADD               = "add"
	CLUSTER_ACTION_UPDATE            = "update"
	SECRET_NAME                      = "cluster-event"
	SECRET_FIELD_CLUSTER_ID          = "cluster_id"
	SECRET_FIELD_UPDATED_ON          = "updated_on"
	SECRET_FIELD_ACTION              = "action"
	TokenFilePath                    = "/var/run/secrets/kubernetes.io/serviceaccount/token"
)

Variables

This section is empty.

Functions

func BuildEnvironmentIdentifer added in v0.3.17

func BuildEnvironmentIdentifer(clusterName string, namespace string) string

func GetAndUpdateConnectionStatusForOneCluster added in v0.6.18

func GetAndUpdateConnectionStatusForOneCluster(k8sClientSet *kubernetes.Clientset, clusterId int, respMap map[int]error, mutex *sync.Mutex)

Types

type AppGroupingResponse added in v0.6.13

type AppGroupingResponse struct {
	EnvList  []EnvironmentBean `json:"envList"`
	EnvCount int               `json:"envCount"`
}

type ClusterBean

type ClusterBean struct {
	Id                      int                        `json:"id" 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"`
	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:"-"`
	UserName                string                     `json:"userName,omitempty"`
	InsecureSkipTLSVerify   bool                       `json:"insecureSkipTlsVerify"`
	ErrorInConnecting       string                     `json:"errorInConnecting"`
	IsCdArgoSetup           bool                       `json:"isCdArgoSetup"`
	IsVirtualCluster        bool                       `json:"isVirtualCluster"`

	ClusterUpdated bool `json:"clusterUpdated"`
	// contains filtered or unexported fields
}

func GetClusterBean added in v0.6.18

func GetClusterBean(model repository.Cluster) ClusterBean

func (ClusterBean) GetClusterConfig added in v0.6.18

func (bean ClusterBean) GetClusterConfig() util.ClusterConfig

type ClusterDescriptionBean added in v0.6.17

type ClusterDescriptionBean struct {
	ClusterId        int                      `json:"clusterId" validate:"number"`
	ClusterName      string                   `json:"clusterName" validate:"required"`
	ClusterCreatedBy string                   `json:"clusterCreatedBy" validate:"number"`
	ClusterCreatedOn time.Time                `json:"clusterCreatedOn" validate:"required"`
	ClusterNote      *ClusterNoteResponseBean `json:"clusterNote,omitempty"`
}

type ClusterDescriptionService added in v0.6.17

type ClusterDescriptionService interface {
	FindByClusterIdWithClusterDetails(id int) (*ClusterDescriptionBean, error)
}

type ClusterDescriptionServiceImpl added in v0.6.17

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

func NewClusterDescriptionServiceImpl added in v0.6.17

func NewClusterDescriptionServiceImpl(repository repository.ClusterDescriptionRepository, userRepository repository2.UserRepository, logger *zap.SugaredLogger) *ClusterDescriptionServiceImpl

func (*ClusterDescriptionServiceImpl) FindByClusterIdWithClusterDetails added in v0.6.17

func (impl *ClusterDescriptionServiceImpl) FindByClusterIdWithClusterDetails(id int) (*ClusterDescriptionBean, error)

type ClusterEnvDto added in v0.3.14

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

type ClusterNoteBean added in v0.6.17

type ClusterNoteBean struct {
	Id          int       `json:"id" validate:"number"`
	ClusterId   int       `json:"clusterId" validate:"required"`
	Description string    `json:"description" validate:"required"`
	UpdatedBy   int32     `json:"updatedBy"`
	UpdatedOn   time.Time `json:"updatedOn"`
}

type ClusterNoteHistoryBean added in v0.6.17

type ClusterNoteHistoryBean struct {
	Id          int       `json:"id" validate:"number"`
	NoteId      int       `json:"noteId" validate:"required"`
	Description string    `json:"description" validate:"required"`
	CreatedBy   int32     `json:"createdBy" validate:"number"`
	CreatedOn   time.Time `json:"createdOn" validate:"required"`
}

type ClusterNoteHistoryService added in v0.6.17

type ClusterNoteHistoryService interface {
	Save(bean *ClusterNoteHistoryBean, userId int32) (*ClusterNoteHistoryBean, error)
}

type ClusterNoteHistoryServiceImpl added in v0.6.17

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

func NewClusterNoteHistoryServiceImpl added in v0.6.17

func NewClusterNoteHistoryServiceImpl(repositoryHistory repository.ClusterNoteHistoryRepository, logger *zap.SugaredLogger) *ClusterNoteHistoryServiceImpl

func (*ClusterNoteHistoryServiceImpl) Save added in v0.6.17

type ClusterNoteResponseBean added in v0.6.17

type ClusterNoteResponseBean struct {
	Id          int       `json:"id" validate:"number"`
	Description string    `json:"description" validate:"required"`
	UpdatedBy   string    `json:"updatedBy"`
	UpdatedOn   time.Time `json:"updatedOn"`
}

type ClusterNoteService added in v0.6.17

type ClusterNoteService interface {
	Save(bean *ClusterNoteBean, userId int32) (*ClusterNoteBean, error)
	Update(bean *ClusterNoteBean, userId int32) (*ClusterNoteBean, error)
}

type ClusterNoteServiceImpl added in v0.6.17

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

func NewClusterNoteServiceImpl added in v0.6.17

func NewClusterNoteServiceImpl(repository repository.ClusterNoteRepository, clusterNoteHistoryService ClusterNoteHistoryService, logger *zap.SugaredLogger) *ClusterNoteServiceImpl

func (*ClusterNoteServiceImpl) Save added in v0.6.17

func (impl *ClusterNoteServiceImpl) Save(bean *ClusterNoteBean, userId int32) (*ClusterNoteBean, error)

func (*ClusterNoteServiceImpl) Update added in v0.6.17

func (impl *ClusterNoteServiceImpl) Update(bean *ClusterNoteBean, userId int32) (*ClusterNoteBean, error)

type ClusterService

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

	FindById(id int) (*ClusterBean, error)
	FindByIdWithoutConfig(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)
	GetK8sClient() (*v12.CoreV1Client, error)
	GetAllClusterNamespaces() map[string][]string
	FindAllNamespacesByUserIdAndClusterId(userId int32, clusterId int, isActionUserSuperAdmin bool) ([]string, error)
	FindAllForClusterByUserId(userId int32, isActionUserSuperAdmin bool) ([]ClusterBean, error)
	FetchRolesFromGroup(userId int32) ([]*repository2.RoleModel, error)
	ConnectClustersInBatch(clusters []*ClusterBean, clusterExistInDb bool)
	ConvertClusterBeanToCluster(clusterBean *ClusterBean, userId int32) *repository.Cluster
	ConvertClusterBeanObjectToCluster(bean *ClusterBean) *v1alpha1.Cluster
}

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,
	userAuthRepository repository2.UserAuthRepository, userRepository repository2.UserRepository,
	roleGroupRepository repository2.RoleGroupRepository) *ClusterServiceImpl

func (ClusterServiceImpl) CheckIfConfigIsValid added in v0.6.2

func (impl ClusterServiceImpl) CheckIfConfigIsValid(cluster *ClusterBean) error

func (*ClusterServiceImpl) ConnectClustersInBatch added in v0.6.18

func (impl *ClusterServiceImpl) ConnectClustersInBatch(clusters []*ClusterBean, clusterExistInDb bool)

func (ClusterServiceImpl) ConvertClusterBeanObjectToCluster added in v0.6.18

func (impl ClusterServiceImpl) ConvertClusterBeanObjectToCluster(bean *ClusterBean) *v1alpha1.Cluster

func (*ClusterServiceImpl) ConvertClusterBeanToCluster added in v0.6.18

func (impl *ClusterServiceImpl) ConvertClusterBeanToCluster(clusterBean *ClusterBean, userId int32) *repository.Cluster

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 added in v0.3.15

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

func (*ClusterServiceImpl) FetchRolesFromGroup added in v0.6.11

func (impl *ClusterServiceImpl) FetchRolesFromGroup(userId int32) ([]*repository2.RoleModel, 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) FindAllForClusterByUserId added in v0.6.11

func (impl *ClusterServiceImpl) FindAllForClusterByUserId(userId int32, isActionUserSuperAdmin bool) ([]ClusterBean, error)

func (*ClusterServiceImpl) FindAllNamespacesByUserIdAndClusterId added in v0.6.11

func (impl *ClusterServiceImpl) FindAllNamespacesByUserIdAndClusterId(userId int32, clusterId int, isActionUserSuperAdmin bool) ([]string, error)

func (*ClusterServiceImpl) FindAllWithoutConfig added in v0.6.13

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

func (*ClusterServiceImpl) FindById

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

func (*ClusterServiceImpl) FindByIdWithoutConfig added in v0.6.13

func (impl *ClusterServiceImpl) FindByIdWithoutConfig(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) GetAllClusterNamespaces added in v0.6.10

func (impl *ClusterServiceImpl) GetAllClusterNamespaces() map[string][]string

func (*ClusterServiceImpl) GetClusterConfig added in v0.2.8

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

func (*ClusterServiceImpl) GetK8sClient added in v0.6.1

func (impl *ClusterServiceImpl) GetK8sClient() (*v12.CoreV1Client, error)

func (*ClusterServiceImpl) HandleErrorInClusterConnections added in v0.6.18

func (impl *ClusterServiceImpl) HandleErrorInClusterConnections(clusters []*ClusterBean, respMap map[int]error, clusterExistInDb bool)

func (*ClusterServiceImpl) Save

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

func (*ClusterServiceImpl) SyncNsInformer added in v0.3.14

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

func (*ClusterServiceImpl) Update

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

func (*ClusterServiceImpl) ValidateKubeconfig added in v0.6.18

func (impl *ClusterServiceImpl) ValidateKubeconfig(kubeConfig string) (map[string]*ValidateClusterBean, error)

type ClusterServiceImplExtended added in v0.3.9

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 added in v0.3.9

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,
	gitOpsRepository repository3.GitOpsConfigRepository, userAuthRepository repository4.UserAuthRepository,
	userRepository repository4.UserRepository, roleGroupRepository repository4.RoleGroupRepository) *ClusterServiceImplExtended

func (*ClusterServiceImplExtended) CreateGrafanaDataSource added in v0.3.9

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

func (ClusterServiceImplExtended) DeleteFromDb added in v0.3.15

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

func (*ClusterServiceImplExtended) FindAll added in v0.3.9

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

func (*ClusterServiceImplExtended) FindAllWithoutConfig added in v0.6.13

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

func (*ClusterServiceImplExtended) Save added in v0.3.9

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

func (*ClusterServiceImplExtended) Update added in v0.3.9

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 added in v0.3.14

type EnvDto struct {
	EnvironmentId         int    `json:"environmentId" validate:"number"`
	EnvironmentName       string `json:"environmentName,omitempty" validate:"max=50"`
	Namespace             string `json:"namespace,omitempty" validate:"name-space-component,max=50"`
	EnvironmentIdentifier string `json:"environmentIdentifier,omitempty"`
	Description           string `json:"description" validate:"max=40"`
	IsVirtualEnvironment  bool   `json:"isVirtualEnvironment"`
}

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:"name-space-component,max=50"`
	CdArgoSetup           bool   `json:"isClusterCdActive"`
	EnvironmentIdentifier string `json:"environmentIdentifier"`
	Description           string `json:"description" validate:"max=40"`
	AppCount              int    `json:"appCount"`
	IsVirtualEnvironment  bool   `json:"isVirtualEnvironment"`
}

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)
	GetEnvironmentOnlyListForAutocomplete() ([]EnvironmentBean, error)
	FindByIds(ids []*int) ([]*EnvironmentBean, error)
	FindByNamespaceAndClusterName(namespaces string, clusterName string) (*repository.Environment, error)
	GetByClusterId(id int) ([]*EnvironmentBean, error)
	GetCombinedEnvironmentListForDropDown(emailId string, isActionUserSuperAdmin bool, auth func(email string, object []string) map[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 added in v0.3.15

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 added in v0.3.14

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

func (EnvironmentServiceImpl) GetCombinedEnvironmentListForDropDownByClusterIds added in v0.3.14

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) GetEnvironmentOnlyListForAutocomplete added in v0.6.17

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

func (EnvironmentServiceImpl) Update

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

type Kubeconfig added in v0.6.18

type Kubeconfig struct {
	Config string `json:"config"`
}

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"`
}

type UserClusterBeanMapping added in v0.6.18

type UserClusterBeanMapping struct {
	Mapping map[string]*ClusterBean `json:"mapping"`
}

type UserInfo added in v0.6.18

type UserInfo struct {
	UserName          string            `json:"userName,omitempty"`
	Config            map[string]string `json:"config,omitempty"`
	ErrorInConnecting string            `json:"errorInConnecting"`
}

type ValidateClusterBean added in v0.6.18

type ValidateClusterBean struct {
	UserInfos map[string]*UserInfo `json:"userInfos,omitempty""`
	*ClusterBean
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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