Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kubelet: remove superfluous function #111220

Merged
merged 1 commit into from Nov 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 2 additions & 11 deletions pkg/kubelet/util/store/filestore.go
Expand Up @@ -41,7 +41,7 @@ type FileStore struct {

// NewFileStore returns an instance of FileStore.
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 &FileStore{directoryPath: path, filesystem: fs}, nil
Expand All @@ -52,7 +52,7 @@ func (f *FileStore) Write(key string, data []byte) error {
if err := ValidateKey(key); err != nil {
return err
}
if err := ensureDirectory(f.filesystem, f.directoryPath); err != nil {
if err := f.filesystem.MkdirAll(f.directoryPath, 0755); err != nil {
return err
}

Expand Down Expand Up @@ -99,15 +99,6 @@ func (f *FileStore) getPathByKey(key string) string {
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.
func writeFile(fs utilfs.Filesystem, path string, data []byte) (retErr error) {
// Create a temporary file in the base directory of `path` with a prefix.
Expand Down