Documentation ¶
Index ¶
- Constants
- Variables
- func CreateProvisionRequestDetails(ctx context.Context, object *models.ProvisionRequestDetails) error
- func CreateServiceBindingCredentials(ctx context.Context, object *models.ServiceBindingCredentials) error
- func CreateServiceInstanceDetails(ctx context.Context, object *models.ServiceInstanceDetails) error
- func CreateTerraformDeployment(ctx context.Context, object *models.TerraformDeployment) error
- func DeleteProvisionRequestDetails(ctx context.Context, record *models.ProvisionRequestDetails) error
- func DeleteProvisionRequestDetailsById(ctx context.Context, id uint) error
- func DeleteServiceBindingCredentials(ctx context.Context, record *models.ServiceBindingCredentials) error
- func DeleteServiceBindingCredentialsByBindingId(ctx context.Context, bindingId string) error
- func DeleteServiceBindingCredentialsById(ctx context.Context, id uint) error
- func DeleteServiceBindingCredentialsByServiceInstanceIdAndBindingId(ctx context.Context, serviceInstanceId string, bindingId string) error
- func DeleteServiceInstanceDetails(ctx context.Context, record *models.ServiceInstanceDetails) error
- func DeleteServiceInstanceDetailsById(ctx context.Context, id string) error
- func DeleteTerraformDeployment(ctx context.Context, record *models.TerraformDeployment) error
- func DeleteTerraformDeploymentById(ctx context.Context, id string) error
- func ExistsProvisionRequestDetailsById(ctx context.Context, id uint) (bool, error)
- func ExistsServiceBindingCredentialsByBindingId(ctx context.Context, bindingId string) (bool, error)
- func ExistsServiceBindingCredentialsById(ctx context.Context, id uint) (bool, error)
- func ExistsServiceBindingCredentialsByServiceInstanceIdAndBindingId(ctx context.Context, serviceInstanceId string, bindingId string) (bool, error)
- func ExistsServiceInstanceDetailsById(ctx context.Context, id string) (bool, error)
- func ExistsTerraformDeploymentById(ctx context.Context, id string) (bool, error)
- func GetProvisionRequestDetailsById(ctx context.Context, id uint) (*models.ProvisionRequestDetails, error)
- func GetServiceBindingCredentialsByBindingId(ctx context.Context, bindingId string) (*models.ServiceBindingCredentials, error)
- func GetServiceBindingCredentialsById(ctx context.Context, id uint) (*models.ServiceBindingCredentials, error)
- func GetServiceBindingCredentialsByServiceInstanceIdAndBindingId(ctx context.Context, serviceInstanceId string, bindingId string) (*models.ServiceBindingCredentials, error)
- func GetServiceInstanceDetailsById(ctx context.Context, id string) (*models.ServiceInstanceDetails, error)
- func GetTerraformDeploymentById(ctx context.Context, id string) (*models.TerraformDeployment, error)
- func New(logger lager.Logger) *gorm.DB
- func RunMigrations(db *gorm.DB) error
- func SaveProvisionRequestDetails(ctx context.Context, object *models.ProvisionRequestDetails) error
- func SaveServiceBindingCredentials(ctx context.Context, object *models.ServiceBindingCredentials) error
- func SaveServiceInstanceDetails(ctx context.Context, object *models.ServiceInstanceDetails) error
- func SaveTerraformDeployment(ctx context.Context, object *models.TerraformDeployment) error
- func SetDatabaseCredentials(vcapService VcapService) error
- func SetupDb(logger lager.Logger) *gorm.DB
- func UseVcapServices() error
- func ValidateLastMigration(lastMigration int) error
- type SqlDatastore
- func (ds *SqlDatastore) CreateProvisionRequestDetails(ctx context.Context, object *models.ProvisionRequestDetails) error
- func (ds *SqlDatastore) CreateServiceBindingCredentials(ctx context.Context, object *models.ServiceBindingCredentials) error
- func (ds *SqlDatastore) CreateServiceInstanceDetails(ctx context.Context, object *models.ServiceInstanceDetails) error
- func (ds *SqlDatastore) CreateTerraformDeployment(ctx context.Context, object *models.TerraformDeployment) error
- func (ds *SqlDatastore) DeleteProvisionRequestDetails(ctx context.Context, record *models.ProvisionRequestDetails) error
- func (ds *SqlDatastore) DeleteProvisionRequestDetailsById(ctx context.Context, id uint) error
- func (ds *SqlDatastore) DeleteServiceBindingCredentials(ctx context.Context, record *models.ServiceBindingCredentials) error
- func (ds *SqlDatastore) DeleteServiceBindingCredentialsByBindingId(ctx context.Context, bindingId string) error
- func (ds *SqlDatastore) DeleteServiceBindingCredentialsById(ctx context.Context, id uint) error
- func (ds *SqlDatastore) DeleteServiceBindingCredentialsByServiceInstanceIdAndBindingId(ctx context.Context, serviceInstanceId string, bindingId string) error
- func (ds *SqlDatastore) DeleteServiceInstanceDetails(ctx context.Context, record *models.ServiceInstanceDetails) error
- func (ds *SqlDatastore) DeleteServiceInstanceDetailsById(ctx context.Context, id string) error
- func (ds *SqlDatastore) DeleteTerraformDeployment(ctx context.Context, record *models.TerraformDeployment) error
- func (ds *SqlDatastore) DeleteTerraformDeploymentById(ctx context.Context, id string) error
- func (ds *SqlDatastore) ExistsProvisionRequestDetailsById(ctx context.Context, id uint) (bool, error)
- func (ds *SqlDatastore) ExistsServiceBindingCredentialsByBindingId(ctx context.Context, bindingId string) (bool, error)
- func (ds *SqlDatastore) ExistsServiceBindingCredentialsById(ctx context.Context, id uint) (bool, error)
- func (ds *SqlDatastore) ExistsServiceBindingCredentialsByServiceInstanceIdAndBindingId(ctx context.Context, serviceInstanceId string, bindingId string) (bool, error)
- func (ds *SqlDatastore) ExistsServiceInstanceDetailsById(ctx context.Context, id string) (bool, error)
- func (ds *SqlDatastore) ExistsTerraformDeploymentById(ctx context.Context, id string) (bool, error)
- func (ds *SqlDatastore) GetProvisionRequestDetailsById(ctx context.Context, id uint) (*models.ProvisionRequestDetails, error)
- func (ds *SqlDatastore) GetServiceBindingCredentialsByBindingId(ctx context.Context, bindingId string) (*models.ServiceBindingCredentials, error)
- func (ds *SqlDatastore) GetServiceBindingCredentialsById(ctx context.Context, id uint) (*models.ServiceBindingCredentials, error)
- func (ds *SqlDatastore) GetServiceBindingCredentialsByServiceInstanceIdAndBindingId(ctx context.Context, serviceInstanceId string, bindingId string) (*models.ServiceBindingCredentials, error)
- func (ds *SqlDatastore) GetServiceInstanceDetailsById(ctx context.Context, id string) (*models.ServiceInstanceDetails, error)
- func (ds *SqlDatastore) GetTerraformDeploymentById(ctx context.Context, id string) (*models.TerraformDeployment, error)
- func (ds *SqlDatastore) SaveProvisionRequestDetails(ctx context.Context, object *models.ProvisionRequestDetails) error
- func (ds *SqlDatastore) SaveServiceBindingCredentials(ctx context.Context, object *models.ServiceBindingCredentials) error
- func (ds *SqlDatastore) SaveServiceInstanceDetails(ctx context.Context, object *models.ServiceInstanceDetails) error
- func (ds *SqlDatastore) SaveTerraformDeployment(ctx context.Context, object *models.TerraformDeployment) error
- type VcapService
Examples ¶
Constants ¶
const ( DbTypeMysql = "mysql" DbTypeSqlite3 = "sqlite3" )
Variables ¶
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 ¶
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 ¶
DeleteServiceBindingCredentialsByBindingId soft-deletes the record by its key (bindingId).
func DeleteServiceBindingCredentialsById ¶
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 ¶
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 ¶
DeleteTerraformDeploymentById soft-deletes the record by its key (id).
func ExistsProvisionRequestDetailsById ¶
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 ¶
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 ¶
ExistsServiceInstanceDetailsById checks to see if an instance of ServiceInstanceDetails exists by its key (id).
func ExistsTerraformDeploymentById ¶
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 RunMigrations ¶
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 ¶
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 ¶
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 (*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 (*SqlDatastore) ExistsServiceBindingCredentialsByBindingId ¶
func (*SqlDatastore) ExistsServiceBindingCredentialsById ¶
func (*SqlDatastore) ExistsServiceBindingCredentialsByServiceInstanceIdAndBindingId ¶
func (*SqlDatastore) ExistsServiceInstanceDetailsById ¶
func (*SqlDatastore) ExistsTerraformDeploymentById ¶
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)