Merge pull request #48256 from xiangpengzhao/move-pkg-util
Automatic merge from submit-queue (batch tested with PRs 48481, 48256) Refactor: pkg/util into sub-pkgs **What this PR does / why we need it**: - move code in pkg/util into sub-pkgs - delete some unused funcs **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #15634 **Special notes for your reviewer**: This is the final work of #15634. It will close that issue. /cc @thockin **Release note**: ```release-note NONE ```
This commit is contained in:
		@@ -60,7 +60,7 @@ go_library(
 | 
				
			|||||||
        "//pkg/client/metrics/prometheus:go_default_library",
 | 
					        "//pkg/client/metrics/prometheus:go_default_library",
 | 
				
			||||||
        "//pkg/kubectl/cmd:go_default_library",
 | 
					        "//pkg/kubectl/cmd:go_default_library",
 | 
				
			||||||
        "//pkg/kubectl/cmd/util:go_default_library",
 | 
					        "//pkg/kubectl/cmd/util:go_default_library",
 | 
				
			||||||
        "//pkg/util:go_default_library",
 | 
					        "//pkg/util/template:go_default_library",
 | 
				
			||||||
        "//pkg/version/prometheus:go_default_library",
 | 
					        "//pkg/version/prometheus:go_default_library",
 | 
				
			||||||
        "//pkg/version/verflag:go_default_library",
 | 
					        "//pkg/version/verflag:go_default_library",
 | 
				
			||||||
        "//plugin/cmd/kube-scheduler/app:go_default_library",
 | 
					        "//plugin/cmd/kube-scheduler/app:go_default_library",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,7 +27,7 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	utilflag "k8s.io/apiserver/pkg/util/flag"
 | 
						utilflag "k8s.io/apiserver/pkg/util/flag"
 | 
				
			||||||
	"k8s.io/apiserver/pkg/util/logs"
 | 
						"k8s.io/apiserver/pkg/util/logs"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util"
 | 
						utiltemplate "k8s.io/kubernetes/pkg/util/template"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/version/verflag"
 | 
						"k8s.io/kubernetes/pkg/version/verflag"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/spf13/pflag"
 | 
						"github.com/spf13/pflag"
 | 
				
			||||||
@@ -205,7 +205,7 @@ Servers
 | 
				
			|||||||
Call '{{.Name}} --make-symlinks' to create symlinks for each server in the local directory.
 | 
					Call '{{.Name}} --make-symlinks' to create symlinks for each server in the local directory.
 | 
				
			||||||
Call '{{.Name}} <server> --help' for help on a specific server.
 | 
					Call '{{.Name}} <server> --help' for help on a specific server.
 | 
				
			||||||
`
 | 
					`
 | 
				
			||||||
	util.ExecuteTemplate(hk.Out(), tt, hk)
 | 
						utiltemplate.ExecuteTemplate(hk.Out(), tt, hk)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// MakeSymlinks will create a symlink for each registered hyperkube server in the local directory.
 | 
					// MakeSymlinks will create a symlink for each registered hyperkube server in the local directory.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,7 +21,7 @@ import (
 | 
				
			|||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/apiserver/pkg/util/flag"
 | 
						"k8s.io/apiserver/pkg/util/flag"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util"
 | 
						utiltemplate "k8s.io/kubernetes/pkg/util/template"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/spf13/pflag"
 | 
						"github.com/spf13/pflag"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@@ -49,7 +49,7 @@ func (s *Server) Usage() error {
 | 
				
			|||||||
Available Flags:
 | 
					Available Flags:
 | 
				
			||||||
{{.Flags.FlagUsages}}`
 | 
					{{.Flags.FlagUsages}}`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return util.ExecuteTemplate(s.hk.Out(), tt, s)
 | 
						return utiltemplate.ExecuteTemplate(s.hk.Out(), tt, s)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Name returns the name of the command as derived from the usage line.
 | 
					// Name returns the name of the command as derived from the usage line.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,7 +30,6 @@ go_library(
 | 
				
			|||||||
        "//pkg/proxy/iptables:go_default_library",
 | 
					        "//pkg/proxy/iptables:go_default_library",
 | 
				
			||||||
        "//pkg/proxy/userspace:go_default_library",
 | 
					        "//pkg/proxy/userspace:go_default_library",
 | 
				
			||||||
        "//pkg/proxy/winuserspace:go_default_library",
 | 
					        "//pkg/proxy/winuserspace:go_default_library",
 | 
				
			||||||
        "//pkg/util:go_default_library",
 | 
					 | 
				
			||||||
        "//pkg/util/configz:go_default_library",
 | 
					        "//pkg/util/configz:go_default_library",
 | 
				
			||||||
        "//pkg/util/dbus:go_default_library",
 | 
					        "//pkg/util/dbus:go_default_library",
 | 
				
			||||||
        "//pkg/util/exec:go_default_library",
 | 
					        "//pkg/util/exec:go_default_library",
 | 
				
			||||||
@@ -39,6 +38,7 @@ go_library(
 | 
				
			|||||||
        "//pkg/util/netsh:go_default_library",
 | 
					        "//pkg/util/netsh:go_default_library",
 | 
				
			||||||
        "//pkg/util/node:go_default_library",
 | 
					        "//pkg/util/node:go_default_library",
 | 
				
			||||||
        "//pkg/util/oom:go_default_library",
 | 
					        "//pkg/util/oom:go_default_library",
 | 
				
			||||||
 | 
					        "//pkg/util/pointer:go_default_library",
 | 
				
			||||||
        "//pkg/util/resourcecontainer:go_default_library",
 | 
					        "//pkg/util/resourcecontainer:go_default_library",
 | 
				
			||||||
        "//pkg/util/sysctl:go_default_library",
 | 
					        "//pkg/util/sysctl:go_default_library",
 | 
				
			||||||
        "//pkg/version/verflag:go_default_library",
 | 
					        "//pkg/version/verflag:go_default_library",
 | 
				
			||||||
@@ -74,9 +74,9 @@ go_test(
 | 
				
			|||||||
        "//pkg/api:go_default_library",
 | 
					        "//pkg/api:go_default_library",
 | 
				
			||||||
        "//pkg/apis/componentconfig:go_default_library",
 | 
					        "//pkg/apis/componentconfig:go_default_library",
 | 
				
			||||||
        "//pkg/apis/componentconfig/v1alpha1:go_default_library",
 | 
					        "//pkg/apis/componentconfig/v1alpha1:go_default_library",
 | 
				
			||||||
        "//pkg/util:go_default_library",
 | 
					 | 
				
			||||||
        "//pkg/util/configz:go_default_library",
 | 
					        "//pkg/util/configz:go_default_library",
 | 
				
			||||||
        "//pkg/util/iptables:go_default_library",
 | 
					        "//pkg/util/iptables:go_default_library",
 | 
				
			||||||
 | 
					        "//pkg/util/pointer:go_default_library",
 | 
				
			||||||
        "//vendor/github.com/stretchr/testify/assert:go_default_library",
 | 
					        "//vendor/github.com/stretchr/testify/assert:go_default_library",
 | 
				
			||||||
        "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
 | 
					        "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
 | 
				
			||||||
        "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
 | 
					        "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -60,14 +60,14 @@ import (
 | 
				
			|||||||
	"k8s.io/kubernetes/pkg/proxy/iptables"
 | 
						"k8s.io/kubernetes/pkg/proxy/iptables"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/proxy/userspace"
 | 
						"k8s.io/kubernetes/pkg/proxy/userspace"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/proxy/winuserspace"
 | 
						"k8s.io/kubernetes/pkg/proxy/winuserspace"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util"
 | 
					 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util/configz"
 | 
						"k8s.io/kubernetes/pkg/util/configz"
 | 
				
			||||||
	utildbus "k8s.io/kubernetes/pkg/util/dbus"
 | 
						utildbus "k8s.io/kubernetes/pkg/util/dbus"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util/exec"
 | 
						"k8s.io/kubernetes/pkg/util/exec"
 | 
				
			||||||
	utiliptables "k8s.io/kubernetes/pkg/util/iptables"
 | 
						utiliptables "k8s.io/kubernetes/pkg/util/iptables"
 | 
				
			||||||
	utilnetsh "k8s.io/kubernetes/pkg/util/netsh"
 | 
						utilnetsh "k8s.io/kubernetes/pkg/util/netsh"
 | 
				
			||||||
	nodeutil "k8s.io/kubernetes/pkg/util/node"
 | 
						utilnode "k8s.io/kubernetes/pkg/util/node"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util/oom"
 | 
						"k8s.io/kubernetes/pkg/util/oom"
 | 
				
			||||||
 | 
						utilpointer "k8s.io/kubernetes/pkg/util/pointer"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util/resourcecontainer"
 | 
						"k8s.io/kubernetes/pkg/util/resourcecontainer"
 | 
				
			||||||
	utilsysctl "k8s.io/kubernetes/pkg/util/sysctl"
 | 
						utilsysctl "k8s.io/kubernetes/pkg/util/sysctl"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/version/verflag"
 | 
						"k8s.io/kubernetes/pkg/version/verflag"
 | 
				
			||||||
@@ -131,14 +131,14 @@ func AddFlags(options *Options, fs *pflag.FlagSet) {
 | 
				
			|||||||
	fs.Int32Var(&options.healthzPort, "healthz-port", options.healthzPort, "The port to bind the health check server. Use 0 to disable.")
 | 
						fs.Int32Var(&options.healthzPort, "healthz-port", options.healthzPort, "The port to bind the health check server. Use 0 to disable.")
 | 
				
			||||||
	fs.Var(componentconfig.IPVar{Val: &options.config.HealthzBindAddress}, "healthz-bind-address", "The IP address and port for the health check server to serve on (set to 0.0.0.0 for all interfaces)")
 | 
						fs.Var(componentconfig.IPVar{Val: &options.config.HealthzBindAddress}, "healthz-bind-address", "The IP address and port for the health check server to serve on (set to 0.0.0.0 for all interfaces)")
 | 
				
			||||||
	fs.Var(componentconfig.IPVar{Val: &options.config.MetricsBindAddress}, "metrics-bind-address", "The IP address and port for the metrics server to serve on (set to 0.0.0.0 for all interfaces)")
 | 
						fs.Var(componentconfig.IPVar{Val: &options.config.MetricsBindAddress}, "metrics-bind-address", "The IP address and port for the metrics server to serve on (set to 0.0.0.0 for all interfaces)")
 | 
				
			||||||
	fs.Int32Var(options.config.OOMScoreAdj, "oom-score-adj", util.Int32PtrDerefOr(options.config.OOMScoreAdj, int32(qos.KubeProxyOOMScoreAdj)), "The oom-score-adj value for kube-proxy process. Values must be within the range [-1000, 1000]")
 | 
						fs.Int32Var(options.config.OOMScoreAdj, "oom-score-adj", utilpointer.Int32PtrDerefOr(options.config.OOMScoreAdj, int32(qos.KubeProxyOOMScoreAdj)), "The oom-score-adj value for kube-proxy process. Values must be within the range [-1000, 1000]")
 | 
				
			||||||
	fs.StringVar(&options.config.ResourceContainer, "resource-container", options.config.ResourceContainer, "Absolute name of the resource-only container to create and run the Kube-proxy in (Default: /kube-proxy).")
 | 
						fs.StringVar(&options.config.ResourceContainer, "resource-container", options.config.ResourceContainer, "Absolute name of the resource-only container to create and run the Kube-proxy in (Default: /kube-proxy).")
 | 
				
			||||||
	fs.MarkDeprecated("resource-container", "This feature will be removed in a later release.")
 | 
						fs.MarkDeprecated("resource-container", "This feature will be removed in a later release.")
 | 
				
			||||||
	fs.StringVar(&options.config.ClientConnection.KubeConfigFile, "kubeconfig", options.config.ClientConnection.KubeConfigFile, "Path to kubeconfig file with authorization information (the master location is set by the master flag).")
 | 
						fs.StringVar(&options.config.ClientConnection.KubeConfigFile, "kubeconfig", options.config.ClientConnection.KubeConfigFile, "Path to kubeconfig file with authorization information (the master location is set by the master flag).")
 | 
				
			||||||
	fs.Var(componentconfig.PortRangeVar{Val: &options.config.PortRange}, "proxy-port-range", "Range of host ports (beginPort-endPort, inclusive) that may be consumed in order to proxy service traffic. If unspecified (0-0) then ports will be randomly chosen.")
 | 
						fs.Var(componentconfig.PortRangeVar{Val: &options.config.PortRange}, "proxy-port-range", "Range of host ports (beginPort-endPort, inclusive) that may be consumed in order to proxy service traffic. If unspecified (0-0) then ports will be randomly chosen.")
 | 
				
			||||||
	fs.StringVar(&options.config.HostnameOverride, "hostname-override", options.config.HostnameOverride, "If non-empty, will use this string as identification instead of the actual hostname.")
 | 
						fs.StringVar(&options.config.HostnameOverride, "hostname-override", options.config.HostnameOverride, "If non-empty, will use this string as identification instead of the actual hostname.")
 | 
				
			||||||
	fs.Var(&options.config.Mode, "proxy-mode", "Which proxy mode to use: 'userspace' (older) or 'iptables' (faster). If blank, use the best-available proxy (currently iptables).  If the iptables proxy is selected, regardless of how, but the system's kernel or iptables versions are insufficient, this always falls back to the userspace proxy.")
 | 
						fs.Var(&options.config.Mode, "proxy-mode", "Which proxy mode to use: 'userspace' (older) or 'iptables' (faster). If blank, use the best-available proxy (currently iptables).  If the iptables proxy is selected, regardless of how, but the system's kernel or iptables versions are insufficient, this always falls back to the userspace proxy.")
 | 
				
			||||||
	fs.Int32Var(options.config.IPTables.MasqueradeBit, "iptables-masquerade-bit", util.Int32PtrDerefOr(options.config.IPTables.MasqueradeBit, 14), "If using the pure iptables proxy, the bit of the fwmark space to mark packets requiring SNAT with.  Must be within the range [0, 31].")
 | 
						fs.Int32Var(options.config.IPTables.MasqueradeBit, "iptables-masquerade-bit", utilpointer.Int32PtrDerefOr(options.config.IPTables.MasqueradeBit, 14), "If using the pure iptables proxy, the bit of the fwmark space to mark packets requiring SNAT with.  Must be within the range [0, 31].")
 | 
				
			||||||
	fs.DurationVar(&options.config.IPTables.SyncPeriod.Duration, "iptables-sync-period", options.config.IPTables.SyncPeriod.Duration, "The maximum interval of how often iptables rules are refreshed (e.g. '5s', '1m', '2h22m').  Must be greater than 0.")
 | 
						fs.DurationVar(&options.config.IPTables.SyncPeriod.Duration, "iptables-sync-period", options.config.IPTables.SyncPeriod.Duration, "The maximum interval of how often iptables rules are refreshed (e.g. '5s', '1m', '2h22m').  Must be greater than 0.")
 | 
				
			||||||
	fs.DurationVar(&options.config.IPTables.MinSyncPeriod.Duration, "iptables-min-sync-period", options.config.IPTables.MinSyncPeriod.Duration, "The minimum interval of how often the iptables rules can be refreshed as endpoints and services change (e.g. '5s', '1m', '2h22m').")
 | 
						fs.DurationVar(&options.config.IPTables.MinSyncPeriod.Duration, "iptables-min-sync-period", options.config.IPTables.MinSyncPeriod.Duration, "The minimum interval of how often the iptables rules can be refreshed as endpoints and services change (e.g. '5s', '1m', '2h22m').")
 | 
				
			||||||
	fs.DurationVar(&options.config.ConfigSyncPeriod.Duration, "config-sync-period", options.config.ConfigSyncPeriod.Duration, "How often configuration from the apiserver is refreshed.  Must be greater than 0.")
 | 
						fs.DurationVar(&options.config.ConfigSyncPeriod.Duration, "config-sync-period", options.config.ConfigSyncPeriod.Duration, "How often configuration from the apiserver is refreshed.  Must be greater than 0.")
 | 
				
			||||||
@@ -458,7 +458,7 @@ func NewProxyServer(config *componentconfig.KubeProxyConfiguration, cleanupAndEx
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Create event recorder
 | 
						// Create event recorder
 | 
				
			||||||
	hostname := nodeutil.GetHostname(config.HostnameOverride)
 | 
						hostname := utilnode.GetHostname(config.HostnameOverride)
 | 
				
			||||||
	eventBroadcaster := record.NewBroadcaster()
 | 
						eventBroadcaster := record.NewBroadcaster()
 | 
				
			||||||
	recorder := eventBroadcaster.NewRecorder(scheme, clientv1.EventSource{Component: "kube-proxy", Host: hostname})
 | 
						recorder := eventBroadcaster.NewRecorder(scheme, clientv1.EventSource{Component: "kube-proxy", Host: hostname})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -785,7 +785,7 @@ func getNodeIP(client clientset.Interface, hostname string) net.IP {
 | 
				
			|||||||
		glog.Warningf("Failed to retrieve node info: %v", err)
 | 
							glog.Warningf("Failed to retrieve node info: %v", err)
 | 
				
			||||||
		return nil
 | 
							return nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	nodeIP, err = nodeutil.InternalGetNodeHostIP(node)
 | 
						nodeIP, err = utilnode.InternalGetNodeHostIP(node)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		glog.Warningf("Failed to retrieve node IP: %v", err)
 | 
							glog.Warningf("Failed to retrieve node IP: %v", err)
 | 
				
			||||||
		return nil
 | 
							return nil
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,9 +33,9 @@ import (
 | 
				
			|||||||
	"k8s.io/kubernetes/pkg/api"
 | 
						"k8s.io/kubernetes/pkg/api"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/apis/componentconfig"
 | 
						"k8s.io/kubernetes/pkg/apis/componentconfig"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/apis/componentconfig/v1alpha1"
 | 
						"k8s.io/kubernetes/pkg/apis/componentconfig/v1alpha1"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util"
 | 
					 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util/configz"
 | 
						"k8s.io/kubernetes/pkg/util/configz"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util/iptables"
 | 
						"k8s.io/kubernetes/pkg/util/iptables"
 | 
				
			||||||
 | 
						utilpointer "k8s.io/kubernetes/pkg/util/pointer"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type fakeNodeInterface struct {
 | 
					type fakeNodeInterface struct {
 | 
				
			||||||
@@ -342,13 +342,13 @@ udpTimeoutMilliseconds: 123ms
 | 
				
			|||||||
			HostnameOverride:   "foo",
 | 
								HostnameOverride:   "foo",
 | 
				
			||||||
			IPTables: componentconfig.KubeProxyIPTablesConfiguration{
 | 
								IPTables: componentconfig.KubeProxyIPTablesConfiguration{
 | 
				
			||||||
				MasqueradeAll: true,
 | 
									MasqueradeAll: true,
 | 
				
			||||||
				MasqueradeBit: util.Int32Ptr(17),
 | 
									MasqueradeBit: utilpointer.Int32Ptr(17),
 | 
				
			||||||
				MinSyncPeriod: metav1.Duration{Duration: 10 * time.Second},
 | 
									MinSyncPeriod: metav1.Duration{Duration: 10 * time.Second},
 | 
				
			||||||
				SyncPeriod:    metav1.Duration{Duration: 60 * time.Second},
 | 
									SyncPeriod:    metav1.Duration{Duration: 60 * time.Second},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			MetricsBindAddress: tc.metricsBindAddress,
 | 
								MetricsBindAddress: tc.metricsBindAddress,
 | 
				
			||||||
			Mode:               "iptables",
 | 
								Mode:               "iptables",
 | 
				
			||||||
			OOMScoreAdj:        util.Int32Ptr(17),
 | 
								OOMScoreAdj:        utilpointer.Int32Ptr(17),
 | 
				
			||||||
			PortRange:          "2-7",
 | 
								PortRange:          "2-7",
 | 
				
			||||||
			ResourceContainer:  "/foo",
 | 
								ResourceContainer:  "/foo",
 | 
				
			||||||
			UDPIdleTimeout:     metav1.Duration{Duration: 123 * time.Millisecond},
 | 
								UDPIdleTimeout:     metav1.Duration{Duration: 123 * time.Millisecond},
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -431,7 +431,6 @@ pkg/security/podsecuritypolicy/user
 | 
				
			|||||||
pkg/security/podsecuritypolicy/util
 | 
					pkg/security/podsecuritypolicy/util
 | 
				
			||||||
pkg/securitycontext
 | 
					pkg/securitycontext
 | 
				
			||||||
pkg/ssh
 | 
					pkg/ssh
 | 
				
			||||||
pkg/util
 | 
					 | 
				
			||||||
pkg/util/bandwidth
 | 
					pkg/util/bandwidth
 | 
				
			||||||
pkg/util/config
 | 
					pkg/util/config
 | 
				
			||||||
pkg/util/configz
 | 
					pkg/util/configz
 | 
				
			||||||
@@ -439,6 +438,7 @@ pkg/util/dbus
 | 
				
			|||||||
pkg/util/ebtables
 | 
					pkg/util/ebtables
 | 
				
			||||||
pkg/util/env
 | 
					pkg/util/env
 | 
				
			||||||
pkg/util/exec
 | 
					pkg/util/exec
 | 
				
			||||||
 | 
					pkg/util/file
 | 
				
			||||||
pkg/util/goroutinemap/exponentialbackoff
 | 
					pkg/util/goroutinemap/exponentialbackoff
 | 
				
			||||||
pkg/util/initsystem
 | 
					pkg/util/initsystem
 | 
				
			||||||
pkg/util/ipconfig
 | 
					pkg/util/ipconfig
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,8 +23,8 @@ go_library(
 | 
				
			|||||||
    deps = [
 | 
					    deps = [
 | 
				
			||||||
        "//pkg/api:go_default_library",
 | 
					        "//pkg/api:go_default_library",
 | 
				
			||||||
        "//pkg/apis/extensions:go_default_library",
 | 
					        "//pkg/apis/extensions:go_default_library",
 | 
				
			||||||
        "//pkg/util:go_default_library",
 | 
					 | 
				
			||||||
        "//pkg/util/parsers:go_default_library",
 | 
					        "//pkg/util/parsers:go_default_library",
 | 
				
			||||||
 | 
					        "//pkg/util/pointer:go_default_library",
 | 
				
			||||||
        "//vendor/k8s.io/api/core/v1:go_default_library",
 | 
					        "//vendor/k8s.io/api/core/v1:go_default_library",
 | 
				
			||||||
        "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
 | 
					        "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
 | 
				
			||||||
        "//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",
 | 
					        "//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,8 +20,8 @@ import (
 | 
				
			|||||||
	"k8s.io/api/core/v1"
 | 
						"k8s.io/api/core/v1"
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/runtime"
 | 
						"k8s.io/apimachinery/pkg/runtime"
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/util/intstr"
 | 
						"k8s.io/apimachinery/pkg/util/intstr"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util"
 | 
					 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util/parsers"
 | 
						"k8s.io/kubernetes/pkg/util/parsers"
 | 
				
			||||||
 | 
						utilpointer "k8s.io/kubernetes/pkg/util/pointer"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func addDefaultingFuncs(scheme *runtime.Scheme) error {
 | 
					func addDefaultingFuncs(scheme *runtime.Scheme) error {
 | 
				
			||||||
@@ -67,7 +67,7 @@ func SetDefaults_ReplicationController(obj *v1.ReplicationController) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
func SetDefaults_Volume(obj *v1.Volume) {
 | 
					func SetDefaults_Volume(obj *v1.Volume) {
 | 
				
			||||||
	if util.AllPtrFieldsNil(&obj.VolumeSource) {
 | 
						if utilpointer.AllPtrFieldsNil(&obj.VolumeSource) {
 | 
				
			||||||
		obj.VolumeSource = v1.VolumeSource{
 | 
							obj.VolumeSource = v1.VolumeSource{
 | 
				
			||||||
			EmptyDir: &v1.EmptyDirVolumeSource{},
 | 
								EmptyDir: &v1.EmptyDirVolumeSource{},
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,7 +27,7 @@ go_library(
 | 
				
			|||||||
        "//pkg/kubelet/qos:go_default_library",
 | 
					        "//pkg/kubelet/qos:go_default_library",
 | 
				
			||||||
        "//pkg/kubelet/types:go_default_library",
 | 
					        "//pkg/kubelet/types:go_default_library",
 | 
				
			||||||
        "//pkg/master/ports:go_default_library",
 | 
					        "//pkg/master/ports:go_default_library",
 | 
				
			||||||
        "//pkg/util:go_default_library",
 | 
					        "//pkg/util/pointer:go_default_library",
 | 
				
			||||||
        "//vendor/k8s.io/api/core/v1:go_default_library",
 | 
					        "//vendor/k8s.io/api/core/v1:go_default_library",
 | 
				
			||||||
        "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
 | 
					        "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
 | 
				
			||||||
        "//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",
 | 
					        "//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,7 +30,7 @@ import (
 | 
				
			|||||||
	"k8s.io/kubernetes/pkg/kubelet/qos"
 | 
						"k8s.io/kubernetes/pkg/kubelet/qos"
 | 
				
			||||||
	kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
 | 
						kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/master/ports"
 | 
						"k8s.io/kubernetes/pkg/master/ports"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util"
 | 
						utilpointer "k8s.io/kubernetes/pkg/util/pointer"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
@@ -218,7 +218,7 @@ func SetDefaults_KubeletConfiguration(obj *KubeletConfiguration) {
 | 
				
			|||||||
		obj.CloudProvider = AutoDetectCloudProvider
 | 
							obj.CloudProvider = AutoDetectCloudProvider
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if obj.CAdvisorPort == nil {
 | 
						if obj.CAdvisorPort == nil {
 | 
				
			||||||
		obj.CAdvisorPort = util.Int32Ptr(4194)
 | 
							obj.CAdvisorPort = utilpointer.Int32Ptr(4194)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if obj.VolumeStatsAggPeriod == zeroDuration {
 | 
						if obj.VolumeStatsAggPeriod == zeroDuration {
 | 
				
			||||||
		obj.VolumeStatsAggPeriod = metav1.Duration{Duration: time.Minute}
 | 
							obj.VolumeStatsAggPeriod = metav1.Duration{Duration: time.Minute}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -92,9 +92,9 @@ go_library(
 | 
				
			|||||||
        "//pkg/kubelet/volumemanager:go_default_library",
 | 
					        "//pkg/kubelet/volumemanager:go_default_library",
 | 
				
			||||||
        "//pkg/security/apparmor:go_default_library",
 | 
					        "//pkg/security/apparmor:go_default_library",
 | 
				
			||||||
        "//pkg/securitycontext:go_default_library",
 | 
					        "//pkg/securitycontext:go_default_library",
 | 
				
			||||||
        "//pkg/util:go_default_library",
 | 
					 | 
				
			||||||
        "//pkg/util/dbus:go_default_library",
 | 
					        "//pkg/util/dbus:go_default_library",
 | 
				
			||||||
        "//pkg/util/exec:go_default_library",
 | 
					        "//pkg/util/exec:go_default_library",
 | 
				
			||||||
 | 
					        "//pkg/util/file:go_default_library",
 | 
				
			||||||
        "//pkg/util/io:go_default_library",
 | 
					        "//pkg/util/io:go_default_library",
 | 
				
			||||||
        "//pkg/util/iptables:go_default_library",
 | 
					        "//pkg/util/iptables:go_default_library",
 | 
				
			||||||
        "//pkg/util/mount:go_default_library",
 | 
					        "//pkg/util/mount:go_default_library",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,7 +18,7 @@ go_library(
 | 
				
			|||||||
    tags = ["automanaged"],
 | 
					    tags = ["automanaged"],
 | 
				
			||||||
    deps = [
 | 
					    deps = [
 | 
				
			||||||
        "//pkg/apis/componentconfig:go_default_library",
 | 
					        "//pkg/apis/componentconfig:go_default_library",
 | 
				
			||||||
        "//pkg/util:go_default_library",
 | 
					        "//pkg/util/file:go_default_library",
 | 
				
			||||||
        "//vendor/github.com/golang/glog:go_default_library",
 | 
					        "//vendor/github.com/golang/glog:go_default_library",
 | 
				
			||||||
        "//vendor/k8s.io/api/certificates/v1beta1:go_default_library",
 | 
					        "//vendor/k8s.io/api/certificates/v1beta1:go_default_library",
 | 
				
			||||||
        "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
 | 
					        "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,7 +29,7 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	"github.com/golang/glog"
 | 
						"github.com/golang/glog"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util"
 | 
						utilfile "k8s.io/kubernetes/pkg/util/file"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
@@ -86,7 +86,7 @@ func NewFileStore(
 | 
				
			|||||||
func (s *fileStore) recover() error {
 | 
					func (s *fileStore) recover() error {
 | 
				
			||||||
	// If the 'current' file doesn't exist, continue on with the recovery process.
 | 
						// If the 'current' file doesn't exist, continue on with the recovery process.
 | 
				
			||||||
	currentPath := filepath.Join(s.certDirectory, s.filename(currentPair))
 | 
						currentPath := filepath.Join(s.certDirectory, s.filename(currentPair))
 | 
				
			||||||
	if exists, err := util.FileExists(currentPath); err != nil {
 | 
						if exists, err := utilfile.FileExists(currentPath); err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	} else if exists {
 | 
						} else if exists {
 | 
				
			||||||
		return nil
 | 
							return nil
 | 
				
			||||||
@@ -113,18 +113,18 @@ func (s *fileStore) recover() error {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func (s *fileStore) Current() (*tls.Certificate, error) {
 | 
					func (s *fileStore) Current() (*tls.Certificate, error) {
 | 
				
			||||||
	pairFile := filepath.Join(s.certDirectory, s.filename(currentPair))
 | 
						pairFile := filepath.Join(s.certDirectory, s.filename(currentPair))
 | 
				
			||||||
	if pairFileExists, err := util.FileExists(pairFile); err != nil {
 | 
						if pairFileExists, err := utilfile.FileExists(pairFile); err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	} else if pairFileExists {
 | 
						} else if pairFileExists {
 | 
				
			||||||
		glog.Infof("Loading cert/key pair from %q.", pairFile)
 | 
							glog.Infof("Loading cert/key pair from %q.", pairFile)
 | 
				
			||||||
		return loadFile(pairFile)
 | 
							return loadFile(pairFile)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	certFileExists, err := util.FileExists(s.certFile)
 | 
						certFileExists, err := utilfile.FileExists(s.certFile)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	keyFileExists, err := util.FileExists(s.keyFile)
 | 
						keyFileExists, err := utilfile.FileExists(s.keyFile)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -135,11 +135,11 @@ func (s *fileStore) Current() (*tls.Certificate, error) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	c := filepath.Join(s.certDirectory, s.pairNamePrefix+certExtension)
 | 
						c := filepath.Join(s.certDirectory, s.pairNamePrefix+certExtension)
 | 
				
			||||||
	k := filepath.Join(s.keyDirectory, s.pairNamePrefix+keyExtension)
 | 
						k := filepath.Join(s.keyDirectory, s.pairNamePrefix+keyExtension)
 | 
				
			||||||
	certFileExists, err = util.FileExists(c)
 | 
						certFileExists, err = utilfile.FileExists(c)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	keyFileExists, err = util.FileExists(k)
 | 
						keyFileExists, err = utilfile.FileExists(k)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -262,7 +262,7 @@ func (s *fileStore) updateSymlink(filename string) error {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// Check that the new cert/key pair file exists to avoid rotating to an
 | 
						// Check that the new cert/key pair file exists to avoid rotating to an
 | 
				
			||||||
	// invalid cert/key.
 | 
						// invalid cert/key.
 | 
				
			||||||
	if filenameExists, err := util.FileExists(filename); err != nil {
 | 
						if filenameExists, err := utilfile.FileExists(filename); err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	} else if !filenameExists {
 | 
						} else if !filenameExists {
 | 
				
			||||||
		return fmt.Errorf("file %q does not exist so it can not be used as the currently selected cert/key", filename)
 | 
							return fmt.Errorf("file %q does not exist so it can not be used as the currently selected cert/key", filename)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,7 +33,7 @@ go_library(
 | 
				
			|||||||
        "//pkg/kubelet/eviction/api:go_default_library",
 | 
					        "//pkg/kubelet/eviction/api:go_default_library",
 | 
				
			||||||
        "//pkg/kubelet/metrics:go_default_library",
 | 
					        "//pkg/kubelet/metrics:go_default_library",
 | 
				
			||||||
        "//pkg/kubelet/qos:go_default_library",
 | 
					        "//pkg/kubelet/qos:go_default_library",
 | 
				
			||||||
        "//pkg/util:go_default_library",
 | 
					        "//pkg/util/file:go_default_library",
 | 
				
			||||||
        "//pkg/util/mount:go_default_library",
 | 
					        "//pkg/util/mount:go_default_library",
 | 
				
			||||||
        "//pkg/util/oom:go_default_library",
 | 
					        "//pkg/util/oom:go_default_library",
 | 
				
			||||||
        "//pkg/util/procfs:go_default_library",
 | 
					        "//pkg/util/procfs:go_default_library",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -43,7 +43,7 @@ import (
 | 
				
			|||||||
	"k8s.io/kubernetes/pkg/kubelet/cadvisor"
 | 
						"k8s.io/kubernetes/pkg/kubelet/cadvisor"
 | 
				
			||||||
	cmutil "k8s.io/kubernetes/pkg/kubelet/cm/util"
 | 
						cmutil "k8s.io/kubernetes/pkg/kubelet/cm/util"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/qos"
 | 
						"k8s.io/kubernetes/pkg/kubelet/qos"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util"
 | 
						utilfile "k8s.io/kubernetes/pkg/util/file"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util/mount"
 | 
						"k8s.io/kubernetes/pkg/util/mount"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util/oom"
 | 
						"k8s.io/kubernetes/pkg/util/oom"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util/procfs"
 | 
						"k8s.io/kubernetes/pkg/util/procfs"
 | 
				
			||||||
@@ -163,11 +163,11 @@ func validateSystemRequirements(mountUtil mount.Interface) (features, error) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// Check if cpu quota is available.
 | 
						// Check if cpu quota is available.
 | 
				
			||||||
	// CPU cgroup is required and so it expected to be mounted at this point.
 | 
						// CPU cgroup is required and so it expected to be mounted at this point.
 | 
				
			||||||
	periodExists, err := util.FileExists(path.Join(cpuMountPoint, "cpu.cfs_period_us"))
 | 
						periodExists, err := utilfile.FileExists(path.Join(cpuMountPoint, "cpu.cfs_period_us"))
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		glog.Errorf("failed to detect if CPU cgroup cpu.cfs_period_us is available - %v", err)
 | 
							glog.Errorf("failed to detect if CPU cgroup cpu.cfs_period_us is available - %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	quotaExists, err := util.FileExists(path.Join(cpuMountPoint, "cpu.cfs_quota_us"))
 | 
						quotaExists, err := utilfile.FileExists(path.Join(cpuMountPoint, "cpu.cfs_quota_us"))
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		glog.Errorf("failed to detect if CPU cgroup cpu.cfs_quota_us is available - %v", err)
 | 
							glog.Errorf("failed to detect if CPU cgroup cpu.cfs_quota_us is available - %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,8 +28,8 @@ import (
 | 
				
			|||||||
	"k8s.io/kubernetes/cmd/kubelet/app/options"
 | 
						"k8s.io/kubernetes/cmd/kubelet/app/options"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/cm"
 | 
						"k8s.io/kubernetes/pkg/kubelet/cm"
 | 
				
			||||||
	kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
 | 
						kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util"
 | 
						utilfile "k8s.io/kubernetes/pkg/util/file"
 | 
				
			||||||
	nodeutil "k8s.io/kubernetes/pkg/util/node"
 | 
						utilnode "k8s.io/kubernetes/pkg/util/node"
 | 
				
			||||||
	volumeutil "k8s.io/kubernetes/pkg/volume/util"
 | 
						volumeutil "k8s.io/kubernetes/pkg/volume/util"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -220,7 +220,7 @@ func (kl *Kubelet) GetHostIP() (net.IP, error) {
 | 
				
			|||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("cannot get node: %v", err)
 | 
							return nil, fmt.Errorf("cannot get node: %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return nodeutil.GetNodeHostIP(node)
 | 
						return utilnode.GetNodeHostIP(node)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// getHostIPAnyway attempts to return the host IP from kubelet's nodeInfo, or
 | 
					// getHostIPAnyway attempts to return the host IP from kubelet's nodeInfo, or
 | 
				
			||||||
@@ -230,7 +230,7 @@ func (kl *Kubelet) getHostIPAnyWay() (net.IP, error) {
 | 
				
			|||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return nodeutil.GetNodeHostIP(node)
 | 
						return utilnode.GetNodeHostIP(node)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GetExtraSupplementalGroupsForPod returns a list of the extra
 | 
					// GetExtraSupplementalGroupsForPod returns a list of the extra
 | 
				
			||||||
@@ -261,7 +261,7 @@ func (kl *Kubelet) getPodVolumePathListFromDisk(podUID types.UID) ([]string, err
 | 
				
			|||||||
	for _, volumePluginDir := range volumePluginDirs {
 | 
						for _, volumePluginDir := range volumePluginDirs {
 | 
				
			||||||
		volumePluginName := volumePluginDir.Name()
 | 
							volumePluginName := volumePluginDir.Name()
 | 
				
			||||||
		volumePluginPath := filepath.Join(podVolDir, volumePluginName)
 | 
							volumePluginPath := filepath.Join(podVolDir, volumePluginName)
 | 
				
			||||||
		volumeDirs, err := util.ReadDirNoStat(volumePluginPath)
 | 
							volumeDirs, err := utilfile.ReadDirNoStat(volumePluginPath)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return volumes, fmt.Errorf("Could not read directory %s: %v", volumePluginPath, err)
 | 
								return volumes, fmt.Errorf("Could not read directory %s: %v", volumePluginPath, err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -58,7 +58,7 @@ import (
 | 
				
			|||||||
	"k8s.io/kubernetes/pkg/kubelet/status"
 | 
						"k8s.io/kubernetes/pkg/kubelet/status"
 | 
				
			||||||
	kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
 | 
						kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/util/format"
 | 
						"k8s.io/kubernetes/pkg/kubelet/util/format"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util"
 | 
						utilfile "k8s.io/kubernetes/pkg/util/file"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/volume"
 | 
						"k8s.io/kubernetes/pkg/volume"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/volume/util/volumehelper"
 | 
						"k8s.io/kubernetes/pkg/volume/util/volumehelper"
 | 
				
			||||||
	volumevalidation "k8s.io/kubernetes/pkg/volume/validation"
 | 
						volumevalidation "k8s.io/kubernetes/pkg/volume/validation"
 | 
				
			||||||
@@ -156,7 +156,7 @@ func makeMounts(pod *v1.Pod, podDir string, container *v1.Container, hostName, h
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			hostPath = filepath.Join(hostPath, mount.SubPath)
 | 
								hostPath = filepath.Join(hostPath, mount.SubPath)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if subPathExists, err := util.FileOrSymlinkExists(hostPath); err != nil {
 | 
								if subPathExists, err := utilfile.FileOrSymlinkExists(hostPath); err != nil {
 | 
				
			||||||
				glog.Errorf("Could not determine if subPath %s exists; will not attempt to change its permissions", hostPath)
 | 
									glog.Errorf("Could not determine if subPath %s exists; will not attempt to change its permissions", hostPath)
 | 
				
			||||||
			} else if !subPathExists {
 | 
								} else if !subPathExists {
 | 
				
			||||||
				// Create the sub path now because if it's auto-created later when referenced, it may have an
 | 
									// Create the sub path now because if it's auto-created later when referenced, it may have an
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,7 +15,7 @@ go_library(
 | 
				
			|||||||
    deps = [
 | 
					    deps = [
 | 
				
			||||||
        "//cmd/kubelet/app/options:go_default_library",
 | 
					        "//cmd/kubelet/app/options:go_default_library",
 | 
				
			||||||
        "//pkg/kubelet/volumemanager/cache:go_default_library",
 | 
					        "//pkg/kubelet/volumemanager/cache:go_default_library",
 | 
				
			||||||
        "//pkg/util:go_default_library",
 | 
					        "//pkg/util/file:go_default_library",
 | 
				
			||||||
        "//pkg/util/goroutinemap/exponentialbackoff:go_default_library",
 | 
					        "//pkg/util/goroutinemap/exponentialbackoff:go_default_library",
 | 
				
			||||||
        "//pkg/util/mount:go_default_library",
 | 
					        "//pkg/util/mount:go_default_library",
 | 
				
			||||||
        "//pkg/util/strings:go_default_library",
 | 
					        "//pkg/util/strings:go_default_library",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,7 +33,7 @@ import (
 | 
				
			|||||||
	clientset "k8s.io/client-go/kubernetes"
 | 
						clientset "k8s.io/client-go/kubernetes"
 | 
				
			||||||
	"k8s.io/kubernetes/cmd/kubelet/app/options"
 | 
						"k8s.io/kubernetes/cmd/kubelet/app/options"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/volumemanager/cache"
 | 
						"k8s.io/kubernetes/pkg/kubelet/volumemanager/cache"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util"
 | 
						utilfile "k8s.io/kubernetes/pkg/util/file"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util/goroutinemap/exponentialbackoff"
 | 
						"k8s.io/kubernetes/pkg/util/goroutinemap/exponentialbackoff"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util/mount"
 | 
						"k8s.io/kubernetes/pkg/util/mount"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util/strings"
 | 
						"k8s.io/kubernetes/pkg/util/strings"
 | 
				
			||||||
@@ -569,7 +569,7 @@ func getVolumesFromPodDir(podDir string) ([]podVolume, error) {
 | 
				
			|||||||
			pluginName := volumeDir.Name()
 | 
								pluginName := volumeDir.Name()
 | 
				
			||||||
			volumePluginPath := path.Join(volumesDir, pluginName)
 | 
								volumePluginPath := path.Join(volumesDir, pluginName)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			volumePluginDirs, err := util.ReadDirNoStat(volumePluginPath)
 | 
								volumePluginDirs, err := utilfile.ReadDirNoStat(volumePluginPath)
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
				glog.Errorf("Could not read volume plugin directory %q: %v", volumePluginPath, err)
 | 
									glog.Errorf("Could not read volume plugin directory %q: %v", volumePluginPath, err)
 | 
				
			||||||
				continue
 | 
									continue
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -31,13 +31,13 @@ go_library(
 | 
				
			|||||||
        "//pkg/proxy:go_default_library",
 | 
					        "//pkg/proxy:go_default_library",
 | 
				
			||||||
        "//pkg/proxy/config:go_default_library",
 | 
					        "//pkg/proxy/config:go_default_library",
 | 
				
			||||||
        "//pkg/proxy/iptables:go_default_library",
 | 
					        "//pkg/proxy/iptables:go_default_library",
 | 
				
			||||||
        "//pkg/util:go_default_library",
 | 
					 | 
				
			||||||
        "//pkg/util/exec:go_default_library",
 | 
					        "//pkg/util/exec:go_default_library",
 | 
				
			||||||
        "//pkg/util/io:go_default_library",
 | 
					        "//pkg/util/io:go_default_library",
 | 
				
			||||||
        "//pkg/util/iptables:go_default_library",
 | 
					        "//pkg/util/iptables:go_default_library",
 | 
				
			||||||
        "//pkg/util/mount:go_default_library",
 | 
					        "//pkg/util/mount:go_default_library",
 | 
				
			||||||
        "//pkg/util/node:go_default_library",
 | 
					        "//pkg/util/node:go_default_library",
 | 
				
			||||||
        "//pkg/util/oom:go_default_library",
 | 
					        "//pkg/util/oom:go_default_library",
 | 
				
			||||||
 | 
					        "//pkg/util/pointer:go_default_library",
 | 
				
			||||||
        "//pkg/util/sysctl:go_default_library",
 | 
					        "//pkg/util/sysctl:go_default_library",
 | 
				
			||||||
        "//pkg/volume/empty_dir:go_default_library",
 | 
					        "//pkg/volume/empty_dir:go_default_library",
 | 
				
			||||||
        "//pkg/volume/secret:go_default_library",
 | 
					        "//pkg/volume/secret:go_default_library",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -32,10 +32,10 @@ import (
 | 
				
			|||||||
	"k8s.io/kubernetes/pkg/proxy"
 | 
						"k8s.io/kubernetes/pkg/proxy"
 | 
				
			||||||
	proxyconfig "k8s.io/kubernetes/pkg/proxy/config"
 | 
						proxyconfig "k8s.io/kubernetes/pkg/proxy/config"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/proxy/iptables"
 | 
						"k8s.io/kubernetes/pkg/proxy/iptables"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util"
 | 
					 | 
				
			||||||
	utilexec "k8s.io/kubernetes/pkg/util/exec"
 | 
						utilexec "k8s.io/kubernetes/pkg/util/exec"
 | 
				
			||||||
	utiliptables "k8s.io/kubernetes/pkg/util/iptables"
 | 
						utiliptables "k8s.io/kubernetes/pkg/util/iptables"
 | 
				
			||||||
	nodeutil "k8s.io/kubernetes/pkg/util/node"
 | 
						utilnode "k8s.io/kubernetes/pkg/util/node"
 | 
				
			||||||
 | 
						utilpointer "k8s.io/kubernetes/pkg/util/pointer"
 | 
				
			||||||
	utilsysctl "k8s.io/kubernetes/pkg/util/sysctl"
 | 
						utilsysctl "k8s.io/kubernetes/pkg/util/sysctl"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/golang/glog"
 | 
						"github.com/golang/glog"
 | 
				
			||||||
@@ -122,7 +122,7 @@ func NewHollowProxyOrDie(
 | 
				
			|||||||
			Recorder:              recorder,
 | 
								Recorder:              recorder,
 | 
				
			||||||
			ProxyMode:             "fake",
 | 
								ProxyMode:             "fake",
 | 
				
			||||||
			NodeRef:               nodeRef,
 | 
								NodeRef:               nodeRef,
 | 
				
			||||||
			OOMScoreAdj:           util.Int32Ptr(0),
 | 
								OOMScoreAdj:           utilpointer.Int32Ptr(0),
 | 
				
			||||||
			ResourceContainer:     "",
 | 
								ResourceContainer:     "",
 | 
				
			||||||
			ConfigSyncPeriod:      30 * time.Second,
 | 
								ConfigSyncPeriod:      30 * time.Second,
 | 
				
			||||||
			ServiceEventHandler:   serviceHandler,
 | 
								ServiceEventHandler:   serviceHandler,
 | 
				
			||||||
@@ -144,7 +144,7 @@ func getNodeIP(client clientset.Interface, hostname string) net.IP {
 | 
				
			|||||||
		glog.Warningf("Failed to retrieve node info: %v", err)
 | 
							glog.Warningf("Failed to retrieve node info: %v", err)
 | 
				
			||||||
		return nil
 | 
							return nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	nodeIP, err = nodeutil.InternalGetNodeHostIP(node)
 | 
						nodeIP, err = utilnode.InternalGetNodeHostIP(node)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		glog.Warningf("Failed to retrieve node IP: %v", err)
 | 
							glog.Warningf("Failed to retrieve node IP: %v", err)
 | 
				
			||||||
		return nil
 | 
							return nil
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,7 +25,7 @@ go_library(
 | 
				
			|||||||
    tags = ["automanaged"],
 | 
					    tags = ["automanaged"],
 | 
				
			||||||
    deps = [
 | 
					    deps = [
 | 
				
			||||||
        "//pkg/ssh:go_default_library",
 | 
					        "//pkg/ssh:go_default_library",
 | 
				
			||||||
        "//pkg/util:go_default_library",
 | 
					        "//pkg/util/file:go_default_library",
 | 
				
			||||||
        "//vendor/github.com/golang/glog:go_default_library",
 | 
					        "//vendor/github.com/golang/glog:go_default_library",
 | 
				
			||||||
        "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library",
 | 
					        "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library",
 | 
				
			||||||
        "//vendor/k8s.io/apimachinery/pkg/util/clock:go_default_library",
 | 
					        "//vendor/k8s.io/apimachinery/pkg/util/clock:go_default_library",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,7 +29,7 @@ import (
 | 
				
			|||||||
	"k8s.io/apimachinery/pkg/util/clock"
 | 
						"k8s.io/apimachinery/pkg/util/clock"
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/util/wait"
 | 
						"k8s.io/apimachinery/pkg/util/wait"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/ssh"
 | 
						"k8s.io/kubernetes/pkg/ssh"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util"
 | 
						utilfile "k8s.io/kubernetes/pkg/util/file"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/golang/glog"
 | 
						"github.com/golang/glog"
 | 
				
			||||||
	"github.com/prometheus/client_golang/prometheus"
 | 
						"github.com/prometheus/client_golang/prometheus"
 | 
				
			||||||
@@ -116,7 +116,7 @@ func (c *SSHTunneler) Run(getAddresses AddressFunc) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// public keyfile is written last, so check for that.
 | 
						// public keyfile is written last, so check for that.
 | 
				
			||||||
	publicKeyFile := c.SSHKeyfile + ".pub"
 | 
						publicKeyFile := c.SSHKeyfile + ".pub"
 | 
				
			||||||
	exists, err := util.FileExists(publicKeyFile)
 | 
						exists, err := utilfile.FileExists(publicKeyFile)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		glog.Errorf("Error detecting if key exists: %v", err)
 | 
							glog.Errorf("Error detecting if key exists: %v", err)
 | 
				
			||||||
	} else if !exists {
 | 
						} else if !exists {
 | 
				
			||||||
@@ -205,7 +205,7 @@ func generateSSHKey(privateKeyfile, publicKeyfile string) error {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	// If private keyfile already exists, we must have only made it halfway
 | 
						// If private keyfile already exists, we must have only made it halfway
 | 
				
			||||||
	// through last time, so delete it.
 | 
						// through last time, so delete it.
 | 
				
			||||||
	exists, err := util.FileExists(privateKeyfile)
 | 
						exists, err := utilfile.FileExists(privateKeyfile)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		glog.Errorf("Error detecting if private key exists: %v", err)
 | 
							glog.Errorf("Error detecting if private key exists: %v", err)
 | 
				
			||||||
	} else if exists {
 | 
						} else if exists {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -32,7 +32,7 @@ go_test(
 | 
				
			|||||||
        "//pkg/client/clientset_generated/internalclientset/fake:go_default_library",
 | 
					        "//pkg/client/clientset_generated/internalclientset/fake:go_default_library",
 | 
				
			||||||
        "//pkg/kubectl/testing:go_default_library",
 | 
					        "//pkg/kubectl/testing:go_default_library",
 | 
				
			||||||
        "//pkg/printers:go_default_library",
 | 
					        "//pkg/printers:go_default_library",
 | 
				
			||||||
        "//pkg/util:go_default_library",
 | 
					        "//pkg/util/pointer:go_default_library",
 | 
				
			||||||
        "//vendor/github.com/ghodss/yaml:go_default_library",
 | 
					        "//vendor/github.com/ghodss/yaml:go_default_library",
 | 
				
			||||||
        "//vendor/k8s.io/api/core/v1:go_default_library",
 | 
					        "//vendor/k8s.io/api/core/v1:go_default_library",
 | 
				
			||||||
        "//vendor/k8s.io/api/extensions/v1beta1:go_default_library",
 | 
					        "//vendor/k8s.io/api/extensions/v1beta1:go_default_library",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -42,7 +42,7 @@ import (
 | 
				
			|||||||
	"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
 | 
						"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake"
 | 
						"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/printers"
 | 
						"k8s.io/kubernetes/pkg/printers"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util"
 | 
						utilpointer "k8s.io/kubernetes/pkg/util/pointer"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type describeClient struct {
 | 
					type describeClient struct {
 | 
				
			||||||
@@ -731,7 +731,7 @@ func TestDescribeDeployment(t *testing.T) {
 | 
				
			|||||||
			Namespace: "foo",
 | 
								Namespace: "foo",
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		Spec: v1beta1.DeploymentSpec{
 | 
							Spec: v1beta1.DeploymentSpec{
 | 
				
			||||||
			Replicas: util.Int32Ptr(1),
 | 
								Replicas: utilpointer.Int32Ptr(1),
 | 
				
			||||||
			Selector: &metav1.LabelSelector{},
 | 
								Selector: &metav1.LabelSelector{},
 | 
				
			||||||
			Template: v1.PodTemplateSpec{
 | 
								Template: v1.PodTemplateSpec{
 | 
				
			||||||
				Spec: v1.PodSpec{
 | 
									Spec: v1.PodSpec{
 | 
				
			||||||
@@ -1229,7 +1229,7 @@ func TestDescribeEvents(t *testing.T) {
 | 
				
			|||||||
					Namespace: "foo",
 | 
										Namespace: "foo",
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				Spec: v1beta1.DeploymentSpec{
 | 
									Spec: v1beta1.DeploymentSpec{
 | 
				
			||||||
					Replicas: util.Int32Ptr(1),
 | 
										Replicas: utilpointer.Int32Ptr(1),
 | 
				
			||||||
					Selector: &metav1.LabelSelector{},
 | 
										Selector: &metav1.LabelSelector{},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			}),
 | 
								}),
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,7 +17,7 @@ go_library(
 | 
				
			|||||||
    tags = ["automanaged"],
 | 
					    tags = ["automanaged"],
 | 
				
			||||||
    deps = [
 | 
					    deps = [
 | 
				
			||||||
        "//pkg/features:go_default_library",
 | 
					        "//pkg/features:go_default_library",
 | 
				
			||||||
        "//pkg/util:go_default_library",
 | 
					        "//pkg/util/file:go_default_library",
 | 
				
			||||||
        "//vendor/k8s.io/api/core/v1:go_default_library",
 | 
					        "//vendor/k8s.io/api/core/v1:go_default_library",
 | 
				
			||||||
        "//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library",
 | 
					        "//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library",
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,7 +28,7 @@ import (
 | 
				
			|||||||
	"k8s.io/api/core/v1"
 | 
						"k8s.io/api/core/v1"
 | 
				
			||||||
	utilfeature "k8s.io/apiserver/pkg/util/feature"
 | 
						utilfeature "k8s.io/apiserver/pkg/util/feature"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/features"
 | 
						"k8s.io/kubernetes/pkg/features"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util"
 | 
						utilfile "k8s.io/kubernetes/pkg/util/file"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Whether AppArmor should be disabled by default.
 | 
					// Whether AppArmor should be disabled by default.
 | 
				
			||||||
@@ -194,7 +194,7 @@ func getAppArmorFS() (string, error) {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		if fields[2] == "securityfs" {
 | 
							if fields[2] == "securityfs" {
 | 
				
			||||||
			appArmorFS := path.Join(fields[1], "apparmor")
 | 
								appArmorFS := path.Join(fields[1], "apparmor")
 | 
				
			||||||
			if ok, err := util.FileExists(appArmorFS); !ok {
 | 
								if ok, err := utilfile.FileExists(appArmorFS); !ok {
 | 
				
			||||||
				msg := fmt.Sprintf("path %s does not exist", appArmorFS)
 | 
									msg := fmt.Sprintf("path %s does not exist", appArmorFS)
 | 
				
			||||||
				if err != nil {
 | 
									if err != nil {
 | 
				
			||||||
					return "", fmt.Errorf("%s: %v", msg, err)
 | 
										return "", fmt.Errorf("%s: %v", msg, err)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,36 +2,6 @@ package(default_visibility = ["//visibility:public"])
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
licenses(["notice"])
 | 
					licenses(["notice"])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
load(
 | 
					 | 
				
			||||||
    "@io_bazel_rules_go//go:def.bzl",
 | 
					 | 
				
			||||||
    "go_library",
 | 
					 | 
				
			||||||
    "go_test",
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
go_library(
 | 
					 | 
				
			||||||
    name = "go_default_library",
 | 
					 | 
				
			||||||
    srcs = [
 | 
					 | 
				
			||||||
        "doc.go",
 | 
					 | 
				
			||||||
        "template.go",
 | 
					 | 
				
			||||||
        "util.go",
 | 
					 | 
				
			||||||
    ],
 | 
					 | 
				
			||||||
    tags = ["automanaged"],
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
go_test(
 | 
					 | 
				
			||||||
    name = "go_default_test",
 | 
					 | 
				
			||||||
    srcs = [
 | 
					 | 
				
			||||||
        "template_test.go",
 | 
					 | 
				
			||||||
        "util_test.go",
 | 
					 | 
				
			||||||
    ],
 | 
					 | 
				
			||||||
    library = ":go_default_library",
 | 
					 | 
				
			||||||
    tags = ["automanaged"],
 | 
					 | 
				
			||||||
    deps = [
 | 
					 | 
				
			||||||
        "//vendor/github.com/stretchr/testify/assert:go_default_library",
 | 
					 | 
				
			||||||
        "//vendor/k8s.io/apimachinery/pkg/util/diff:go_default_library",
 | 
					 | 
				
			||||||
    ],
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
filegroup(
 | 
					filegroup(
 | 
				
			||||||
    name = "package-srcs",
 | 
					    name = "package-srcs",
 | 
				
			||||||
    srcs = glob(["**"]),
 | 
					    srcs = glob(["**"]),
 | 
				
			||||||
@@ -51,6 +21,7 @@ filegroup(
 | 
				
			|||||||
        "//pkg/util/ebtables:all-srcs",
 | 
					        "//pkg/util/ebtables:all-srcs",
 | 
				
			||||||
        "//pkg/util/env:all-srcs",
 | 
					        "//pkg/util/env:all-srcs",
 | 
				
			||||||
        "//pkg/util/exec:all-srcs",
 | 
					        "//pkg/util/exec:all-srcs",
 | 
				
			||||||
 | 
					        "//pkg/util/file:all-srcs",
 | 
				
			||||||
        "//pkg/util/flock:all-srcs",
 | 
					        "//pkg/util/flock:all-srcs",
 | 
				
			||||||
        "//pkg/util/goroutinemap:all-srcs",
 | 
					        "//pkg/util/goroutinemap:all-srcs",
 | 
				
			||||||
        "//pkg/util/hash:all-srcs",
 | 
					        "//pkg/util/hash:all-srcs",
 | 
				
			||||||
@@ -72,6 +43,7 @@ filegroup(
 | 
				
			|||||||
        "//pkg/util/node:all-srcs",
 | 
					        "//pkg/util/node:all-srcs",
 | 
				
			||||||
        "//pkg/util/oom:all-srcs",
 | 
					        "//pkg/util/oom:all-srcs",
 | 
				
			||||||
        "//pkg/util/parsers:all-srcs",
 | 
					        "//pkg/util/parsers:all-srcs",
 | 
				
			||||||
 | 
					        "//pkg/util/pointer:all-srcs",
 | 
				
			||||||
        "//pkg/util/procfs:all-srcs",
 | 
					        "//pkg/util/procfs:all-srcs",
 | 
				
			||||||
        "//pkg/util/removeall:all-srcs",
 | 
					        "//pkg/util/removeall:all-srcs",
 | 
				
			||||||
        "//pkg/util/resourcecontainer:all-srcs",
 | 
					        "//pkg/util/resourcecontainer:all-srcs",
 | 
				
			||||||
@@ -83,6 +55,7 @@ filegroup(
 | 
				
			|||||||
        "//pkg/util/system:all-srcs",
 | 
					        "//pkg/util/system:all-srcs",
 | 
				
			||||||
        "//pkg/util/tail:all-srcs",
 | 
					        "//pkg/util/tail:all-srcs",
 | 
				
			||||||
        "//pkg/util/taints:all-srcs",
 | 
					        "//pkg/util/taints:all-srcs",
 | 
				
			||||||
 | 
					        "//pkg/util/template:all-srcs",
 | 
				
			||||||
        "//pkg/util/term:all-srcs",
 | 
					        "//pkg/util/term:all-srcs",
 | 
				
			||||||
        "//pkg/util/threading:all-srcs",
 | 
					        "//pkg/util/threading:all-srcs",
 | 
				
			||||||
        "//pkg/util/tolerations:all-srcs",
 | 
					        "//pkg/util/tolerations:all-srcs",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,20 +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 util implements various utility functions used in both testing and implementation
 | 
					 | 
				
			||||||
// of Kubernetes. Package util may not depend on any other package in the Kubernetes
 | 
					 | 
				
			||||||
// package tree.
 | 
					 | 
				
			||||||
package util // import "k8s.io/kubernetes/pkg/util"
 | 
					 | 
				
			||||||
							
								
								
									
										27
									
								
								pkg/util/file/BUILD
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								pkg/util/file/BUILD
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
				
			|||||||
 | 
					package(default_visibility = ["//visibility:public"])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					licenses(["notice"])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					load(
 | 
				
			||||||
 | 
					    "@io_bazel_rules_go//go:def.bzl",
 | 
				
			||||||
 | 
					    "go_library",
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					go_library(
 | 
				
			||||||
 | 
					    name = "go_default_library",
 | 
				
			||||||
 | 
					    srcs = ["file.go"],
 | 
				
			||||||
 | 
					    tags = ["automanaged"],
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					filegroup(
 | 
				
			||||||
 | 
					    name = "package-srcs",
 | 
				
			||||||
 | 
					    srcs = glob(["**"]),
 | 
				
			||||||
 | 
					    tags = ["automanaged"],
 | 
				
			||||||
 | 
					    visibility = ["//visibility:private"],
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					filegroup(
 | 
				
			||||||
 | 
					    name = "all-srcs",
 | 
				
			||||||
 | 
					    srcs = [":package-srcs"],
 | 
				
			||||||
 | 
					    tags = ["automanaged"],
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
							
								
								
									
										57
									
								
								pkg/util/file/file.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								pkg/util/file/file.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,57 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					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"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// FileExists checks if specified file exists.
 | 
				
			||||||
 | 
					func FileExists(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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// FileOrSymlinkExists checks if specified file or symlink exists.
 | 
				
			||||||
 | 
					func FileOrSymlinkExists(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)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										35
									
								
								pkg/util/pointer/BUILD
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								pkg/util/pointer/BUILD
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,35 @@
 | 
				
			|||||||
 | 
					package(default_visibility = ["//visibility:public"])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					licenses(["notice"])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					load(
 | 
				
			||||||
 | 
					    "@io_bazel_rules_go//go:def.bzl",
 | 
				
			||||||
 | 
					    "go_library",
 | 
				
			||||||
 | 
					    "go_test",
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					go_test(
 | 
				
			||||||
 | 
					    name = "go_default_test",
 | 
				
			||||||
 | 
					    srcs = ["pointer_test.go"],
 | 
				
			||||||
 | 
					    library = ":go_default_library",
 | 
				
			||||||
 | 
					    tags = ["automanaged"],
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					go_library(
 | 
				
			||||||
 | 
					    name = "go_default_library",
 | 
				
			||||||
 | 
					    srcs = ["pointer.go"],
 | 
				
			||||||
 | 
					    tags = ["automanaged"],
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					filegroup(
 | 
				
			||||||
 | 
					    name = "package-srcs",
 | 
				
			||||||
 | 
					    srcs = glob(["**"]),
 | 
				
			||||||
 | 
					    tags = ["automanaged"],
 | 
				
			||||||
 | 
					    visibility = ["//visibility:private"],
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					filegroup(
 | 
				
			||||||
 | 
					    name = "all-srcs",
 | 
				
			||||||
 | 
					    srcs = [":package-srcs"],
 | 
				
			||||||
 | 
					    tags = ["automanaged"],
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
							
								
								
									
										62
									
								
								pkg/util/pointer/pointer.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								pkg/util/pointer/pointer.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,62 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					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 pointer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
 | 
						"reflect"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// AllPtrFieldsNil tests whether all pointer fields in a struct are nil.  This is useful when,
 | 
				
			||||||
 | 
					// for example, an API struct is handled by plugins which need to distinguish
 | 
				
			||||||
 | 
					// "no plugin accepted this spec" from "this spec is empty".
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					// This function is only valid for structs and pointers to structs.  Any other
 | 
				
			||||||
 | 
					// type will cause a panic.  Passing a typed nil pointer will return true.
 | 
				
			||||||
 | 
					func AllPtrFieldsNil(obj interface{}) bool {
 | 
				
			||||||
 | 
						v := reflect.ValueOf(obj)
 | 
				
			||||||
 | 
						if !v.IsValid() {
 | 
				
			||||||
 | 
							panic(fmt.Sprintf("reflect.ValueOf() produced a non-valid Value for %#v", obj))
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if v.Kind() == reflect.Ptr {
 | 
				
			||||||
 | 
							if v.IsNil() {
 | 
				
			||||||
 | 
								return true
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							v = v.Elem()
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						for i := 0; i < v.NumField(); i++ {
 | 
				
			||||||
 | 
							if v.Field(i).Kind() == reflect.Ptr && !v.Field(i).IsNil() {
 | 
				
			||||||
 | 
								return false
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return true
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Int32Ptr returns a pointer to an int32
 | 
				
			||||||
 | 
					func Int32Ptr(i int32) *int32 {
 | 
				
			||||||
 | 
						o := i
 | 
				
			||||||
 | 
						return &o
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Int32PtrDerefOr dereference the int32 ptr and returns it i not nil,
 | 
				
			||||||
 | 
					// else returns def.
 | 
				
			||||||
 | 
					func Int32PtrDerefOr(ptr *int32, def int32) int32 {
 | 
				
			||||||
 | 
						if ptr != nil {
 | 
				
			||||||
 | 
							return *ptr
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return def
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
Copyright 2014 The Kubernetes Authors.
 | 
					Copyright 2017 The Kubernetes Authors.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
					Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
you may not use this file except in compliance with the License.
 | 
					you may not use this file except in compliance with the License.
 | 
				
			||||||
@@ -14,22 +14,12 @@ See the License for the specific language governing permissions and
 | 
				
			|||||||
limitations under the License.
 | 
					limitations under the License.
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
package util
 | 
					package pointer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"testing"
 | 
						"testing"
 | 
				
			||||||
 | 
					 | 
				
			||||||
	"k8s.io/apimachinery/pkg/util/diff"
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestStringDiff(t *testing.T) {
 | 
					 | 
				
			||||||
	diff := diff.StringDiff("aaabb", "aaacc")
 | 
					 | 
				
			||||||
	expect := "aaa\n\nA: bb\n\nB: cc\n\n"
 | 
					 | 
				
			||||||
	if diff != expect {
 | 
					 | 
				
			||||||
		t.Errorf("diff returned %v", diff)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func TestAllPtrFieldsNil(t *testing.T) {
 | 
					func TestAllPtrFieldsNil(t *testing.T) {
 | 
				
			||||||
	testCases := []struct {
 | 
						testCases := []struct {
 | 
				
			||||||
		obj      interface{}
 | 
							obj      interface{}
 | 
				
			||||||
							
								
								
									
										36
									
								
								pkg/util/template/BUILD
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								pkg/util/template/BUILD
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
				
			|||||||
 | 
					package(default_visibility = ["//visibility:public"])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					licenses(["notice"])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					load(
 | 
				
			||||||
 | 
					    "@io_bazel_rules_go//go:def.bzl",
 | 
				
			||||||
 | 
					    "go_library",
 | 
				
			||||||
 | 
					    "go_test",
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					go_test(
 | 
				
			||||||
 | 
					    name = "go_default_test",
 | 
				
			||||||
 | 
					    srcs = ["template_test.go"],
 | 
				
			||||||
 | 
					    library = ":go_default_library",
 | 
				
			||||||
 | 
					    tags = ["automanaged"],
 | 
				
			||||||
 | 
					    deps = ["//vendor/github.com/stretchr/testify/assert:go_default_library"],
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					go_library(
 | 
				
			||||||
 | 
					    name = "go_default_library",
 | 
				
			||||||
 | 
					    srcs = ["template.go"],
 | 
				
			||||||
 | 
					    tags = ["automanaged"],
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					filegroup(
 | 
				
			||||||
 | 
					    name = "package-srcs",
 | 
				
			||||||
 | 
					    srcs = glob(["**"]),
 | 
				
			||||||
 | 
					    tags = ["automanaged"],
 | 
				
			||||||
 | 
					    visibility = ["//visibility:private"],
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					filegroup(
 | 
				
			||||||
 | 
					    name = "all-srcs",
 | 
				
			||||||
 | 
					    srcs = [":package-srcs"],
 | 
				
			||||||
 | 
					    tags = ["automanaged"],
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
Copyright 2015 The Kubernetes Authors.
 | 
					Copyright 2017 The Kubernetes Authors.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
					Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
you may not use this file except in compliance with the License.
 | 
					you may not use this file except in compliance with the License.
 | 
				
			||||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
 | 
				
			|||||||
limitations under the License.
 | 
					limitations under the License.
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
package util
 | 
					package template
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"bytes"
 | 
						"bytes"
 | 
				
			||||||
@@ -41,6 +41,7 @@ func ExecuteTemplate(w io.Writer, templateText string, data interface{}) error {
 | 
				
			|||||||
	return t.Execute(w, data)
 | 
						return t.Execute(w, data)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ExecuteTemplateToString executes templateText with data and output written to string.
 | 
				
			||||||
func ExecuteTemplateToString(templateText string, data interface{}) (string, error) {
 | 
					func ExecuteTemplateToString(templateText string, data interface{}) (string, error) {
 | 
				
			||||||
	b := bytes.Buffer{}
 | 
						b := bytes.Buffer{}
 | 
				
			||||||
	err := ExecuteTemplate(&b, templateText, data)
 | 
						err := ExecuteTemplate(&b, templateText, data)
 | 
				
			||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
Copyright 2015 The Kubernetes Authors.
 | 
					Copyright 2017 The Kubernetes Authors.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
					Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
you may not use this file except in compliance with the License.
 | 
					you may not use this file except in compliance with the License.
 | 
				
			||||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
 | 
				
			|||||||
limitations under the License.
 | 
					limitations under the License.
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
package util
 | 
					package template
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"testing"
 | 
						"testing"
 | 
				
			||||||
							
								
								
									
										140
									
								
								pkg/util/util.go
									
									
									
									
									
								
							
							
						
						
									
										140
									
								
								pkg/util/util.go
									
									
									
									
									
								
							@@ -1,140 +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 util
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import (
 | 
					 | 
				
			||||||
	"fmt"
 | 
					 | 
				
			||||||
	"os"
 | 
					 | 
				
			||||||
	"reflect"
 | 
					 | 
				
			||||||
	"regexp"
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Takes a list of strings and compiles them into a list of regular expressions
 | 
					 | 
				
			||||||
func CompileRegexps(regexpStrings []string) ([]*regexp.Regexp, error) {
 | 
					 | 
				
			||||||
	regexps := []*regexp.Regexp{}
 | 
					 | 
				
			||||||
	for _, regexpStr := range regexpStrings {
 | 
					 | 
				
			||||||
		r, err := regexp.Compile(regexpStr)
 | 
					 | 
				
			||||||
		if err != nil {
 | 
					 | 
				
			||||||
			return []*regexp.Regexp{}, err
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		regexps = append(regexps, r)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return regexps, nil
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Detects if using systemd as the init system
 | 
					 | 
				
			||||||
// Please note that simply reading /proc/1/cmdline can be misleading because
 | 
					 | 
				
			||||||
// some installation of various init programs can automatically make /sbin/init
 | 
					 | 
				
			||||||
// a symlink or even a renamed version of their main program.
 | 
					 | 
				
			||||||
// TODO(dchen1107): realiably detects the init system using on the system:
 | 
					 | 
				
			||||||
// systemd, upstart, initd, etc.
 | 
					 | 
				
			||||||
func UsingSystemdInitSystem() bool {
 | 
					 | 
				
			||||||
	if _, err := os.Stat("/run/systemd/system"); err == nil {
 | 
					 | 
				
			||||||
		return true
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return false
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Tests whether all pointer fields in a struct are nil.  This is useful when,
 | 
					 | 
				
			||||||
// for example, an API struct is handled by plugins which need to distinguish
 | 
					 | 
				
			||||||
// "no plugin accepted this spec" from "this spec is empty".
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// This function is only valid for structs and pointers to structs.  Any other
 | 
					 | 
				
			||||||
// type will cause a panic.  Passing a typed nil pointer will return true.
 | 
					 | 
				
			||||||
func AllPtrFieldsNil(obj interface{}) bool {
 | 
					 | 
				
			||||||
	v := reflect.ValueOf(obj)
 | 
					 | 
				
			||||||
	if !v.IsValid() {
 | 
					 | 
				
			||||||
		panic(fmt.Sprintf("reflect.ValueOf() produced a non-valid Value for %#v", obj))
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if v.Kind() == reflect.Ptr {
 | 
					 | 
				
			||||||
		if v.IsNil() {
 | 
					 | 
				
			||||||
			return true
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		v = v.Elem()
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	for i := 0; i < v.NumField(); i++ {
 | 
					 | 
				
			||||||
		if v.Field(i).Kind() == reflect.Ptr && !v.Field(i).IsNil() {
 | 
					 | 
				
			||||||
			return false
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return true
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func FileExists(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
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func FileOrSymlinkExists(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)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// IntPtr returns a pointer to an int
 | 
					 | 
				
			||||||
func IntPtr(i int) *int {
 | 
					 | 
				
			||||||
	o := i
 | 
					 | 
				
			||||||
	return &o
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Int32Ptr returns a pointer to an int32
 | 
					 | 
				
			||||||
func Int32Ptr(i int32) *int32 {
 | 
					 | 
				
			||||||
	o := i
 | 
					 | 
				
			||||||
	return &o
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// IntPtrDerefOr dereference the int ptr and returns it i not nil,
 | 
					 | 
				
			||||||
// else returns def.
 | 
					 | 
				
			||||||
func IntPtrDerefOr(ptr *int, def int) int {
 | 
					 | 
				
			||||||
	if ptr != nil {
 | 
					 | 
				
			||||||
		return *ptr
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return def
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Int32PtrDerefOr dereference the int32 ptr and returns it i not nil,
 | 
					 | 
				
			||||||
// else returns def.
 | 
					 | 
				
			||||||
func Int32PtrDerefOr(ptr *int32, def int32) int32 {
 | 
					 | 
				
			||||||
	if ptr != nil {
 | 
					 | 
				
			||||||
		return *ptr
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return def
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -32,7 +32,7 @@ go_test(
 | 
				
			|||||||
    library = ":go_default_library",
 | 
					    library = ":go_default_library",
 | 
				
			||||||
    tags = ["automanaged"],
 | 
					    tags = ["automanaged"],
 | 
				
			||||||
    deps = [
 | 
					    deps = [
 | 
				
			||||||
        "//pkg/util:go_default_library",
 | 
					        "//pkg/util/file:go_default_library",
 | 
				
			||||||
        "//pkg/volume:go_default_library",
 | 
					        "//pkg/volume:go_default_library",
 | 
				
			||||||
        "//pkg/volume/testing:go_default_library",
 | 
					        "//pkg/volume/testing:go_default_library",
 | 
				
			||||||
        "//vendor/k8s.io/api/core/v1:go_default_library",
 | 
					        "//vendor/k8s.io/api/core/v1:go_default_library",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,7 +29,7 @@ import (
 | 
				
			|||||||
	"k8s.io/apimachinery/pkg/types"
 | 
						"k8s.io/apimachinery/pkg/types"
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/util/uuid"
 | 
						"k8s.io/apimachinery/pkg/util/uuid"
 | 
				
			||||||
	"k8s.io/client-go/kubernetes/fake"
 | 
						"k8s.io/client-go/kubernetes/fake"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util"
 | 
						utilfile "k8s.io/kubernetes/pkg/util/file"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/volume"
 | 
						"k8s.io/kubernetes/pkg/volume"
 | 
				
			||||||
	volumetest "k8s.io/kubernetes/pkg/volume/testing"
 | 
						volumetest "k8s.io/kubernetes/pkg/volume/testing"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@@ -108,7 +108,7 @@ func TestDeleter(t *testing.T) {
 | 
				
			|||||||
	if err := deleter.Delete(); err != nil {
 | 
						if err := deleter.Delete(); err != nil {
 | 
				
			||||||
		t.Errorf("Mock Recycler expected to return nil but got %s", err)
 | 
							t.Errorf("Mock Recycler expected to return nil but got %s", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if exists, _ := util.FileExists("foo"); exists {
 | 
						if exists, _ := utilfile.FileExists("foo"); exists {
 | 
				
			||||||
		t.Errorf("Temp path expected to be deleted, but was found at %s", tempPath)
 | 
							t.Errorf("Temp path expected to be deleted, but was found at %s", tempPath)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -86,3 +86,11 @@ object.A:
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func TestStringDiff(t *testing.T) {
 | 
				
			||||||
 | 
						diff := StringDiff("aaabb", "aaacc")
 | 
				
			||||||
 | 
						expect := "aaa\n\nA: bb\n\nB: cc\n\n"
 | 
				
			||||||
 | 
						if diff != expect {
 | 
				
			||||||
 | 
							t.Errorf("diff returned %v", diff)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,15 +8,15 @@ load(
 | 
				
			|||||||
    "go_test",
 | 
					    "go_test",
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					go_library(
 | 
				
			||||||
 | 
					    name = "go_default_library",
 | 
				
			||||||
 | 
					    srcs = ["json.go"],
 | 
				
			||||||
 | 
					    tags = ["automanaged"],
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
go_test(
 | 
					go_test(
 | 
				
			||||||
    name = "go_default_test",
 | 
					    name = "go_default_test",
 | 
				
			||||||
    srcs = ["json_test.go"],
 | 
					    srcs = ["json_test.go"],
 | 
				
			||||||
    library = ":go_default_library",
 | 
					    library = ":go_default_library",
 | 
				
			||||||
    tags = ["automanaged"],
 | 
					    tags = ["automanaged"],
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					 | 
				
			||||||
go_library(
 | 
					 | 
				
			||||||
    name = "go_default_library",
 | 
					 | 
				
			||||||
    srcs = ["json.go"],
 | 
					 | 
				
			||||||
    tags = ["automanaged"],
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -70,8 +70,8 @@ go_library(
 | 
				
			|||||||
        "//pkg/kubelet/util/format:go_default_library",
 | 
					        "//pkg/kubelet/util/format:go_default_library",
 | 
				
			||||||
        "//pkg/master/ports:go_default_library",
 | 
					        "//pkg/master/ports:go_default_library",
 | 
				
			||||||
        "//pkg/ssh:go_default_library",
 | 
					        "//pkg/ssh:go_default_library",
 | 
				
			||||||
        "//pkg/util:go_default_library",
 | 
					 | 
				
			||||||
        "//pkg/util/exec:go_default_library",
 | 
					        "//pkg/util/exec:go_default_library",
 | 
				
			||||||
 | 
					        "//pkg/util/file:go_default_library",
 | 
				
			||||||
        "//pkg/util/labels:go_default_library",
 | 
					        "//pkg/util/labels:go_default_library",
 | 
				
			||||||
        "//pkg/util/system:go_default_library",
 | 
					        "//pkg/util/system:go_default_library",
 | 
				
			||||||
        "//pkg/util/version:go_default_library",
 | 
					        "//pkg/util/version:go_default_library",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -48,8 +48,8 @@ import (
 | 
				
			|||||||
	"k8s.io/apimachinery/pkg/util/wait"
 | 
						"k8s.io/apimachinery/pkg/util/wait"
 | 
				
			||||||
	clientset "k8s.io/client-go/kubernetes"
 | 
						clientset "k8s.io/client-go/kubernetes"
 | 
				
			||||||
	gcecloud "k8s.io/kubernetes/pkg/cloudprovider/providers/gce"
 | 
						gcecloud "k8s.io/kubernetes/pkg/cloudprovider/providers/gce"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util"
 | 
					 | 
				
			||||||
	utilexec "k8s.io/kubernetes/pkg/util/exec"
 | 
						utilexec "k8s.io/kubernetes/pkg/util/exec"
 | 
				
			||||||
 | 
						utilfile "k8s.io/kubernetes/pkg/util/file"
 | 
				
			||||||
	"k8s.io/kubernetes/test/e2e/manifest"
 | 
						"k8s.io/kubernetes/test/e2e/manifest"
 | 
				
			||||||
	testutils "k8s.io/kubernetes/test/utils"
 | 
						testutils "k8s.io/kubernetes/test/utils"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -823,7 +823,7 @@ func (j *IngressTestJig) CreateIngress(manifestPath, ns string, ingAnnotations m
 | 
				
			|||||||
	Logf("creating service")
 | 
						Logf("creating service")
 | 
				
			||||||
	RunKubectlOrDie("create", "-f", mkpath("svc.yaml"), fmt.Sprintf("--namespace=%v", ns))
 | 
						RunKubectlOrDie("create", "-f", mkpath("svc.yaml"), fmt.Sprintf("--namespace=%v", ns))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if exists, _ := util.FileExists(mkpath("secret.yaml")); exists {
 | 
						if exists, _ := utilfile.FileExists(mkpath("secret.yaml")); exists {
 | 
				
			||||||
		Logf("creating secret")
 | 
							Logf("creating secret")
 | 
				
			||||||
		RunKubectlOrDie("create", "-f", mkpath("secret.yaml"), fmt.Sprintf("--namespace=%v", ns))
 | 
							RunKubectlOrDie("create", "-f", mkpath("secret.yaml"), fmt.Sprintf("--namespace=%v", ns))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -38,7 +38,7 @@ go_library(
 | 
				
			|||||||
        "//pkg/controller/replication:go_default_library",
 | 
					        "//pkg/controller/replication:go_default_library",
 | 
				
			||||||
        "//pkg/kubectl:go_default_library",
 | 
					        "//pkg/kubectl:go_default_library",
 | 
				
			||||||
        "//pkg/master/ports:go_default_library",
 | 
					        "//pkg/master/ports:go_default_library",
 | 
				
			||||||
        "//pkg/util:go_default_library",
 | 
					        "//pkg/util/pointer:go_default_library",
 | 
				
			||||||
        "//plugin/pkg/scheduler/schedulercache:go_default_library",
 | 
					        "//plugin/pkg/scheduler/schedulercache:go_default_library",
 | 
				
			||||||
        "//test/e2e/framework:go_default_library",
 | 
					        "//test/e2e/framework:go_default_library",
 | 
				
			||||||
        "//test/utils:go_default_library",
 | 
					        "//test/utils:go_default_library",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -41,7 +41,7 @@ import (
 | 
				
			|||||||
	"k8s.io/kubernetes/pkg/controller"
 | 
						"k8s.io/kubernetes/pkg/controller"
 | 
				
			||||||
	deploymentutil "k8s.io/kubernetes/pkg/controller/deployment/util"
 | 
						deploymentutil "k8s.io/kubernetes/pkg/controller/deployment/util"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubectl"
 | 
						"k8s.io/kubernetes/pkg/kubectl"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util"
 | 
						utilpointer "k8s.io/kubernetes/pkg/util/pointer"
 | 
				
			||||||
	"k8s.io/kubernetes/test/e2e/framework"
 | 
						"k8s.io/kubernetes/test/e2e/framework"
 | 
				
			||||||
	testutil "k8s.io/kubernetes/test/utils"
 | 
						testutil "k8s.io/kubernetes/test/utils"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@@ -370,7 +370,7 @@ func testDeploymentCleanUpPolicy(f *framework.Framework) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	rsName := "test-cleanup-controller"
 | 
						rsName := "test-cleanup-controller"
 | 
				
			||||||
	replicas := int32(1)
 | 
						replicas := int32(1)
 | 
				
			||||||
	revisionHistoryLimit := util.Int32Ptr(0)
 | 
						revisionHistoryLimit := utilpointer.Int32Ptr(0)
 | 
				
			||||||
	_, err := c.Extensions().ReplicaSets(ns).Create(newRS(rsName, replicas, rsPodLabels, NginxImageName, NginxImage))
 | 
						_, err := c.Extensions().ReplicaSets(ns).Create(newRS(rsName, replicas, rsPodLabels, NginxImageName, NginxImage))
 | 
				
			||||||
	Expect(err).NotTo(HaveOccurred())
 | 
						Expect(err).NotTo(HaveOccurred())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user