Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bluebrown/labelparser
Parse labels into go maps
https://github.com/bluebrown/labelparser
docker docker-swarm go-package golang label parsing
Last synced: 15 days ago
JSON representation
Parse labels into go maps
- Host: GitHub
- URL: https://github.com/bluebrown/labelparser
- Owner: bluebrown
- Created: 2021-07-15T01:32:02.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-07-15T23:22:44.000Z (over 3 years ago)
- Last Synced: 2023-07-27T21:57:55.745Z (over 1 year ago)
- Topics: docker, docker-swarm, go-package, golang, label, parsing
- Language: Go
- Homepage:
- Size: 2.93 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Parse Labels Into Maps
Example Program:
```go
import (
"encoding/json"
"fmt"
"github.com/bluebrown/labelparser"
)func main() {
labels := map[string]string{
"com.docker.stack.namespace": "my-stack",
"com.docker.swarm.node.id": "y7t70zw5vmylsbo5qhmc56fgb",
"com.docker.swarm.service.id": "dy4kw0r22a4wqunp53sb7brqs",
"com.docker.swarm.service.name": "my-stack_manager",
"com.docker.swarm.task": "",
"com.docker.swarm.task.id": "ymx9j64986pnkmqii951a98nj",
"com.docker.swarm.task.name": "my-stack_manager.1.ymx9j64986pnkmqii951a98nj",
}conf := map[string]interface{}{}
labelparser.Parse(labels, &conf)b, _ := json.MarshalIndent(conf, "", " ")
fmt.Println(string(b))
}
```Output:
```json
{
"com": {
"docker": {
"stack": {
"namespace": "my-stack"
},
"swarm": {
"node": {
"id": "y7t70zw5vmylsbo5qhmc56fgb"
},
"service": {
"id": "dy4kw0r22a4wqunp53sb7brqs",
"name": "my-stack_manager"
},
"task": {
"id": "ymx9j64986pnkmqii951a98nj",
"name": "my-stack_manager.1.ymx9j64986pnkmqii951a98nj",
"task": ""
}
}
}
}
}
```