mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-20 17:49:10 +00:00
Add support to fetch yaml file with http
For example you can do ``` moby build https://raw.githubusercontent.com/linuxkit/linuxkit/master/linuxkit.yml ``` Signed-off-by: Justin Cormack <justin.cormack@docker.com>
This commit is contained in:
parent
90fd3e7e41
commit
d7ca674ea6
@ -8,6 +8,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
@ -198,6 +199,18 @@ func build(args []string) {
|
||||
if err != nil {
|
||||
log.Fatalf("Cannot read stdin: %v", err)
|
||||
}
|
||||
} else if strings.HasPrefix(arg, "http://") || strings.HasPrefix(arg, "https://") {
|
||||
buffer := new(bytes.Buffer)
|
||||
response, err := http.Get(arg)
|
||||
if err != nil {
|
||||
log.Fatal("Cannot fetch remote yaml file: %v", err)
|
||||
}
|
||||
defer response.Body.Close()
|
||||
_, err = io.Copy(buffer, response.Body)
|
||||
if err != nil {
|
||||
log.Fatalf("Error reading http body: %v", err)
|
||||
}
|
||||
config = buffer.Bytes()
|
||||
} else {
|
||||
var err error
|
||||
config, err = ioutil.ReadFile(conf)
|
||||
|
Loading…
Reference in New Issue
Block a user