Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/compose-spec/compose-go
Reference library for parsing and loading Compose YAML files
https://github.com/compose-spec/compose-go
compose compose-spec containers docker docker-compose
Last synced: 1 day ago
JSON representation
Reference library for parsing and loading Compose YAML files
- Host: GitHub
- URL: https://github.com/compose-spec/compose-go
- Owner: compose-spec
- License: apache-2.0
- Created: 2019-12-11T11:10:30.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-05-22T09:49:30.000Z (8 months ago)
- Last Synced: 2024-05-28T15:55:57.085Z (8 months ago)
- Topics: compose, compose-spec, containers, docker, docker-compose
- Language: Go
- Homepage: https://compose-spec.io
- Size: 3.5 MB
- Stars: 324
- Watchers: 13
- Forks: 101
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# compose-go
[![Continuous integration](https://github.com/compose-spec/compose-go/actions/workflows/ci.yml/badge.svg)](https://github.com/compose-spec/compose-go/actions/workflows/ci.yml)
[![Go Reference](https://pkg.go.dev/badge/github.com/compose-spec/compose-go.svg)](https://pkg.go.dev/github.com/compose-spec/compose-go)Go reference library for parsing and loading Compose files as specified by the
[Compose specification](https://github.com/compose-spec/compose-spec).## Usage
```go
package mainimport (
"context"
"fmt"
"log""github.com/compose-spec/compose-go/v2/cli"
)func main() {
composeFilePath := "docker-compose.yml"
projectName := "my_project"
ctx := context.Background()options, err := cli.NewProjectOptions(
[]string{composeFilePath},
cli.WithOsEnv,
cli.WithDotEnv,
cli.WithName(projectName),
)
if err != nil {
log.Fatal(err)
}project, err := options.LoadProject(ctx)
if err != nil {
log.Fatal(err)
}// Use the MarshalYAML method to get YAML representation
projectYAML, err := project.MarshalYAML()
if err != nil {
log.Fatal(err)
}fmt.Println(string(projectYAML))
}
```## Build the library
To build the library, you could either use the makefile
```bash
make build
```
or use the go build command
```bash
go build ./...
```## Run the tests
You can run the tests with the makefile
```bash
make test
```
or with the go test command
```bash
gotestsum ./...
```## Other helpful make commands
Run the linter
```bash
make lint
```Check the license headers
```bash
make check_license
```Check the `compose-spec.json` file is sync with the `compose-spec` repository
```bash
make check_compose_spec
```## Used by
* [compose](https://github.com/docker/compose)
* [containerd/nerdctl](https://github.com/containerd/nerdctl)
* [compose-cli](https://github.com/docker/compose-cli)
* [tilt.dev](https://github.com/tilt-dev/tilt)
* [kompose](https://github.com/kubernetes/kompose)
* [kurtosis](https://github.com/kurtosis-tech/kurtosis/)
* [testcontainers-go's Compose module](https://github.com/testcontainers/testcontainers-go/tree/main/modules/compose)
* [compose2nix](https://github.com/aksiksi/compose2nix)
* [Defang](https://github.com/DefangLabs/defang)
* [score-compose](https://github.com/score-spec/score-compose)
* [CasaOS](https://github.com/IceWhaleTech/CasaOS)