db_service

package
v4.4.0-rc2+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2019 License: Apache-2.0 Imports: 15 Imported by: 3

Documentation

Index

Examples

Constants

View Source
const (
	DbTypeMysql   = "mysql"
	DbTypeSqlite3 = "sqlite3"
)

Variables

View Source
var DbConnection *gorm.DB

Functions

func CreateProvisionRequestDetails

func CreateProvisionRequestDetails(ctx context.Context, object *models.ProvisionRequestDetails) error

CreateProvisionRequestDetails creates a new record in the database and assigns it a primary key.

func CreateServiceBindingCredentials

func CreateServiceBindingCredentials(ctx context.Context, object *models.ServiceBindingCredentials) error

CreateServiceBindingCredentials creates a new record in the database and assigns it a primary key.

func CreateServiceInstanceDetails

func CreateServiceInstanceDetails(ctx context.Context, object *models.ServiceInstanceDetails) error

CreateServiceInstanceDetails creates a new record in the database and assigns it a primary key.

func CreateTerraformDeployment

func CreateTerraformDeployment(ctx context.Context, object *models.TerraformDeployment) error

CreateTerraformDeployment creates a new record in the database and assigns it a primary key.

func DeleteProvisionRequestDetails

func DeleteProvisionRequestDetails(ctx context.Context, record *models.ProvisionRequestDetails) error

DeleteProvisionRequestDetails soft-deletes the record.

func DeleteProvisionRequestDetailsById

func DeleteProvisionRequestDetailsById(ctx context.Context, id uint) error

DeleteProvisionRequestDetailsById soft-deletes the record by its key (id).

func DeleteServiceBindingCredentials

func DeleteServiceBindingCredentials(ctx context.Context, record *models.ServiceBindingCredentials) error

DeleteServiceBindingCredentials soft-deletes the record.

func DeleteServiceBindingCredentialsByBindingId

func DeleteServiceBindingCredentialsByBindingId(ctx context.Context, bindingId string) error

DeleteServiceBindingCredentialsByBindingId soft-deletes the record by its key (bindingId).

func DeleteServiceBindingCredentialsById

func DeleteServiceBindingCredentialsById(ctx context.Context, id uint) error

DeleteServiceBindingCredentialsById soft-deletes the record by its key (id).

func DeleteServiceBindingCredentialsByServiceInstanceIdAndBindingId

func DeleteServiceBindingCredentialsByServiceInstanceIdAndBindingId(ctx context.Context, serviceInstanceId string, bindingId string) error

DeleteServiceBindingCredentialsByServiceInstanceIdAndBindingId soft-deletes the record by its key (serviceInstanceId, bindingId).

func DeleteServiceInstanceDetails

func DeleteServiceInstanceDetails(ctx context.Context, record *models.ServiceInstanceDetails) error

DeleteServiceInstanceDetails soft-deletes the record.

func DeleteServiceInstanceDetailsById

func DeleteServiceInstanceDetailsById(ctx context.Context, id string) error

DeleteServiceInstanceDetailsById soft-deletes the record by its key (id).

func DeleteTerraformDeployment

func DeleteTerraformDeployment(ctx context.Context, record *models.TerraformDeployment) error

DeleteTerraformDeployment soft-deletes the record.

func DeleteTerraformDeploymentById

func DeleteTerraformDeploymentById(ctx context.Context, id string) error

DeleteTerraformDeploymentById soft-deletes the record by its key (id).

func ExistsProvisionRequestDetailsById

func ExistsProvisionRequestDetailsById(ctx context.Context, id uint) (bool, error)

ExistsProvisionRequestDetailsById checks to see if an instance of ProvisionRequestDetails exists by its key (id).

func ExistsServiceBindingCredentialsByBindingId

func ExistsServiceBindingCredentialsByBindingId(ctx context.Context, bindingId string) (bool, error)

ExistsServiceBindingCredentialsByBindingId checks to see if an instance of ServiceBindingCredentials exists by its key (bindingId).

func ExistsServiceBindingCredentialsById

func ExistsServiceBindingCredentialsById(ctx context.Context, id uint) (bool, error)

ExistsServiceBindingCredentialsById checks to see if an instance of ServiceBindingCredentials exists by its key (id).

func ExistsServiceBindingCredentialsByServiceInstanceIdAndBindingId

func ExistsServiceBindingCredentialsByServiceInstanceIdAndBindingId(ctx context.Context, serviceInstanceId string, bindingId string) (bool, error)

ExistsServiceBindingCredentialsByServiceInstanceIdAndBindingId checks to see if an instance of ServiceBindingCredentials exists by its key (serviceInstanceId, bindingId).

func ExistsServiceInstanceDetailsById

func ExistsServiceInstanceDetailsById(ctx context.Context, id string) (bool, error)

ExistsServiceInstanceDetailsById checks to see if an instance of ServiceInstanceDetails exists by its key (id).

func ExistsTerraformDeploymentById

func ExistsTerraformDeploymentById(ctx context.Context, id string) (bool, error)

ExistsTerraformDeploymentById checks to see if an instance of TerraformDeployment exists by its key (id).

func GetProvisionRequestDetailsById

func GetProvisionRequestDetailsById(ctx context.Context, id uint) (*models.ProvisionRequestDetails, error)

GetProvisionRequestDetailsById gets an instance of ProvisionRequestDetails by its key (id).

func GetServiceBindingCredentialsByBindingId

func GetServiceBindingCredentialsByBindingId(ctx context.Context, bindingId string) (*models.ServiceBindingCredentials, error)

GetServiceBindingCredentialsByBindingId gets an instance of ServiceBindingCredentials by its key (bindingId).

func GetServiceBindingCredentialsById

func GetServiceBindingCredentialsById(ctx context.Context, id uint) (*models.ServiceBindingCredentials, error)

GetServiceBindingCredentialsById gets an instance of ServiceBindingCredentials by its key (id).

func GetServiceBindingCredentialsByServiceInstanceIdAndBindingId

func GetServiceBindingCredentialsByServiceInstanceIdAndBindingId(ctx context.Context, serviceInstanceId string, bindingId string) (*models.ServiceBindingCredentials, error)

GetServiceBindingCredentialsByServiceInstanceIdAndBindingId gets an instance of ServiceBindingCredentials by its key (serviceInstanceId, bindingId).

func GetServiceInstanceDetailsById

func GetServiceInstanceDetailsById(ctx context.Context, id string) (*models.ServiceInstanceDetails, error)

GetServiceInstanceDetailsById gets an instance of ServiceInstanceDetails by its key (id).

func GetTerraformDeploymentById

func GetTerraformDeploymentById(ctx context.Context, id string) (*models.TerraformDeployment, error)

GetTerraformDeploymentById gets an instance of TerraformDeployment by its key (id).

func New

func New(logger lager.Logger) *gorm.DB

Instantiates the db connection and runs migrations

func RunMigrations

func RunMigrations(db *gorm.DB) error

runs schema migrations on the provided service broker database to get it up to date

func SaveProvisionRequestDetails

func SaveProvisionRequestDetails(ctx context.Context, object *models.ProvisionRequestDetails) error

SaveProvisionRequestDetails updates an existing record in the database.

func SaveServiceBindingCredentials

func SaveServiceBindingCredentials(ctx context.Context, object *models.ServiceBindingCredentials) error

SaveServiceBindingCredentials updates an existing record in the database.

func SaveServiceInstanceDetails

func SaveServiceInstanceDetails(ctx context.Context, object *models.ServiceInstanceDetails) error

SaveServiceInstanceDetails updates an existing record in the database.

func SaveTerraformDeployment

func SaveTerraformDeployment(ctx context.Context, object *models.TerraformDeployment) error

SaveTerraformDeployment updates an existing record in the database.

func SetDatabaseCredentials

func SetDatabaseCredentials(vcapService VcapService) error

func SetupDb

func SetupDb(logger lager.Logger) *gorm.DB

pulls db credentials from the environment, connects to the db, and returns the db connection

func UseVcapServices

func UseVcapServices() error
Example
os.Setenv("VCAP_SERVICES", `{
  "p.mysql": [
    {
      "label": "p.mysql",
      "name": "my-instance",
      "plan": "db-medium",
      "provider": null,
      "syslog_drain_url": null,
      "tags": [
        "mysql"
      ],
      "credentials": {
        "hostname": "10.0.0.20",
        "jdbcUrl": "jdbc:mysql://10.0.0.20:3306/service_instance_db?user=fefcbe8360854a18a7994b870e7b0bf5\u0026password=z9z6eskdbs1rhtxt",
        "name": "service_instance_db",
        "password": "z9z6eskdbs1rhtxt",
        "port": 3306,
        "uri": "mysql://fefcbe8360854a18a7994b870e7b0bf5:z9z6eskdbs1rhtxt@10.0.0.20:3306/service_instance_db?reconnect=true",
        "username": "fefcbe8360854a18a7994b870e7b0bf5"
      },
      "volume_mounts": []
    }
  ]
}`)
UseVcapServices()
fmt.Println(viper.Get(dbHostProp))
fmt.Println(viper.Get(dbUserProp))
fmt.Println(viper.Get(dbPassProp))
fmt.Println(viper.Get(dbNameProp))
Output:

10.0.0.20
fefcbe8360854a18a7994b870e7b0bf5
z9z6eskdbs1rhtxt
service_instance_db

func ValidateLastMigration

func ValidateLastMigration(lastMigration int) error

ValidateLastMigration returns an error if the database version is newer than this tool supports or is too old to be updated.

Types

type SqlDatastore

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

func (*SqlDatastore) CreateProvisionRequestDetails

func (ds *SqlDatastore) CreateProvisionRequestDetails(ctx context.Context, object *models.ProvisionRequestDetails) error

func (*SqlDatastore) CreateServiceBindingCredentials

func (ds *SqlDatastore) CreateServiceBindingCredentials(ctx context.Context, object *models.ServiceBindingCredentials) error

func (*SqlDatastore) CreateServiceInstanceDetails

func (ds *SqlDatastore) CreateServiceInstanceDetails(ctx context.Context, object *models.ServiceInstanceDetails) error

func (*SqlDatastore) CreateTerraformDeployment

func (ds *SqlDatastore) CreateTerraformDeployment(ctx context.Context, object *models.TerraformDeployment) error

func (*SqlDatastore) DeleteProvisionRequestDetails

func (ds *SqlDatastore) DeleteProvisionRequestDetails(ctx context.Context, record *models.ProvisionRequestDetails) error

func (*SqlDatastore) DeleteProvisionRequestDetailsById

func (ds *SqlDatastore) DeleteProvisionRequestDetailsById(ctx context.Context, id uint) error

func (*SqlDatastore) DeleteServiceBindingCredentials

func (ds *SqlDatastore) DeleteServiceBindingCredentials(ctx context.Context, record *models.ServiceBindingCredentials) error

func (*SqlDatastore) DeleteServiceBindingCredentialsByBindingId

func (ds *SqlDatastore) DeleteServiceBindingCredentialsByBindingId(ctx context.Context, bindingId string) error

func (*SqlDatastore) DeleteServiceBindingCredentialsById

func (ds *SqlDatastore) DeleteServiceBindingCredentialsById(ctx context.Context, id uint) error

func (*SqlDatastore) DeleteServiceBindingCredentialsByServiceInstanceIdAndBindingId

func (ds *SqlDatastore) DeleteServiceBindingCredentialsByServiceInstanceIdAndBindingId(ctx context.Context, serviceInstanceId string, bindingId string) error

func (*SqlDatastore) DeleteServiceInstanceDetails

func (ds *SqlDatastore) DeleteServiceInstanceDetails(ctx context.Context, record *models.ServiceInstanceDetails) error

func (*SqlDatastore) DeleteServiceInstanceDetailsById

func (ds *SqlDatastore) DeleteServiceInstanceDetailsById(ctx context.Context, id string) error

func (*SqlDatastore) DeleteTerraformDeployment

func (ds *SqlDatastore) DeleteTerraformDeployment(ctx context.Context, record *models.TerraformDeployment) error

func (*SqlDatastore) DeleteTerraformDeploymentById

func (ds *SqlDatastore) DeleteTerraformDeploymentById(ctx context.Context, id string) error

func (*SqlDatastore) ExistsProvisionRequestDetailsById

func (ds *SqlDatastore) ExistsProvisionRequestDetailsById(ctx context.Context, id uint) (bool, error)

func (*SqlDatastore) ExistsServiceBindingCredentialsByBindingId

func (ds *SqlDatastore) ExistsServiceBindingCredentialsByBindingId(ctx context.Context, bindingId string) (bool, error)

func (*SqlDatastore) ExistsServiceBindingCredentialsById

func (ds *SqlDatastore) ExistsServiceBindingCredentialsById(ctx context.Context, id uint) (bool, error)

func (*SqlDatastore) ExistsServiceBindingCredentialsByServiceInstanceIdAndBindingId

func (ds *SqlDatastore) ExistsServiceBindingCredentialsByServiceInstanceIdAndBindingId(ctx context.Context, serviceInstanceId string, bindingId string) (bool, error)

func (*SqlDatastore) ExistsServiceInstanceDetailsById

func (ds *SqlDatastore) ExistsServiceInstanceDetailsById(ctx context.Context, id string) (bool, error)

func (*SqlDatastore) ExistsTerraformDeploymentById

func (ds *SqlDatastore) ExistsTerraformDeploymentById(ctx context.Context, id string) (bool, error)

func (*SqlDatastore) GetProvisionRequestDetailsById

func (ds *SqlDatastore) GetProvisionRequestDetailsById(ctx context.Context, id uint) (*models.ProvisionRequestDetails, error)

func (*SqlDatastore) GetServiceBindingCredentialsByBindingId

func (ds *SqlDatastore) GetServiceBindingCredentialsByBindingId(ctx context.Context, bindingId string) (*models.ServiceBindingCredentials, error)

func (*SqlDatastore) GetServiceBindingCredentialsById

func (ds *SqlDatastore) GetServiceBindingCredentialsById(ctx context.Context, id uint) (*models.ServiceBindingCredentials, error)

func (*SqlDatastore) GetServiceBindingCredentialsByServiceInstanceIdAndBindingId

func (ds *SqlDatastore) GetServiceBindingCredentialsByServiceInstanceIdAndBindingId(ctx context.Context, serviceInstanceId string, bindingId string) (*models.ServiceBindingCredentials, error)

func (*SqlDatastore) GetServiceInstanceDetailsById

func (ds *SqlDatastore) GetServiceInstanceDetailsById(ctx context.Context, id string) (*models.ServiceInstanceDetails, error)

func (*SqlDatastore) GetTerraformDeploymentById

func (ds *SqlDatastore) GetTerraformDeploymentById(ctx context.Context, id string) (*models.TerraformDeployment, error)

func (*SqlDatastore) SaveProvisionRequestDetails

func (ds *SqlDatastore) SaveProvisionRequestDetails(ctx context.Context, object *models.ProvisionRequestDetails) error

func (*SqlDatastore) SaveServiceBindingCredentials

func (ds *SqlDatastore) SaveServiceBindingCredentials(ctx context.Context, object *models.ServiceBindingCredentials) error

func (*SqlDatastore) SaveServiceInstanceDetails

func (ds *SqlDatastore) SaveServiceInstanceDetails(ctx context.Context, object *models.ServiceInstanceDetails) error

func (*SqlDatastore) SaveTerraformDeployment

func (ds *SqlDatastore) SaveTerraformDeployment(ctx context.Context, object *models.TerraformDeployment) error

type VcapService

type VcapService struct {
	BindingName  string                 `json:"binding_name"`  // The name assigned to the service binding by the user.
	InstanceName string                 `json:"instance_name"` // The name assigned to the service instance by the user.
	Name         string                 `json:"name"`          // The binding_name if it exists; otherwise the instance_name.
	Label        string                 `json:"label"`         // The name of the service offering.
	Tags         []string               `json:"tags"`          // An array of strings an app can use to identify a service instance.
	Plan         string                 `json:"plan"`          // The service plan selected when the service instance was created.
	Credentials  map[string]interface{} `json:"credentials"`   // The service-specific credentials needed to access the service instance.
}

func ParseVcapServices

func ParseVcapServices(vcapServicesData string) (VcapService, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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