mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-20 17:49:10 +00:00
Merge pull request #27 from chanwit/add_source
add Source attribute to File
This commit is contained in:
commit
b47f3dec4a
@ -6,6 +6,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
@ -35,6 +36,7 @@ type Moby struct {
|
||||
Directory bool
|
||||
Symlink string
|
||||
Contents string
|
||||
Source string
|
||||
}
|
||||
Outputs []struct {
|
||||
Format string
|
||||
@ -671,7 +673,16 @@ func filesystem(m Moby) (*bytes.Buffer, error) {
|
||||
return buf, errors.New("Did not specify path for file")
|
||||
}
|
||||
if !f.Directory && f.Contents == "" && f.Symlink == "" {
|
||||
return buf, errors.New("Contents of file not specified")
|
||||
if f.Source == "" {
|
||||
return buf, errors.New("Contents of file not specified")
|
||||
}
|
||||
|
||||
contents, err := ioutil.ReadFile(f.Source)
|
||||
if err != nil {
|
||||
return buf, err
|
||||
}
|
||||
|
||||
f.Contents = string(contents)
|
||||
}
|
||||
// we need all the leading directories
|
||||
parts := strings.Split(path.Dir(f.Path), "/")
|
||||
|
@ -21,7 +21,8 @@ var schema = string(`
|
||||
"path": {"type": "string"},
|
||||
"directory": {"type": "boolean"},
|
||||
"symlink": {"type": "string"},
|
||||
"contents": {"type": "string"}
|
||||
"contents": {"type": "string"},
|
||||
"source": {"type": "string"}
|
||||
}
|
||||
},
|
||||
"files": {
|
||||
|
Loading…
Reference in New Issue
Block a user