clustergroup

package
v0.0.0-...-e7c744b Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsClusterGroupAlreadyExistsError

func IsClusterGroupAlreadyExistsError(err error) bool

IsClusterGroupAlreadyExistsError returns true if the passed in error designates a cluster group already exists error

func IsClusterGroupNotFoundError

func IsClusterGroupNotFoundError(err error) bool

IsClusterGroupNotFoundError returns true if the passed in error designates a cluster group not found error

func IsClusterGroupUpdateRejectedError

func IsClusterGroupUpdateRejectedError(err error) bool

IsClusterGroupUpdateRejectedError returns true if the passed in error designates that a cluster group update is denied

func IsFeatureReconcileError

func IsFeatureReconcileError(err error) bool

IsFeatureReconcileError returns true if the passed in error designates a feature reconciliation error

func IsFeatureRecordNotFoundError

func IsFeatureRecordNotFoundError(err error) bool

IsFeatureRecordNotFoundError returns true if the passed in error designates that a feature DB record not found

func IsInvalidClusterGroupCreateRequestError

func IsInvalidClusterGroupCreateRequestError(err error) bool

IsInvalidClusterGroupCreateRequestError returns true if the passed in error designates invalid cluster group create request

func IsMemberClusterNotFoundError

func IsMemberClusterNotFoundError(err error) (*memberClusterNotFoundError, bool)

IsMemberClusterNotFoundError returns true if the passed in error designates a cluster group member is not found

func IsMemberClusterPartOfAClusterGroupError

func IsMemberClusterPartOfAClusterGroupError(err error) (*memberClusterPartOfAClusterGroupError, bool)

IsMemberClusterPartOfAClusterGroupError returns true if the passed in error designates a cluster group member is already part of a cluster group

func IsRecordNotFoundError

func IsRecordNotFoundError(err error) bool

IsRecordNotFoundError returns true if the passed in error designates that a DB record not found

func IsUnableToJoinMemberClusterError

func IsUnableToJoinMemberClusterError(err error) bool

IsUnableToJoinMemberClusterError returns true if the passed in error is IsUnableToJoinMemberClusterError

func IsUnknownFeatureError

func IsUnknownFeatureError(err error) bool

IsUnknownFeatureError returns true if the passed in error designates an unknown feature (no registered handler) error

func Migrate

func Migrate(db *gorm.DB, logger logrus.FieldLogger) error

Migrate executes the table migrations for the cluster module.

Types

type ClusterGroupFeatureModel

type ClusterGroupFeatureModel struct {
	ID                 uint `gorm:"primary_key"`
	Name               string
	ClusterGroupID     uint
	Enabled            bool
	Properties         []byte `sql:"type:json"`
	ReconcileState     string
	LastReconcileError string `sql:"type:text"`
}

ClusterGroupFeature describes a feature of a cluster group.

func (ClusterGroupFeatureModel) TableName

func (ClusterGroupFeatureModel) TableName() string

TableName changes the default table name.

type ClusterGroupModel

type ClusterGroupModel struct {
	ID             uint   `gorm:"primary_key"`
	UID            string `gorm:"unique_index:idx_uid"`
	CreatedAt      time.Time
	UpdatedAt      time.Time
	DeletedAt      *time.Time `gorm:"unique_index:idx_unique_id" sql:"index"`
	CreatedBy      uint
	Name           string                     `gorm:"unique_index:idx_unique_id"`
	OrganizationID uint                       `gorm:"unique_index:idx_unique_id"`
	Members        []MemberClusterModel       `gorm:"foreignkey:ClusterGroupID"`
	FeatureParams  []ClusterGroupFeatureModel `gorm:"foreignkey:ClusterGroupID"`
}

ClusterGroupModel describes the cluster group model.

func (*ClusterGroupModel) BeforeCreate

func (g *ClusterGroupModel) BeforeCreate() (err error)

func (ClusterGroupModel) String

func (g ClusterGroupModel) String() string

String method prints formatted cluster fields.

func (ClusterGroupModel) TableName

func (ClusterGroupModel) TableName() string

TableName changes the default table name.

type ClusterGroupRepository

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

ClusterGroupRepository

func NewClusterGroupRepository

func NewClusterGroupRepository(
	db *gorm.DB,
	logger logrus.FieldLogger,
) *ClusterGroupRepository

NewClusterGroupRepository returns a new ClusterGroupRepository instance.

func (*ClusterGroupRepository) Create

func (g *ClusterGroupRepository) Create(name string, orgID uint, memberClusterModels []MemberClusterModel) (*uint, error)

Create persists a cluster group

func (*ClusterGroupRepository) Delete

func (g *ClusterGroupRepository) Delete(cgroup *ClusterGroupModel) error

Delete deletes a cluster group

func (*ClusterGroupRepository) FindAll

func (g *ClusterGroupRepository) FindAll(orgID uint) ([]*ClusterGroupModel, error)

FindAll returns all cluster groups

func (*ClusterGroupRepository) FindMemberClusterByID

func (g *ClusterGroupRepository) FindMemberClusterByID(clusterID uint) (*MemberClusterModel, error)

FindMemberClusterByID returns a MemberClusterModel for a cluster ID

func (*ClusterGroupRepository) FindOne

FindOne returns a cluster group instance for an organization by clusterGroupID.

func (*ClusterGroupRepository) GetAllFeatures

func (g *ClusterGroupRepository) GetAllFeatures(clusterGroupID uint) ([]ClusterGroupFeatureModel, error)

GetAllFeatures gets all features for a cluster group

func (*ClusterGroupRepository) GetFeature

func (g *ClusterGroupRepository) GetFeature(clusterGroupID uint, featureName string) (*ClusterGroupFeatureModel, error)

GetFeature gets a feature for a cluster

func (*ClusterGroupRepository) SaveFeature

func (g *ClusterGroupRepository) SaveFeature(feature *ClusterGroupFeatureModel) error

SaveFeature persists a cluster group feature

func (*ClusterGroupRepository) UpdateMembers

func (g *ClusterGroupRepository) UpdateMembers(cgroup *api.ClusterGroup, newMembers map[uint]api.Cluster) error

UpdateMembers updates cluster group members

type Manager

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

Manager

func NewManager

func NewManager(
	clusterGetter api.ClusterGetter,
	repository *ClusterGroupRepository,
	logger logrus.FieldLogger,
	errorHandler emperror.Handler,
) *Manager

NewManager returns a new Manager instance.

func (*Manager) CreateClusterGroup

func (g *Manager) CreateClusterGroup(ctx context.Context, name string, orgID uint, members []uint) (*uint, error)

CreateClusterGroup creates a cluster group

func (*Manager) DeleteClusterGroupByID

func (g *Manager) DeleteClusterGroupByID(ctx context.Context, orgID uint, clusterGroupID uint) error

DeleteClusterGroup deletes a cluster group by id

func (*Manager) DisableFeature

func (g *Manager) DisableFeature(featureName string, clusterGroup *api.ClusterGroup) error

DisableFeature disable a cluster group feature

func (*Manager) DisableFeatures

func (g *Manager) DisableFeatures(clusterGroup api.ClusterGroup) error

func (*Manager) EnableFeature

func (g *Manager) EnableFeature(featureName string, clusterGroup *api.ClusterGroup, properties interface{}) error

func (*Manager) GetAllClusterGroups

func (g *Manager) GetAllClusterGroups(ctx context.Context, orgID uint) ([]api.ClusterGroup, error)

GetAllClusterGroups returns every cluster groups

func (*Manager) GetClusterGroupByID

func (g *Manager) GetClusterGroupByID(ctx context.Context, clusterGroupID uint, orgID uint) (*api.ClusterGroup, error)

GetClusterGroupByID gets a cluster group by id

func (*Manager) GetClusterGroupByIDWithStatus

func (g *Manager) GetClusterGroupByIDWithStatus(ctx context.Context, clusterGroupID uint, orgID uint, withStatus bool) (*api.ClusterGroup, error)

GetClusterGroupByIDWithStatus gets a cluster group by id - optionally with a status info

func (*Manager) GetClusterGroupFromModel

func (g *Manager) GetClusterGroupFromModel(ctx context.Context, cg *ClusterGroupModel, withStatus bool) *api.ClusterGroup

GetClusterGroupFromModel converts a ClusterGroupModel to api.ClusterGroup

func (*Manager) GetClusterGroupNameForCluster

func (g *Manager) GetClusterGroupNameForCluster(clusterID uint, orgID uint) (*string, error)

func (*Manager) GetEnabledFeatures

func (g *Manager) GetEnabledFeatures(clusterGroup api.ClusterGroup) (map[string]api.Feature, error)

func (*Manager) GetFeature

func (g *Manager) GetFeature(clusterGroup api.ClusterGroup, featureName string) (*api.Feature, error)

GetFeature returns params of a cluster group feature by clusterGroupId and feature name

func (*Manager) GetFeatureHandler

func (g *Manager) GetFeatureHandler(featureName string) (api.FeatureHandler, error)

func (*Manager) GetFeatureStatus

func (g *Manager) GetFeatureStatus(feature api.Feature) (map[uint]string, error)

func (*Manager) GetFeatures

func (g *Manager) GetFeatures(clusterGroup api.ClusterGroup) (map[string]api.Feature, error)

func (*Manager) ReconcileFeature

func (g *Manager) ReconcileFeature(clusterGroup api.ClusterGroup, featureName string) error

func (*Manager) ReconcileFeatures

func (g *Manager) ReconcileFeatures(clusterGroup api.ClusterGroup, onlyEnabledHandlers bool) error

func (*Manager) RegisterFeatureHandler

func (g *Manager) RegisterFeatureHandler(featureName string, handler api.FeatureHandler)

func (*Manager) RemoveClusterFromGroup

func (g *Manager) RemoveClusterFromGroup(ctx context.Context, clusterID uint) error

RemoveClusterFromGroup removes a cluster from group

func (*Manager) UpdateClusterGroup

func (g *Manager) UpdateClusterGroup(ctx context.Context, clusterGroupID uint, orgID uint, name string, members []uint) error

UpdateClusterGroup updates a cluster group

func (*Manager) UpdateFeature

func (g *Manager) UpdateFeature(featureName string, clusterGroup *api.ClusterGroup, properties interface{}) error

func (*Manager) ValidateClusterRemoval

func (g *Manager) ValidateClusterRemoval(ctx context.Context, clusterID uint) error

type MemberClusterModel

type MemberClusterModel struct {
	ID             uint `gorm:"primary_key"`
	ClusterGroupID uint
	ClusterID      uint
}

MemberClusterModel describes a member of a cluster group.

func (MemberClusterModel) TableName

func (MemberClusterModel) TableName() string

TableName changes the default table name.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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