GithubHelp home page GithubHelp logo

yp05327 / compose-go Goto Github PK

View Code? Open in Web Editor NEW

This project forked from compose-spec/compose-go

0.0 1.0 0.0 3.39 MB

Reference library for the parsing and loading Compose files

Home Page: https://compose-spec.io

License: Apache License 2.0

Shell 0.15% Go 99.47% Makefile 0.23% Dockerfile 0.15%

compose-go's Introduction

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 (
	"fmt"
	"github.com/compose-spec/compose-go/loader"
	"github.com/compose-spec/compose-go/types"
	"log"
)

func main() {
	composeFilePath := "docker-compose.yml"
	projectName := "my_project"

	options, err := loader.NewProjectOptions(
		[]string{composeFilePath},
		types.WithOsEnv,
		types.WithDotEnv,
		types.WithName(projectName),
	)
	if err != nil {
		log.Fatal(err)
	}

	project, err := loader.ProjectFromOptions(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

compose-go's People

Contributors

ndeloof avatar glours avatar ulyssessouza avatar milas avatar dnephin avatar vdemeester avatar laurazard avatar dependabot-preview[bot] avatar thajeztah avatar dependabot[bot] avatar chris-crone avatar gtardif avatar mat007 avatar mbland avatar kklin avatar jhrotko avatar srebhan avatar silvin-lubecki avatar tbocek avatar lionello avatar shin- avatar akihirosuda avatar adshmh avatar zappy-shu avatar nicks avatar denverdino avatar sirlatrom avatar simonferquel avatar michaelperel avatar mmorel-35 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.