mirror of
https://github.com/kubernetes-sigs/descheduler.git
synced 2026-01-28 14:41:10 +01:00
Commit for gofmt
Signed-off-by: ravisantoshgudimetla <ravisantoshgudimetla@gmail.com>
This commit is contained in:
@@ -2,5 +2,6 @@ language: go
|
|||||||
go:
|
go:
|
||||||
- 1.8.3
|
- 1.8.3
|
||||||
script:
|
script:
|
||||||
|
- hack/verify-gofmt.sh
|
||||||
- make build
|
- make build
|
||||||
- make test
|
- make test
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ limitations under the License.
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"flag"
|
"flag"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/kubernetes-incubator/descheduler/cmd/descheduler/app/options"
|
"github.com/kubernetes-incubator/descheduler/cmd/descheduler/app/options"
|
||||||
@@ -27,8 +27,8 @@ import (
|
|||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"k8s.io/apiserver/pkg/util/logs"
|
|
||||||
aflag "k8s.io/apiserver/pkg/util/flag"
|
aflag "k8s.io/apiserver/pkg/util/flag"
|
||||||
|
"k8s.io/apiserver/pkg/util/logs"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewDeschedulerCommand creates a *cobra.Command object with default parameters
|
// NewDeschedulerCommand creates a *cobra.Command object with default parameters
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"github.com/kubernetes-incubator/descheduler/cmd/descheduler/app"
|
"github.com/kubernetes-incubator/descheduler/cmd/descheduler/app"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
54
hack/verify-gofmt.sh
Executable file
54
hack/verify-gofmt.sh
Executable file
@@ -0,0 +1,54 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
DESCHEDULER_ROOT=$(dirname "${BASH_SOURCE}")/..
|
||||||
|
|
||||||
|
GO_VERSION=($(go version))
|
||||||
|
|
||||||
|
if [[ -z $(echo "${GO_VERSION[2]}" | grep -E 'go1.2|go1.3|go1.4|go1.5|go1.6|go1.7|go1.8') ]]; then
|
||||||
|
echo "Unknown go version '${GO_VERSION}', skipping gofmt."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd "${DESCHEDULER_ROOT}"
|
||||||
|
|
||||||
|
find_files() {
|
||||||
|
find . -not \( \
|
||||||
|
\( \
|
||||||
|
-wholename './output' \
|
||||||
|
-o -wholename './_output' \
|
||||||
|
-o -wholename './release' \
|
||||||
|
-o -wholename './target' \
|
||||||
|
-o -wholename './.git' \
|
||||||
|
-o -wholename '*/third_party/*' \
|
||||||
|
-o -wholename '*/Godeps/*' \
|
||||||
|
-o -wholename '*/vendor/*' \
|
||||||
|
\) -prune \
|
||||||
|
\) -name '*.go'
|
||||||
|
}
|
||||||
|
|
||||||
|
GOFMT="gofmt -s"
|
||||||
|
bad_files=$(find_files | xargs $GOFMT -l)
|
||||||
|
if [[ -n "${bad_files}" ]]; then
|
||||||
|
echo "!!! '$GOFMT' needs to be run on the following files: "
|
||||||
|
echo "${bad_files}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
@@ -19,6 +19,7 @@ package node
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/golang/glog"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
@@ -26,7 +27,6 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/api/v1"
|
"k8s.io/kubernetes/pkg/api/v1"
|
||||||
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
|
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
|
||||||
corelisters "k8s.io/kubernetes/pkg/client/listers/core/v1"
|
corelisters "k8s.io/kubernetes/pkg/client/listers/core/v1"
|
||||||
"github.com/golang/glog"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ReadyNodes returns ready nodes irrespective of whether they are
|
// ReadyNodes returns ready nodes irrespective of whether they are
|
||||||
@@ -45,7 +45,7 @@ func ReadyNodes(client clientset.Interface, stopChannel <-chan struct{}) ([]*v1.
|
|||||||
return []*v1.Node{}, err
|
return []*v1.Node{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, _ := range nItems.Items {
|
for i := range nItems.Items {
|
||||||
node := nItems.Items[i]
|
node := nItems.Items[i]
|
||||||
nodes = append(nodes, &node)
|
nodes = append(nodes, &node)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ import (
|
|||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
|
||||||
|
"github.com/golang/glog"
|
||||||
"github.com/kubernetes-incubator/descheduler/pkg/api"
|
"github.com/kubernetes-incubator/descheduler/pkg/api"
|
||||||
_ "github.com/kubernetes-incubator/descheduler/pkg/api/install"
|
_ "github.com/kubernetes-incubator/descheduler/pkg/api/install"
|
||||||
"github.com/kubernetes-incubator/descheduler/pkg/api/v1alpha1"
|
"github.com/kubernetes-incubator/descheduler/pkg/api/v1alpha1"
|
||||||
"github.com/kubernetes-incubator/descheduler/pkg/descheduler/scheme"
|
"github.com/kubernetes-incubator/descheduler/pkg/descheduler/scheme"
|
||||||
"github.com/golang/glog"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func LoadPolicyConfig(policyConfigFile string) (*api.DeschedulerPolicy, error) {
|
func LoadPolicyConfig(policyConfigFile string) (*api.DeschedulerPolicy, error) {
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ func validateThresholds(thresholds api.ResourceThresholds) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
found := false
|
found := false
|
||||||
for name, _ := range thresholds {
|
for name := range thresholds {
|
||||||
if name == v1.ResourceCPU || name == v1.ResourceMemory || name == v1.ResourcePods {
|
if name == v1.ResourceCPU || name == v1.ResourceMemory || name == v1.ResourcePods {
|
||||||
found = true
|
found = true
|
||||||
break
|
break
|
||||||
@@ -171,8 +171,6 @@ func evictPodsFromTargetNodes(client clientset.Interface, evictionPolicyGroupVer
|
|||||||
return podsEvicted
|
return podsEvicted
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func evictPods(inputPods []*v1.Pod,
|
func evictPods(inputPods []*v1.Pod,
|
||||||
client clientset.Interface,
|
client clientset.Interface,
|
||||||
evictionPolicyGroupVersion string,
|
evictionPolicyGroupVersion string,
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ limitations under the License.
|
|||||||
|
|
||||||
package test
|
package test
|
||||||
|
|
||||||
import ("fmt"
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
@@ -92,7 +93,6 @@ func GetCriticalPodAnnotation() map[string]string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// BuildTestNode creates a node with specified capacity.
|
// BuildTestNode creates a node with specified capacity.
|
||||||
func BuildTestNode(name string, millicpu int64, mem int64, pods int64) *v1.Node {
|
func BuildTestNode(name string, millicpu int64, mem int64, pods int64) *v1.Node {
|
||||||
node := &v1.Node{
|
node := &v1.Node{
|
||||||
|
|||||||
Reference in New Issue
Block a user