MCPcopy Index your code
hub / github.com/compose-spec/compose-go

github.com/compose-spec/compose-go @v2.13.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.13.0 ↗ · + Follow
1,308 symbols 3,734 edges 229 files 384 documented · 29% 29 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

compose-go

Continuous integration Go Reference

Go reference library for parsing and loading Compose files as specified by the Compose specification.

Usage

package main

import (
    "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

make build

or use the go build command

go build ./...

Run the tests

You can run the tests with the makefile

make test

or with the go test command

gotestsum ./...

Other helpful make commands

Run the linter

make lint

Check the license headers

make check_license

Check the compose-spec.json file is sync with the compose-spec repository

make check_compose_spec

Used by

Extension points exported contracts — how you extend this code

ResourceLoader (Interface)
ResourceLoader is a plugable remote resource resolver [2 implementers]
loader/loader.go
LookupFn (FuncType)
Keys starting with numbers are ignored LookupFn represents a lookup function to resolve variables from
dotenv/godotenv.go
LookupValue (FuncType)
LookupValue is a function which maps from variable names to values. Returns the value as a string and a bool indicating
interpolation/interpolation.go
Mapping (FuncType)
Mapping is a user-supplied function which maps from variable names to values. Returns the value as a string and a bool i
template/template.go
CollectorFn (FuncType)
CollectorFn executes on each graph vertex based on visit order and return associated value
graph/traversal.go
Func (FuncType)
Func is a function that can transform data at a specific path
transform/canonical.go
ServiceFunc (FuncType)
(no doc)
types/project.go
RemoteResource (FuncType)
(no doc)
paths/resolve.go

Core symbols most depended-on inside this repo

LoadWithContext
called by 93
loader/loader.go
NewPath
called by 55
tree/path.go
Error
called by 47
schema/schema.go
DeepCopy
called by 42
types/config.go
GetService
called by 39
types/project.go
servicePath
called by 34
loader/interpolate.go
Substitute
called by 33
template/template.go
NewProjectOptions
called by 31
cli/options.go

Shape

Function 973
Method 196
Struct 81
TypeAlias 35
FuncType 20
Interface 3

Languages

Go100%

Modules by API surface

loader/loader_test.go123 symbols
types/derived.gen.go69 symbols
types/types.go68 symbols
types/project.go51 symbols
loader/loader.go49 symbols
cli/options.go38 symbols
template/template_test.go35 symbols
dotenv/godotenv_test.go34 symbols
template/template.go31 symbols
format/volume_test.go24 symbols
types/project_test.go20 symbols
override/merge.go18 symbols

For agents

$ claude mcp add compose-go \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact