mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 13:45:06 +00:00
Merge pull request #57494 from stewart-yu/fixFunctionError
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. fix unstandardized function name new() **What this PR does / why we need it**: fix unstandardized function name, rename new() to newSourceFile() **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes [https://github.com/kubernetes/kubernetes/issues/57495](https://github.com/kubernetes/kubernetes/issues/57495) **Special notes for your reviewer**: **Release note**: ```release-note NONE ```
This commit is contained in:
@@ -48,12 +48,12 @@ func NewSourceFile(path string, nodeName types.NodeName, period time.Duration, u
|
|||||||
// "golang.org/x/exp/inotify" requires a path without trailing "/"
|
// "golang.org/x/exp/inotify" requires a path without trailing "/"
|
||||||
path = strings.TrimRight(path, string(os.PathSeparator))
|
path = strings.TrimRight(path, string(os.PathSeparator))
|
||||||
|
|
||||||
config := new(path, nodeName, period, updates)
|
config := newSourceFile(path, nodeName, period, updates)
|
||||||
glog.V(1).Infof("Watching path %q", path)
|
glog.V(1).Infof("Watching path %q", path)
|
||||||
go wait.Forever(config.run, period)
|
go wait.Forever(config.run, period)
|
||||||
}
|
}
|
||||||
|
|
||||||
func new(path string, nodeName types.NodeName, period time.Duration, updates chan<- interface{}) *sourceFile {
|
func newSourceFile(path string, nodeName types.NodeName, period time.Duration, updates chan<- interface{}) *sourceFile {
|
||||||
send := func(objs []interface{}) {
|
send := func(objs []interface{}) {
|
||||||
var pods []*v1.Pod
|
var pods []*v1.Pod
|
||||||
for _, o := range objs {
|
for _, o := range objs {
|
||||||
|
@@ -46,7 +46,7 @@ import (
|
|||||||
|
|
||||||
func TestExtractFromNonExistentFile(t *testing.T) {
|
func TestExtractFromNonExistentFile(t *testing.T) {
|
||||||
ch := make(chan interface{}, 1)
|
ch := make(chan interface{}, 1)
|
||||||
c := new("/some/fake/file", "localhost", time.Millisecond, ch)
|
c := newSourceFile("/some/fake/file", "localhost", time.Millisecond, ch)
|
||||||
err := c.watch()
|
err := c.watch()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Errorf("Expected error")
|
t.Errorf("Expected error")
|
||||||
@@ -137,7 +137,7 @@ func TestExtractFromBadDataFile(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ch := make(chan interface{}, 1)
|
ch := make(chan interface{}, 1)
|
||||||
c := new(fileName, "localhost", time.Millisecond, ch)
|
c := newSourceFile(fileName, "localhost", time.Millisecond, ch)
|
||||||
err = c.resetStoreFromPath()
|
err = c.resetStoreFromPath()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("expected error, got nil")
|
t.Fatalf("expected error, got nil")
|
||||||
@@ -153,7 +153,7 @@ func TestExtractFromEmptyDir(t *testing.T) {
|
|||||||
defer os.RemoveAll(dirName)
|
defer os.RemoveAll(dirName)
|
||||||
|
|
||||||
ch := make(chan interface{}, 1)
|
ch := make(chan interface{}, 1)
|
||||||
c := new(dirName, "localhost", time.Millisecond, ch)
|
c := newSourceFile(dirName, "localhost", time.Millisecond, ch)
|
||||||
err = c.resetStoreFromPath()
|
err = c.resetStoreFromPath()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
|
Reference in New Issue
Block a user