mirror of
https://github.com/rancher/os.git
synced 2025-08-31 22:32:14 +00:00
Refactor configuration to compose syntax
This commit is contained in:
16
util/util.go
16
util/util.go
@@ -4,9 +4,12 @@ import (
|
||||
"archive/tar"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/docker/docker/pkg/mount"
|
||||
@@ -182,3 +185,16 @@ func MergeMaps(left, right map[interface{}]interface{}) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func LoadResource(location string) ([]byte, error) {
|
||||
if strings.HasPrefix(location, "http:/") || strings.HasPrefix(location, "https:/") {
|
||||
resp, err := http.Get(location)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
return ioutil.ReadAll(resp.Body)
|
||||
} else {
|
||||
return ioutil.ReadFile(location)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user