Skip to content

Commit

Permalink
Fix issues reported by go fmt and lint checks
Browse files Browse the repository at this point in the history
Signed-off-by: Yuan Chen <[email protected]>
  • Loading branch information
yuanchen8911 committed May 10, 2024
1 parent cc2121e commit 3221f3a
Show file tree
Hide file tree
Showing 22 changed files with 31 additions and 47 deletions.
4 changes: 4 additions & 0 deletions .yamlfmt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
formatter:
type: basic
indentless_arrays: true
retain_line_breaks_single: true
5 changes: 2 additions & 3 deletions cmd/knavigator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ import (
"fmt"
"os"

"k8s.io/klog/v2"
"k8s.io/klog/v2/textlogger"

"github.com/NVIDIA/knavigator/pkg/config"
"github.com/NVIDIA/knavigator/pkg/engine"
"github.com/NVIDIA/knavigator/pkg/utils"
"k8s.io/klog/v2"
"k8s.io/klog/v2/textlogger"
)

func mainInternal() error {
Expand Down
2 changes: 1 addition & 1 deletion docs/task_management.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ Tasks are defined in a YAML format or received via HTTP/gRPC protocols. The Task
- Check the spec and status of nodes
- Check the spec and status of pods
- Run PromQL query
- Sleep for a specified duration
- Sleep for a specified duration
5 changes: 2 additions & 3 deletions pkg/engine/check_object_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ import (
"context"
"fmt"

"github.com/NVIDIA/knavigator/pkg/config"
"github.com/NVIDIA/knavigator/pkg/utils"
"github.com/go-logr/logr"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/dynamic/dynamicinformer"
"k8s.io/client-go/tools/cache"

"github.com/NVIDIA/knavigator/pkg/config"
"github.com/NVIDIA/knavigator/pkg/utils"
)

// CheckObjTask represents a task that checks object state and status.
Expand Down
3 changes: 1 addition & 2 deletions pkg/engine/check_object_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"

"github.com/NVIDIA/knavigator/pkg/config"
"github.com/stretchr/testify/require"
)

func TestNewCheckObjTask(t *testing.T) {
Expand Down
5 changes: 2 additions & 3 deletions pkg/engine/check_pod_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@ import (
"fmt"
"time"

"github.com/NVIDIA/knavigator/pkg/config"
"github.com/NVIDIA/knavigator/pkg/utils"
"github.com/go-logr/logr"
"gopkg.in/yaml.v3"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/cache"

"github.com/NVIDIA/knavigator/pkg/config"
"github.com/NVIDIA/knavigator/pkg/utils"
)

// CheckPodTask represents CheckPod task.
Expand Down
3 changes: 1 addition & 2 deletions pkg/engine/check_pod_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"

"github.com/NVIDIA/knavigator/pkg/config"
"github.com/stretchr/testify/require"
)

func TestCheckPodParams(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions pkg/engine/delete_object_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ import (
"context"
"fmt"

"github.com/NVIDIA/knavigator/pkg/config"
"github.com/go-logr/logr"
"gopkg.in/yaml.v3"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/dynamic"

"github.com/NVIDIA/knavigator/pkg/config"
)

type DeleteObjTask struct {
Expand Down
3 changes: 1 addition & 2 deletions pkg/engine/delete_object_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ package engine
import (
"testing"

"github.com/stretchr/testify/require"

"github.com/NVIDIA/knavigator/pkg/config"
"github.com/stretchr/testify/require"
)

func TestNewDeleteObjTask(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions pkg/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ import (
"sync"
"time"

"github.com/NVIDIA/knavigator/pkg/config"
"github.com/go-logr/logr"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"

"github.com/NVIDIA/knavigator/pkg/config"
)

type Engine interface {
Expand Down
3 changes: 1 addition & 2 deletions pkg/engine/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ import (
"fmt"
"testing"

"github.com/NVIDIA/knavigator/pkg/config"
"github.com/stretchr/testify/require"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"
"k8s.io/klog/v2/textlogger"

"github.com/NVIDIA/knavigator/pkg/config"
)

var (
Expand Down
3 changes: 1 addition & 2 deletions pkg/engine/pause_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ import (
"fmt"
"os"

"github.com/go-logr/logr"

"github.com/NVIDIA/knavigator/pkg/config"
"github.com/go-logr/logr"
)

type PauseTask struct {
Expand Down
3 changes: 1 addition & 2 deletions pkg/engine/pause_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"

"github.com/NVIDIA/knavigator/pkg/config"
"github.com/stretchr/testify/require"
)

func TestPauseExec(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions pkg/engine/sleep_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ import (
"fmt"
"time"

"github.com/NVIDIA/knavigator/pkg/config"
"github.com/go-logr/logr"
"gopkg.in/yaml.v3"

"github.com/NVIDIA/knavigator/pkg/config"
)

type SleepTask struct {
Expand Down
3 changes: 1 addition & 2 deletions pkg/engine/sleep_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"

"github.com/NVIDIA/knavigator/pkg/config"
"github.com/stretchr/testify/require"
)

func TestSleepParams(t *testing.T) {
Expand Down
5 changes: 2 additions & 3 deletions pkg/engine/submit_object_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ import (
"fmt"
"text/template"

"github.com/NVIDIA/knavigator/pkg/config"
"github.com/NVIDIA/knavigator/pkg/utils"
"github.com/go-logr/logr"
"gopkg.in/yaml.v3"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"

"github.com/NVIDIA/knavigator/pkg/config"
"github.com/NVIDIA/knavigator/pkg/utils"
)

type SubmitObjTask struct {
Expand Down
3 changes: 1 addition & 2 deletions pkg/engine/submit_object_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ package engine
import (
"testing"

"github.com/stretchr/testify/require"

"github.com/NVIDIA/knavigator/pkg/config"
"github.com/NVIDIA/knavigator/pkg/utils"
"github.com/stretchr/testify/require"
)

func TestNewSubmitObjTask(t *testing.T) {
Expand Down
5 changes: 2 additions & 3 deletions pkg/engine/update_nodes_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ import (
"context"
"fmt"

"github.com/NVIDIA/knavigator/pkg/config"
"github.com/NVIDIA/knavigator/pkg/utils"
"github.com/go-logr/logr"
"gopkg.in/yaml.v3"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes"

"github.com/NVIDIA/knavigator/pkg/config"
"github.com/NVIDIA/knavigator/pkg/utils"
)

// UpdateNodesTask represents UpdateNodes task.
Expand Down
3 changes: 1 addition & 2 deletions pkg/engine/update_nodes_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ package engine
import (
"testing"

"github.com/stretchr/testify/require"

"github.com/NVIDIA/knavigator/pkg/config"
"github.com/NVIDIA/knavigator/pkg/utils"
"github.com/stretchr/testify/require"
)

func TestUpdateNodesTask(t *testing.T) {
Expand Down
6 changes: 2 additions & 4 deletions pkg/engine/update_object_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ import (
"context"
"fmt"

"github.com/NVIDIA/knavigator/pkg/config"
"github.com/NVIDIA/knavigator/pkg/utils"
"github.com/go-logr/logr"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/dynamic"

"github.com/NVIDIA/knavigator/pkg/config"
"github.com/NVIDIA/knavigator/pkg/utils"
)

// UpdateObjTask represents task that updates object state and status
Expand Down
3 changes: 1 addition & 2 deletions pkg/engine/update_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"

"github.com/NVIDIA/knavigator/pkg/config"
"github.com/stretchr/testify/require"
)

func TestNewUpdateObjTask(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/k8s_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func GetK8sConfig(log logr.Logger, kubeConfigPath, kubectx string) (*rest.Config
if err != nil {
return nil, err
}
//update cert file location if needed
// update cert file location if needed
for _, info := range config.AuthInfos {
if len(info.LocationOfOrigin) != 0 {
dir := filepath.Dir(info.LocationOfOrigin)
Expand Down

0 comments on commit 3221f3a

Please sign in to comment.