repository

package
v0.0.0-...-9b56418 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2020 License: Apache-2.0 Imports: 15 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertAPIURL

func ConvertAPIURL(apiURL, newPrefix, newPath string) (string, error)

ConvertAPIURL converts the given `apiURL` by adding the new prefix (or subdomain) and a path eg: ConvertAPIURL("https://foo.com", "api", "some/path") gives "https://api.foo.com/some/path"

Types

type Cluster

type Cluster struct {
	gormsupport.LifecycleHardDelete
	// This is the primary key value
	ClusterID uuid.UUID `sql:"type:uuid default uuid_generate_v4()" gorm:"primary_key;column:cluster_id"`
	// The name of the cluster
	Name string `mapstructure:"name"`
	// API URL of the cluster
	URL string `sql:"unique_index" mapstructure:"api-url"`
	// Console URL of the cluster
	ConsoleURL string `mapstructure:"console-url" optional:"true"` // Optional in config file
	// Metrics URL of the cluster
	MetricsURL string `mapstructure:"metrics-url" optional:"true"` // Optional in config file
	// Logging URL of the cluster
	LoggingURL string `mapstructure:"logging-url" optional:"true"` // Optional in config file
	// Application host name used by the cluster
	AppDNS string `mapstructure:"app-dns"`
	// Service Account token (encrypted or not, depending on the state of the sibling SATokenEncrypted field)
	SAToken string `mapstructure:"service-account-token"`
	// Service Account username
	SAUsername string `mapstructure:"service-account-username"`
	// SA Token encrypted
	SATokenEncrypted bool `mapstructure:"service-account-token-encrypted" optional:"true" default:"true"` // Optional in config file
	// Token Provider ID
	TokenProviderID string `mapstructure:"token-provider-id"`
	// OAuthClient ID used to link users account
	AuthClientID string `mapstructure:"auth-client-id"`
	// OAuthClient secret used to link users account
	AuthClientSecret string `mapstructure:"auth-client-secret"`
	// OAuthClient default scope used to link users account
	AuthDefaultScope string `mapstructure:"auth-client-default-scope"`
	// Cluster type. Such as OSD, OSO, OCP, etc
	Type string `mapstructure:"type" optional:"true" default:"OSO"` // Optional in config file
	// cluster capacity exhausted by default false
	CapacityExhausted bool `mapstructure:"capacity-exhausted" optional:"true"` // Optional in config file
}

Cluster the struct that holds the cluster info

func (*Cluster) Normalize

func (c *Cluster) Normalize() error

Normalize fills the `console`, `metrics` and `logging` URL if there were missing, and appends a trailing slash if needed.

func (Cluster) TableName

func (c Cluster) TableName() string

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

type ClusterRepository

type ClusterRepository interface {
	base.Exister
	Load(ctx context.Context, ID uuid.UUID) (*Cluster, error)
	Create(ctx context.Context, u *Cluster) error
	Save(ctx context.Context, u *Cluster) error
	CreateOrSave(ctx context.Context, u *Cluster) error
	Delete(ctx context.Context, ID uuid.UUID) error
	Query(funcs ...func(*gorm.DB) *gorm.DB) ([]Cluster, error)
	FindByURL(ctx context.Context, url string) (*Cluster, error)
	List(ctx context.Context, clusterType *string) ([]Cluster, error)
}

ClusterRepository represents the storage interface.

func NewClusterRepository

func NewClusterRepository(db *gorm.DB) ClusterRepository

NewClusterRepository creates a new storage type.

type GormClusterRepository

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

GormClusterRepository is the implementation of the storage interface for Cluster.

func (*GormClusterRepository) CheckExists

func (m *GormClusterRepository) CheckExists(ctx context.Context, id string) error

CheckExists returns nil if the given ID exists otherwise returns an error

func (*GormClusterRepository) Create

func (m *GormClusterRepository) Create(ctx context.Context, c *Cluster) error

Create creates a new record.

func (*GormClusterRepository) CreateOrSave

func (m *GormClusterRepository) CreateOrSave(ctx context.Context, c *Cluster) error

CreateOrSave creates cluster or saves cluster if any cluster found using url

func (*GormClusterRepository) Delete

func (m *GormClusterRepository) Delete(ctx context.Context, id uuid.UUID) error

Delete removes a single record. This is a hard delete! Also, removes all identity/cluster relationship associated with this cluster.

func (*GormClusterRepository) FindByURL

func (m *GormClusterRepository) FindByURL(ctx context.Context, url string) (*Cluster, error)

LoadByURL returns a single Cluster filtered using 'url'

func (*GormClusterRepository) List

func (m *GormClusterRepository) List(ctx context.Context, clusterType *string) ([]Cluster, error)

List lists all clusters (with the given optional type)

func (*GormClusterRepository) Load

Load returns a single Cluster as a Database Model

func (*GormClusterRepository) Query

func (m *GormClusterRepository) Query(funcs ...func(*gorm.DB) *gorm.DB) ([]Cluster, error)

Query exposes an open ended Query model

func (*GormClusterRepository) Save

Save modifies a single record

func (*GormClusterRepository) TableName

func (m *GormClusterRepository) TableName() string

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

type GormIdentityClusterRepository

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

GormIdentityClusterRepository is the implementation of the storage interface for IdentityCluster.

func (*GormIdentityClusterRepository) Create

Create creates a new record.

func (*GormIdentityClusterRepository) Delete

func (m *GormIdentityClusterRepository) Delete(ctx context.Context, identityID uuid.UUID, clusterURL string) error

Delete removes the identity/cluster relationship identified by the given `identityID` and `clusterURL`

func (*GormIdentityClusterRepository) ListClustersForIdentity

func (m *GormIdentityClusterRepository) ListClustersForIdentity(ctx context.Context, identityID uuid.UUID) ([]Cluster, error)

ListClustersForIdentity returns the list of all cluster for the identity

func (*GormIdentityClusterRepository) Load

func (m *GormIdentityClusterRepository) Load(ctx context.Context, identityID, clusterID uuid.UUID) (*IdentityCluster, error)

Load returns a single Identity Cluster as a Database Model

func (*GormIdentityClusterRepository) TableName

func (m *GormIdentityClusterRepository) TableName() string

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

type IdentityCluster

type IdentityCluster struct {
	gormsupport.Lifecycle
	// The associated Identity ID
	IdentityID uuid.UUID `sql:"type:uuid" gorm:"primary_key;column:identity_id"`
	// The associated cluster
	Cluster Cluster `gorm:"ForeignKey:ClusterID;association_foreignkey:ClusterID"`
	// The foreign key value for ClusterID
	ClusterID uuid.UUID ` sql:"type:uuid" gorm:"primary_key;column:cluster_id"`
}

IdentityCluster a type that associates an Identity to a Cluster

func (IdentityCluster) TableName

func (m IdentityCluster) TableName() string

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

type IdentityClusterRepository

type IdentityClusterRepository interface {
	Load(ctx context.Context, identityID, clusterID uuid.UUID) (*IdentityCluster, error)
	ListClustersForIdentity(ctx context.Context, identityID uuid.UUID) ([]Cluster, error)
	Create(ctx context.Context, u *IdentityCluster) error
	Delete(ctx context.Context, identityID uuid.UUID, clusterURL string) error
}

IdentityClusterRepository represents the storage interface.

func NewIdentityClusterRepository

func NewIdentityClusterRepository(db *gorm.DB) IdentityClusterRepository

NewIdentityClusterRepository creates a new storage type.

Jump to

Keyboard shortcuts

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