Skip to content

Instantly share code, notes, and snippets.

@tmlbl
Created September 13, 2014 23:46
Show Gist options
  • Save tmlbl/c325c7c94c8af1a1446e to your computer and use it in GitHub Desktop.
Save tmlbl/c325c7c94c8af1a1446e to your computer and use it in GitHub Desktop.
Basic implementation of fig syntax
// Implements fig syntax.
package main
import (
"gopkg.in/yaml.v1"
"io/ioutil"
"log"
)
var metaConfig MetaConfig
type MetaConfig map[string]MetaService
type MetaService struct {
Image string `yaml:"image"`
Build string `yaml:"build"`
Command string `yaml:"command"`
Links []string `yaml:"links"`
Ports []string `yaml:"ports"`
Expose []string `yaml:"expose"`
Volumes []string `yaml:"volumes"`
VolumesFrom []string `yaml:"volumes_from"`
}
func (mc *MetaConfig) Load() {
data, err := ioutil.ReadFile("./fig.yml")
if err != nil {
logErr(err)
}
yaml.Unmarshal(data, mc)
for _, svc := range *mc {
log.Println(svc.Image)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment