From 26b03a4777d14634e2292f9cbe70d9eb343b2910 Mon Sep 17 00:00:00 2001 From: Anusha Ramineni Date: Wed, 7 Aug 2019 10:33:07 +0530 Subject: [PATCH] Use k8s.io/utils package --- pkg/cloudprovider/providers/openstack/doc.go | 17 ------ .../src/k8s.io/legacy-cloud-providers/go.mod | 1 - .../src/k8s.io/legacy-cloud-providers/go.sum | 3 +- .../legacy-cloud-providers/openstack/BUILD | 3 - .../openstack/util/file/BUILD | 23 -------- .../openstack/util/file/file.go | 57 ------------------- .../openstack/util/io/BUILD | 23 -------- .../openstack/util/io/consistentread.go | 45 --------------- .../openstack/util/mount/BUILD | 6 +- .../openstack/util/mount/mount_linux.go | 6 +- .../openstack/util/mount/mount_windows.go | 4 +- vendor/modules.txt | 2 - 12 files changed, 10 insertions(+), 180 deletions(-) delete mode 100644 pkg/cloudprovider/providers/openstack/doc.go delete mode 100644 staging/src/k8s.io/legacy-cloud-providers/openstack/util/file/BUILD delete mode 100644 staging/src/k8s.io/legacy-cloud-providers/openstack/util/file/file.go delete mode 100644 staging/src/k8s.io/legacy-cloud-providers/openstack/util/io/BUILD delete mode 100644 staging/src/k8s.io/legacy-cloud-providers/openstack/util/io/consistentread.go diff --git a/pkg/cloudprovider/providers/openstack/doc.go b/pkg/cloudprovider/providers/openstack/doc.go deleted file mode 100644 index f970097aa5f..00000000000 --- a/pkg/cloudprovider/providers/openstack/doc.go +++ /dev/null @@ -1,17 +0,0 @@ -/* -Copyright 2019 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 openstack diff --git a/staging/src/k8s.io/legacy-cloud-providers/go.mod b/staging/src/k8s.io/legacy-cloud-providers/go.mod index b0ae66a9f3b..8ec7c26636d 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/go.mod +++ b/staging/src/k8s.io/legacy-cloud-providers/go.mod @@ -15,7 +15,6 @@ require ( github.com/aws/aws-sdk-go v1.16.26 github.com/dnaeon/go-vcr v1.0.1 // indirect github.com/gophercloud/gophercloud v0.1.0 - github.com/marstr/guid v0.0.0-20170427235115-8bdf7d1a087c // indirect github.com/mitchellh/mapstructure v1.1.2 github.com/prometheus/client_golang v0.9.2 github.com/rubiojr/go-vhd v0.0.0-20160810183302-0bfd3b39853c diff --git a/staging/src/k8s.io/legacy-cloud-providers/go.sum b/staging/src/k8s.io/legacy-cloud-providers/go.sum index ece16f660f7..f24dd8e12be 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/go.sum +++ b/staging/src/k8s.io/legacy-cloud-providers/go.sum @@ -137,9 +137,9 @@ github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= @@ -177,6 +177,7 @@ github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/soheilhy/cmux v0.1.3/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= diff --git a/staging/src/k8s.io/legacy-cloud-providers/openstack/BUILD b/staging/src/k8s.io/legacy-cloud-providers/openstack/BUILD index 925fcacbec2..ce61e815cc0 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/openstack/BUILD +++ b/staging/src/k8s.io/legacy-cloud-providers/openstack/BUILD @@ -9,7 +9,6 @@ load( go_library( name = "go_default_library", srcs = [ - "doc.go", "metadata.go", "openstack.go", "openstack_client.go", @@ -106,8 +105,6 @@ filegroup( name = "all-srcs", srcs = [ ":package-srcs", - "//staging/src/k8s.io/legacy-cloud-providers/openstack/util/file:all-srcs", - "//staging/src/k8s.io/legacy-cloud-providers/openstack/util/io:all-srcs", "//staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount:all-srcs", ], tags = ["automanaged"], diff --git a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/file/BUILD b/staging/src/k8s.io/legacy-cloud-providers/openstack/util/file/BUILD deleted file mode 100644 index e464bc43fdc..00000000000 --- a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/file/BUILD +++ /dev/null @@ -1,23 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = ["file.go"], - importmap = "k8s.io/kubernetes/vendor/k8s.io/legacy-cloud-providers/openstack/util/file", - importpath = "k8s.io/legacy-cloud-providers/openstack/util/file", - visibility = ["//visibility:public"], -) - -filegroup( - name = "package-srcs", - srcs = glob(["**"]), - tags = ["automanaged"], - visibility = ["//visibility:private"], -) - -filegroup( - name = "all-srcs", - srcs = [":package-srcs"], - tags = ["automanaged"], - visibility = ["//visibility:public"], -) diff --git a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/file/file.go b/staging/src/k8s.io/legacy-cloud-providers/openstack/util/file/file.go deleted file mode 100644 index 846c2d294a6..00000000000 --- a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/file/file.go +++ /dev/null @@ -1,57 +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 file - -import ( - "os" -) - -// Exists checks if specified file exists. -func Exists(filename string) (bool, error) { - if _, err := os.Stat(filename); os.IsNotExist(err) { - return false, nil - } else if err != nil { - return false, err - } - return true, nil -} - -// OrSymlinkExists checks if specified file or symlink exists. -func OrSymlinkExists(filename string) (bool, error) { - if _, err := os.Lstat(filename); os.IsNotExist(err) { - return false, nil - } else if err != nil { - return false, err - } - return true, nil -} - -// ReadDirNoStat returns a string of files/directories contained -// in dirname without calling lstat on them. -func ReadDirNoStat(dirname string) ([]string, error) { - if dirname == "" { - dirname = "." - } - - f, err := os.Open(dirname) - if err != nil { - return nil, err - } - defer f.Close() - - return f.Readdirnames(-1) -} diff --git a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/io/BUILD b/staging/src/k8s.io/legacy-cloud-providers/openstack/util/io/BUILD deleted file mode 100644 index c80afc4d210..00000000000 --- a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/io/BUILD +++ /dev/null @@ -1,23 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = ["consistentread.go"], - importmap = "k8s.io/kubernetes/vendor/k8s.io/legacy-cloud-providers/openstack/util/io", - importpath = "k8s.io/legacy-cloud-providers/openstack/util/io", - visibility = ["//visibility:public"], -) - -filegroup( - name = "package-srcs", - srcs = glob(["**"]), - tags = ["automanaged"], - visibility = ["//visibility:private"], -) - -filegroup( - name = "all-srcs", - srcs = [":package-srcs"], - tags = ["automanaged"], - visibility = ["//visibility:public"], -) diff --git a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/io/consistentread.go b/staging/src/k8s.io/legacy-cloud-providers/openstack/util/io/consistentread.go deleted file mode 100644 index 6e1f17b0985..00000000000 --- a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/io/consistentread.go +++ /dev/null @@ -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) -} diff --git a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/BUILD b/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/BUILD index 2fc723ebedb..79921a0102e 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/BUILD +++ b/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/BUILD @@ -14,15 +14,15 @@ go_library( deps = select({ "@io_bazel_rules_go//go/platform:linux": [ "//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library", - "//staging/src/k8s.io/legacy-cloud-providers/openstack/util/file:go_default_library", - "//staging/src/k8s.io/legacy-cloud-providers/openstack/util/io:go_default_library", "//vendor/golang.org/x/sys/unix:go_default_library", "//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/utils/exec:go_default_library", + "//vendor/k8s.io/utils/io:go_default_library", + "//vendor/k8s.io/utils/path:go_default_library", ], "@io_bazel_rules_go//go/platform:windows": [ - "//staging/src/k8s.io/legacy-cloud-providers/openstack/util/file:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/path:go_default_library", ], "//conditions:default": [], }), diff --git a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount_linux.go b/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount_linux.go index 5bc6ef59bed..69f93425f06 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount_linux.go +++ b/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount_linux.go @@ -32,10 +32,10 @@ import ( "golang.org/x/sys/unix" "k8s.io/apimachinery/pkg/util/sets" - utilfile "k8s.io/cloud-provider-openstack/pkg/util/file" - utilio "k8s.io/cloud-provider-openstack/pkg/util/io" "k8s.io/klog" utilexec "k8s.io/utils/exec" + utilio "k8s.io/utils/io" + utilpath "k8s.io/utils/path" ) const ( @@ -424,7 +424,7 @@ func (mounter *Mounter) MakeFile(pathname string) error { // ExistsPath returns true if the specified path exists. func (mounter *Mounter) ExistsPath(pathname string) (bool, error) { - return utilfile.Exists(pathname) + return utilpath.Exists(utilpath.CheckFollowSymlink, pathname) } // EvalHostSymlinks returns the actual path a symlink points to. diff --git a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount_windows.go b/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount_windows.go index d3c8194049e..8b0ac99407e 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount_windows.go +++ b/staging/src/k8s.io/legacy-cloud-providers/openstack/util/mount/mount_windows.go @@ -30,7 +30,7 @@ import ( "k8s.io/klog" - utilfile "k8s.io/cloud-provider-openstack/pkg/util/file" + utilpath "k8s.io/utils/path" ) // Mounter provides the default implementation of mount.Interface @@ -235,7 +235,7 @@ func (mounter *Mounter) MakeFile(pathname string) error { // ExistsPath checks whether the path exists func (mounter *Mounter) ExistsPath(pathname string) (bool, error) { - return utilfile.Exists(pathname) + return utilpath.Exists(utilpath.CheckFollowSymlink, pathname) } // EvalHostSymlinks returns the path name after evaluating symlinks diff --git a/vendor/modules.txt b/vendor/modules.txt index b27d28c4d26..11c569833be 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1832,8 +1832,6 @@ k8s.io/legacy-cloud-providers/azure k8s.io/legacy-cloud-providers/azure/auth k8s.io/legacy-cloud-providers/gce k8s.io/legacy-cloud-providers/openstack -k8s.io/legacy-cloud-providers/openstack/util/file -k8s.io/legacy-cloud-providers/openstack/util/io k8s.io/legacy-cloud-providers/openstack/util/mount k8s.io/legacy-cloud-providers/vsphere k8s.io/legacy-cloud-providers/vsphere/testing