Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused code #76796

Merged
merged 1 commit into from
Apr 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions cmd/kubeadm/app/preflight/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -1088,10 +1088,6 @@ func RunPullImagesCheck(execer utilsexec.Interface, cfg *kubeadmapi.InitConfigur
// RunChecks runs each check, displays it's warnings/errors, and once all
// are processed will exit if any errors occurred.
func RunChecks(checks []Checker, ww io.Writer, ignorePreflightErrors sets.String) error {
type checkErrors struct {
Name string
Errors []error
}
var errsBuffer bytes.Buffer

for _, c := range checks {
Expand Down
6 changes: 0 additions & 6 deletions pkg/api/v1/persistentvolume/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,3 @@ func collectSecretPaths(t *testing.T, path *field.Path, name string, tp reflect.

return secretPaths
}

func newHostPathType(pathType string) *corev1.HostPathType {
hostPathType := new(corev1.HostPathType)
*hostPathType = corev1.HostPathType(pathType)
return hostPathType
}
7 changes: 0 additions & 7 deletions pkg/apis/batch/validation/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package validation

import (
"fmt"
"strings"
"testing"

Expand Down Expand Up @@ -68,12 +67,6 @@ func getValidPodTemplateSpecForGenerated(selector *metav1.LabelSelector) api.Pod
}
}

func featureToggle(feature utilfeature.Feature) []string {
enabled := fmt.Sprintf("%s=%t", feature, true)
disabled := fmt.Sprintf("%s=%t", feature, false)
return []string{enabled, disabled}
}

func TestValidateJob(t *testing.T) {
validManualSelector := getValidManualSelector()
validPodTemplateSpecForManual := getValidPodTemplateSpecForManual(validManualSelector)
Expand Down
5 changes: 0 additions & 5 deletions pkg/apis/policy/v1beta1/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,8 @@ package v1beta1

import (
policyv1beta1 "k8s.io/api/policy/v1beta1"
"k8s.io/apimachinery/pkg/runtime"
)

func addDefaultingFuncs(scheme *runtime.Scheme) error {
return RegisterDefaults(scheme)
}

func SetDefaults_PodSecurityPolicySpec(obj *policyv1beta1.PodSecurityPolicySpec) {
// This field was added after PodSecurityPolicy was released.
// Policies that do not include this field must remain as permissive as they were prior to the introduction of this field.
Expand Down
10 changes: 0 additions & 10 deletions pkg/cloudprovider/providers/azure/azure_standard.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,16 +568,6 @@ func extractResourceGroupByNicID(nicID string) (string, error) {
return matches[1], nil
}

// extractResourceGroupByPipID extracts the resource group name by publicIP ID.
func extractResourceGroupByPipID(pipID string) (string, error) {
matches := publicIPResourceGroupRE.FindStringSubmatch(pipID)
if len(matches) != 2 {
return "", fmt.Errorf("error of extracting resourceGroup from pipID %q", pipID)
}

return matches[1], nil
}

// getPrimaryInterfaceWithVMSet gets machine primary network interface by node name and vmSet.
func (as *availabilitySet) getPrimaryInterfaceWithVMSet(nodeName, vmSetName string) (network.Interface, error) {
var machine compute.VirtualMachine
Expand Down
5 changes: 0 additions & 5 deletions pkg/cloudprovider/providers/gce/gce.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,6 @@ const (
gceComputeAPIEndpointBeta = "https://www.googleapis.com/compute/beta/"
)

// gceObject is an abstraction of all GCE API object in go client
type gceObject interface {
MarshalJSON() ([]byte, error)
}

var _ cloudprovider.Interface = (*Cloud)(nil)
var _ cloudprovider.Instances = (*Cloud)(nil)
var _ cloudprovider.LoadBalancer = (*Cloud)(nil)
Expand Down
4 changes: 0 additions & 4 deletions pkg/cloudprovider/providers/gce/gce_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,6 @@ func makeGoogleAPINotFoundError(message string) error {
return &googleapi.Error{Code: http.StatusNotFound, Message: message}
}

func makeGoogleAPIError(code int, message string) error {
return &googleapi.Error{Code: code, Message: message}
}

// TODO(#51665): Remove this once Network Tiers becomes Beta in GCP.
func handleAlphaNetworkTierGetError(err error) (string, error) {
if isForbidden(err) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ type LbaasV2 struct {
LoadBalancer
}

type empty struct{}

func networkExtensions(client *gophercloud.ServiceClient) (map[string]bool, error) {
seen := make(map[string]bool)

Expand Down
16 changes: 0 additions & 16 deletions pkg/controller/podautoscaler/metrics/legacy_metrics_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,22 +389,6 @@ func TestCPUEmptyMetricsForOnePod(t *testing.T) {
tc.runTest(t)
}

func testCollapseTimeSamples(t *testing.T) {
now := time.Now()
metrics := heapster.MetricResult{
Metrics: []heapster.MetricPoint{
{Timestamp: now, Value: 50, FloatValue: nil},
{Timestamp: now.Add(-15 * time.Second), Value: 100, FloatValue: nil},
{Timestamp: now.Add(-60 * time.Second), Value: 100000, FloatValue: nil}},
LatestTimestamp: now,
}

val, timestamp, hadMetrics := collapseTimeSamples(metrics, time.Minute)
assert.True(t, hadMetrics, "should report that it received a populated list of metrics")
assert.InEpsilon(t, float64(75), val, 0.1, "collapsed sample value should be as expected")
assert.True(t, timestamp.Equal(now), "timestamp should be the current time (the newest)")
}

func offsetTimestampBy(t int) time.Time {
return fixedTimestamp.Add(time.Duration(t) * time.Minute)
}
10 changes: 0 additions & 10 deletions pkg/controller/serviceaccount/tokens_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,16 +702,6 @@ func (e *TokensController) listTokenSecrets(serviceAccount *v1.ServiceAccount) (
return items, nil
}

// serviceAccountNameAndUID is a helper method to get the ServiceAccount Name and UID from the given secret
// Returns "","" if the secret is not a ServiceAccountToken secret
// If the name or uid annotation is missing, "" is returned instead
func serviceAccountNameAndUID(secret *v1.Secret) (string, string) {
if secret.Type != v1.SecretTypeServiceAccountToken {
return "", ""
}
return secret.Annotations[v1.ServiceAccountNameKey], secret.Annotations[v1.ServiceAccountUIDKey]
}

func getSecretReferences(serviceAccount *v1.ServiceAccount) sets.String {
references := sets.NewString()
for _, secret := range serviceAccount.Secrets {
Expand Down
8 changes: 0 additions & 8 deletions pkg/controller/volume/persistentvolume/pv_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,6 @@ func TestControllerCacheParsingError(t *testing.T) {
}
}

func addVolumeAnnotation(volume *v1.PersistentVolume, annName, annValue string) *v1.PersistentVolume {
if volume.Annotations == nil {
volume.Annotations = make(map[string]string)
}
volume.Annotations[annName] = annValue
return volume
}

func makePVCClass(scName *string, hasSelectNodeAnno bool) *v1.PersistentVolumeClaim {
claim := &v1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
Expand Down
10 changes: 0 additions & 10 deletions pkg/credentialprovider/azure/azure_acr_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,6 @@ type authDirective struct {
realm string
}

type accessTokenPayload struct {
TenantID string `json:"tid"`
}

type acrTokenPayload struct {
Expiration int64 `json:"exp"`
TenantID string `json:"tenant"`
Credential string `json:"credential"`
}

type acrAuthResponse struct {
RefreshToken string `json:"refresh_token"`
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/kubectl/apply/element.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ func (mk MergeKeys) GetMergeKeyValue(i interface{}) (MergeKeyValue, error) {
return result, nil
}

type source int

// CombinedPrimitiveSlice implements a slice of primitives
type CombinedPrimitiveSlice struct {
Items []*PrimitiveListItem
Expand Down
1 change: 0 additions & 1 deletion pkg/kubectl/cmd/set/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ go_library(
"//pkg/kubectl/util/templates:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/api/rbac/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/meta:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
Expand Down
31 changes: 0 additions & 31 deletions pkg/kubectl/cmd/set/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@ limitations under the License.
package set

import (
"fmt"
"io"
"strings"

"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/strategicpatch"
"k8s.io/cli-runtime/pkg/resource"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
)

// selectContainers allows one or more containers to be matched against a string or wildcard
Expand All @@ -44,33 +40,6 @@ func selectContainers(containers []v1.Container, spec string) ([]*v1.Container,
return out, skipped
}

// handlePodUpdateError prints a more useful error to the end user when mutating a pod.
func handlePodUpdateError(out io.Writer, err error, resource string) {
if statusError, ok := err.(*errors.StatusError); ok && errors.IsInvalid(err) {
errorDetails := statusError.Status().Details
if errorDetails.Kind == "Pod" {
all, match := true, false
for _, cause := range errorDetails.Causes {
if cause.Field == "spec" && strings.Contains(cause.Message, "may not update fields other than") {
fmt.Fprintf(out, "error: may not update %s in pod %q directly\n", resource, errorDetails.Name)
match = true
} else {
all = false
}
}
if all && match {
return
}
} else {
if ok := cmdutil.PrintErrorWithCauses(err, out); ok {
return
}
}
}

fmt.Fprintf(out, "error: %v\n", err)
}

// selectString returns true if the provided string matches spec, where spec is a string with
// a non-greedy '*' wildcard operator.
// TODO: turn into a regex and handle greedy matches and backtracking.
Expand Down
7 changes: 0 additions & 7 deletions pkg/kubectl/cmd/testing/fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,6 @@ func NewInternalNamespacedType(kind, apiversion, name, namespace string) *Intern

var errInvalidVersion = errors.New("not a version")

func versionErrIfFalse(b bool) error {
if b {
return nil
}
return errInvalidVersion
}

// ValidVersion of API
var ValidVersion = "v1"

Expand Down
10 changes: 0 additions & 10 deletions pkg/kubectl/describe/versioned/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -4393,16 +4393,6 @@ func shorten(s string, maxLength int) string {
return s
}

// translateTimestampUntil returns the elapsed time until timestamp in
// human-readable approximation.
func translateTimestampUntil(timestamp metav1.Time) string {
if timestamp.IsZero() {
return "<unknown>"
}

return duration.HumanDuration(time.Until(timestamp.Time))
}

// translateTimestampSince returns the elapsed time since timestamp in
// human-readable approximation.
func translateTimestampSince(timestamp metav1.Time) string {
Expand Down
1 change: 0 additions & 1 deletion pkg/kubectl/util/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ func rsListFromClient(c appsclient.AppsV1Interface) rsListFunc {

// TODO: switch this to full namespacers
type rsListFunc func(string, metav1.ListOptions) ([]*appsv1.ReplicaSet, error)
type podListFunc func(string, metav1.ListOptions) (*corev1.PodList, error)

// listReplicaSets returns a slice of RSes the given deployment targets.
// Note that this does NOT attempt to reconcile ControllerRef (adopt/orphan),
Expand Down
17 changes: 0 additions & 17 deletions pkg/kubelet/dockershim/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ package dockershim

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"

dockertypes "github.com/docker/docker/api/types"
Expand Down Expand Up @@ -128,20 +125,6 @@ func TestParsingCreationConflictError(t *testing.T) {
require.Equal(t, matches[1], "24666ab8c814d16f986449e504ea0159468ddf8da01897144a770f66dce0e14e")
}

// writeDockerConfig will write a config file into a temporary dir, and return that dir.
// Caller is responsible for deleting the dir and its contents.
func writeDockerConfig(cfg string) (string, error) {
tmpdir, err := ioutil.TempDir("", "dockershim=helpers_test.go=")
if err != nil {
return "", err
}
dir := filepath.Join(tmpdir, ".docker")
if err := os.Mkdir(dir, 0755); err != nil {
return "", err
}
return tmpdir, ioutil.WriteFile(filepath.Join(dir, "config.json"), []byte(cfg), 0644)
}

func TestEnsureSandboxImageExists(t *testing.T) {
sandboxImage := "gcr.io/test/image"
authConfig := dockertypes.AuthConfig{Username: "user", Password: "pass"}
Expand Down
8 changes: 0 additions & 8 deletions pkg/kubelet/eviction/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,14 +434,6 @@ func formatThreshold(threshold evictionapi.Threshold) string {
return fmt.Sprintf("threshold(signal=%v, operator=%v, value=%v, gracePeriod=%v)", threshold.Signal, threshold.Operator, evictionapi.ThresholdValue(threshold.Value), threshold.GracePeriod)
}

// formatevictionapi.ThresholdValue formats a thresholdValue for logging.
func formatThresholdValue(value evictionapi.ThresholdValue) string {
if value.Quantity != nil {
return value.Quantity.String()
}
return fmt.Sprintf("%f%%", value.Percentage*float32(100))
}

// cachedStatsFunc returns a statsFunc based on the provided pod stats.
func cachedStatsFunc(podStats []statsapi.PodStats) statsFunc {
uid2PodStats := map[string]statsapi.PodStats{}
Expand Down
4 changes: 0 additions & 4 deletions pkg/kubelet/kubelet_node_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,6 @@ func (s sortableNodeAddress) Less(i, j int) bool {
}
func (s sortableNodeAddress) Swap(i, j int) { s[j], s[i] = s[i], s[j] }

func sortNodeAddresses(addrs sortableNodeAddress) {
sort.Sort(addrs)
}

func TestUpdateNewNodeStatus(t *testing.T) {
cases := []struct {
desc string
Expand Down
14 changes: 0 additions & 14 deletions pkg/kubelet/kubelet_pods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2018,20 +2018,6 @@ func TestPodPhaseWithRestartOnFailure(t *testing.T) {
}
}

type fakeReadWriteCloser struct{}

func (f *fakeReadWriteCloser) Write(data []byte) (int, error) {
return 0, nil
}

func (f *fakeReadWriteCloser) Read(data []byte) (int, error) {
return 0, nil
}

func (f *fakeReadWriteCloser) Close() error {
return nil
}

func TestGetExec(t *testing.T) {
const (
podName = "podFoo"
Expand Down
16 changes: 0 additions & 16 deletions pkg/kubelet/kubelet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,22 +136,6 @@ func newTestKubelet(t *testing.T, controllerAttachDetachEnabled bool) *TestKubel
return newTestKubeletWithImageList(t, imageList, controllerAttachDetachEnabled, true /*initFakeVolumePlugin*/)
}

func newTestKubeletWithoutFakeVolumePlugin(t *testing.T, controllerAttachDetachEnabled bool) *TestKubelet {
imageList := []kubecontainer.Image{
{
ID: "abc",
RepoTags: []string{"k8s.gcr.io:v1", "k8s.gcr.io:v2"},
Size: 123,
},
{
ID: "efg",
RepoTags: []string{"k8s.gcr.io:v3", "k8s.gcr.io:v4"},
Size: 456,
},
}
return newTestKubeletWithImageList(t, imageList, controllerAttachDetachEnabled, false /*initFakeVolumePlugin*/)
}

func newTestKubeletWithImageList(
t *testing.T,
imageList []kubecontainer.Image,
Expand Down