db

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CreateServiceInstanceSQLStatement           = `` /* 380-byte string literal not displayed */
	DeleteServiceInstanceSQLStatement           = `DELETE FROM service_instances WHERE guid=? AND space_id=?`
	CreateServiceBindingSQLStatement            = `` /* 280-byte string literal not displayed */
	DeleteServiceBindingsSQLStatement           = `DELETE FROM service_bindings WHERE service_instance_guid=?`
	DeleteServiceKeysSQLStatement               = `DELETE FROM service_keys WHERE service_instance_id=?`
	DeleteServiceInstanceOperationsSQLStatement = `DELETE FROM service_instance_operations WHERE service_instance_id=?`
	CreateServiceUsageEventSQLStatement         = `` /* 420-byte string literal not displayed */
	GetIDFromGUIDLimitToOneTemplateQuery        = `SELECT id FROM %s WHERE guid=? LIMIT 1`
	GetIDFromGUIDTemplateQuery                  = `SELECT id FROM %s WHERE guid=?`
	GetServiceInstanceSharesQuery               = `` /* 130-byte string literal not displayed */
)

Variables

View Source
var ErrUnsupportedOperation = errors.New("unsupported operation")

Functions

func NewCCDBConnection

func NewCCDBConnection(dbHost string, dbUsername string, dbPassword string,
	tunnelHost string, tunnelUser string, tunnelPassword string, tunnelPrivateKey string,
	tunnelRequired bool) (*sqlx.DB, error)

NewCCDBConnection will establish a connection to the CCDB on the host with the specified username and password

func NewNullInt64

func NewNullInt64(i int64) sql.NullInt64

NewNullInt64 will return an empty sql.NullInt64 if i is 0, and an sql.NullInt64 with i in it if it is not

func NewNullString

func NewNullString(s string) sql.NullString

NewNullString will return an empty sql.NullString if s is empty, and an sql.NullString with s in it if not

Types

type CloudController

type CloudController struct {
	DB         *sqlx.DB
	SaltLength int
}

CloudController is the concrete struct that will implement Repository

func (*CloudController) CalculateSaltLength

func (d *CloudController) CalculateSaltLength() error

CalculateSaltLength will look in the CCDB for an existing salt to get its length, as it will be static throughout the DB

func (*CloudController) CreateServiceBinding

func (d *CloudController) CreateServiceBinding(binding cfclient.ServiceBinding, appGUID string, encryptionKey string) error

CreateServiceBinding will inject a service binding into the DB

func (*CloudController) CreateServiceInstance

func (d *CloudController) CreateServiceInstance(si cfclient.ServiceInstance, targetSpace cfclient.Space, targetPlan cfclient.ServicePlan, targetService cfclient.Service, key string) error

CreateServiceInstance will insert a service instance (and associated service usage event) in the CC DB

func (*CloudController) DeleteServiceInstance

func (d *CloudController) DeleteServiceInstance(spaceGUID string, serviceInstanceGUID string) (bool, error)

func (*CloudController) GenerateSalt

func (d *CloudController) GenerateSalt() (string, error)

GenerateSalt will create a random hex string with the appropriate length for the foundation

func (*CloudController) ServiceInstanceExists

func (d *CloudController) ServiceInstanceExists(serviceInstanceGUID string) (bool, error)

type Repository

type Repository interface {
	ServiceInstanceExists(guid string) (bool, error)
	CreateServiceInstance(si cfclient.ServiceInstance, targetSpace cfclient.Space, targetPlan cfclient.ServicePlan, targetService cfclient.Service, key string) error
	DeleteServiceInstance(spaceGUID string, serviceInstanceGUID string) (bool, error)
	CreateServiceBinding(binding cfclient.ServiceBinding, appGUID string, encryptionKey string) error
}

Repository calls operations on the CCDB

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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