cloudinit/datasource/file/file.go

44 lines
699 B
Go
Raw Permalink Normal View History

package file
2014-03-18 20:00:41 +04:00
import (
"io/ioutil"
"os"
2014-03-18 20:00:41 +04:00
)
type localFile struct {
path string
}
func NewDatasource(path string) *localFile {
2014-03-18 20:00:41 +04:00
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)
2014-03-18 20:00:41 +04:00
}
func (f *localFile) FetchNetworkConfig(filename string) ([]byte, error) {
return nil, nil
}
func (f *localFile) Type() string {
2014-03-18 20:00:41 +04:00
return "local-file"
}