compose

package module
v2.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

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 := cli.ProjectFromOptions(ctx, options)
	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

Documentation

Overview

Go reference library for parsing and loading Compose files as specified by the Compose specification https://github.com/compose-spec/compose-spec.

Directories

Path Synopsis
Package dotenv is a go port of the ruby dotenv library (https://github.com/bkeepers/dotenv)
Package dotenv is a go port of the ruby dotenv library (https://github.com/bkeepers/dotenv)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL