dbutils

package
v1.11.3 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChartCollection      = "charts"
	RepositoryCollection = "repos"
	ChartFilesCollection = "files"
)
View Source
const (
	// ChartTable table containing Charts info
	ChartTable = "charts"
	// RepositoryTable table containing repositories sync info
	RepositoryTable = "repos"
	// ChartFilesTable table containing files related to other charts
	ChartFilesTable = "files"
	// EnvvarPostgresTests enables tests that run against a local postgres
	EnvvarPostgresTests = "ENABLE_PG_INTEGRATION_TESTS"
)
View Source
const AllNamespaces = "_all"

Variables

This section is empty.

Functions

This section is empty.

Types

type AssetManager

type AssetManager interface {
	Init() error
	Close() error
}

AssetManager basic manager for the different db types

type MongodbAssetManager

type MongodbAssetManager struct {
	DBSession         datastore.Session
	KubeappsNamespace string
	// contains filtered or unexported fields
}

MongodbAssetManager struct containing mongodb info

func NewMongoDBManager

func NewMongoDBManager(config datastore.Config, kubeappsNamespace string) *MongodbAssetManager

NewMongoDBManager creates an asset manager for MongoDB

func (*MongodbAssetManager) Close

func (m *MongodbAssetManager) Close() error

Close (no-op)

func (*MongodbAssetManager) Init

func (m *MongodbAssetManager) Init() error

Init creates dbsession

func (*MongodbAssetManager) InitCollections added in v1.10.1

func (m *MongodbAssetManager) InitCollections() error

InitCollections ensure indexes of the different collections

func (*MongodbAssetManager) InvalidateCache added in v1.9.0

func (m *MongodbAssetManager) InvalidateCache() error

InvalidateCache drops the different collections and initialize them again

type PostgresAssetManager

type PostgresAssetManager struct {
	DB PostgresDB
	// contains filtered or unexported fields
}

PostgresAssetManager asset manager for postgres

func NewPGManager

func NewPGManager(config datastore.Config, kubeappsNamespace string) (*PostgresAssetManager, error)

NewPGManager creates an asset manager for PG

func (*PostgresAssetManager) Close

func (m *PostgresAssetManager) Close() error

Close connection

func (*PostgresAssetManager) EnsureRepoExists added in v1.9.0

func (m *PostgresAssetManager) EnsureRepoExists(repoNamespace, repoName string) (int, error)

EnsureRepoExists upserts to get the primary key of a repo.

func (*PostgresAssetManager) GetDB added in v1.9.0

func (m *PostgresAssetManager) GetDB() PostgresDB

func (*PostgresAssetManager) GetKubeappsNamespace added in v1.9.0

func (m *PostgresAssetManager) GetKubeappsNamespace() string

func (*PostgresAssetManager) Init

func (m *PostgresAssetManager) Init() error

Init connects to PG

func (*PostgresAssetManager) InitTables added in v1.9.0

func (m *PostgresAssetManager) InitTables() error

InitTables creates the required tables for the postgresql backend for assets.

func (*PostgresAssetManager) InvalidateCache added in v1.9.0

func (m *PostgresAssetManager) InvalidateCache() error

InvalidateCache for postgresql deletes and re-writes the schema

func (*PostgresAssetManager) QueryAllCharts

func (m *PostgresAssetManager) QueryAllCharts(query string, args ...interface{}) ([]*models.Chart, error)

QueryAllCharts perform the given query and return the list of charts

func (*PostgresAssetManager) QueryOne

func (m *PostgresAssetManager) QueryOne(target interface{}, query string, args ...interface{}) error

QueryOne element and store it in the target

type PostgresAssetManagerIface

type PostgresAssetManagerIface interface {
	AssetManager
	QueryOne(target interface{}, query string, args ...interface{}) error
	QueryAllCharts(query string, args ...interface{}) ([]*models.Chart, error)
	InitTables() error
	InvalidateCache() error
	EnsureRepoExists(repoNamespace, repoName string) (int, error)
	GetDB() PostgresDB
	GetKubeappsNamespace() string
}

PostgresAssetManagerIface represents the methods of the PG asset manager The interface is used by the tests to implement a fake PostgresAssetManagerIface

type PostgresDB added in v1.9.0

type PostgresDB interface {
	Query(query string, args ...interface{}) (*sql.Rows, error)
	Begin() (*sql.Tx, error)
	QueryRow(query string, args ...interface{}) *sql.Row
	Close() error
	Exec(query string, args ...interface{}) (sql.Result, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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