Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nebhale/client-jvm
Service Bindings for Kubernetes Java Client
https://github.com/nebhale/client-jvm
java
Last synced: about 2 months ago
JSON representation
Service Bindings for Kubernetes Java Client
- Host: GitHub
- URL: https://github.com/nebhale/client-jvm
- Owner: nebhale
- License: apache-2.0
- Created: 2021-08-20T15:05:54.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-23T21:36:37.000Z (2 months ago)
- Last Synced: 2024-10-24T10:03:52.460Z (2 months ago)
- Topics: java
- Language: Java
- Homepage:
- Size: 257 KB
- Stars: 1
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# client-jvm
[![Tests](https://github.com/nebhale/client-jvm/workflows/Tests/badge.svg?branch=main)](https://github.com/nebhale/client-jvm/actions/workflows/tests.yaml)
[![codecov](https://codecov.io/gh/nebhale/client-jvm/branch/main/graph/badge.svg)](https://codecov.io/gh/nebhale/client-jvm)`client-jvm` is a library to access [Service Binding Specification for Kubernetes](https://servicebinding.io/spec/core/1.1.0/) conformant Service Binding [Workload Projections](https://servicebinding.io/spec/core/1.1.0/#workload-projection).
## Example
```java
import com.nebhale.bindings.Binding;
import com.nebhale.bindings.Bindings;import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;public class Application {
public static void main(String[] args) {
Binding[] bindings = Bindings.fromServiceBindingRoot();
bindings = Bindings.filter(bindings, "postgresql");
if (bindings.length != 1) {
System.err.printf("Incorrect number of PostgreSQL drivers: %d\n", bindings.length);
System.exit(1);
}String url = bindings[0].get("url");
if (url == null) {
System.err.println("No URL in binding");
System.exit(1);
}Connection conn;
try {
conn = DriverManager.getConnection(url);
} catch (SQLException e) {
System.err.printf("Unable to connect to database: %s", e);
System.exit(1);
}// ...
}}
```## License
Apache License v2.0: see [LICENSE](./LICENSE) for details.