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

39
datasource/file/file.go Normal file
View File

@@ -0,0 +1,39 @@
package file
import (
"io/ioutil"
"os"
)
type localFile struct {
path string
}
func NewDatasource(path string) *localFile {
return &localFile{path}
}
func (f *localFile) IsAvailable() bool {
_, err := os.Stat(f.path)
return !os.IsNotExist(err)
}
func (f *localFile) AvailabilityChanges() bool {
return true
}
func (f *localFile) ConfigRoot() string {
return ""
}
func (f *localFile) FetchMetadata() ([]byte, error) {
return []byte{}, nil
}
func (f *localFile) FetchUserdata() ([]byte, error) {
return ioutil.ReadFile(f.path)
}
func (f *localFile) Type() string {
return "local-file"
}