Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nebhale/client-go
Service Bindings for Kubernetes Go Client
https://github.com/nebhale/client-go
go golang
Last synced: 4 days ago
JSON representation
Service Bindings for Kubernetes Go Client
- Host: GitHub
- URL: https://github.com/nebhale/client-go
- Owner: nebhale
- License: apache-2.0
- Created: 2021-08-19T17:52:34.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-11T14:10:19.000Z (8 months ago)
- Last Synced: 2024-04-17T00:57:37.457Z (7 months ago)
- Topics: go, golang
- Language: Go
- Homepage:
- Size: 95.7 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# client-go
[![Tests](https://github.com/nebhale/client-go/workflows/Tests/badge.svg?branch=main)](https://github.com/nebhale/client-go/actions/workflows/tests.yaml)
[![GoDoc](https://godoc.org/github.com/nebhale/client-go?status.svg)](https://godoc.org/github.com/nebhale/client-go)
[![Go Report Card](https://goreportcard.com/badge/github.com/nebhale/client-go)](https://goreportcard.com/report/github.com/nebhale/client-go)
[![codecov](https://codecov.io/gh/nebhale/client-go/branch/main/graph/badge.svg)](https://codecov.io/gh/nebhale/client-go)`client-go` is a library to access [Service Binding Specification for Kubernetes](https://k8s-service-bindings.github.io/spec/) conformant Service Binding [Workload Projections](https://k8s-service-bindings.github.io/spec/#workload-projection).
## Example
```golang
import (
"context"
"fmt"
"github.com/jackc/pgx/v4"
"github.com/nebhale/client-go/bindings"
"os"
)func main() {
b := bindings.FromServiceBindingRoot()
b = bindings.Filter(b, "postgresql")
if len(b) != 1 {
_, _ = fmt.Fprintf(os.Stderr, "Incorrect number of PostgreSQL drivers: %d\n", len(b))
os.Exit(1)
}u, ok := bindings.Get(b[0], "url")
if !ok {
_, _ = fmt.Fprintln(os.Stderr, "No URL in binding")
os.Exit(1)
}conn, err := pgx.Connect(context.Background(), u)
if err != nil {
_, _ = fmt.Fprintf(os.Stderr, "Unable to connect to database: %v\n", err)
os.Exit(1)
}
defer conn.Close(context.Background())// ...
}
```## License
Apache License v2.0: see [LICENSE](./LICENSE) for details.