From fa4f12a30c8179dbf44658d57bc46b420928f215 Mon Sep 17 00:00:00 2001 From: chaosi-zju Date: Wed, 22 Jan 2025 19:12:52 +0800 Subject: [PATCH] format code about goimports and gci Signed-off-by: chaosi-zju --- .github/workflows/ci.yml | 2 + .golangci.yml | 108 ++++++++++++++++++ cmd/api/app/api.go | 54 ++++----- cmd/api/app/options/options.go | 3 +- cmd/api/app/router/middleware.go | 6 +- cmd/api/app/router/setup.go | 1 + cmd/api/app/routes/auth/handler.go | 3 +- cmd/api/app/routes/auth/login.go | 3 +- cmd/api/app/routes/auth/me.go | 4 +- cmd/api/app/routes/cluster/accesscluster.go | 3 +- cmd/api/app/routes/cluster/handler.go | 14 ++- .../routes/clusteroverridepolicy/handler.go | 12 +- .../clusterpropagationpolicy/handler.go | 12 +- cmd/api/app/routes/config/handler.go | 3 +- cmd/api/app/routes/configmap/handler.go | 1 + cmd/api/app/routes/cronjob/handler.go | 1 + cmd/api/app/routes/daemonset/handler.go | 1 + cmd/api/app/routes/deployment/handler.go | 10 +- cmd/api/app/routes/ingress/handler.go | 1 + cmd/api/app/routes/job/handler.go | 1 + .../app/routes/member/deployment/handler.go | 1 + .../app/routes/member/namespace/handler.go | 1 + cmd/api/app/routes/member/node/handler.go | 1 + cmd/api/app/routes/member/pod/handler.go | 1 + cmd/api/app/routes/namespace/handler.go | 1 + cmd/api/app/routes/overridepolicy/handler.go | 12 +- cmd/api/app/routes/overview/handler.go | 1 + cmd/api/app/routes/overview/misc.go | 16 +-- .../app/routes/propagationpolicy/handler.go | 12 +- cmd/api/app/routes/secret/handler.go | 1 + cmd/api/app/routes/service/handler.go | 1 + cmd/api/app/routes/statefulset/handler.go | 1 + cmd/api/app/routes/unstructured/handler.go | 10 +- cmd/api/app/types/common/request.go | 6 +- cmd/api/app/types/common/response.go | 3 +- cmd/api/main.go | 6 +- cmd/metrics-scraper/app/metricsscraper.go | 18 +-- cmd/metrics-scraper/app/options/options.go | 3 +- cmd/metrics-scraper/app/router/setup.go | 1 + .../app/routes/metrics/handler.go | 6 +- .../app/routes/metrics/handlerqueries.go | 27 +++-- cmd/metrics-scraper/app/scrape/job.go | 14 +-- cmd/metrics-scraper/app/scrape/other.go | 8 +- cmd/metrics-scraper/app/scrape/scrape.go | 6 +- cmd/metrics-scraper/main.go | 6 +- cmd/web/app/options/options.go | 3 +- cmd/web/app/web.go | 20 ++-- cmd/web/main.go | 6 +- hack/verify-staticcheck.sh | 43 +++++++ pkg/client/auth.go | 5 +- pkg/client/client.go | 3 +- pkg/client/verber.go | 5 +- pkg/common/errors/localizer_test.go | 3 +- pkg/config/config.go | 3 +- pkg/resource/cluster/cluster.go | 10 +- pkg/resource/cluster/common.go | 3 +- pkg/resource/cluster/detail.go | 3 +- pkg/resource/clusteroverridepolicy/common.go | 3 +- pkg/resource/clusteroverridepolicy/detail.go | 4 +- pkg/resource/clusteroverridepolicy/list.go | 6 +- .../clusterpropagationpolicy/common.go | 3 +- .../clusterpropagationpolicy/detail.go | 4 +- pkg/resource/clusterpropagationpolicy/list.go | 6 +- pkg/resource/common/event.go | 3 +- pkg/resource/common/resourcechannels.go | 4 +- pkg/resource/configmap/common.go | 3 +- pkg/resource/configmap/detail_test.go | 3 +- pkg/resource/configmap/list.go | 9 +- pkg/resource/configmap/list_test.go | 5 +- pkg/resource/cronjob/common.go | 3 +- pkg/resource/cronjob/events.go | 3 +- pkg/resource/cronjob/jobs.go | 11 +- pkg/resource/cronjob/list.go | 9 +- pkg/resource/daemonset/common.go | 7 +- pkg/resource/daemonset/detail.go | 3 +- pkg/resource/daemonset/list.go | 7 +- pkg/resource/deployment/common.go | 5 +- pkg/resource/deployment/detail.go | 8 +- pkg/resource/deployment/list.go | 10 +- pkg/resource/endpoint/endpoint.go | 5 +- pkg/resource/endpoint/list.go | 3 +- pkg/resource/event/common.go | 12 +- pkg/resource/event/event.go | 6 +- pkg/resource/ingress/common.go | 3 +- pkg/resource/ingress/filter.go | 3 +- pkg/resource/ingress/list.go | 6 +- pkg/resource/job/common.go | 5 +- pkg/resource/job/detail.go | 5 +- pkg/resource/job/events.go | 3 +- pkg/resource/job/list.go | 11 +- pkg/resource/job/pods.go | 29 +---- pkg/resource/namespace/common.go | 6 +- pkg/resource/namespace/list.go | 8 +- pkg/resource/node/common.go | 3 +- pkg/resource/node/list.go | 9 +- pkg/resource/overridepolicy/common.go | 3 +- pkg/resource/overridepolicy/detail.go | 4 +- pkg/resource/overridepolicy/list.go | 10 +- pkg/resource/pod/common.go | 3 +- pkg/resource/pod/list.go | 7 +- pkg/resource/propagationpolicy/common.go | 3 +- pkg/resource/propagationpolicy/detail.go | 4 +- pkg/resource/propagationpolicy/list.go | 14 ++- pkg/resource/secret/common.go | 3 +- pkg/resource/secret/list.go | 11 +- pkg/resource/service/common.go | 3 +- pkg/resource/service/detail.go | 8 +- pkg/resource/service/events.go | 7 +- pkg/resource/service/list.go | 8 +- pkg/resource/statefulset/common.go | 5 +- pkg/resource/statefulset/detail.go | 8 +- pkg/resource/statefulset/list.go | 10 +- pkg/resource/statefulset/pods.go | 4 +- 113 files changed, 569 insertions(+), 295 deletions(-) create mode 100644 .golangci.yml create mode 100755 hack/verify-staticcheck.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ae7311af..861d3f97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,6 +29,8 @@ jobs: go-version-file: go.mod - name: verify license run: hack/verify-license.sh + - name: lint + run: hack/verify-staticcheck.sh build-frontend: runs-on: ubuntu-22.04 steps: diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 00000000..f321129a --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,108 @@ +# This files contains all configuration options for analysis running. +# More details please refer to: https://golangci-lint.run/usage/configuration/ + +run: + # timeout for analysis, e.g. 30s, 5m, default is 1m + timeout: 10m + + # One of 'readonly' and 'vendor'. + # - readonly: the go command is disallowed from the implicit automatic updating of go.mod described above. + # Instead, it fails when any changes to go.mod are needed. This setting is most useful to check + # that go.mod does not need updates, such as in a continuous integration and testing system. + # - vendor: the go command assumes that the vendor directory holds the correct copies of dependencies and ignores + # the dependency descriptions in go.mod. + modules-download-mode: readonly +linters: + enable: + # linters maintained by golang.org + - gofmt + - goimports + - govet + # linters default enabled by golangci-lint . + - errcheck + - gosimple + - ineffassign + - staticcheck + - typecheck + - unused + # other linters supported by golangci-lint. + - gci + - gocyclo + - gosec + - misspell + - whitespace + - revive + - depguard + +linters-settings: + depguard: + rules: + main: + deny: + - pkg: "io/ioutil" + desc: "replaced by io and os packages since Go 1.16: https://tip.golang.org/doc/go1.16#ioutil" + goimports: + local-prefixes: github.com/karmada-io/dashboard + gocyclo: + # minimal cyclomatic complexity to report + min-complexity: 15 + gci: + sections: + - Standard + - Default + - Prefix(github.com/karmada-io/dashboard) + revive: + rules: + # Disable if-return as it is too strict and not always useful. + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#if-return + - name: if-return + disabled: true + - name: package-comments + - name: superfluous-else + arguments: + - preserveScope + - name: error-strings + - name: error-return + - name: receiver-naming + - name: increment-decrement + - name: range + - name: error-naming + - name: dot-imports + - name: errorf + - name: exported + - name: var-declaration + - name: blank-imports + - name: indent-error-flow + - name: unreachable-code + - name: var-naming + - name: redefines-builtin-id + - name: unused-parameter + - name: context-as-argument + - name: context-keys-type + - name: unexported-return + - name: time-naming + - name: empty-block + +issues: + # The list of ids of default excludes to include or disable. By default it's empty. + include: + # disable excluding of issues about comments from revive + # see https://golangci-lint.run/usage/configuration/#command-line-options for more info + - EXC0012 + - EXC0013 + - EXC0014 + # Which dirs to exclude: issues from them won't be reported. + # Can use regexp here: `generated.*`, regexp is applied on full path, + # including the path prefix if one is set. + # Default dirs are skipped independently of this option's value (see exclude-dirs-use-default). + # "/" will be replaced by current OS file path separator to properly work on Windows. + # Default: [] + exclude-dirs: + - hack/tools/preferredimports # This code is directly lifted from the Kubernetes codebase, skip checking + - (^|/)vendor($|/) + - (^|/)third_party($|/) + - pkg/util/lifted # This code is lifted from other projects(Kubernetes, Kubefed, and so on), skip checking. + # Enables exclude of directories: + # - vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ + # Default: true + exclude-dirs-use-default: false diff --git a/cmd/api/app/api.go b/cmd/api/app/api.go index c629b5c3..3a5ee626 100644 --- a/cmd/api/app/api.go +++ b/cmd/api/app/api.go @@ -19,38 +19,38 @@ package app import ( "context" "fmt" - "github.com/karmada-io/dashboard/cmd/api/app/options" - "github.com/karmada-io/dashboard/cmd/api/app/router" - "github.com/karmada-io/dashboard/pkg/client" - "github.com/karmada-io/dashboard/pkg/config" - "github.com/karmada-io/dashboard/pkg/environment" + "os" + "github.com/karmada-io/karmada/pkg/sharedcli/klogflag" "github.com/spf13/cobra" cliflag "k8s.io/component-base/cli/flag" "k8s.io/klog/v2" - "os" - // Importing route packages forces route registration - _ "github.com/karmada-io/dashboard/cmd/api/app/routes/auth" - _ "github.com/karmada-io/dashboard/cmd/api/app/routes/cluster" - _ "github.com/karmada-io/dashboard/cmd/api/app/routes/clusteroverridepolicy" - _ "github.com/karmada-io/dashboard/cmd/api/app/routes/clusterpropagationpolicy" - _ "github.com/karmada-io/dashboard/cmd/api/app/routes/config" - _ "github.com/karmada-io/dashboard/cmd/api/app/routes/configmap" - _ "github.com/karmada-io/dashboard/cmd/api/app/routes/cronjob" - _ "github.com/karmada-io/dashboard/cmd/api/app/routes/daemonset" - _ "github.com/karmada-io/dashboard/cmd/api/app/routes/deployment" - _ "github.com/karmada-io/dashboard/cmd/api/app/routes/ingress" - _ "github.com/karmada-io/dashboard/cmd/api/app/routes/job" - _ "github.com/karmada-io/dashboard/cmd/api/app/routes/member" - _ "github.com/karmada-io/dashboard/cmd/api/app/routes/namespace" - _ "github.com/karmada-io/dashboard/cmd/api/app/routes/overridepolicy" - _ "github.com/karmada-io/dashboard/cmd/api/app/routes/overview" - _ "github.com/karmada-io/dashboard/cmd/api/app/routes/propagationpolicy" - _ "github.com/karmada-io/dashboard/cmd/api/app/routes/secret" - _ "github.com/karmada-io/dashboard/cmd/api/app/routes/service" - _ "github.com/karmada-io/dashboard/cmd/api/app/routes/statefulset" - _ "github.com/karmada-io/dashboard/cmd/api/app/routes/unstructured" + "github.com/karmada-io/dashboard/cmd/api/app/options" + "github.com/karmada-io/dashboard/cmd/api/app/router" + _ "github.com/karmada-io/dashboard/cmd/api/app/routes/auth" // Importing route packages forces route registration + _ "github.com/karmada-io/dashboard/cmd/api/app/routes/cluster" // Importing route packages forces route registration + _ "github.com/karmada-io/dashboard/cmd/api/app/routes/clusteroverridepolicy" // Importing route packages forces route registration + _ "github.com/karmada-io/dashboard/cmd/api/app/routes/clusterpropagationpolicy" // Importing route packages forces route registration + _ "github.com/karmada-io/dashboard/cmd/api/app/routes/config" // Importing route packages forces route registration + _ "github.com/karmada-io/dashboard/cmd/api/app/routes/configmap" // Importing route packages forces route registration + _ "github.com/karmada-io/dashboard/cmd/api/app/routes/cronjob" // Importing route packages forces route registration + _ "github.com/karmada-io/dashboard/cmd/api/app/routes/daemonset" // Importing route packages forces route registration + _ "github.com/karmada-io/dashboard/cmd/api/app/routes/deployment" // Importing route packages forces route registration + _ "github.com/karmada-io/dashboard/cmd/api/app/routes/ingress" // Importing route packages forces route registration + _ "github.com/karmada-io/dashboard/cmd/api/app/routes/job" // Importing route packages forces route registration + _ "github.com/karmada-io/dashboard/cmd/api/app/routes/member" // Importing route packages forces route registration + _ "github.com/karmada-io/dashboard/cmd/api/app/routes/namespace" // Importing route packages forces route registration + _ "github.com/karmada-io/dashboard/cmd/api/app/routes/overridepolicy" // Importing route packages forces route registration + _ "github.com/karmada-io/dashboard/cmd/api/app/routes/overview" // Importing route packages forces route registration + _ "github.com/karmada-io/dashboard/cmd/api/app/routes/propagationpolicy" // Importing route packages forces route registration + _ "github.com/karmada-io/dashboard/cmd/api/app/routes/secret" // Importing route packages forces route registration + _ "github.com/karmada-io/dashboard/cmd/api/app/routes/service" // Importing route packages forces route registration + _ "github.com/karmada-io/dashboard/cmd/api/app/routes/statefulset" // Importing route packages forces route registration + _ "github.com/karmada-io/dashboard/cmd/api/app/routes/unstructured" // Importing route packages forces route registration + "github.com/karmada-io/dashboard/pkg/client" + "github.com/karmada-io/dashboard/pkg/config" + "github.com/karmada-io/dashboard/pkg/environment" ) // NewApiCommand creates a *cobra.Command object with default parameters diff --git a/cmd/api/app/options/options.go b/cmd/api/app/options/options.go index c552c08a..33c85574 100644 --- a/cmd/api/app/options/options.go +++ b/cmd/api/app/options/options.go @@ -17,8 +17,9 @@ limitations under the License. package options import ( - "github.com/spf13/pflag" "net" + + "github.com/spf13/pflag" ) // Options contains everything necessary to create and run api. diff --git a/cmd/api/app/router/middleware.go b/cmd/api/app/router/middleware.go index 0259601a..68104a8d 100644 --- a/cmd/api/app/router/middleware.go +++ b/cmd/api/app/router/middleware.go @@ -18,11 +18,13 @@ package router import ( "context" + "net/http" + "github.com/gin-gonic/gin" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "github.com/karmada-io/dashboard/cmd/api/app/types/common" "github.com/karmada-io/dashboard/pkg/client" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "net/http" ) func EnsureMemberClusterMiddleware() gin.HandlerFunc { diff --git a/cmd/api/app/router/setup.go b/cmd/api/app/router/setup.go index ee1a6863..5649c848 100644 --- a/cmd/api/app/router/setup.go +++ b/cmd/api/app/router/setup.go @@ -18,6 +18,7 @@ package router import ( "github.com/gin-gonic/gin" + "github.com/karmada-io/dashboard/pkg/environment" ) diff --git a/cmd/api/app/routes/auth/handler.go b/cmd/api/app/routes/auth/handler.go index 4f71a513..3d044393 100644 --- a/cmd/api/app/routes/auth/handler.go +++ b/cmd/api/app/routes/auth/handler.go @@ -18,10 +18,11 @@ package auth import ( "github.com/gin-gonic/gin" + "k8s.io/klog/v2" + "github.com/karmada-io/dashboard/cmd/api/app/router" v1 "github.com/karmada-io/dashboard/cmd/api/app/types/api/v1" "github.com/karmada-io/dashboard/cmd/api/app/types/common" - "k8s.io/klog/v2" ) func handleLogin(c *gin.Context) { diff --git a/cmd/api/app/routes/auth/login.go b/cmd/api/app/routes/auth/login.go index 0510a318..677c2ed5 100644 --- a/cmd/api/app/routes/auth/login.go +++ b/cmd/api/app/routes/auth/login.go @@ -17,10 +17,11 @@ limitations under the License. package auth import ( + "net/http" + v1 "github.com/karmada-io/dashboard/cmd/api/app/types/api/v1" "github.com/karmada-io/dashboard/pkg/client" "github.com/karmada-io/dashboard/pkg/common/errors" - "net/http" ) func login(spec *v1.LoginRequest, request *http.Request) (*v1.LoginResponse, int, error) { diff --git a/cmd/api/app/routes/auth/me.go b/cmd/api/app/routes/auth/me.go index 6351caf1..bbf720c4 100644 --- a/cmd/api/app/routes/auth/me.go +++ b/cmd/api/app/routes/auth/me.go @@ -19,11 +19,13 @@ package auth import ( "bytes" "encoding/json" + "net/http" + "github.com/golang-jwt/jwt/v5" + v1 "github.com/karmada-io/dashboard/cmd/api/app/types/api/v1" "github.com/karmada-io/dashboard/pkg/client" "github.com/karmada-io/dashboard/pkg/common/errors" - "net/http" ) const ( diff --git a/cmd/api/app/routes/cluster/accesscluster.go b/cmd/api/app/routes/cluster/accesscluster.go index c7c89f4c..5add32be 100644 --- a/cmd/api/app/routes/cluster/accesscluster.go +++ b/cmd/api/app/routes/cluster/accesscluster.go @@ -19,6 +19,8 @@ package cluster import ( "context" "fmt" + "time" + clusterv1alpha1 "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1" karmadaclientset "github.com/karmada-io/karmada/pkg/generated/clientset/versioned" cmdutil "github.com/karmada-io/karmada/pkg/karmadactl/util" @@ -32,7 +34,6 @@ import ( "k8s.io/client-go/tools/clientcmd" clientcmdapi "k8s.io/client-go/tools/clientcmd/api" "k8s.io/klog/v2" - "time" ) const ( diff --git a/cmd/api/app/routes/cluster/handler.go b/cmd/api/app/routes/cluster/handler.go index 32b9e77c..dc044966 100644 --- a/cmd/api/app/routes/cluster/handler.go +++ b/cmd/api/app/routes/cluster/handler.go @@ -19,19 +19,21 @@ package cluster import ( "context" "fmt" + "time" + "github.com/gin-gonic/gin" - "github.com/karmada-io/dashboard/cmd/api/app/router" - v1 "github.com/karmada-io/dashboard/cmd/api/app/types/api/v1" - "github.com/karmada-io/dashboard/cmd/api/app/types/common" - "github.com/karmada-io/dashboard/pkg/client" - "github.com/karmada-io/dashboard/pkg/resource/cluster" "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1" 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/util/wait" "k8s.io/klog/v2" - "time" + + "github.com/karmada-io/dashboard/cmd/api/app/router" + v1 "github.com/karmada-io/dashboard/cmd/api/app/types/api/v1" + "github.com/karmada-io/dashboard/cmd/api/app/types/common" + "github.com/karmada-io/dashboard/pkg/client" + "github.com/karmada-io/dashboard/pkg/resource/cluster" ) func handleGetClusterList(c *gin.Context) { diff --git a/cmd/api/app/routes/clusteroverridepolicy/handler.go b/cmd/api/app/routes/clusteroverridepolicy/handler.go index 461fa456..e46d0fde 100644 --- a/cmd/api/app/routes/clusteroverridepolicy/handler.go +++ b/cmd/api/app/routes/clusteroverridepolicy/handler.go @@ -18,18 +18,20 @@ package propagationpolicy import ( "context" + "github.com/gin-gonic/gin" + "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/util/retry" + "k8s.io/klog/v2" + "sigs.k8s.io/yaml" + "github.com/karmada-io/dashboard/cmd/api/app/router" v1 "github.com/karmada-io/dashboard/cmd/api/app/types/api/v1" "github.com/karmada-io/dashboard/cmd/api/app/types/common" "github.com/karmada-io/dashboard/pkg/client" "github.com/karmada-io/dashboard/pkg/common/errors" "github.com/karmada-io/dashboard/pkg/resource/clusteroverridepolicy" - "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/client-go/util/retry" - "k8s.io/klog/v2" - "sigs.k8s.io/yaml" ) func handleGetClusterOverridePolicyList(c *gin.Context) { diff --git a/cmd/api/app/routes/clusterpropagationpolicy/handler.go b/cmd/api/app/routes/clusterpropagationpolicy/handler.go index 8650566f..fd4ccfbc 100644 --- a/cmd/api/app/routes/clusterpropagationpolicy/handler.go +++ b/cmd/api/app/routes/clusterpropagationpolicy/handler.go @@ -18,18 +18,20 @@ package propagationpolicy import ( "context" + "github.com/gin-gonic/gin" + "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/util/retry" + "k8s.io/klog/v2" + "sigs.k8s.io/yaml" + "github.com/karmada-io/dashboard/cmd/api/app/router" v1 "github.com/karmada-io/dashboard/cmd/api/app/types/api/v1" "github.com/karmada-io/dashboard/cmd/api/app/types/common" "github.com/karmada-io/dashboard/pkg/client" "github.com/karmada-io/dashboard/pkg/common/errors" "github.com/karmada-io/dashboard/pkg/resource/clusterpropagationpolicy" - "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/client-go/util/retry" - "k8s.io/klog/v2" - "sigs.k8s.io/yaml" ) func handleGetClusterPropagationPolicyList(c *gin.Context) { diff --git a/cmd/api/app/routes/config/handler.go b/cmd/api/app/routes/config/handler.go index ac8e9c9c..3948fea4 100644 --- a/cmd/api/app/routes/config/handler.go +++ b/cmd/api/app/routes/config/handler.go @@ -18,12 +18,13 @@ package config import ( "github.com/gin-gonic/gin" + "k8s.io/klog/v2" + "github.com/karmada-io/dashboard/cmd/api/app/router" v1 "github.com/karmada-io/dashboard/cmd/api/app/types/api/v1" "github.com/karmada-io/dashboard/cmd/api/app/types/common" "github.com/karmada-io/dashboard/pkg/client" "github.com/karmada-io/dashboard/pkg/config" - "k8s.io/klog/v2" ) func GetDashboardConfig(c *gin.Context) { diff --git a/cmd/api/app/routes/configmap/handler.go b/cmd/api/app/routes/configmap/handler.go index dbe092c4..05513607 100644 --- a/cmd/api/app/routes/configmap/handler.go +++ b/cmd/api/app/routes/configmap/handler.go @@ -18,6 +18,7 @@ package service import ( "github.com/gin-gonic/gin" + "github.com/karmada-io/dashboard/cmd/api/app/router" "github.com/karmada-io/dashboard/cmd/api/app/types/common" "github.com/karmada-io/dashboard/pkg/client" diff --git a/cmd/api/app/routes/cronjob/handler.go b/cmd/api/app/routes/cronjob/handler.go index e03f5a7e..573f0027 100644 --- a/cmd/api/app/routes/cronjob/handler.go +++ b/cmd/api/app/routes/cronjob/handler.go @@ -18,6 +18,7 @@ package deployment import ( "github.com/gin-gonic/gin" + "github.com/karmada-io/dashboard/cmd/api/app/router" "github.com/karmada-io/dashboard/cmd/api/app/types/common" "github.com/karmada-io/dashboard/pkg/client" diff --git a/cmd/api/app/routes/daemonset/handler.go b/cmd/api/app/routes/daemonset/handler.go index 49abe12c..3fe2fb3a 100644 --- a/cmd/api/app/routes/daemonset/handler.go +++ b/cmd/api/app/routes/daemonset/handler.go @@ -18,6 +18,7 @@ package deployment import ( "github.com/gin-gonic/gin" + "github.com/karmada-io/dashboard/cmd/api/app/router" "github.com/karmada-io/dashboard/cmd/api/app/types/common" "github.com/karmada-io/dashboard/pkg/client" diff --git a/cmd/api/app/routes/deployment/handler.go b/cmd/api/app/routes/deployment/handler.go index bc2c4cfa..10cef5dc 100644 --- a/cmd/api/app/routes/deployment/handler.go +++ b/cmd/api/app/routes/deployment/handler.go @@ -18,17 +18,19 @@ package deployment import ( "context" + "github.com/gin-gonic/gin" + appsv1 "k8s.io/api/apps/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/kubernetes" + "sigs.k8s.io/yaml" + "github.com/karmada-io/dashboard/cmd/api/app/router" v1 "github.com/karmada-io/dashboard/cmd/api/app/types/api/v1" "github.com/karmada-io/dashboard/cmd/api/app/types/common" "github.com/karmada-io/dashboard/pkg/client" "github.com/karmada-io/dashboard/pkg/resource/deployment" "github.com/karmada-io/dashboard/pkg/resource/event" - appsv1 "k8s.io/api/apps/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/client-go/kubernetes" - "sigs.k8s.io/yaml" ) func handlerCreateDeployment(c *gin.Context) { diff --git a/cmd/api/app/routes/ingress/handler.go b/cmd/api/app/routes/ingress/handler.go index 43f319a8..522c91a6 100644 --- a/cmd/api/app/routes/ingress/handler.go +++ b/cmd/api/app/routes/ingress/handler.go @@ -18,6 +18,7 @@ package ingress import ( "github.com/gin-gonic/gin" + "github.com/karmada-io/dashboard/cmd/api/app/router" "github.com/karmada-io/dashboard/cmd/api/app/types/common" "github.com/karmada-io/dashboard/pkg/client" diff --git a/cmd/api/app/routes/job/handler.go b/cmd/api/app/routes/job/handler.go index dea53839..428edc3d 100644 --- a/cmd/api/app/routes/job/handler.go +++ b/cmd/api/app/routes/job/handler.go @@ -18,6 +18,7 @@ package deployment import ( "github.com/gin-gonic/gin" + "github.com/karmada-io/dashboard/cmd/api/app/router" "github.com/karmada-io/dashboard/cmd/api/app/types/common" "github.com/karmada-io/dashboard/pkg/client" diff --git a/cmd/api/app/routes/member/deployment/handler.go b/cmd/api/app/routes/member/deployment/handler.go index 2de6c315..a70faaaf 100644 --- a/cmd/api/app/routes/member/deployment/handler.go +++ b/cmd/api/app/routes/member/deployment/handler.go @@ -18,6 +18,7 @@ package deployment import ( "github.com/gin-gonic/gin" + "github.com/karmada-io/dashboard/cmd/api/app/router" "github.com/karmada-io/dashboard/cmd/api/app/types/common" "github.com/karmada-io/dashboard/pkg/client" diff --git a/cmd/api/app/routes/member/namespace/handler.go b/cmd/api/app/routes/member/namespace/handler.go index 5f4d22bf..29ec3f7a 100644 --- a/cmd/api/app/routes/member/namespace/handler.go +++ b/cmd/api/app/routes/member/namespace/handler.go @@ -18,6 +18,7 @@ package namespace import ( "github.com/gin-gonic/gin" + "github.com/karmada-io/dashboard/cmd/api/app/router" "github.com/karmada-io/dashboard/cmd/api/app/types/common" "github.com/karmada-io/dashboard/pkg/client" diff --git a/cmd/api/app/routes/member/node/handler.go b/cmd/api/app/routes/member/node/handler.go index 8a4c738a..7a8c5af0 100644 --- a/cmd/api/app/routes/member/node/handler.go +++ b/cmd/api/app/routes/member/node/handler.go @@ -18,6 +18,7 @@ package node import ( "github.com/gin-gonic/gin" + "github.com/karmada-io/dashboard/cmd/api/app/router" "github.com/karmada-io/dashboard/cmd/api/app/types/common" "github.com/karmada-io/dashboard/pkg/client" diff --git a/cmd/api/app/routes/member/pod/handler.go b/cmd/api/app/routes/member/pod/handler.go index 9c3acd67..f6d23dbc 100644 --- a/cmd/api/app/routes/member/pod/handler.go +++ b/cmd/api/app/routes/member/pod/handler.go @@ -18,6 +18,7 @@ package pod import ( "github.com/gin-gonic/gin" + "github.com/karmada-io/dashboard/cmd/api/app/router" "github.com/karmada-io/dashboard/cmd/api/app/types/common" "github.com/karmada-io/dashboard/pkg/client" diff --git a/cmd/api/app/routes/namespace/handler.go b/cmd/api/app/routes/namespace/handler.go index d430da91..65d03a4e 100644 --- a/cmd/api/app/routes/namespace/handler.go +++ b/cmd/api/app/routes/namespace/handler.go @@ -18,6 +18,7 @@ package namespace import ( "github.com/gin-gonic/gin" + "github.com/karmada-io/dashboard/cmd/api/app/router" v1 "github.com/karmada-io/dashboard/cmd/api/app/types/api/v1" "github.com/karmada-io/dashboard/cmd/api/app/types/common" diff --git a/cmd/api/app/routes/overridepolicy/handler.go b/cmd/api/app/routes/overridepolicy/handler.go index b4d2e61e..d1136001 100644 --- a/cmd/api/app/routes/overridepolicy/handler.go +++ b/cmd/api/app/routes/overridepolicy/handler.go @@ -18,18 +18,20 @@ package overridepolicy import ( "context" + "github.com/gin-gonic/gin" + "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/util/retry" + "k8s.io/klog/v2" + "sigs.k8s.io/yaml" + "github.com/karmada-io/dashboard/cmd/api/app/router" v1 "github.com/karmada-io/dashboard/cmd/api/app/types/api/v1" "github.com/karmada-io/dashboard/cmd/api/app/types/common" "github.com/karmada-io/dashboard/pkg/client" "github.com/karmada-io/dashboard/pkg/common/errors" "github.com/karmada-io/dashboard/pkg/resource/overridepolicy" - "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/client-go/util/retry" - "k8s.io/klog/v2" - "sigs.k8s.io/yaml" ) func handleGetOverridePolicyList(c *gin.Context) { diff --git a/cmd/api/app/routes/overview/handler.go b/cmd/api/app/routes/overview/handler.go index 7ef5b496..15cee65a 100644 --- a/cmd/api/app/routes/overview/handler.go +++ b/cmd/api/app/routes/overview/handler.go @@ -18,6 +18,7 @@ package overview import ( "github.com/gin-gonic/gin" + "github.com/karmada-io/dashboard/cmd/api/app/router" v1 "github.com/karmada-io/dashboard/cmd/api/app/types/api/v1" "github.com/karmada-io/dashboard/cmd/api/app/types/common" diff --git a/cmd/api/app/routes/overview/misc.go b/cmd/api/app/routes/overview/misc.go index 19b1fdc4..5032cb25 100644 --- a/cmd/api/app/routes/overview/misc.go +++ b/cmd/api/app/routes/overview/misc.go @@ -20,19 +20,21 @@ import ( "bytes" "context" "errors" - v1 "github.com/karmada-io/dashboard/cmd/api/app/types/api/v1" - "github.com/karmada-io/dashboard/pkg/client" - "github.com/karmada-io/dashboard/pkg/dataselect" - "github.com/karmada-io/dashboard/pkg/resource/cluster" + "math/rand" + "strings" + "time" + "github.com/karmada-io/karmada/pkg/version" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/tools/remotecommand" - "math/rand" - "strings" - "time" + + v1 "github.com/karmada-io/dashboard/cmd/api/app/types/api/v1" + "github.com/karmada-io/dashboard/pkg/client" + "github.com/karmada-io/dashboard/pkg/dataselect" + "github.com/karmada-io/dashboard/pkg/resource/cluster" ) const ( diff --git a/cmd/api/app/routes/propagationpolicy/handler.go b/cmd/api/app/routes/propagationpolicy/handler.go index ef88cf33..2bb2e893 100644 --- a/cmd/api/app/routes/propagationpolicy/handler.go +++ b/cmd/api/app/routes/propagationpolicy/handler.go @@ -18,18 +18,20 @@ package propagationpolicy import ( "context" + "github.com/gin-gonic/gin" + "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/util/retry" + "k8s.io/klog/v2" + "sigs.k8s.io/yaml" + "github.com/karmada-io/dashboard/cmd/api/app/router" v1 "github.com/karmada-io/dashboard/cmd/api/app/types/api/v1" "github.com/karmada-io/dashboard/cmd/api/app/types/common" "github.com/karmada-io/dashboard/pkg/client" "github.com/karmada-io/dashboard/pkg/common/errors" "github.com/karmada-io/dashboard/pkg/resource/propagationpolicy" - "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/client-go/util/retry" - "k8s.io/klog/v2" - "sigs.k8s.io/yaml" ) func handleGetPropagationPolicyList(c *gin.Context) { diff --git a/cmd/api/app/routes/secret/handler.go b/cmd/api/app/routes/secret/handler.go index 065500e2..67c87389 100644 --- a/cmd/api/app/routes/secret/handler.go +++ b/cmd/api/app/routes/secret/handler.go @@ -18,6 +18,7 @@ package service import ( "github.com/gin-gonic/gin" + "github.com/karmada-io/dashboard/cmd/api/app/router" "github.com/karmada-io/dashboard/cmd/api/app/types/common" "github.com/karmada-io/dashboard/pkg/client" diff --git a/cmd/api/app/routes/service/handler.go b/cmd/api/app/routes/service/handler.go index b80e8f2f..efa9490a 100644 --- a/cmd/api/app/routes/service/handler.go +++ b/cmd/api/app/routes/service/handler.go @@ -18,6 +18,7 @@ package service import ( "github.com/gin-gonic/gin" + "github.com/karmada-io/dashboard/cmd/api/app/router" "github.com/karmada-io/dashboard/cmd/api/app/types/common" "github.com/karmada-io/dashboard/pkg/client" diff --git a/cmd/api/app/routes/statefulset/handler.go b/cmd/api/app/routes/statefulset/handler.go index 31f2dcff..db7dd84f 100644 --- a/cmd/api/app/routes/statefulset/handler.go +++ b/cmd/api/app/routes/statefulset/handler.go @@ -18,6 +18,7 @@ package deployment import ( "github.com/gin-gonic/gin" + "github.com/karmada-io/dashboard/cmd/api/app/router" "github.com/karmada-io/dashboard/cmd/api/app/types/common" "github.com/karmada-io/dashboard/pkg/client" diff --git a/cmd/api/app/routes/unstructured/handler.go b/cmd/api/app/routes/unstructured/handler.go index 88b5186f..422c8ac3 100644 --- a/cmd/api/app/routes/unstructured/handler.go +++ b/cmd/api/app/routes/unstructured/handler.go @@ -17,15 +17,17 @@ limitations under the License. package unstructured import ( - "github.com/gin-gonic/gin" - "github.com/karmada-io/dashboard/cmd/api/app/router" - "github.com/karmada-io/dashboard/cmd/api/app/types/common" - "github.com/karmada-io/dashboard/pkg/client" "io" + + "github.com/gin-gonic/gin" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/client-go/util/retry" "k8s.io/klog/v2" + + "github.com/karmada-io/dashboard/cmd/api/app/router" + "github.com/karmada-io/dashboard/cmd/api/app/types/common" + "github.com/karmada-io/dashboard/pkg/client" ) func handleDeleteResource(c *gin.Context) { diff --git a/cmd/api/app/types/common/request.go b/cmd/api/app/types/common/request.go index 921babdb..5c61e3af 100644 --- a/cmd/api/app/types/common/request.go +++ b/cmd/api/app/types/common/request.go @@ -17,11 +17,13 @@ limitations under the License. package common import ( + "strconv" + "strings" + "github.com/gin-gonic/gin" + "github.com/karmada-io/dashboard/pkg/dataselect" "github.com/karmada-io/dashboard/pkg/resource/common" - "strconv" - "strings" ) func parsePaginationPathParameter(request *gin.Context) *dataselect.PaginationQuery { diff --git a/cmd/api/app/types/common/response.go b/cmd/api/app/types/common/response.go index 28616a45..cbb285fa 100644 --- a/cmd/api/app/types/common/response.go +++ b/cmd/api/app/types/common/response.go @@ -17,8 +17,9 @@ limitations under the License. package common import ( - "github.com/gin-gonic/gin" "net/http" + + "github.com/gin-gonic/gin" ) type BaseResponse struct { diff --git a/cmd/api/main.go b/cmd/api/main.go index b0ed1db7..1693196a 100644 --- a/cmd/api/main.go +++ b/cmd/api/main.go @@ -18,9 +18,11 @@ package main import ( "context" - "github.com/karmada-io/dashboard/cmd/api/app" - "k8s.io/component-base/cli" "os" + + "k8s.io/component-base/cli" + + "github.com/karmada-io/dashboard/cmd/api/app" ) func main() { diff --git a/cmd/metrics-scraper/app/metricsscraper.go b/cmd/metrics-scraper/app/metricsscraper.go index ba3f1739..1a7e76a5 100644 --- a/cmd/metrics-scraper/app/metricsscraper.go +++ b/cmd/metrics-scraper/app/metricsscraper.go @@ -19,19 +19,20 @@ package app import ( "context" "fmt" + "os" + + "github.com/karmada-io/karmada/pkg/sharedcli/klogflag" "github.com/spf13/cobra" cliflag "k8s.io/component-base/cli/flag" "k8s.io/klog/v2" - "os" + "github.com/karmada-io/dashboard/cmd/metrics-scraper/app/options" + "github.com/karmada-io/dashboard/cmd/metrics-scraper/app/router" + "github.com/karmada-io/dashboard/cmd/metrics-scraper/app/routes/metrics" + "github.com/karmada-io/dashboard/cmd/metrics-scraper/app/scrape" "github.com/karmada-io/dashboard/pkg/client" "github.com/karmada-io/dashboard/pkg/config" "github.com/karmada-io/dashboard/pkg/environment" - "github.com/karmada-io/karmada/pkg/sharedcli/klogflag" - "github.com/karmada-io/dashboard/cmd/metrics-scraper/app/router" - "github.com/karmada-io/dashboard/cmd/metrics-scraper/app/scrape" - "github.com/karmada-io/dashboard/cmd/metrics-scraper/app/routes/metrics" - "github.com/karmada-io/dashboard/cmd/metrics-scraper/app/options" ) // NewMetricsScraperCommand creates a *cobra.Command object with default parameters @@ -88,7 +89,7 @@ func run(ctx context.Context, opts *options.Options) error { ensureAPIServerConnectionOrDie() serve(opts) go scrape.InitDatabase() - + config.InitDashboardConfig(client.InClusterClient(), ctx.Done()) select { case <-ctx.Done(): @@ -105,7 +106,6 @@ func serve(opts *options.Options) { }() } - func ensureAPIServerConnectionOrDie() { versionInfo, err := client.InClusterClient().Discovery().ServerVersion() if err != nil { @@ -125,7 +125,7 @@ func ensureAPIServerConnectionOrDie() { } func init() { - r := router.V1() + r := router.V1() r.GET("/metrics", metrics.GetMetrics) r.GET("/metrics/:app_name", metrics.GetMetrics) r.GET("/metrics/:app_name/:pod_name", metrics.QueryMetrics) diff --git a/cmd/metrics-scraper/app/options/options.go b/cmd/metrics-scraper/app/options/options.go index c552c08a..33c85574 100644 --- a/cmd/metrics-scraper/app/options/options.go +++ b/cmd/metrics-scraper/app/options/options.go @@ -17,8 +17,9 @@ limitations under the License. package options import ( - "github.com/spf13/pflag" "net" + + "github.com/spf13/pflag" ) // Options contains everything necessary to create and run api. diff --git a/cmd/metrics-scraper/app/router/setup.go b/cmd/metrics-scraper/app/router/setup.go index 06dcec2c..7e2f2012 100644 --- a/cmd/metrics-scraper/app/router/setup.go +++ b/cmd/metrics-scraper/app/router/setup.go @@ -18,6 +18,7 @@ package router import ( "github.com/gin-gonic/gin" + "github.com/karmada-io/dashboard/pkg/environment" ) diff --git a/cmd/metrics-scraper/app/routes/metrics/handler.go b/cmd/metrics-scraper/app/routes/metrics/handler.go index 3d0fb44f..a2195afc 100644 --- a/cmd/metrics-scraper/app/routes/metrics/handler.go +++ b/cmd/metrics-scraper/app/routes/metrics/handler.go @@ -18,10 +18,12 @@ package metrics import ( "net/http" - "github.com/karmada-io/dashboard/cmd/metrics-scraper/app/scrape" + "github.com/gin-gonic/gin" + + "github.com/karmada-io/dashboard/cmd/metrics-scraper/app/scrape" ) - + var requests = make(chan scrape.SaveRequest) func GetMetrics(c *gin.Context) { diff --git a/cmd/metrics-scraper/app/routes/metrics/handlerqueries.go b/cmd/metrics-scraper/app/routes/metrics/handlerqueries.go index e23f1509..a7ecc900 100644 --- a/cmd/metrics-scraper/app/routes/metrics/handlerqueries.go +++ b/cmd/metrics-scraper/app/routes/metrics/handlerqueries.go @@ -17,15 +17,18 @@ limitations under the License. package metrics import ( + "database/sql" + "fmt" "log" "net/http" "strings" - "fmt" "time" - "database/sql" - "github.com/karmada-io/dashboard/cmd/metrics-scraper/app/scrape" + "github.com/gin-gonic/gin" + + "github.com/karmada-io/dashboard/cmd/metrics-scraper/app/scrape" ) + type MetricInfo struct { Help string `json:"help"` Type string `json:"type"` @@ -34,8 +37,8 @@ type MetricInfo struct { func QueryMetrics(c *gin.Context) { appName := c.Param("app_name") podName := c.Param("pod_name") - queryType := c.Query("type") // Use a query parameter to determine the action - metricName := c.Query("mname") // Optional: only needed for details + queryType := c.Query("type") // Use a query parameter to determine the action + metricName := c.Query("mname") // Optional: only needed for details sanitizedAppName := strings.ReplaceAll(appName, "-", "_") sanitizedPodName := strings.ReplaceAll(podName, "-", "_") @@ -77,13 +80,13 @@ func QueryMetrics(c *gin.Context) { metricNames = append(metricNames, metricName) } - c.JSON(http.StatusOK, gin.H{ "metricNames": metricNames}) + c.JSON(http.StatusOK, gin.H{"metricNames": metricNames}) case "details": - if metricName == "" { - c.JSON(http.StatusBadRequest, gin.H{"error": "Metric name required for details"}) - return - } + if metricName == "" { + c.JSON(http.StatusBadRequest, gin.H{"error": "Metric name required for details"}) + return + } query := fmt.Sprintf(` SELECT m.currentTime, @@ -162,11 +165,11 @@ func QueryMetrics(c *gin.Context) { Labels: labels, }) - detailsMap[timeKey] = detail + detailsMap[timeKey] = detail } c.JSON(http.StatusOK, gin.H{"details": detailsMap}) - + case "metricsdetails": // Handle metricsdetails query type db, err := sql.Open("sqlite", strings.ReplaceAll(appName, "-", "_")+".db") diff --git a/cmd/metrics-scraper/app/scrape/job.go b/cmd/metrics-scraper/app/scrape/job.go index a1079071..9a89a934 100644 --- a/cmd/metrics-scraper/app/scrape/job.go +++ b/cmd/metrics-scraper/app/scrape/job.go @@ -20,18 +20,18 @@ import ( "context" "encoding/json" "fmt" + "os" + "path/filepath" + "strings" + "sync" - "github.com/karmada-io/dashboard/cmd/metrics-scraper/app/db" - "github.com/karmada-io/dashboard/pkg/client" "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" kubeclient "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/clientcmd" - "os" - "path/filepath" - "strings" - "sync" + + "github.com/karmada-io/dashboard/cmd/metrics-scraper/app/db" + "github.com/karmada-io/dashboard/pkg/client" ) // Define a struct for save requests diff --git a/cmd/metrics-scraper/app/scrape/other.go b/cmd/metrics-scraper/app/scrape/other.go index 0993f038..14ecc036 100644 --- a/cmd/metrics-scraper/app/scrape/other.go +++ b/cmd/metrics-scraper/app/scrape/other.go @@ -20,13 +20,15 @@ import ( "database/sql" "encoding/json" "fmt" - _ "github.com/glebarez/sqlite" - "github.com/karmada-io/dashboard/cmd/metrics-scraper/app/db" - "github.com/prometheus/common/expfmt" "log" "strings" "sync" "time" + + _ "github.com/glebarez/sqlite" + "github.com/prometheus/common/expfmt" + + "github.com/karmada-io/dashboard/cmd/metrics-scraper/app/db" ) var dbMutex sync.Mutex diff --git a/cmd/metrics-scraper/app/scrape/scrape.go b/cmd/metrics-scraper/app/scrape/scrape.go index 2a80114e..25cb3c23 100644 --- a/cmd/metrics-scraper/app/scrape/scrape.go +++ b/cmd/metrics-scraper/app/scrape/scrape.go @@ -19,14 +19,14 @@ package scrape import ( "context" "database/sql" + "fmt" "log" + "net/http" "sync" "time" - "fmt" - "net/http" - "github.com/gin-gonic/gin" + "github.com/karmada-io/dashboard/cmd/metrics-scraper/app/db" ) diff --git a/cmd/metrics-scraper/main.go b/cmd/metrics-scraper/main.go index dc571ef9..0b7e11c8 100644 --- a/cmd/metrics-scraper/main.go +++ b/cmd/metrics-scraper/main.go @@ -18,9 +18,11 @@ package main import ( "context" - "github.com/karmada-io/dashboard/cmd/metrics-scraper/app" - "k8s.io/component-base/cli" "os" + + "k8s.io/component-base/cli" + + "github.com/karmada-io/dashboard/cmd/metrics-scraper/app" ) func main() { diff --git a/cmd/web/app/options/options.go b/cmd/web/app/options/options.go index 32aba214..a11dc239 100644 --- a/cmd/web/app/options/options.go +++ b/cmd/web/app/options/options.go @@ -17,8 +17,9 @@ limitations under the License. package options import ( - "github.com/spf13/pflag" "net" + + "github.com/spf13/pflag" ) // Options contains everything necessary to create and run api. diff --git a/cmd/web/app/web.go b/cmd/web/app/web.go index e38564bc..c8cb5680 100644 --- a/cmd/web/app/web.go +++ b/cmd/web/app/web.go @@ -19,22 +19,24 @@ package app import ( "context" "fmt" - "github.com/gin-gonic/gin" - "github.com/karmada-io/dashboard/cmd/api/app/router" - "github.com/karmada-io/dashboard/cmd/web/app/options" - "github.com/karmada-io/dashboard/pkg/config" - "github.com/karmada-io/dashboard/pkg/environment" - "github.com/karmada-io/karmada/pkg/sharedcli/klogflag" - "github.com/spf13/cobra" "io" - cliflag "k8s.io/component-base/cli/flag" - "k8s.io/klog/v2" "net/http" "net/http/httputil" "net/url" "os" "path" "strings" + + "github.com/gin-gonic/gin" + "github.com/karmada-io/karmada/pkg/sharedcli/klogflag" + "github.com/spf13/cobra" + cliflag "k8s.io/component-base/cli/flag" + "k8s.io/klog/v2" + + "github.com/karmada-io/dashboard/cmd/api/app/router" + "github.com/karmada-io/dashboard/cmd/web/app/options" + "github.com/karmada-io/dashboard/pkg/config" + "github.com/karmada-io/dashboard/pkg/environment" ) // NewWebCommand creates a *cobra.Command object with default parameters diff --git a/cmd/web/main.go b/cmd/web/main.go index 94a98d63..d36c56f5 100644 --- a/cmd/web/main.go +++ b/cmd/web/main.go @@ -18,9 +18,11 @@ package main import ( "context" - "github.com/karmada-io/dashboard/cmd/web/app" - "k8s.io/component-base/cli" "os" + + "k8s.io/component-base/cli" + + "github.com/karmada-io/dashboard/cmd/web/app" ) func main() { diff --git a/hack/verify-staticcheck.sh b/hack/verify-staticcheck.sh new file mode 100755 index 00000000..44e172df --- /dev/null +++ b/hack/verify-staticcheck.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# copyright 2024 the karmada 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 + +REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. +GOLANGCI_LINT_VER="v1.59.0" + +cd "${REPO_ROOT}" + +if [ -x "$(command -v golangci-lint)" ]; then + echo "Using golangci-lint version:" + golangci-lint version +else + echo "Installing golangci-lint ${GOLANGCI_LINT_VER}" + # https://golangci-lint.run/usage/install/#other-ci + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VER} +fi + +if golangci-lint run --enable-only goimports,gci; then + echo 'Congratulations! All Go source files have passed staticcheck.' +else + echo # print one empty line, separate from warning messages. + echo 'Please review the above warnings.' + echo 'Tips: The golangci-lint might help you fix some issues, try with the command "golangci-lint run --fix".' + echo 'If the above warnings do not make sense, feel free to file an issue.' + exit 1 +fi diff --git a/pkg/client/auth.go b/pkg/client/auth.go index 8c616795..ea520f2e 100644 --- a/pkg/client/auth.go +++ b/pkg/client/auth.go @@ -17,12 +17,13 @@ limitations under the License. package client import ( + "net/http" + "strings" + k8serrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" clientcmdapi "k8s.io/client-go/tools/clientcmd/api" - "net/http" - "strings" ) const ( diff --git a/pkg/client/client.go b/pkg/client/client.go index ffdb0357..b2458c4f 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -18,13 +18,14 @@ package client import ( "fmt" + "net/http" + karmadaclientset "github.com/karmada-io/karmada/pkg/generated/clientset/versioned" kubeclient "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" clientcmdapi "k8s.io/client-go/tools/clientcmd/api" "k8s.io/klog/v2" - "net/http" ) // LoadRestConfig creates a rest.Config using the passed kubeconfig. If context is empty, current context in kubeconfig will be used. diff --git a/pkg/client/verber.go b/pkg/client/verber.go index b02d3dc5..e4bcf662 100644 --- a/pkg/client/verber.go +++ b/pkg/client/verber.go @@ -19,6 +19,9 @@ package client import ( "context" "fmt" + "net/http" + "strings" + "github.com/gobuffalo/flect" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -30,8 +33,6 @@ import ( "k8s.io/client-go/dynamic" "k8s.io/client-go/util/retry" "k8s.io/klog/v2" - "net/http" - "strings" ) var ( diff --git a/pkg/common/errors/localizer_test.go b/pkg/common/errors/localizer_test.go index 02504f2e..e2cb30cd 100644 --- a/pkg/common/errors/localizer_test.go +++ b/pkg/common/errors/localizer_test.go @@ -15,8 +15,9 @@ package errors_test import ( - "github.com/karmada-io/dashboard/pkg/common/errors" "testing" + + "github.com/karmada-io/dashboard/pkg/common/errors" ) func TestLocalizeError(t *testing.T) { diff --git a/pkg/config/config.go b/pkg/config/config.go index 8338c5a6..70306818 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -19,6 +19,8 @@ package config import ( "context" "fmt" + "os" + "github.com/karmada-io/karmada/pkg/util/fedinformer" "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" @@ -27,7 +29,6 @@ import ( "k8s.io/client-go/informers" "k8s.io/client-go/kubernetes" "k8s.io/klog/v2" - "os" ) var dashboardConfig DashboardConfig diff --git a/pkg/resource/cluster/cluster.go b/pkg/resource/cluster/cluster.go index d7d0f8dc..ebcf84cc 100644 --- a/pkg/resource/cluster/cluster.go +++ b/pkg/resource/cluster/cluster.go @@ -18,14 +18,16 @@ package cluster import ( "context" + "log" + + "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1" + karmadaclientset "github.com/karmada-io/karmada/pkg/generated/clientset/versioned" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "github.com/karmada-io/dashboard/pkg/common/errors" "github.com/karmada-io/dashboard/pkg/common/helpers" "github.com/karmada-io/dashboard/pkg/common/types" "github.com/karmada-io/dashboard/pkg/dataselect" - "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1" - karmadaclientset "github.com/karmada-io/karmada/pkg/generated/clientset/versioned" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "log" ) type Cluster struct { diff --git a/pkg/resource/cluster/common.go b/pkg/resource/cluster/common.go index 5b391da3..86c708b2 100644 --- a/pkg/resource/cluster/common.go +++ b/pkg/resource/cluster/common.go @@ -17,8 +17,9 @@ limitations under the License. package cluster import ( - "github.com/karmada-io/dashboard/pkg/dataselect" "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1" + + "github.com/karmada-io/dashboard/pkg/dataselect" ) type ClusterCell v1alpha1.Cluster diff --git a/pkg/resource/cluster/detail.go b/pkg/resource/cluster/detail.go index 0a21149a..5a6798cf 100644 --- a/pkg/resource/cluster/detail.go +++ b/pkg/resource/cluster/detail.go @@ -19,12 +19,13 @@ package cluster import ( "context" "fmt" + "log" + "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1" karmadaclientset "github.com/karmada-io/karmada/pkg/generated/clientset/versioned" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "log" ) type ClusterAllocatedResources struct { diff --git a/pkg/resource/clusteroverridepolicy/common.go b/pkg/resource/clusteroverridepolicy/common.go index 87be07e0..bafb1c38 100644 --- a/pkg/resource/clusteroverridepolicy/common.go +++ b/pkg/resource/clusteroverridepolicy/common.go @@ -17,8 +17,9 @@ limitations under the License. package clusteroverridepolicy import ( - "github.com/karmada-io/dashboard/pkg/dataselect" "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1" + + "github.com/karmada-io/dashboard/pkg/dataselect" ) type ClusterOverridePolicyCell v1alpha1.ClusterOverridePolicy diff --git a/pkg/resource/clusteroverridepolicy/detail.go b/pkg/resource/clusteroverridepolicy/detail.go index 4346f08c..baf500ed 100644 --- a/pkg/resource/clusteroverridepolicy/detail.go +++ b/pkg/resource/clusteroverridepolicy/detail.go @@ -18,10 +18,12 @@ package clusteroverridepolicy import ( "context" - "github.com/karmada-io/dashboard/pkg/common/errors" + "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1" karmadaclientset "github.com/karmada-io/karmada/pkg/generated/clientset/versioned" metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/karmada-io/dashboard/pkg/common/errors" ) type ClusterOverridePolicyDetail struct { diff --git a/pkg/resource/clusteroverridepolicy/list.go b/pkg/resource/clusteroverridepolicy/list.go index 98f883f4..e5f0424f 100644 --- a/pkg/resource/clusteroverridepolicy/list.go +++ b/pkg/resource/clusteroverridepolicy/list.go @@ -18,12 +18,14 @@ package clusteroverridepolicy import ( "context" + + "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1" + karmadaclientset "github.com/karmada-io/karmada/pkg/generated/clientset/versioned" + "github.com/karmada-io/dashboard/pkg/common/errors" "github.com/karmada-io/dashboard/pkg/common/helpers" "github.com/karmada-io/dashboard/pkg/common/types" "github.com/karmada-io/dashboard/pkg/dataselect" - "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1" - karmadaclientset "github.com/karmada-io/karmada/pkg/generated/clientset/versioned" ) // ClusterOverridePolicyList contains a list of overriders in the karmada control-plane. diff --git a/pkg/resource/clusterpropagationpolicy/common.go b/pkg/resource/clusterpropagationpolicy/common.go index 5292795d..274901bd 100644 --- a/pkg/resource/clusterpropagationpolicy/common.go +++ b/pkg/resource/clusterpropagationpolicy/common.go @@ -17,8 +17,9 @@ limitations under the License. package clusterpropagationpolicy import ( - "github.com/karmada-io/dashboard/pkg/dataselect" "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1" + + "github.com/karmada-io/dashboard/pkg/dataselect" ) type ClusterPropagationPolicyCell v1alpha1.ClusterPropagationPolicy diff --git a/pkg/resource/clusterpropagationpolicy/detail.go b/pkg/resource/clusterpropagationpolicy/detail.go index 79b1140a..7cae0f08 100644 --- a/pkg/resource/clusterpropagationpolicy/detail.go +++ b/pkg/resource/clusterpropagationpolicy/detail.go @@ -18,10 +18,12 @@ package clusterpropagationpolicy import ( "context" - "github.com/karmada-io/dashboard/pkg/common/errors" + "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1" karmadaclientset "github.com/karmada-io/karmada/pkg/generated/clientset/versioned" metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/karmada-io/dashboard/pkg/common/errors" ) type ClusterPropagationPolicyDetail struct { diff --git a/pkg/resource/clusterpropagationpolicy/list.go b/pkg/resource/clusterpropagationpolicy/list.go index d41b2eb1..218e91df 100644 --- a/pkg/resource/clusterpropagationpolicy/list.go +++ b/pkg/resource/clusterpropagationpolicy/list.go @@ -18,12 +18,14 @@ package clusterpropagationpolicy import ( "context" + + "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1" + karmadaclientset "github.com/karmada-io/karmada/pkg/generated/clientset/versioned" + "github.com/karmada-io/dashboard/pkg/common/errors" "github.com/karmada-io/dashboard/pkg/common/helpers" "github.com/karmada-io/dashboard/pkg/common/types" "github.com/karmada-io/dashboard/pkg/dataselect" - "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1" - karmadaclientset "github.com/karmada-io/karmada/pkg/generated/clientset/versioned" ) // ClusterPropagationPolicyList contains a list of propagation in the karmada control-plane. diff --git a/pkg/resource/common/event.go b/pkg/resource/common/event.go index e9a68f64..5db4fee0 100644 --- a/pkg/resource/common/event.go +++ b/pkg/resource/common/event.go @@ -15,8 +15,9 @@ package common import ( - "github.com/karmada-io/dashboard/pkg/common/types" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/karmada-io/dashboard/pkg/common/types" ) // EventList is an events response structure. diff --git a/pkg/resource/common/resourcechannels.go b/pkg/resource/common/resourcechannels.go index 20e8c988..71757885 100644 --- a/pkg/resource/common/resourcechannels.go +++ b/pkg/resource/common/resourcechannels.go @@ -18,7 +18,7 @@ package common import ( "context" - "github.com/karmada-io/dashboard/pkg/common/helpers" + apps "k8s.io/api/apps/v1" autoscaling "k8s.io/api/autoscaling/v1" batch "k8s.io/api/batch/v1" @@ -28,6 +28,8 @@ import ( storage "k8s.io/api/storage/v1" metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1" client "k8s.io/client-go/kubernetes" + + "github.com/karmada-io/dashboard/pkg/common/helpers" ) // ResourceChannels struct holds channels to resource lists. Each list channel is paired with diff --git a/pkg/resource/configmap/common.go b/pkg/resource/configmap/common.go index 4c4fff72..e1260ad4 100644 --- a/pkg/resource/configmap/common.go +++ b/pkg/resource/configmap/common.go @@ -17,8 +17,9 @@ limitations under the License. package configmap import ( - "github.com/karmada-io/dashboard/pkg/dataselect" api "k8s.io/api/core/v1" + + "github.com/karmada-io/dashboard/pkg/dataselect" ) // The code below allows to perform complex data section on []api.ConfigMap diff --git a/pkg/resource/configmap/detail_test.go b/pkg/resource/configmap/detail_test.go index ee39d948..5ad3da44 100644 --- a/pkg/resource/configmap/detail_test.go +++ b/pkg/resource/configmap/detail_test.go @@ -17,12 +17,13 @@ limitations under the License. package configmap import ( - "github.com/karmada-io/dashboard/pkg/common/types" "reflect" "testing" v1 "k8s.io/api/core/v1" metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/karmada-io/dashboard/pkg/common/types" ) func TestGetConfigMapDetail(t *testing.T) { diff --git a/pkg/resource/configmap/list.go b/pkg/resource/configmap/list.go index 240a19d0..3b90f8f9 100644 --- a/pkg/resource/configmap/list.go +++ b/pkg/resource/configmap/list.go @@ -17,15 +17,16 @@ limitations under the License. package configmap import ( - "github.com/karmada-io/dashboard/pkg/common/errors" - "github.com/karmada-io/dashboard/pkg/common/types" - "github.com/karmada-io/dashboard/pkg/dataselect" - "github.com/karmada-io/dashboard/pkg/resource/common" "log" v1 "k8s.io/api/core/v1" metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" + + "github.com/karmada-io/dashboard/pkg/common/errors" + "github.com/karmada-io/dashboard/pkg/common/types" + "github.com/karmada-io/dashboard/pkg/dataselect" + "github.com/karmada-io/dashboard/pkg/resource/common" ) // ConfigMapList contains a list of Config Maps in the cluster. diff --git a/pkg/resource/configmap/list_test.go b/pkg/resource/configmap/list_test.go index 2fc85a34..fae5548c 100644 --- a/pkg/resource/configmap/list_test.go +++ b/pkg/resource/configmap/list_test.go @@ -15,13 +15,14 @@ package configmap import ( - "github.com/karmada-io/dashboard/pkg/common/types" - "github.com/karmada-io/dashboard/pkg/dataselect" "reflect" "testing" v1 "k8s.io/api/core/v1" metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/karmada-io/dashboard/pkg/common/types" + "github.com/karmada-io/dashboard/pkg/dataselect" ) func TestToConfigMapList(t *testing.T) { diff --git a/pkg/resource/cronjob/common.go b/pkg/resource/cronjob/common.go index 4e386f2c..b1556198 100644 --- a/pkg/resource/cronjob/common.go +++ b/pkg/resource/cronjob/common.go @@ -17,9 +17,10 @@ limitations under the License. package cronjob import ( + batch "k8s.io/api/batch/v1" + "github.com/karmada-io/dashboard/pkg/dataselect" "github.com/karmada-io/dashboard/pkg/resource/common" - batch "k8s.io/api/batch/v1" ) // The code below allows to perform complex data section on []batch.CronJob diff --git a/pkg/resource/cronjob/events.go b/pkg/resource/cronjob/events.go index 12e0e246..79febc68 100644 --- a/pkg/resource/cronjob/events.go +++ b/pkg/resource/cronjob/events.go @@ -17,10 +17,11 @@ limitations under the License. package cronjob import ( + client "k8s.io/client-go/kubernetes" + "github.com/karmada-io/dashboard/pkg/dataselect" "github.com/karmada-io/dashboard/pkg/resource/common" "github.com/karmada-io/dashboard/pkg/resource/event" - client "k8s.io/client-go/kubernetes" ) // GetCronJobEvents gets events associated to cron job. diff --git a/pkg/resource/cronjob/jobs.go b/pkg/resource/cronjob/jobs.go index 96f45044..6a4406c9 100644 --- a/pkg/resource/cronjob/jobs.go +++ b/pkg/resource/cronjob/jobs.go @@ -18,17 +18,18 @@ package cronjob import ( "context" - "github.com/karmada-io/dashboard/pkg/common/errors" - "github.com/karmada-io/dashboard/pkg/common/types" - "github.com/karmada-io/dashboard/pkg/dataselect" - "github.com/karmada-io/dashboard/pkg/resource/common" - "github.com/karmada-io/dashboard/pkg/resource/job" batch "k8s.io/api/batch/v1" meta "k8s.io/apimachinery/pkg/apis/meta/v1" apimachinery "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/rand" client "k8s.io/client-go/kubernetes" + + "github.com/karmada-io/dashboard/pkg/common/errors" + "github.com/karmada-io/dashboard/pkg/common/types" + "github.com/karmada-io/dashboard/pkg/dataselect" + "github.com/karmada-io/dashboard/pkg/resource/common" + "github.com/karmada-io/dashboard/pkg/resource/job" ) const ( diff --git a/pkg/resource/cronjob/list.go b/pkg/resource/cronjob/list.go index 5c2e795a..4dfd51b2 100644 --- a/pkg/resource/cronjob/list.go +++ b/pkg/resource/cronjob/list.go @@ -17,15 +17,16 @@ limitations under the License. package cronjob import ( - "github.com/karmada-io/dashboard/pkg/common/errors" - "github.com/karmada-io/dashboard/pkg/common/types" - "github.com/karmada-io/dashboard/pkg/dataselect" - "github.com/karmada-io/dashboard/pkg/resource/common" "log" batch "k8s.io/api/batch/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" client "k8s.io/client-go/kubernetes" + + "github.com/karmada-io/dashboard/pkg/common/errors" + "github.com/karmada-io/dashboard/pkg/common/types" + "github.com/karmada-io/dashboard/pkg/dataselect" + "github.com/karmada-io/dashboard/pkg/resource/common" ) // CronJobList contains a list of CronJobs in the cluster. diff --git a/pkg/resource/daemonset/common.go b/pkg/resource/daemonset/common.go index 51000408..04b812b5 100644 --- a/pkg/resource/daemonset/common.go +++ b/pkg/resource/daemonset/common.go @@ -18,9 +18,6 @@ package daemonset import ( "context" - "github.com/karmada-io/dashboard/pkg/dataselect" - "github.com/karmada-io/dashboard/pkg/resource/common" - "github.com/karmada-io/dashboard/pkg/resource/event" apps "k8s.io/api/apps/v1" v1 "k8s.io/api/core/v1" @@ -28,6 +25,10 @@ import ( "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/labels" client "k8s.io/client-go/kubernetes" + + "github.com/karmada-io/dashboard/pkg/dataselect" + "github.com/karmada-io/dashboard/pkg/resource/common" + "github.com/karmada-io/dashboard/pkg/resource/event" ) // GetServicesForDSDeletion is based on given selector returns list of services that are candidates for deletion. diff --git a/pkg/resource/daemonset/detail.go b/pkg/resource/daemonset/detail.go index 23cfd833..bea6778f 100644 --- a/pkg/resource/daemonset/detail.go +++ b/pkg/resource/daemonset/detail.go @@ -18,11 +18,12 @@ package daemonset import ( "context" - "github.com/karmada-io/dashboard/pkg/resource/common" "log" metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1" k8sClient "k8s.io/client-go/kubernetes" + + "github.com/karmada-io/dashboard/pkg/resource/common" ) // DaemonSetDetail represents detailed information about a Daemon Set. diff --git a/pkg/resource/daemonset/list.go b/pkg/resource/daemonset/list.go index 0fc91c4d..cdb38d89 100644 --- a/pkg/resource/daemonset/list.go +++ b/pkg/resource/daemonset/list.go @@ -17,14 +17,15 @@ limitations under the License. package daemonset import ( + apps "k8s.io/api/apps/v1" + v1 "k8s.io/api/core/v1" + "k8s.io/client-go/kubernetes" + "github.com/karmada-io/dashboard/pkg/common/errors" "github.com/karmada-io/dashboard/pkg/common/types" "github.com/karmada-io/dashboard/pkg/dataselect" "github.com/karmada-io/dashboard/pkg/resource/common" "github.com/karmada-io/dashboard/pkg/resource/event" - apps "k8s.io/api/apps/v1" - v1 "k8s.io/api/core/v1" - "k8s.io/client-go/kubernetes" ) // DaemonSetList contains a list of Daemon Sets in the cluster. diff --git a/pkg/resource/deployment/common.go b/pkg/resource/deployment/common.go index 7adc910f..2a800dc8 100644 --- a/pkg/resource/deployment/common.go +++ b/pkg/resource/deployment/common.go @@ -17,11 +17,12 @@ limitations under the License. package deployment import ( + apps "k8s.io/api/apps/v1" + v1 "k8s.io/api/core/v1" + "github.com/karmada-io/dashboard/pkg/dataselect" "github.com/karmada-io/dashboard/pkg/resource/common" "github.com/karmada-io/dashboard/pkg/resource/event" - apps "k8s.io/api/apps/v1" - v1 "k8s.io/api/core/v1" ) type DeploymentCell apps.Deployment diff --git a/pkg/resource/deployment/detail.go b/pkg/resource/deployment/detail.go index ef801512..678bd26d 100644 --- a/pkg/resource/deployment/detail.go +++ b/pkg/resource/deployment/detail.go @@ -18,13 +18,15 @@ package deployment import ( "context" - "github.com/karmada-io/dashboard/pkg/common/errors" - "github.com/karmada-io/dashboard/pkg/resource/common" + "log" + apps "k8s.io/api/apps/v1" metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" client "k8s.io/client-go/kubernetes" - "log" + + "github.com/karmada-io/dashboard/pkg/common/errors" + "github.com/karmada-io/dashboard/pkg/resource/common" ) // RollingUpdateStrategy is behavior of a rolling update. See RollingUpdateDeployment K8s object. diff --git a/pkg/resource/deployment/list.go b/pkg/resource/deployment/list.go index 5a8f61c5..8a3c08ba 100644 --- a/pkg/resource/deployment/list.go +++ b/pkg/resource/deployment/list.go @@ -17,15 +17,17 @@ limitations under the License. package deployment import ( + "log" + + apps "k8s.io/api/apps/v1" + v1 "k8s.io/api/core/v1" + client "k8s.io/client-go/kubernetes" + "github.com/karmada-io/dashboard/pkg/common/errors" "github.com/karmada-io/dashboard/pkg/common/types" "github.com/karmada-io/dashboard/pkg/dataselect" "github.com/karmada-io/dashboard/pkg/resource/common" "github.com/karmada-io/dashboard/pkg/resource/event" - apps "k8s.io/api/apps/v1" - v1 "k8s.io/api/core/v1" - client "k8s.io/client-go/kubernetes" - "log" ) // DeploymentList contains a list of Deployments in the cluster. diff --git a/pkg/resource/endpoint/endpoint.go b/pkg/resource/endpoint/endpoint.go index 215809c9..d5c8322d 100644 --- a/pkg/resource/endpoint/endpoint.go +++ b/pkg/resource/endpoint/endpoint.go @@ -15,8 +15,6 @@ package endpoint import ( - "github.com/karmada-io/dashboard/pkg/common/types" - "github.com/karmada-io/dashboard/pkg/resource/common" "log" v1 "k8s.io/api/core/v1" @@ -24,6 +22,9 @@ import ( "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/labels" k8sClient "k8s.io/client-go/kubernetes" + + "github.com/karmada-io/dashboard/pkg/common/types" + "github.com/karmada-io/dashboard/pkg/resource/common" ) type Endpoint struct { diff --git a/pkg/resource/endpoint/list.go b/pkg/resource/endpoint/list.go index 5203c431..38678c76 100644 --- a/pkg/resource/endpoint/list.go +++ b/pkg/resource/endpoint/list.go @@ -15,8 +15,9 @@ package endpoint import ( - "github.com/karmada-io/dashboard/pkg/common/types" v1 "k8s.io/api/core/v1" + + "github.com/karmada-io/dashboard/pkg/common/types" ) type EndpointList struct { diff --git a/pkg/resource/event/common.go b/pkg/resource/event/common.go index 6fec5da4..1161eb4e 100644 --- a/pkg/resource/event/common.go +++ b/pkg/resource/event/common.go @@ -18,16 +18,18 @@ package event import ( "context" - "github.com/karmada-io/dashboard/pkg/common/errors" - "github.com/karmada-io/dashboard/pkg/common/helpers" - "github.com/karmada-io/dashboard/pkg/common/types" - "github.com/karmada-io/dashboard/pkg/dataselect" - "github.com/karmada-io/dashboard/pkg/resource/common" + v1 "k8s.io/api/core/v1" metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/kubernetes" + + "github.com/karmada-io/dashboard/pkg/common/errors" + "github.com/karmada-io/dashboard/pkg/common/helpers" + "github.com/karmada-io/dashboard/pkg/common/types" + "github.com/karmada-io/dashboard/pkg/dataselect" + "github.com/karmada-io/dashboard/pkg/resource/common" ) // EmptyEventList is a empty list of events. diff --git a/pkg/resource/event/event.go b/pkg/resource/event/event.go index 3a3ac703..26f914ca 100644 --- a/pkg/resource/event/event.go +++ b/pkg/resource/event/event.go @@ -17,10 +17,12 @@ limitations under the License. package event import ( - "github.com/karmada-io/dashboard/pkg/resource/common" + "strings" + api "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" - "strings" + + "github.com/karmada-io/dashboard/pkg/resource/common" ) // FailedReasonPartials is an array of partial strings to correctly filter warning events. diff --git a/pkg/resource/ingress/common.go b/pkg/resource/ingress/common.go index d6927a97..9a6c26e3 100644 --- a/pkg/resource/ingress/common.go +++ b/pkg/resource/ingress/common.go @@ -17,8 +17,9 @@ limitations under the License. package ingress import ( - "github.com/karmada-io/dashboard/pkg/dataselect" v1 "k8s.io/api/networking/v1" + + "github.com/karmada-io/dashboard/pkg/dataselect" ) // The code below allows to perform complex data section on []extensions.Ingress diff --git a/pkg/resource/ingress/filter.go b/pkg/resource/ingress/filter.go index eb8ff80b..4ba56ec6 100644 --- a/pkg/resource/ingress/filter.go +++ b/pkg/resource/ingress/filter.go @@ -17,8 +17,9 @@ limitations under the License. package ingress import ( - "github.com/karmada-io/dashboard/pkg/common/types" networkingv1 "k8s.io/api/networking/v1" + + "github.com/karmada-io/dashboard/pkg/common/types" ) func FilterIngressByService(ingresses []networkingv1.Ingress, serviceName string) []networkingv1.Ingress { diff --git a/pkg/resource/ingress/list.go b/pkg/resource/ingress/list.go index 2519ee28..e04594cf 100644 --- a/pkg/resource/ingress/list.go +++ b/pkg/resource/ingress/list.go @@ -18,13 +18,15 @@ package ingress import ( "context" + + v1 "k8s.io/api/networking/v1" + client "k8s.io/client-go/kubernetes" + "github.com/karmada-io/dashboard/pkg/common/errors" "github.com/karmada-io/dashboard/pkg/common/helpers" "github.com/karmada-io/dashboard/pkg/common/types" "github.com/karmada-io/dashboard/pkg/dataselect" "github.com/karmada-io/dashboard/pkg/resource/common" - v1 "k8s.io/api/networking/v1" - client "k8s.io/client-go/kubernetes" ) // Ingress - a single ingress returned to the frontend. diff --git a/pkg/resource/job/common.go b/pkg/resource/job/common.go index b69d2c85..f822daf3 100644 --- a/pkg/resource/job/common.go +++ b/pkg/resource/job/common.go @@ -17,10 +17,11 @@ limitations under the License. package job import ( - "github.com/karmada-io/dashboard/pkg/dataselect" - "github.com/karmada-io/dashboard/pkg/resource/common" batch "k8s.io/api/batch/v1" v1 "k8s.io/api/core/v1" + + "github.com/karmada-io/dashboard/pkg/dataselect" + "github.com/karmada-io/dashboard/pkg/resource/common" ) // The code below allows to perform complex data section on []batch.Job diff --git a/pkg/resource/job/detail.go b/pkg/resource/job/detail.go index a04748b6..102aaf2c 100644 --- a/pkg/resource/job/detail.go +++ b/pkg/resource/job/detail.go @@ -18,12 +18,13 @@ package job import ( "context" - "github.com/karmada-io/dashboard/pkg/common/errors" - "github.com/karmada-io/dashboard/pkg/resource/common" batch "k8s.io/api/batch/v1" metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1" k8sClient "k8s.io/client-go/kubernetes" + + "github.com/karmada-io/dashboard/pkg/common/errors" + "github.com/karmada-io/dashboard/pkg/resource/common" ) // JobDetail is a presentation layer view of Kubernetes Job resource. diff --git a/pkg/resource/job/events.go b/pkg/resource/job/events.go index 26f7cfdd..fa62668f 100644 --- a/pkg/resource/job/events.go +++ b/pkg/resource/job/events.go @@ -17,10 +17,11 @@ limitations under the License. package job import ( + client "k8s.io/client-go/kubernetes" + "github.com/karmada-io/dashboard/pkg/dataselect" "github.com/karmada-io/dashboard/pkg/resource/common" "github.com/karmada-io/dashboard/pkg/resource/event" - client "k8s.io/client-go/kubernetes" ) // GetJobEvents gets events associated to job. diff --git a/pkg/resource/job/list.go b/pkg/resource/job/list.go index 625be4d0..1a187f6e 100644 --- a/pkg/resource/job/list.go +++ b/pkg/resource/job/list.go @@ -17,16 +17,17 @@ limitations under the License. package job import ( - "github.com/karmada-io/dashboard/pkg/common/errors" - "github.com/karmada-io/dashboard/pkg/common/types" - "github.com/karmada-io/dashboard/pkg/dataselect" - "github.com/karmada-io/dashboard/pkg/resource/common" - "github.com/karmada-io/dashboard/pkg/resource/event" "log" batch "k8s.io/api/batch/v1" v1 "k8s.io/api/core/v1" client "k8s.io/client-go/kubernetes" + + "github.com/karmada-io/dashboard/pkg/common/errors" + "github.com/karmada-io/dashboard/pkg/common/types" + "github.com/karmada-io/dashboard/pkg/dataselect" + "github.com/karmada-io/dashboard/pkg/resource/common" + "github.com/karmada-io/dashboard/pkg/resource/event" ) // JobList contains a list of Jobs in the cluster. diff --git a/pkg/resource/job/pods.go b/pkg/resource/job/pods.go index 61586605..09efb33f 100644 --- a/pkg/resource/job/pods.go +++ b/pkg/resource/job/pods.go @@ -17,39 +17,14 @@ limitations under the License. package job import ( - "context" - "github.com/karmada-io/dashboard/pkg/resource/common" batch "k8s.io/api/batch/v1" - v1 "k8s.io/api/core/v1" metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/labels" k8sClient "k8s.io/client-go/kubernetes" -) - -// Returns array of api pods targeting job with given name. -func getRawJobPods(client k8sClient.Interface, petSetName, namespace string) ([]v1.Pod, error) { - job, err := client.BatchV1().Jobs(namespace).Get(context.TODO(), petSetName, metaV1.GetOptions{}) - if err != nil { - return nil, err - } - - labelSelector := labels.SelectorFromSet(job.Spec.Selector.MatchLabels) - channels := &common.ResourceChannels{ - PodList: common.GetPodListChannelWithOptions(client, common.NewSameNamespaceQuery(namespace), - metaV1.ListOptions{ - LabelSelector: labelSelector.String(), - FieldSelector: fields.Everything().String(), - }, 1), - } - - podList := <-channels.PodList.List - if err := <-channels.PodList.Error; err != nil { - return nil, err - } - return podList.Items, nil -} + "github.com/karmada-io/dashboard/pkg/resource/common" +) // Returns simple info about pods(running, desired, failing, etc.) related to given job. func getJobPodInfo(client k8sClient.Interface, job *batch.Job) (*common.PodInfo, error) { diff --git a/pkg/resource/namespace/common.go b/pkg/resource/namespace/common.go index 151e3394..095467bf 100644 --- a/pkg/resource/namespace/common.go +++ b/pkg/resource/namespace/common.go @@ -18,11 +18,13 @@ package namespace import ( "context" - "github.com/karmada-io/dashboard/pkg/dataselect" + "log" + api "k8s.io/api/core/v1" metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" - "log" + + "github.com/karmada-io/dashboard/pkg/dataselect" ) const ( diff --git a/pkg/resource/namespace/list.go b/pkg/resource/namespace/list.go index d56a8353..2a667472 100644 --- a/pkg/resource/namespace/list.go +++ b/pkg/resource/namespace/list.go @@ -18,13 +18,15 @@ package namespace import ( "context" + "log" + + v1 "k8s.io/api/core/v1" + "k8s.io/client-go/kubernetes" + "github.com/karmada-io/dashboard/pkg/common/errors" "github.com/karmada-io/dashboard/pkg/common/helpers" "github.com/karmada-io/dashboard/pkg/common/types" "github.com/karmada-io/dashboard/pkg/dataselect" - v1 "k8s.io/api/core/v1" - "k8s.io/client-go/kubernetes" - "log" ) // NamespaceList contains a list of namespaces in the cluster. diff --git a/pkg/resource/node/common.go b/pkg/resource/node/common.go index 0a5813c9..f4ca197e 100644 --- a/pkg/resource/node/common.go +++ b/pkg/resource/node/common.go @@ -17,8 +17,9 @@ limitations under the License. package node import ( - "github.com/karmada-io/dashboard/pkg/dataselect" api "k8s.io/api/core/v1" + + "github.com/karmada-io/dashboard/pkg/dataselect" ) type NodeCell api.Node diff --git a/pkg/resource/node/list.go b/pkg/resource/node/list.go index 7e990934..5f718931 100644 --- a/pkg/resource/node/list.go +++ b/pkg/resource/node/list.go @@ -19,14 +19,15 @@ package node import ( "log" - "github.com/karmada-io/dashboard/pkg/common/errors" - "github.com/karmada-io/dashboard/pkg/common/types" - "github.com/karmada-io/dashboard/pkg/dataselect" - "github.com/karmada-io/dashboard/pkg/resource/common" "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" + + "github.com/karmada-io/dashboard/pkg/common/errors" + "github.com/karmada-io/dashboard/pkg/common/types" + "github.com/karmada-io/dashboard/pkg/dataselect" + "github.com/karmada-io/dashboard/pkg/resource/common" ) type Node struct { diff --git a/pkg/resource/overridepolicy/common.go b/pkg/resource/overridepolicy/common.go index 11336404..57253b14 100644 --- a/pkg/resource/overridepolicy/common.go +++ b/pkg/resource/overridepolicy/common.go @@ -17,8 +17,9 @@ limitations under the License. package overridepolicy import ( - "github.com/karmada-io/dashboard/pkg/dataselect" "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1" + + "github.com/karmada-io/dashboard/pkg/dataselect" ) type OverridePolicyCell v1alpha1.OverridePolicy diff --git a/pkg/resource/overridepolicy/detail.go b/pkg/resource/overridepolicy/detail.go index 23c76c8e..41a5c59e 100644 --- a/pkg/resource/overridepolicy/detail.go +++ b/pkg/resource/overridepolicy/detail.go @@ -18,10 +18,12 @@ package overridepolicy import ( "context" - "github.com/karmada-io/dashboard/pkg/common/errors" + "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1" karmadaclientset "github.com/karmada-io/karmada/pkg/generated/clientset/versioned" metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/karmada-io/dashboard/pkg/common/errors" ) // OverridePolicyDetail is a presentation layer view of Karmada OverridePolicy resource. This means it is OverridePolicy plus diff --git a/pkg/resource/overridepolicy/list.go b/pkg/resource/overridepolicy/list.go index e6547eb1..6837aebf 100644 --- a/pkg/resource/overridepolicy/list.go +++ b/pkg/resource/overridepolicy/list.go @@ -18,15 +18,17 @@ package overridepolicy import ( "context" + "log" + + "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1" + karmadaclientset "github.com/karmada-io/karmada/pkg/generated/clientset/versioned" + "k8s.io/client-go/kubernetes" + "github.com/karmada-io/dashboard/pkg/common/errors" "github.com/karmada-io/dashboard/pkg/common/helpers" "github.com/karmada-io/dashboard/pkg/common/types" "github.com/karmada-io/dashboard/pkg/dataselect" "github.com/karmada-io/dashboard/pkg/resource/common" - "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1" - karmadaclientset "github.com/karmada-io/karmada/pkg/generated/clientset/versioned" - "k8s.io/client-go/kubernetes" - "log" ) // OverridePolicyList contains a list of propagation in the karmada control-plance. diff --git a/pkg/resource/pod/common.go b/pkg/resource/pod/common.go index 1c84baf3..bbcb1591 100644 --- a/pkg/resource/pod/common.go +++ b/pkg/resource/pod/common.go @@ -17,8 +17,9 @@ limitations under the License. package pod import ( - "github.com/karmada-io/dashboard/pkg/dataselect" api "k8s.io/api/core/v1" + + "github.com/karmada-io/dashboard/pkg/dataselect" ) type PodCell api.Pod diff --git a/pkg/resource/pod/list.go b/pkg/resource/pod/list.go index cb90e661..faa9ba4f 100644 --- a/pkg/resource/pod/list.go +++ b/pkg/resource/pod/list.go @@ -19,13 +19,14 @@ package pod import ( "log" + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/kubernetes" + "github.com/karmada-io/dashboard/pkg/common/errors" "github.com/karmada-io/dashboard/pkg/common/types" "github.com/karmada-io/dashboard/pkg/dataselect" "github.com/karmada-io/dashboard/pkg/resource/common" - v1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/client-go/kubernetes" ) type Pod struct { diff --git a/pkg/resource/propagationpolicy/common.go b/pkg/resource/propagationpolicy/common.go index 8cbfd5f6..7c858c14 100644 --- a/pkg/resource/propagationpolicy/common.go +++ b/pkg/resource/propagationpolicy/common.go @@ -17,8 +17,9 @@ limitations under the License. package propagationpolicy import ( - "github.com/karmada-io/dashboard/pkg/dataselect" "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1" + + "github.com/karmada-io/dashboard/pkg/dataselect" ) type PropagationPolicyCell v1alpha1.PropagationPolicy diff --git a/pkg/resource/propagationpolicy/detail.go b/pkg/resource/propagationpolicy/detail.go index 89d9e237..66c4e6b7 100644 --- a/pkg/resource/propagationpolicy/detail.go +++ b/pkg/resource/propagationpolicy/detail.go @@ -18,10 +18,12 @@ package propagationpolicy import ( "context" - "github.com/karmada-io/dashboard/pkg/common/errors" + "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1" karmadaclientset "github.com/karmada-io/karmada/pkg/generated/clientset/versioned" metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/karmada-io/dashboard/pkg/common/errors" ) // PropagationPolicyDetail is a presentation layer view of Karmada PropagationPolicy resource. This means it is PropagationPolicy plus diff --git a/pkg/resource/propagationpolicy/list.go b/pkg/resource/propagationpolicy/list.go index 771af223..eda09bec 100644 --- a/pkg/resource/propagationpolicy/list.go +++ b/pkg/resource/propagationpolicy/list.go @@ -19,18 +19,20 @@ package propagationpolicy import ( "context" "fmt" - "github.com/karmada-io/dashboard/pkg/common/errors" - "github.com/karmada-io/dashboard/pkg/common/helpers" - "github.com/karmada-io/dashboard/pkg/common/types" - "github.com/karmada-io/dashboard/pkg/dataselect" - "github.com/karmada-io/dashboard/pkg/resource/common" + "log" + "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1" karmadaclientset "github.com/karmada-io/karmada/pkg/generated/clientset/versioned" "github.com/samber/lo" appsv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" - "log" + + "github.com/karmada-io/dashboard/pkg/common/errors" + "github.com/karmada-io/dashboard/pkg/common/helpers" + "github.com/karmada-io/dashboard/pkg/common/types" + "github.com/karmada-io/dashboard/pkg/dataselect" + "github.com/karmada-io/dashboard/pkg/resource/common" ) // PropagationPolicyList contains a list of propagation in the karmada control-plance. diff --git a/pkg/resource/secret/common.go b/pkg/resource/secret/common.go index 77b135cf..24ac3114 100644 --- a/pkg/resource/secret/common.go +++ b/pkg/resource/secret/common.go @@ -17,8 +17,9 @@ limitations under the License. package secret import ( - "github.com/karmada-io/dashboard/pkg/dataselect" api "k8s.io/api/core/v1" + + "github.com/karmada-io/dashboard/pkg/dataselect" ) type SecretCell api.Secret diff --git a/pkg/resource/secret/list.go b/pkg/resource/secret/list.go index c38bdbb4..a3e561e2 100644 --- a/pkg/resource/secret/list.go +++ b/pkg/resource/secret/list.go @@ -18,16 +18,17 @@ package secret import ( "context" - "github.com/karmada-io/dashboard/pkg/common/errors" - "github.com/karmada-io/dashboard/pkg/common/helpers" - "github.com/karmada-io/dashboard/pkg/common/types" - "github.com/karmada-io/dashboard/pkg/dataselect" - "github.com/karmada-io/dashboard/pkg/resource/common" "log" v1 "k8s.io/api/core/v1" metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" + + "github.com/karmada-io/dashboard/pkg/common/errors" + "github.com/karmada-io/dashboard/pkg/common/helpers" + "github.com/karmada-io/dashboard/pkg/common/types" + "github.com/karmada-io/dashboard/pkg/dataselect" + "github.com/karmada-io/dashboard/pkg/resource/common" ) // SecretSpec is a common interface for the specification of different secrets. diff --git a/pkg/resource/service/common.go b/pkg/resource/service/common.go index 67580b18..b1b8106d 100644 --- a/pkg/resource/service/common.go +++ b/pkg/resource/service/common.go @@ -17,8 +17,9 @@ limitations under the License. package service import ( - "github.com/karmada-io/dashboard/pkg/dataselect" v1 "k8s.io/api/core/v1" + + "github.com/karmada-io/dashboard/pkg/dataselect" ) // The code below allows to perform complex data section on []api.Service diff --git a/pkg/resource/service/detail.go b/pkg/resource/service/detail.go index 7002b6f5..d2a45928 100644 --- a/pkg/resource/service/detail.go +++ b/pkg/resource/service/detail.go @@ -18,12 +18,14 @@ package service import ( "context" - "github.com/karmada-io/dashboard/pkg/common/errors" - "github.com/karmada-io/dashboard/pkg/resource/endpoint" + "log" + v1 "k8s.io/api/core/v1" metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1" k8sClient "k8s.io/client-go/kubernetes" - "log" + + "github.com/karmada-io/dashboard/pkg/common/errors" + "github.com/karmada-io/dashboard/pkg/resource/endpoint" ) // Service is a representation of a service. diff --git a/pkg/resource/service/events.go b/pkg/resource/service/events.go index 539eefac..e4234947 100644 --- a/pkg/resource/service/events.go +++ b/pkg/resource/service/events.go @@ -17,13 +17,14 @@ limitations under the License. package service import ( + "log" + + client "k8s.io/client-go/kubernetes" + "github.com/karmada-io/dashboard/pkg/common/types" "github.com/karmada-io/dashboard/pkg/dataselect" "github.com/karmada-io/dashboard/pkg/resource/common" "github.com/karmada-io/dashboard/pkg/resource/event" - "log" - - client "k8s.io/client-go/kubernetes" ) // GetServiceEvents returns model events for a service with the given name in the given namespace. diff --git a/pkg/resource/service/list.go b/pkg/resource/service/list.go index 9c127cda..6396f3e1 100644 --- a/pkg/resource/service/list.go +++ b/pkg/resource/service/list.go @@ -17,13 +17,15 @@ limitations under the License. package service import ( + "log" + + v1 "k8s.io/api/core/v1" + client "k8s.io/client-go/kubernetes" + "github.com/karmada-io/dashboard/pkg/common/errors" "github.com/karmada-io/dashboard/pkg/common/types" "github.com/karmada-io/dashboard/pkg/dataselect" "github.com/karmada-io/dashboard/pkg/resource/common" - v1 "k8s.io/api/core/v1" - client "k8s.io/client-go/kubernetes" - "log" ) // Service is a representation of a service. diff --git a/pkg/resource/statefulset/common.go b/pkg/resource/statefulset/common.go index d8030d6f..3d6cd84c 100644 --- a/pkg/resource/statefulset/common.go +++ b/pkg/resource/statefulset/common.go @@ -17,11 +17,12 @@ limitations under the License. package statefulset import ( + apps "k8s.io/api/apps/v1" + v1 "k8s.io/api/core/v1" + "github.com/karmada-io/dashboard/pkg/dataselect" "github.com/karmada-io/dashboard/pkg/resource/common" "github.com/karmada-io/dashboard/pkg/resource/event" - apps "k8s.io/api/apps/v1" - v1 "k8s.io/api/core/v1" ) // The code below allows to perform complex data section on []apps.StatefulSet diff --git a/pkg/resource/statefulset/detail.go b/pkg/resource/statefulset/detail.go index a54cfb59..3a76d3ef 100644 --- a/pkg/resource/statefulset/detail.go +++ b/pkg/resource/statefulset/detail.go @@ -18,12 +18,14 @@ package statefulset import ( "context" - "github.com/karmada-io/dashboard/pkg/common/errors" - "github.com/karmada-io/dashboard/pkg/resource/common" + "log" + apps "k8s.io/api/apps/v1" metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" - "log" + + "github.com/karmada-io/dashboard/pkg/common/errors" + "github.com/karmada-io/dashboard/pkg/resource/common" ) // StatefulSetDetail is a presentation layer view of Kubernetes Stateful Set resource. This means it is Stateful diff --git a/pkg/resource/statefulset/list.go b/pkg/resource/statefulset/list.go index 4a980449..2921e7e3 100644 --- a/pkg/resource/statefulset/list.go +++ b/pkg/resource/statefulset/list.go @@ -17,15 +17,17 @@ limitations under the License. package statefulset import ( + "log" + + apps "k8s.io/api/apps/v1" + v1 "k8s.io/api/core/v1" + "k8s.io/client-go/kubernetes" + "github.com/karmada-io/dashboard/pkg/common/errors" "github.com/karmada-io/dashboard/pkg/common/types" "github.com/karmada-io/dashboard/pkg/dataselect" "github.com/karmada-io/dashboard/pkg/resource/common" "github.com/karmada-io/dashboard/pkg/resource/event" - apps "k8s.io/api/apps/v1" - v1 "k8s.io/api/core/v1" - "k8s.io/client-go/kubernetes" - "log" ) // StatefulSetList contains a list of Stateful Sets in the cluster. diff --git a/pkg/resource/statefulset/pods.go b/pkg/resource/statefulset/pods.go index f1b773cb..f42e7acd 100644 --- a/pkg/resource/statefulset/pods.go +++ b/pkg/resource/statefulset/pods.go @@ -18,11 +18,13 @@ package statefulset import ( "context" - "github.com/karmada-io/dashboard/pkg/resource/common" + apps "k8s.io/api/apps/v1" v1 "k8s.io/api/core/v1" metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" + + "github.com/karmada-io/dashboard/pkg/resource/common" ) // getRawStatefulSetPods return array of api pods targeting pet set with given name.