2014-07-31 00:56:36 +04:00
|
|
|
package url
|
2014-06-21 08:11:57 +04:00
|
|
|
|
|
|
|
import "github.com/coreos/coreos-cloudinit/pkg"
|
|
|
|
|
|
|
|
type remoteFile struct {
|
|
|
|
url string
|
|
|
|
}
|
|
|
|
|
2014-07-31 00:56:36 +04:00
|
|
|
func NewDatasource(url string) *remoteFile {
|
2014-06-21 08:11:57 +04:00
|
|
|
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"
|
|
|
|
}
|