Skip to content

bluefunda/btp-go

Repository files navigation

btp-go

Go Reference License

A Go workspace monorepo of small, focused, stdlib-only libraries for consuming SAP BTP (Business Technology Platform) services from Go applications — on Cloud Foundry, Kyma, or any Go-capable runtime.

Module overview

Module Import path Purpose
connectivity github.com/bluefunda/btp-go/connectivity Open TCP tunnels through SAP Cloud Connector via the SOCKS5 proxy (SAP 0x80 auth)
xsuaa github.com/bluefunda/btp-go/xsuaa Fetch and cache client-credentials tokens from SAP XSUAA
destination github.com/bluefunda/btp-go/destination Look up named destinations from the SAP Destination Service REST API
binding github.com/bluefunda/btp-go/binding Parse service bindings from VCAP_SERVICES (CF), Kyma, or auto-detect
sshclient github.com/bluefunda/btp-go/sshclient High-level SSH/SFTP client over the Cloud Connector tunnel (wraps connectivity + destination)
httpclient github.com/bluefunda/btp-go/httpclient HTTP/REST/OData client wired for a Destination's auth + Cloud Connector tunnel; OData v2 CSRF helper

Dependency diagram

consumer app
    ├── binding/auto   (detects CF vs Kyma at runtime)
    │   ├── binding/cf    (VCAP_SERVICES)
    │   └── binding/kyma  (Servicebinding.io file layout)
    ├── connectivity   (SOCKS5 dialer — SAP 0x80 auth)
    ├── destination    (Destination Service REST client)
    ├── sshclient      (SSH/SFTP over Cloud Connector tunnel)
    ├── httpclient     (HTTP/OData client with auth + proxy wiring)
    └── xsuaa          (token source)

connectivity ─── (local TokenSource interface, satisfied by xsuaa)
destination  ─── (local TokenSource interface, satisfied by xsuaa)
sshclient    ─── (local Dialer interface, satisfied by connectivity.Dialer)
httpclient   ─── (local Dialer + TokenSource interfaces)

Zero cross-module imports among the library modules.
Each module is independently go get-able by semver tag.

Binding API

The binding.Provider interface has a single method:

type Provider interface {
    Binding(serviceType, name string) (map[string]string, error)
}

Typed credentials are returned by package-level extractor functions:

import (
    "github.com/bluefunda/btp-go/binding"
    "github.com/bluefunda/btp-go/binding/auto"
)

prov, _ := auto.NewProvider()

cb, _ := binding.Connectivity(prov, "")   // *binding.ConnectivityBinding
db, _ := binding.Destination(prov, "")   // *binding.DestinationBinding
xb, _ := binding.XSUAA(prov, "")         // *binding.XSUAABinding

Adding support for a new SAP service type requires only a new extractor function, not a change to the Provider interface.

Destination API

destination.Destination exposes helper methods for common field access:

import "github.com/bluefunda/btp-go/destination"

dest, _ := client.Find(ctx, "MY_DEST")

portNum, err := dest.PortNum()       // parses Port as uint16
user    := dest.ResolvedUser()       // checks User field, then Properties["User"]
pass    := dest.ResolvedPassword()   // checks Password field, then Properties["Password"]

These helpers remove the need for inline strconv.ParseUint calls and manual Properties map lookups in calling code.

Quickstart

SFTP over Cloud Connectorexamples/sftp-count Go Reference

A complete Cloud Foundry app that counts files on a remote SFTP server via the Cloud Connector, exercising binding, xsuaa, connectivity, and destination end-to-end.

cd examples/sftp-count
cf push
curl "https://<app-route>/sftp/count?destination=MY_SFTP_DEST"

HTTP / OData destinationsexamples/http-odata Go Reference

A complete Cloud Foundry app that proxies OData reads and writes through httpclient, wired via the Connectivity HTTP CONNECT proxy (port 20003) with automatic CSRF-token / cookie-jar handling.

cd examples/http-odata
cf push
curl "https://<app-route>/odata?destination=MY_HTTP_DEST&path=/Items?%24top=5"
curl -X POST "https://<app-route>/odata?destination=MY_HTTP_DEST&path=/Items" \
  -H "Content-Type: application/json" -d '{"Name":"test"}'

SFTP via sshclientexamples/sftp-sshclient shows the same SFTP count use-case as sftp-count but uses sshclient.Dial (the high-level wrapper with retry) instead of raw golang.org/x/crypto/ssh.

cd examples/sftp-sshclient
cf push
curl "https://<app-route>/sftp/count?destination=MY_SFTP_DEST"

Local development

git clone https://github.com/bluefunda/btp-go
cd btp-go
go build ./...
go test ./...

Milestones

Milestone Status Description
M1 ✅ shipped Core modules: xsuaa, connectivity, destination, binding (CF + Kyma), sshclient
M2 planned Oracle consumer using go-ora (pure Go), layers cleanly on net.Conn from connectivity.Dial
M3 ✅ shipped HTTP destination support — httpclient.New(dest, cfg) returns a configured *http.Client (auth headers, Cloud Connector dialer, cookie jar) plus FetchCSRF for OData v2 writes
M4 ✅ shipped Kyma binding provider — reads Servicebinding.io file-mounted secrets; handles per-key files, JSON-blob fallback, and Kubernetes atomic-update sentinels
M5 planned Principal propagation and user-token-exchange flows in xsuaa

Support model

btp-go is maintained by BlueFunda. Security fixes are released within 7 days of disclosure. Feature requests are evaluated quarterly. Please open a GitHub issue for bug reports or enhancement proposals.

License

Apache-2.0. See LICENSE.

Authored by Amish Kushwaha, open-sourced under Apache 2.0 by BlueFunda, Inc.

About

stdlib-only Go libraries for SAP BTP — XSUAA, Connectivity, Destination, service bindings

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages