Skip to content

Commit

Permalink
Merge pull request #103123 from dims/remove-fakefs-to-drop-spf13/afer…
Browse files Browse the repository at this point in the history
…o-dependency

Remove fakefs to drop spf13/afero dependency
  • Loading branch information
k8s-ci-robot committed Jun 24, 2021
2 parents 6d27e23 + 5feff28 commit 06dfe68
Show file tree
Hide file tree
Showing 39 changed files with 85 additions and 4,349 deletions.
178 changes: 0 additions & 178 deletions LICENSES/vendor/github.com/spf13/afero/LICENSE

This file was deleted.

2 changes: 1 addition & 1 deletion cmd/kubelet/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ func loadConfigFile(name string) (*kubeletconfiginternal.KubeletConfiguration, e
if err != nil {
return nil, fmt.Errorf(errFmt, name, err)
}
loader, err := configfiles.NewFsLoader(utilfs.DefaultFs{}, kubeletConfigFile)
loader, err := configfiles.NewFsLoader(&utilfs.DefaultFs{}, kubeletConfigFile)
if err != nil {
return nil, fmt.Errorf(errFmt, name, err)
}
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ require (
github.com/prometheus/common v0.26.0
github.com/quobyte/api v0.1.8
github.com/robfig/cron/v3 v3.0.1
github.com/spf13/afero v1.2.2
github.com/spf13/cobra v1.1.3
github.com/spf13/pflag v1.0.5
github.com/storageos/go-api v2.2.0+incompatible
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubelet/checkpointmanager/checkpoint_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type impl struct {

// NewCheckpointManager returns a new instance of a checkpoint manager
func NewCheckpointManager(checkpointDir string) (CheckpointManager, error) {
fstore, err := utilstore.NewFileStore(checkpointDir, utilfs.DefaultFs{})
fstore, err := utilstore.NewFileStore(checkpointDir, &utilfs.DefaultFs{})
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubelet/kubeletconfig/checkpoint/store/fsstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (
func newInitializedFakeFsStore() (*fsStore, error) {
// Test with the default filesystem, the fake filesystem has an issue caused by afero: https://github.com/spf13/afero/issues/141
// The default filesystem also behaves more like production, so we should probably not mock the filesystem for unit tests.
fs := utilfs.DefaultFs{}
fs := &utilfs.DefaultFs{}

tmpDir, err := fs.TempDir("", "fsstore-test-")
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion pkg/kubelet/kubeletconfig/configfiles/configfiles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ foo: bar`),

for _, c := range cases {
t.Run(c.desc, func(t *testing.T) {
fs := utilfs.NewFakeFs()
fs := utilfs.NewTempFs()
fs.MkdirAll(configDir, 0777)
path := filepath.Join(configDir, kubeletFile)
if c.file != nil {
if err := addFile(fs, path, *c.file); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubelet/kubeletconfig/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func NewController(dynamicConfigDir string, transform TransformFunc) *Controller
// channels must have capacity at least 1, since we signal with non-blocking writes
pendingConfigSource: make(chan bool, 1),
configStatus: status.NewNodeConfigStatus(),
checkpointStore: store.NewFsStore(utilfs.DefaultFs{}, filepath.Join(dynamicConfigDir, storeDir)),
checkpointStore: store.NewFsStore(&utilfs.DefaultFs{}, filepath.Join(dynamicConfigDir, storeDir)),
}
}

Expand Down
16 changes: 8 additions & 8 deletions pkg/kubelet/kubeletconfig/util/files/files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func TestHelpers(t *testing.T) {
}
for _, c := range cases {
t.Run(c.desc, func(t *testing.T) {
c.run(t, utilfs.DefaultFs{})
c.run(t, &utilfs.DefaultFs{})
})
}
}
Expand Down Expand Up @@ -241,7 +241,7 @@ func TestFileExists(t *testing.T) {
}
for _, c := range cases {
t.Run(c.desc, func(t *testing.T) {
c.run(t, utilfs.DefaultFs{})
c.run(t, &utilfs.DefaultFs{})
})
}
}
Expand Down Expand Up @@ -276,7 +276,7 @@ func TestEnsureFile(t *testing.T) {
}
for _, c := range cases {
t.Run(c.desc, func(t *testing.T) {
c.run(t, utilfs.DefaultFs{})
c.run(t, &utilfs.DefaultFs{})
})
}
}
Expand Down Expand Up @@ -317,7 +317,7 @@ func TestReplaceFile(t *testing.T) {
}
for _, c := range cases {
t.Run(c.desc, func(t *testing.T) {
c.run(t, utilfs.DefaultFs{})
c.run(t, &utilfs.DefaultFs{})
})
}
}
Expand Down Expand Up @@ -353,7 +353,7 @@ func TestDirExists(t *testing.T) {
}
for _, c := range cases {
t.Run(c.desc, func(t *testing.T) {
c.run(t, utilfs.DefaultFs{})
c.run(t, &utilfs.DefaultFs{})
})
}
}
Expand Down Expand Up @@ -388,7 +388,7 @@ func TestEnsureDir(t *testing.T) {
}
for _, c := range cases {
t.Run(c.desc, func(t *testing.T) {
c.run(t, utilfs.DefaultFs{})
c.run(t, &utilfs.DefaultFs{})
})
}
}
Expand All @@ -405,7 +405,7 @@ func TestWriteTempDir(t *testing.T) {
return nil
},
}
c.run(t, utilfs.DefaultFs{})
c.run(t, &utilfs.DefaultFs{})
}

func TestReplaceDir(t *testing.T) {
Expand Down Expand Up @@ -471,7 +471,7 @@ func TestReplaceDir(t *testing.T) {
}
for _, c := range cases {
t.Run(c.desc, func(t *testing.T) {
c.run(t, utilfs.DefaultFs{})
c.run(t, &utilfs.DefaultFs{})
})
}
}
13 changes: 1 addition & 12 deletions pkg/kubelet/util/store/filestore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ limitations under the License.
package store

import (
"io/ioutil"
"os"
"sort"
"testing"

Expand All @@ -28,16 +26,7 @@ import (
)

func TestFileStore(t *testing.T) {
path, err := ioutil.TempDir("", "FileStore")
assert.NoError(t, err)
defer os.RemoveAll(path)
store, err := NewFileStore(path, filesystem.DefaultFs{})
assert.NoError(t, err)
testStore(t, store)
}

func TestFakeFileStore(t *testing.T) {
store, err := NewFileStore("/tmp/test-fake-file-store", filesystem.NewFakeFs())
store, err := NewFileStore("/FileStore", filesystem.NewTempFs())
assert.NoError(t, err)
testStore(t, store)
}
Expand Down

0 comments on commit 06dfe68

Please sign in to comment.