mirror of https://github.com/k3s-io/k3s
replace pkg/util/io with k8s.io/utils/io
parent
e321cdaee4
commit
123590d911
|
@ -321,8 +321,7 @@
|
||||||
"k8s.io/kubernetes/pkg/util/resizefs",
|
"k8s.io/kubernetes/pkg/util/resizefs",
|
||||||
"k8s.io/kubernetes/pkg/util/version",
|
"k8s.io/kubernetes/pkg/util/version",
|
||||||
"k8s.io/kubernetes/pkg/apis/apps",
|
"k8s.io/kubernetes/pkg/apis/apps",
|
||||||
"k8s.io/kubernetes/pkg/version",
|
"k8s.io/kubernetes/pkg/version"
|
||||||
"k8s.io/kubernetes/pkg/util/io"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -343,6 +342,8 @@
|
||||||
"k8s.io/metrics/pkg/client/custom_metrics/fake",
|
"k8s.io/metrics/pkg/client/custom_metrics/fake",
|
||||||
"k8s.io/metrics/pkg/client/external_metrics",
|
"k8s.io/metrics/pkg/client/external_metrics",
|
||||||
"k8s.io/metrics/pkg/client/external_metrics/fake",
|
"k8s.io/metrics/pkg/client/external_metrics/fake",
|
||||||
|
"k8s.io/utils/nsenter",
|
||||||
|
"k8s.io/utils/io",
|
||||||
"k8s.io/utils/pointer",
|
"k8s.io/utils/pointer",
|
||||||
"k8s.io/utils/exec"
|
"k8s.io/utils/exec"
|
||||||
]
|
]
|
||||||
|
|
|
@ -131,7 +131,6 @@
|
||||||
"k8s.io/kubernetes/pkg/util/goroutinemap",
|
"k8s.io/kubernetes/pkg/util/goroutinemap",
|
||||||
"k8s.io/kubernetes/pkg/util/hash",
|
"k8s.io/kubernetes/pkg/util/hash",
|
||||||
"k8s.io/kubernetes/pkg/util/interrupt",
|
"k8s.io/kubernetes/pkg/util/interrupt",
|
||||||
"k8s.io/kubernetes/pkg/util/io",
|
|
||||||
"k8s.io/kubernetes/pkg/util/labels",
|
"k8s.io/kubernetes/pkg/util/labels",
|
||||||
"k8s.io/kubernetes/pkg/util/metrics",
|
"k8s.io/kubernetes/pkg/util/metrics",
|
||||||
"k8s.io/kubernetes/pkg/util/mount",
|
"k8s.io/kubernetes/pkg/util/mount",
|
||||||
|
@ -145,6 +144,8 @@
|
||||||
"k8s.io/kubernetes/pkg/version/prometheus",
|
"k8s.io/kubernetes/pkg/version/prometheus",
|
||||||
"k8s.io/kubernetes/pkg/volume",
|
"k8s.io/kubernetes/pkg/volume",
|
||||||
"k8s.io/kubernetes/pkg/volume/util",
|
"k8s.io/kubernetes/pkg/volume/util",
|
||||||
|
"k8s.io/utils/nsenter",
|
||||||
|
"k8s.io/utils/io",
|
||||||
"k8s.io/utils/pointer"
|
"k8s.io/utils/pointer"
|
||||||
],
|
],
|
||||||
"ForbiddenPrefixes": []
|
"ForbiddenPrefixes": []
|
||||||
|
|
|
@ -28,7 +28,6 @@ filegroup(
|
||||||
"//pkg/util/hash:all-srcs",
|
"//pkg/util/hash:all-srcs",
|
||||||
"//pkg/util/initsystem:all-srcs",
|
"//pkg/util/initsystem:all-srcs",
|
||||||
"//pkg/util/interrupt:all-srcs",
|
"//pkg/util/interrupt:all-srcs",
|
||||||
"//pkg/util/io:all-srcs",
|
|
||||||
"//pkg/util/ipconfig:all-srcs",
|
"//pkg/util/ipconfig:all-srcs",
|
||||||
"//pkg/util/ipset:all-srcs",
|
"//pkg/util/ipset:all-srcs",
|
||||||
"//pkg/util/iptables:all-srcs",
|
"//pkg/util/iptables:all-srcs",
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "go_default_library",
|
|
||||||
srcs = ["consistentread.go"],
|
|
||||||
importpath = "k8s.io/kubernetes/pkg/util/io",
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "package-srcs",
|
|
||||||
srcs = glob(["**"]),
|
|
||||||
tags = ["automanaged"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "all-srcs",
|
|
||||||
srcs = [":package-srcs"],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
)
|
|
|
@ -1,45 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2017 The Kubernetes Authors.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ConsistentRead repeatedly reads a file until it gets the same content twice.
|
|
||||||
// This is useful when reading files in /proc that are larger than page size
|
|
||||||
// and kernel may modify them between individual read() syscalls.
|
|
||||||
func ConsistentRead(filename string, attempts int) ([]byte, error) {
|
|
||||||
oldContent, err := ioutil.ReadFile(filename)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
for i := 0; i < attempts; i++ {
|
|
||||||
newContent, err := ioutil.ReadFile(filename)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if bytes.Compare(oldContent, newContent) == 0 {
|
|
||||||
return newContent, nil
|
|
||||||
}
|
|
||||||
// Files are different, continue reading
|
|
||||||
oldContent = newContent
|
|
||||||
}
|
|
||||||
return nil, fmt.Errorf("could not get consistent content of %s after %d attempts", filename, attempts)
|
|
||||||
}
|
|
|
@ -36,10 +36,10 @@ go_library(
|
||||||
],
|
],
|
||||||
"@io_bazel_rules_go//go/platform:linux": [
|
"@io_bazel_rules_go//go/platform:linux": [
|
||||||
"//pkg/util/file:go_default_library",
|
"//pkg/util/file:go_default_library",
|
||||||
"//pkg/util/io:go_default_library",
|
|
||||||
"//pkg/util/nsenter:go_default_library",
|
"//pkg/util/nsenter:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||||
"//vendor/golang.org/x/sys/unix:go_default_library",
|
"//vendor/golang.org/x/sys/unix:go_default_library",
|
||||||
|
"//vendor/k8s.io/utils/io:go_default_library",
|
||||||
],
|
],
|
||||||
"@io_bazel_rules_go//go/platform:nacl": [
|
"@io_bazel_rules_go//go/platform:nacl": [
|
||||||
"//pkg/util/nsenter:go_default_library",
|
"//pkg/util/nsenter:go_default_library",
|
||||||
|
|
|
@ -34,8 +34,8 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
utilfile "k8s.io/kubernetes/pkg/util/file"
|
utilfile "k8s.io/kubernetes/pkg/util/file"
|
||||||
utilio "k8s.io/kubernetes/pkg/util/io"
|
|
||||||
utilexec "k8s.io/utils/exec"
|
utilexec "k8s.io/utils/exec"
|
||||||
|
utilio "k8s.io/utils/io"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
Loading…
Reference in New Issue