2014-06-21 08:11:57 +04:00
|
|
|
package datasource
|
|
|
|
|
|
|
|
import "github.com/coreos/coreos-cloudinit/pkg"
|
|
|
|
|
|
|
|
type remoteFile struct {
|
|
|
|
url string
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewRemoteFile(url string) *remoteFile {
|
|
|
|
return &remoteFile{url}
|
|
|
|
}
|
|
|
|
|
2014-06-27 02:17:53 +04:00
|
|
|
func (f *remoteFile) IsAvailable() bool {
|
|
|
|
client := pkg.NewHttpClient()
|
|
|
|
_, err := client.Get(f.url)
|
|
|
|
return (err == nil)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *remoteFile) AvailabilityChanges() bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2014-06-21 08:11:57 +04:00
|
|
|
func (f *remoteFile) ConfigRoot() string {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *remoteFile) FetchMetadata() ([]byte, error) {
|
|
|
|
return []byte{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *remoteFile) FetchUserdata() ([]byte, error) {
|
|
|
|
client := pkg.NewHttpClient()
|
2014-06-27 01:58:32 +04:00
|
|
|
return client.GetRetry(f.url)
|
2014-06-21 08:11:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (f *remoteFile) Type() string {
|
|
|
|
return "url"
|
|
|
|
}
|