Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 37 additions & 22 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,43 @@ run:
deadline: 5m
allow-parallel-runners: true

# Settings of specific linters
linters-settings:
gci:
sections:
- standard
- default
- prefix(github.com/project-codeflare/appwrapper)
- blank
- dot
skip-generated: true # Skip generated files.

linters:
disable-all: true
enable:
- copyloopvar
- dupl
- dupword
- errcheck
- gci
- ginkgolinter
- goconst
- gocyclo
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- lll
- misspell
- nakedret
- prealloc
- staticcheck
- typecheck
- unconvert
- unparam
- unused

issues:
# don't skip warning about doc comments
# don't exclude the default set of lint
Expand All @@ -28,25 +65,3 @@ issues:
- path: "pkg/*"
linters:
- lll
linters:
disable-all: true
enable:
- copyloopvar
- dupl
- errcheck
- goconst
- gocyclo
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- lll
- misspell
- nakedret
- prealloc
- staticcheck
- typecheck
- unconvert
- unparam
- unused
12 changes: 5 additions & 7 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,16 @@ import (
"os"
"strings"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.
_ "k8s.io/client-go/plugin/pkg/client/auth"

zaplog "go.uber.org/zap"
"go.uber.org/zap/zapcore"
"k8s.io/utils/ptr"

corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"k8s.io/utils/ptr"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
Expand All @@ -52,7 +47,10 @@ import (
"github.com/project-codeflare/appwrapper/pkg/config"
"github.com/project-codeflare/appwrapper/pkg/controller"
"github.com/project-codeflare/appwrapper/pkg/logger"
//+kubebuilder:scaffold:imports

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.
_ "k8s.io/client-go/plugin/pkg/client/auth"
)

var (
Expand Down
1 change: 0 additions & 1 deletion internal/controller/appwrapper/appwrapper_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/client-go/tools/record"

ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
Expand Down
5 changes: 3 additions & 2 deletions internal/controller/appwrapper/appwrapper_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ package appwrapper
import (
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/resource"
Expand All @@ -33,6 +31,9 @@ import (
awv1beta2 "github.com/project-codeflare/appwrapper/api/v1beta2"
"github.com/project-codeflare/appwrapper/pkg/config"
"github.com/project-codeflare/appwrapper/pkg/utils"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

var _ = Describe("AppWrapper Controller", func() {
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/appwrapper/fixtures_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import (
"math/rand"
"time"

. "github.com/onsi/gomega"

v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -33,6 +31,8 @@ import (
"sigs.k8s.io/yaml"

awv1beta2 "github.com/project-codeflare/appwrapper/api/v1beta2"

. "github.com/onsi/gomega"
)

const charset = "abcdefghijklmnopqrstuvwxyz0123456789"
Expand Down
1 change: 0 additions & 1 deletion internal/controller/appwrapper/node_health_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/util/sets"

ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/handler"
Expand Down
16 changes: 9 additions & 7 deletions internal/controller/appwrapper/node_health_monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ limitations under the License.
package appwrapper

import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/project-codeflare/appwrapper/pkg/config"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

"github.com/project-codeflare/appwrapper/pkg/config"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

var _ = Describe("NodeMonitor Controller", func() {
Expand Down Expand Up @@ -74,7 +76,7 @@ var _ = Describe("NodeMonitor Controller", func() {
Expect(err).NotTo(HaveOccurred())

By("Healthy cluster has no unhealthy nodes")
Expect(len(noExecuteNodes)).Should(Equal(0))
Expect(noExecuteNodes).Should(BeEmpty())

By("A node labeled EVICT is detected as unhealthy")
node := getNode(node1Name.Name)
Expand All @@ -84,7 +86,7 @@ var _ = Describe("NodeMonitor Controller", func() {
Expect(err).NotTo(HaveOccurred())
_, err = nodeMonitor.Reconcile(ctx, reconcile.Request{NamespacedName: node2Name})
Expect(err).NotTo(HaveOccurred())
Expect(len(noExecuteNodes)).Should(Equal(1))
Expect(noExecuteNodes).Should(HaveLen(1))
Expect(noExecuteNodes).Should(HaveKey(node1Name.Name))
Expect(noExecuteNodes[node1Name.Name]).Should(HaveKey("nvidia.com/gpu"))

Expand All @@ -93,7 +95,7 @@ var _ = Describe("NodeMonitor Controller", func() {
Expect(err).NotTo(HaveOccurred())
_, err = nodeMonitor.Reconcile(ctx, reconcile.Request{NamespacedName: node2Name})
Expect(err).NotTo(HaveOccurred())
Expect(len(noExecuteNodes)).Should(Equal(1))
Expect(noExecuteNodes).Should(HaveLen(1))
Expect(noExecuteNodes).Should(HaveKey(node1Name.Name))
Expect(noExecuteNodes[node1Name.Name]).Should(HaveKey("nvidia.com/gpu"))

Expand All @@ -102,7 +104,7 @@ var _ = Describe("NodeMonitor Controller", func() {
Expect(k8sClient.Update(ctx, node)).Should(Succeed())
_, err = nodeMonitor.Reconcile(ctx, reconcile.Request{NamespacedName: node1Name})
Expect(err).NotTo(HaveOccurred())
Expect(len(noExecuteNodes)).Should(Equal(0))
Expect(noExecuteNodes).Should(BeEmpty())

deleteNode(node1Name.Name)
deleteNode(node2Name.Name)
Expand Down
7 changes: 4 additions & 3 deletions internal/controller/appwrapper/resource_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ import (
"fmt"
"time"

awv1beta2 "github.com/project-codeflare/appwrapper/api/v1beta2"
utilmaps "github.com/project-codeflare/appwrapper/internal/util"
"github.com/project-codeflare/appwrapper/pkg/utils"
v1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
Expand All @@ -35,6 +32,10 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/log"

awv1beta2 "github.com/project-codeflare/appwrapper/api/v1beta2"
utilmaps "github.com/project-codeflare/appwrapper/internal/util"
"github.com/project-codeflare/appwrapper/pkg/utils"
)

func parseComponent(raw []byte, expectedNamespace string) (*unstructured.Unstructured, error) {
Expand Down
8 changes: 3 additions & 5 deletions internal/controller/appwrapper/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ import (
"runtime"
"testing"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

//+kubebuilder:scaffold:imports

admissionv1 "k8s.io/api/admission/v1"
rbacv1 "k8s.io/api/rbac/v1"
apimachineryruntime "k8s.io/apimachinery/pkg/runtime"
Expand All @@ -39,6 +34,9 @@ import (
"sigs.k8s.io/controller-runtime/pkg/log/zap"

awv1beta2 "github.com/project-codeflare/appwrapper/api/v1beta2"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

// These tests use Ginkgo (BDD-style Go testing framework). Refer to
Expand Down
7 changes: 4 additions & 3 deletions internal/webhook/appwrapper_fixtures_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ import (
"math/rand"
"time"

. "github.com/onsi/gomega"

awv1beta2 "github.com/project-codeflare/appwrapper/api/v1beta2"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/utils/ptr"
"sigs.k8s.io/yaml"

awv1beta2 "github.com/project-codeflare/appwrapper/api/v1beta2"

. "github.com/onsi/gomega"
)

const charset = "abcdefghijklmnopqrstuvwxyz0123456789"
Expand Down
5 changes: 3 additions & 2 deletions internal/webhook/appwrapper_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ package webhook
import (
"encoding/json"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/utils/ptr"

awv1beta2 "github.com/project-codeflare/appwrapper/api/v1beta2"
utilmaps "github.com/project-codeflare/appwrapper/internal/util"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

var _ = Describe("AppWrapper Webhook Tests", func() {
Expand Down
8 changes: 3 additions & 5 deletions internal/webhook/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ import (
"testing"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

//+kubebuilder:scaffold:imports

admissionv1 "k8s.io/api/admission/v1"
rbacv1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -47,6 +42,9 @@ import (

awv1beta2 "github.com/project-codeflare/appwrapper/api/v1beta2"
"github.com/project-codeflare/appwrapper/pkg/config"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

// These tests use Ginkgo (BDD-style Go testing framework). Refer to
Expand Down
3 changes: 1 addition & 2 deletions pkg/controller/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ import (
"fmt"
"net/http"

cert "github.com/open-policy-agent/cert-controller/pkg/rotator"
"k8s.io/apimachinery/pkg/types"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/healthz"

cert "github.com/open-policy-agent/cert-controller/pkg/rotator"

"github.com/project-codeflare/appwrapper/internal/controller/appwrapper"
"github.com/project-codeflare/appwrapper/internal/webhook"
"github.com/project-codeflare/appwrapper/pkg/config"
Expand Down
1 change: 0 additions & 1 deletion pkg/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package logger

import (
"github.com/go-logr/logr"

"k8s.io/apimachinery/pkg/api/errors"
)

Expand Down
11 changes: 5 additions & 6 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@ import (
"strconv"
"strings"

// Import the crypto sha256 algorithm for the docker image parser to work
_ "crypto/sha256"
// Import the crypto/sha512 algorithm for the docker image parser to work with 384 and 512 sha hashes
_ "crypto/sha512"

dockerref "github.com/distribution/reference"

kftraining "github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v1"
batchv1 "k8s.io/api/batch/v1"
v1 "k8s.io/api/core/v1"
Expand All @@ -39,6 +33,11 @@ import (
jobsetapi "sigs.k8s.io/jobset/api/jobset/v1alpha2"

awv1beta2 "github.com/project-codeflare/appwrapper/api/v1beta2"

// Import the crypto sha256 algorithm for the docker image parser to work
_ "crypto/sha256"
// Import the crypto/sha512 algorithm for the docker image parser to work with 384 and 512 sha hashes
_ "crypto/sha512"
)

const templateString = "template"
Expand Down
5 changes: 3 additions & 2 deletions test/e2e/appwrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import (
"fmt"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand All @@ -32,6 +30,9 @@ import (
"k8s.io/utils/ptr"

awv1beta2 "github.com/project-codeflare/appwrapper/api/v1beta2"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

var _ = Describe("AppWrapper E2E Test", func() {
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import (
"context"
"testing"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

var ctx context.Context
Expand Down
Loading
Loading