Skip to content

Commit

Permalink
fix gofmt issues
Browse files Browse the repository at this point in the history
  • Loading branch information
cjerad committed Jun 30, 2020
1 parent 8385e96 commit 1140807
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 16 deletions.
8 changes: 4 additions & 4 deletions pkg/config/config.go
Expand Up @@ -58,11 +58,11 @@ const (
uptimeFromFileConfigKey = "UPTIME_FROM_FILE"
uptimeFromFileDefault = ""
// prometheus
enablePrometheusDefault = false
enablePrometheusConfigKey = "ENABLE_PROMETHEUS_SERVER"
enablePrometheusDefault = false
enablePrometheusConfigKey = "ENABLE_PROMETHEUS_SERVER"
// https://github.com/prometheus/prometheus/wiki/Default-port-allocations
prometheusPortDefault = 9092
prometheusPortConfigKey = "PROMETHEUS_SERVER_PORT"
prometheusPortDefault = 9092
prometheusPortConfigKey = "PROMETHEUS_SERVER_PORT"
)

//Config arguments set via CLI, environment variables, or defaults
Expand Down
2 changes: 1 addition & 1 deletion pkg/interruptionevent/scheduled-event_internal_test.go
Expand Up @@ -21,8 +21,8 @@ import (

"github.com/aws/aws-node-termination-handler/pkg/config"
"github.com/aws/aws-node-termination-handler/pkg/node"
"github.com/aws/aws-node-termination-handler/pkg/uptime"
h "github.com/aws/aws-node-termination-handler/pkg/test"
"github.com/aws/aws-node-termination-handler/pkg/uptime"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/fake"
Expand Down
2 changes: 1 addition & 1 deletion pkg/interruptionevent/spot-itn-event_internal_test.go
Expand Up @@ -20,8 +20,8 @@ import (

"github.com/aws/aws-node-termination-handler/pkg/config"
"github.com/aws/aws-node-termination-handler/pkg/node"
"github.com/aws/aws-node-termination-handler/pkg/uptime"
h "github.com/aws/aws-node-termination-handler/pkg/test"
"github.com/aws/aws-node-termination-handler/pkg/uptime"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/fake"
Expand Down
4 changes: 2 additions & 2 deletions pkg/node/node.go
Expand Up @@ -83,6 +83,7 @@ func NewWithValues(nthConfig config.Config, drainHelper *drain.Helper, uptime up
}, nil
}

// GetName returns node name from the configuration.
func (n Node) GetName() string {
return n.nthConfig.NodeName
}
Expand Down Expand Up @@ -546,10 +547,9 @@ func removeTaint(node *corev1.Node, client kubernetes.Interface, taintKey string

func getUptimeFunc(uptimeFile string) uptime.UptimeFuncType {
if uptimeFile != "" {
return func () (int64, error) {
return func() (int64, error) {
return uptime.UptimeFromFile(uptimeFile)
}
}
return uptime.Uptime
}

2 changes: 1 addition & 1 deletion pkg/node/node_internal_test.go
Expand Up @@ -22,8 +22,8 @@ import (
"time"

"github.com/aws/aws-node-termination-handler/pkg/config"
"github.com/aws/aws-node-termination-handler/pkg/uptime"
h "github.com/aws/aws-node-termination-handler/pkg/test"
"github.com/aws/aws-node-termination-handler/pkg/uptime"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/fake"
Expand Down
2 changes: 1 addition & 1 deletion pkg/node/node_test.go
Expand Up @@ -22,8 +22,8 @@ import (

"github.com/aws/aws-node-termination-handler/pkg/config"
"github.com/aws/aws-node-termination-handler/pkg/node"
"github.com/aws/aws-node-termination-handler/pkg/uptime"
h "github.com/aws/aws-node-termination-handler/pkg/test"
"github.com/aws/aws-node-termination-handler/pkg/uptime"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/fake"
Expand Down
5 changes: 3 additions & 2 deletions pkg/uptime/common.go
Expand Up @@ -20,9 +20,11 @@ import (
"strings"
)

// UptimeFuncType cleans up function arguments or return type.
type UptimeFuncType func() (int64, error)

// Returns number of seconds since last reboot as read from filepath.
// UptimeFromFile reads system uptime information from filepath and returns
// the number of seconds since last system boot.
func UptimeFromFile(filepath string) (int64, error) {
data, err := ioutil.ReadFile(filepath)
if err != nil {
Expand All @@ -35,4 +37,3 @@ func UptimeFromFile(filepath string) (int64, error) {
}
return int64(uptime), nil
}

1 change: 0 additions & 1 deletion pkg/uptime/common_test.go
Expand Up @@ -28,4 +28,3 @@ func TestUptimeFromFileFailure(t *testing.T) {
os.Remove(testFile)
h.Assert(t, err != nil, "Failed to throw error for int64 parse")
}

3 changes: 2 additions & 1 deletion pkg/uptime/uptime_linux.go
Expand Up @@ -13,7 +13,8 @@

package uptime

// Uptime reads system uptime from /proc/uptime and returns the number
// of seconds since last system boot.
func Uptime() (int64, error) {
return UptimeFromFile("/proc/uptime")
}

4 changes: 2 additions & 2 deletions pkg/uptime/uptime_windows.go
Expand Up @@ -21,10 +21,11 @@ import (
)

var (
kernel32 = windows.NewLazySystemDLL("kernel32.dll")
kernel32 = windows.NewLazySystemDLL("kernel32.dll")
getTickCount = kernel32.NewProc("GetTickCount")
)

// Uptime returns the number of seconds since last system boot.
func Uptime() (int64, error) {
millis, _, err := syscall.Syscall(getTickCount.Addr(), 0, 0, 0, 0)
if err != 0 {
Expand All @@ -33,4 +34,3 @@ func Uptime() (int64, error) {
uptime := (time.Duration(millis) * time.Millisecond).Seconds()
return int64(uptime), nil
}

0 comments on commit 1140807

Please sign in to comment.