datasource: Move datasources into their own packages.

This commit is contained in:
Alex Crawford
2014-07-30 13:56:36 -07:00
parent 49ac083af5
commit 8566a2c118
11 changed files with 54 additions and 33 deletions

38
datasource/url/url.go Normal file
View File

@@ -0,0 +1,38 @@
package url
import "github.com/coreos/coreos-cloudinit/pkg"
type remoteFile struct {
url string
}
func NewDatasource(url string) *remoteFile {
return &remoteFile{url}
}
func (f *remoteFile) IsAvailable() bool {
client := pkg.NewHttpClient()
_, err := client.Get(f.url)
return (err == nil)
}
func (f *remoteFile) AvailabilityChanges() bool {
return true
}
func (f *remoteFile) ConfigRoot() string {
return ""
}
func (f *remoteFile) FetchMetadata() ([]byte, error) {
return []byte{}, nil
}
func (f *remoteFile) FetchUserdata() ([]byte, error) {
client := pkg.NewHttpClient()
return client.GetRetry(f.url)
}
func (f *remoteFile) Type() string {
return "url"
}