feat(proc-cmdline): Parse /proc/cmdline for cloud-config-url

If the --from-proc-cmdline flag is given to coreos-cloudinit, the local
/proc/cmdline file will be parsed for a cloud-config-url
This commit is contained in:
Brian Waldon
2014-04-22 15:36:07 -07:00
parent 2ff0762b0c
commit 3de3d2c050
6 changed files with 150 additions and 28 deletions

View File

@@ -1,6 +1,31 @@
package datasource
import (
"io/ioutil"
"net/http"
)
type Datasource interface {
Fetch() ([]byte, error)
Type() string
}
func fetchURL(url string) ([]byte, error) {
client := http.Client{}
resp, err := client.Get(url)
if err != nil {
return []byte{}, err
}
defer resp.Body.Close()
if resp.StatusCode / 100 != 2 {
return []byte{}, nil
}
respBytes, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
return respBytes, nil
}