1
0
mirror of https://github.com/rancher/os.git synced 2025-09-16 23:21:19 +00:00

refactor a little and keep the datasource errors for later

Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
This commit is contained in:
Sven Dowideit
2017-03-01 15:12:56 +10:00
parent 23a4d8ec76
commit 391082fa50
16 changed files with 181 additions and 91 deletions

18
config/cloudinit/datasource/file/file.go Normal file → Executable file
View File

@@ -15,6 +15,7 @@
package file
import (
"fmt"
"io/ioutil"
"os"
@@ -22,16 +23,25 @@ import (
)
type LocalFile struct {
path string
path string
lastError error
}
func NewDatasource(path string) *LocalFile {
return &LocalFile{path}
return &LocalFile{path, nil}
}
func (f *LocalFile) IsAvailable() bool {
_, err := os.Stat(f.path)
return !os.IsNotExist(err)
_, f.lastError = os.Stat(f.path)
return !os.IsNotExist(f.lastError)
}
func (f *LocalFile) Finish() error {
return nil
}
func (f *LocalFile) String() string {
return fmt.Sprintf("%s: %s (lastError: %s)", f.Type(), f.path, f.lastError)
}
func (f *LocalFile) AvailabilityChanges() bool {