func (ms *metadataService) FetchUserdata() ([]byte, error) { client := pkg.NewHttpClient() if data, err := client.GetRetry(Ec2UserdataUrl); err == nil { return data, err } else if _, ok := err.(pkg.ErrTimeout); ok { return data, err } if data, err := client.GetRetry(OpenstackUserdataUrl); err == nil { return data, err } else if _, ok := err.(pkg.ErrNotFound); ok { return []byte{}, nil } else { return data, err } }
func fetchUserKeys(url string) ([]string, error) { client := pkg.NewHttpClient() data, err := client.GetRetry(url) if err != nil { return nil, err } var userKeys []UserKey err = json.Unmarshal(data, &userKeys) if err != nil { return nil, err } keys := make([]string, 0) for _, key := range userKeys { keys = append(keys, key.Key) } return keys, err }
func (c *procCmdline) FetchUserdata() ([]byte, error) { contents, err := ioutil.ReadFile(c.Location) if err != nil { return nil, err } cmdline := strings.TrimSpace(string(contents)) url, err := findCloudConfigURL(cmdline) if err != nil { return nil, err } client := pkg.NewHttpClient() cfg, err := client.GetRetry(url) if err != nil { return nil, err } return cfg, nil }
func NewDatasource(root string) *metadataService { if !strings.HasSuffix(root, "/") { root += "/" } return &metadataService{root, pkg.NewHttpClient()} }
func urlDownload(url string) ([]byte, error) { client := pkg.NewHttpClient() return client.GetRetry(url) }
func (ms *metadataService) FetchMetadata() ([]byte, error) { return fetchMetadata(pkg.NewHttpClient()) }
func (ms *metadataService) IsAvailable() bool { client := pkg.NewHttpClient() _, err := client.Get(BaseUrl) return (err == nil) }
func NewDatasource(root, apiVersion, userdataPath, metadataPath string) MetadataService { if !strings.HasSuffix(root, "/") { root += "/" } return MetadataService{root, pkg.NewHttpClient(), apiVersion, userdataPath, metadataPath} }
func (f *remoteFile) FetchUserdata() ([]byte, error) { client := pkg.NewHttpClient() return client.GetRetry(f.url) }
func (f *remoteFile) IsAvailable() bool { client := pkg.NewHttpClient() _, err := client.Get(f.url) return (err == nil) }
func (ms *metadataService) Fetch() ([]byte, error) { client := pkg.NewHttpClient() return client.Get(ms.url) }