Documentation
¶
Overview ¶
Package binding defines the Provider interface and typed binding structs for SAP BTP service bindings. Concrete implementations are provided by sub-packages:
- binding/cf — Cloud Foundry VCAP_SERVICES parser
- binding/kyma — Kyma/Kubernetes Service Binding (stub, returns ErrUnsupported)
- binding/auto — automatically selects the appropriate provider
Typical usage:
import "github.com/bluefunda/btp-go/binding/auto"
prov, err := auto.NewProvider()
if err != nil {
log.Fatal(err)
}
xb, err := prov.XSUAA("") // "" = first instance
db, err := prov.Destination("")
cb, err := prov.Connectivity("")
The package is stdlib-only and has zero third-party dependencies.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("binding: not found")
ErrNotFound is returned when a requested service binding does not exist.
var ErrUnsupported = errors.New("binding: provider not supported in this runtime")
ErrUnsupported is returned by providers that are not yet implemented for the current runtime environment.
Functions ¶
This section is empty.
Types ¶
type ConnectivityBinding ¶
type ConnectivityBinding struct {
// OnpremiseProxyHost is the hostname of the SOCKS5/HTTP proxy.
OnpremiseProxyHost string
// OnpremiseProxySocks5Port is the SOCKS5 proxy port (typically "20004").
OnpremiseProxySocks5Port string
// OnpremiseProxyHTTPPort is the HTTP proxy port (typically "20003").
OnpremiseProxyHTTPPort string
// ClientID is the OAuth2 client identifier for the connectivity service.
ClientID string
// ClientSecret is the OAuth2 client secret.
ClientSecret string
// TokenServiceURL is the XSUAA token endpoint for the connectivity service.
TokenServiceURL string
}
ConnectivityBinding holds the credentials and proxy endpoints extracted from a Cloud Foundry connectivity service instance.
type DestinationBinding ¶
type DestinationBinding struct {
// URI is the base URL of the Destination Service REST API.
URI string
// ClientID is the OAuth2 client identifier.
ClientID string
// ClientSecret is the OAuth2 client secret.
ClientSecret string
// TokenServiceURL is the XSUAA token endpoint.
TokenServiceURL string
}
DestinationBinding holds the credentials for the SAP Destination service.
type Provider ¶
type Provider interface {
// Connectivity returns the binding for the SAP Connectivity service.
Connectivity(name string) (*ConnectivityBinding, error)
// Destination returns the binding for the SAP Destination service.
Destination(name string) (*DestinationBinding, error)
// XSUAA returns the binding for the SAP XSUAA service.
XSUAA(name string) (*XSUAABinding, error)
}
Provider retrieves typed service bindings from the current runtime environment (Cloud Foundry, Kyma, etc.).
The name argument selects among multiple instances of the same service type. Pass an empty string to select the first available instance.
Example ¶
package main
import (
"fmt"
"log"
"github.com/bluefunda/btp-go/binding/auto"
)
func main() {
// auto.NewProvider detects the runtime (CF vs Kyma) automatically.
prov, err := auto.NewProvider()
if err != nil {
log.Fatal(err)
}
cb, err := prov.Connectivity("")
if err != nil {
log.Fatal(err)
}
fmt.Println("proxy host:", cb.OnpremiseProxyHost)
}
Output:
type XSUAABinding ¶
type XSUAABinding struct {
// ClientID is the OAuth2 client identifier.
ClientID string
// ClientSecret is the OAuth2 client secret.
ClientSecret string
// URL is the XSUAA base URL (used to construct the /oauth/token endpoint).
URL string
// UAADomain is the UAA domain (e.g. "authentication.eu10.hana.ondemand.com").
UAADomain string
}
XSUAABinding holds the credentials for the SAP XSUAA service.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package auto selects the appropriate binding.Provider for the current runtime environment.
|
Package auto selects the appropriate binding.Provider for the current runtime environment. |
|
Package cf implements binding.Provider by parsing the VCAP_SERVICES environment variable present in Cloud Foundry application instances.
|
Package cf implements binding.Provider by parsing the VCAP_SERVICES environment variable present in Cloud Foundry application instances. |
|
Package kyma is a placeholder implementation of binding.Provider for SAP BTP Kyma (Kubernetes) runtime environments.
|
Package kyma is a placeholder implementation of binding.Provider for SAP BTP Kyma (Kubernetes) runtime environments. |