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:
18
config/cloudinit/datasource/file/file.go
Normal file → Executable file
18
config/cloudinit/datasource/file/file.go
Normal file → Executable 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 {
|
||||
|
Reference in New Issue
Block a user