Merge pull request #150 from ijc/updates

Couple of minor updates to metadata file output
This commit is contained in:
Justin Cormack 2017-09-18 13:10:24 -07:00 committed by GitHub
commit 7ee5ff77d1
2 changed files with 5 additions and 2 deletions

View File

@ -110,7 +110,7 @@ supported here is `"yaml"` which will output the yaml used to generate the image
file:
```
- path: etc/linuxkit.yml
metadata:yaml
metadata: yaml
```
## `trust`

View File

@ -15,6 +15,7 @@ import (
"strings"
log "github.com/Sirupsen/logrus"
"gopkg.in/yaml.v2"
)
const defaultNameForStdin = "moby"
@ -389,8 +390,10 @@ func tarAppend(iw *tar.Writer, tr *tar.Reader) error {
// this allows inserting metadata into a file in the image
func metadata(m Moby, md string) ([]byte, error) {
switch md {
case "yaml":
case "json":
return json.MarshalIndent(m, "", " ")
case "yaml":
return yaml.Marshal(m)
default:
return []byte{}, fmt.Errorf("Unsupported metadata type: %s", md)
}