https://github.com/openslo/go-sdk
OpenSLO SDK for the Go programming language.
https://github.com/openslo/go-sdk
Last synced: 12 months ago
JSON representation
OpenSLO SDK for the Go programming language.
- Host: GitHub
- URL: https://github.com/openslo/go-sdk
- Owner: OpenSLO
- License: apache-2.0
- Created: 2025-01-31T15:52:47.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-08T21:10:32.000Z (12 months ago)
- Last Synced: 2025-06-08T22:19:48.680Z (12 months ago)
- Language: Go
- Homepage: https://pkg.go.dev/github.com/OpenSLO/go-sdk
- Size: 235 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
#

---
OpenSLO SDK for the Go programming language.
⚠️ The SDK is in active development and awaits its official, v1 release.
We expect breaking API changes to be introduced freely.
---
## Installation
To add the latest version to your Go module run:
```shell
go get github.com/OpenSLO/go-sdk
```
## Usage
```go
package pkg_test
import (
"bytes"
"os"
v1 "github.com/OpenSLO/go-sdk/pkg/openslo/v1"
"github.com/OpenSLO/go-sdk/pkg/openslosdk"
)
const serviceDefinition = `
apiVersion: openslo/v1
kind: Service
metadata:
name: web-app
displayName: React Web Application
spec:
description: Web application built in React
`
func Example() {
// Decode the Service.
objects, err := openslosdk.Decode(bytes.NewBufferString(serviceDefinition), openslosdk.FormatYAML)
if err != nil {
panic(err)
}
// Define Data Source in code.
dataSource := v1.NewDataSource(
v1.Metadata{
Name: "prometheus",
Labels: v1.Labels{
"env": {"prod"},
},
},
v1.DataSourceSpec{
Description: "Production Prometheus",
Type: "Prometheus",
ConnectionDetails: []byte(`[{"url":"http://prometheus.example.com"}]`),
},
)
// Add Data Source to objects.
objects = append(objects, dataSource)
// Validate the objects.
if err = openslosdk.Validate(objects...); err != nil {
panic(err)
}
// Write objects to stdout in JSON format.
err = openslosdk.Encode(os.Stdout, openslosdk.FormatJSON, objects...)
if err != nil {
panic(err)
}
// Output:
// [
// {
// "apiVersion": "openslo/v1",
// "kind": "Service",
// "metadata": {
// "name": "web-app",
// "displayName": "React Web Application"
// },
// "spec": {
// "description": "Web application built in React"
// }
// },
// {
// "apiVersion": "openslo/v1",
// "kind": "DataSource",
// "metadata": {
// "name": "prometheus",
// "labels": {
// "env": [
// "prod"
// ]
// }
// },
// "spec": {
// "description": "Production Prometheus",
// "type": "Prometheus",
// "connectionDetails": [
// {
// "url": "http://prometheus.example.com"
// }
// ]
// }
// }
// ]
}
```
## Contributing
Checkout [contributing guidelines](./CONTRIBUTING.md).