Merge pull request #44825 from rata/remove-unused-abstraction

Automatic merge from submit-queue (batch tested with PRs 40060, 44860, 44865, 44825, 44162)

Remove unused chmod/chown abstractions

**What this PR does / why we need it**: Simplifies the code

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: 

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
pull/6/head
Kubernetes Submit Queue 2017-04-24 23:07:44 -07:00 committed by GitHub
commit 9ac111c5f9
9 changed files with 2 additions and 186 deletions

View File

@ -46,8 +46,6 @@ filegroup(
":package-srcs",
"//pkg/util/async:all-srcs",
"//pkg/util/bandwidth:all-srcs",
"//pkg/util/chmod:all-srcs",
"//pkg/util/chown:all-srcs",
"//pkg/util/config:all-srcs",
"//pkg/util/configz:all-srcs",
"//pkg/util/crlf:all-srcs",

View File

@ -1,30 +0,0 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"chmod.go",
"doc.go",
],
tags = ["automanaged"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)

View File

@ -1,39 +0,0 @@
/*
Copyright 2015 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 chmod
import (
"os"
)
// Interface is something that knows how to run the chmod system call.
// It is non-recursive.
type Interface interface {
// Chmod changes the mode of the given file, implementing the same
// semantics as os.Chmod.
Chmod(path string, filemode os.FileMode) error
}
func New() Interface {
return &chmodRunner{}
}
type chmodRunner struct{}
func (_ *chmodRunner) Chmod(path string, mode os.FileMode) error {
return os.Chmod(path, mode)
}

View File

@ -1,19 +0,0 @@
/*
Copyright 2014 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 chown provides an interface and implementations
// for things that run run the chmod system call.
package chmod // import "k8s.io/kubernetes/pkg/util/chmod"

View File

@ -1,30 +0,0 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"chown.go",
"doc.go",
],
tags = ["automanaged"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)

View File

@ -1,39 +0,0 @@
/*
Copyright 2015 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 chown
import (
"os"
)
// Interface is something that knows how to run the chown system call.
// It is non-recursive.
type Interface interface {
// Chown changes the owning UID and GID of a file, implementing
// the exact same semantics as os.Chown.
Chown(path string, uid, gid int) error
}
func New() Interface {
return &chownRunner{}
}
type chownRunner struct{}
func (_ *chownRunner) Chown(path string, uid, gid int) error {
return os.Chown(path, uid, gid)
}

View File

@ -1,18 +0,0 @@
/*
Copyright 2015 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 chown provides utilities to chown a path
package chown // import "k8s.io/kubernetes/pkg/util/chown"

View File

@ -27,8 +27,6 @@ go_library(
"//pkg/api/v1:go_default_library",
"//pkg/client/clientset_generated/clientset:go_default_library",
"//pkg/cloudprovider:go_default_library",
"//pkg/util/chmod:go_default_library",
"//pkg/util/chown:go_default_library",
"//pkg/util/io:go_default_library",
"//pkg/util/mount:go_default_library",
"//pkg/volume/util:go_default_library",

View File

@ -22,9 +22,6 @@ import (
"path/filepath"
"syscall"
"k8s.io/kubernetes/pkg/util/chmod"
"k8s.io/kubernetes/pkg/util/chown"
"os"
"github.com/golang/glog"
@ -44,8 +41,6 @@ func SetVolumeOwnership(mounter Mounter, fsGroup *int64) error {
return nil
}
chownRunner := chown.New()
chmodRunner := chmod.New()
return filepath.Walk(mounter.GetPath(), func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
@ -72,7 +67,7 @@ func SetVolumeOwnership(mounter Mounter, fsGroup *int64) error {
return nil
}
err = chownRunner.Chown(path, int(stat.Uid), int(*fsGroup))
err = os.Chown(path, int(stat.Uid), int(*fsGroup))
if err != nil {
glog.Errorf("Chown failed on %v: %v", path, err)
}
@ -86,7 +81,7 @@ func SetVolumeOwnership(mounter Mounter, fsGroup *int64) error {
mask |= os.ModeSetgid
}
err = chmodRunner.Chmod(path, info.Mode()|mask)
err = os.Chmod(path, info.Mode()|mask)
if err != nil {
glog.Errorf("Chmod failed on %v: %v", path, err)
}