mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 03:11:40 +00:00
Merge pull request #111220 from giuseppe/drop-superfluous-function
kubelet: remove superfluous function
This commit is contained in:
commit
e6060f2780
@ -41,7 +41,7 @@ type FileStore struct {
|
|||||||
|
|
||||||
// NewFileStore returns an instance of FileStore.
|
// NewFileStore returns an instance of FileStore.
|
||||||
func NewFileStore(path string, fs utilfs.Filesystem) (Store, error) {
|
func NewFileStore(path string, fs utilfs.Filesystem) (Store, error) {
|
||||||
if err := ensureDirectory(fs, path); err != nil {
|
if err := fs.MkdirAll(path, 0755); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &FileStore{directoryPath: path, filesystem: fs}, nil
|
return &FileStore{directoryPath: path, filesystem: fs}, nil
|
||||||
@ -52,7 +52,7 @@ func (f *FileStore) Write(key string, data []byte) error {
|
|||||||
if err := ValidateKey(key); err != nil {
|
if err := ValidateKey(key); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := ensureDirectory(f.filesystem, f.directoryPath); err != nil {
|
if err := f.filesystem.MkdirAll(f.directoryPath, 0755); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,15 +99,6 @@ func (f *FileStore) getPathByKey(key string) string {
|
|||||||
return filepath.Join(f.directoryPath, key)
|
return filepath.Join(f.directoryPath, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensureDirectory creates the directory if it does not exist.
|
|
||||||
func ensureDirectory(fs utilfs.Filesystem, path string) error {
|
|
||||||
if _, err := fs.Stat(path); err != nil {
|
|
||||||
// MkdirAll returns nil if directory already exists.
|
|
||||||
return fs.MkdirAll(path, 0755)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// writeFile writes data to path in a single transaction.
|
// writeFile writes data to path in a single transaction.
|
||||||
func writeFile(fs utilfs.Filesystem, path string, data []byte) (retErr error) {
|
func writeFile(fs utilfs.Filesystem, path string, data []byte) (retErr error) {
|
||||||
// Create a temporary file in the base directory of `path` with a prefix.
|
// Create a temporary file in the base directory of `path` with a prefix.
|
||||||
|
Loading…
Reference in New Issue
Block a user