tenant

package
v0.0.0-...-bf90f01 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2020 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConstructNamespaceName

func ConstructNamespaceName(envType environment.Type, nsBaseName string) string

func ConstructNsBaseName

func ConstructNsBaseName(repo Service, username string) (string, error)

Types

type DBService

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

func (*DBService) CreateTenant

func (s *DBService) CreateTenant(tenant *Tenant) error

func (*DBService) ExistsWithNsBaseName

func (s *DBService) ExistsWithNsBaseName(nsBaseName string) (bool, error)

func (*DBService) GetClustersToUpdate

func (s *DBService) GetClustersToUpdate(typeWithVersion map[environment.Type]string, commit string) ([]string, error)

func (*DBService) GetNumberOfOutdatedTenants

func (s *DBService) GetNumberOfOutdatedTenants(typeWithVersion map[environment.Type]string, commit string, masterURL string) (int, error)

func (*DBService) GetTenantsToUpdate

func (s *DBService) GetTenantsToUpdate(typeWithVersion map[environment.Type]string, count int, commit string, masterURL string) ([]*Tenant, error)

func (*DBService) LookupTenantByClusterAndNamespace

func (s *DBService) LookupTenantByClusterAndNamespace(masterURL, namespace string) (*Tenant, error)

func (*DBService) NamespaceExists

func (s *DBService) NamespaceExists(nsName string) (bool, error)

func (*DBService) NewTenantRepository

func (s *DBService) NewTenantRepository(tenantID uuid.UUID) Repository

func (*DBService) SaveTenant

func (s *DBService) SaveTenant(tenant *Tenant) error

type DBTenantRepository

type DBTenantRepository struct {
	*DBService
	// contains filtered or unexported fields
}

func (*DBTenantRepository) CreateNamespace

func (r *DBTenantRepository) CreateNamespace(namespace *Namespace) (*Namespace, error)

func (*DBTenantRepository) DeleteNamespace

func (r *DBTenantRepository) DeleteNamespace(namespace *Namespace) error

func (*DBTenantRepository) DeleteNamespaces

func (r *DBTenantRepository) DeleteNamespaces() error

func (*DBTenantRepository) DeleteTenant

func (r *DBTenantRepository) DeleteTenant() error

func (*DBTenantRepository) Exists

func (r *DBTenantRepository) Exists() bool

func (*DBTenantRepository) GetNamespaces

func (r *DBTenantRepository) GetNamespaces() ([]*Namespace, error)

func (*DBTenantRepository) GetTenant

func (r *DBTenantRepository) GetTenant() (*Tenant, error)

func (*DBTenantRepository) NewNamespace

func (r *DBTenantRepository) NewNamespace(envType environment.Type, nsName, masterURL string, state NamespaceState) *Namespace

func (*DBTenantRepository) SaveNamespace

func (r *DBTenantRepository) SaveNamespace(namespace *Namespace) error

type Namespace

type Namespace struct {
	ID        uuid.UUID `sql:"type:uuid default uuid_generate_v4()" gorm:"primary_key"`
	TenantID  uuid.UUID `sql:"type:uuid"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time
	Name      string
	MasterURL string
	Type      environment.Type
	Version   string
	State     NamespaceState
	UpdatedBy string
}

Namespace represent a single namespace owned by an Tenant

func (Namespace) TableName

func (m Namespace) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

func (*Namespace) UpdateData

func (n *Namespace) UpdateData(env *environment.EnvData, cluster *cluster.Cluster, state NamespaceState)

type NamespaceState

type NamespaceState string
const (
	Provisioning NamespaceState = "provisioning"
	Updating     NamespaceState = "updating"
	Ready        NamespaceState = "ready"
	Failed       NamespaceState = "failed"
)

func (*NamespaceState) Scan

func (ns *NamespaceState) Scan(value interface{}) error

Scan - Implement the database/sql scanner interface

func (NamespaceState) String

func (s NamespaceState) String() string

func (*NamespaceState) Value

func (ns *NamespaceState) Value() (driver.Value, error)

Value - Implementation of valuer for database/sql

type Repository

type Repository interface {
	Service
	Exists() bool
	GetTenant() (*Tenant, error)
	NewNamespace(envType environment.Type, nsName, masterURL string, state NamespaceState) *Namespace
	GetNamespaces() ([]*Namespace, error)
	SaveNamespace(namespace *Namespace) error
	CreateNamespace(namespace *Namespace) (*Namespace, error)
	DeleteNamespace(namespace *Namespace) error
	DeleteNamespaces() error
	DeleteTenant() error
}

func NewTenantRepository

func NewTenantRepository(db *gorm.DB, tenantID uuid.UUID) Repository

type Resolve

type Resolve func(ctx context.Context, target, token string) (username, accessToken string, err error)

Resolve a func to resolve tenant tokens based on tenants auth

type Service

type Service interface {
	CreateTenant(tenant *Tenant) error
	SaveTenant(tenant *Tenant) error
	LookupTenantByClusterAndNamespace(masterURL, namespace string) (*Tenant, error)
	NewTenantRepository(tenantID uuid.UUID) Repository
	NamespaceExists(nsName string) (bool, error)
	ExistsWithNsBaseName(nsBaseName string) (bool, error)
	GetTenantsToUpdate(typeWithVersion map[environment.Type]string, count int, commit string, masterURL string) ([]*Tenant, error)
	GetClustersToUpdate(typeWithVersion map[environment.Type]string, commit string) ([]string, error)
	GetNumberOfOutdatedTenants(typeWithVersion map[environment.Type]string, commit string, masterURL string) (int, error)
}

func NewDBService

func NewDBService(db *gorm.DB) Service

type Tenant

type Tenant struct {
	ID         uuid.UUID `sql:"type:uuid" gorm:"primary_key"` // This is the ID PK field
	CreatedAt  time.Time
	UpdatedAt  time.Time
	DeletedAt  *time.Time
	Email      string
	Profile    string
	OSUsername string
	NsBaseName string
}

Tenant is the owning OpenShift account

func (Tenant) TableName

func (m Tenant) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

Jump to

Keyboard shortcuts

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