Skip to content

RHEcosystemAppEng/sbo-go-library

Repository files navigation

Service Binding Go Client for k8s Service Binding

sbo-go-library unit tests status Go Report Card GitHub go.mod Go version of a Go module

Installation

go get -u github.com/RHEcosystemAppEng/sbo-go-library

Usage

Have your connection properties saved under the SERVICE_BINDING_ROOT=./bindings

e.g.:
bindings
└── crdb
    ├── database
    ├── host
    ├── options
    ├── password
    ├── port
    ├── provider
    ├── sslmode
    ├── sslrootcert
    ├── type
    └── username

Add the client in your code

import github.com/RHEcosystemAppEng/sbo-go-library/pkg/binding/convert

Get a MongoDB Connection string

connString, err := convert.GetMongoDBConnectionString()

# sample value for connString
mongodb+srv://someUserName:password123+isItAGoodPassword+7%40%25%7C%3F%5EB6@mongodb0.example.com:11010/random-db?retryWrites=true&w=majority

Get a PostgreSQL Connection string

connString, err := convert.GetPostgreSQLConnectionString()

# sample value for connString
postgresql://remote-user:%5C@aws.postgresql.com:5432/cloud-postgresql-DB?sslmode=disable&options=-c%20search_path=keyword%20-c%20geqo=off

run locally

SERVICE_BINDING_ROOT=bindings go run ./cmd/<main.go>

Relevant info.

About

Go library to help retrieve and manage connection strings from the Service Binding Operator

Resources

License

Stars

Watchers

Forks

Packages

No packages published