Skip to content

Commit

Permalink
style: imports
Browse files Browse the repository at this point in the history
Signed-off-by: Chin-Ya Huang <[email protected]>
  • Loading branch information
c3y1huang authored and David Ko committed Oct 19, 2023
1 parent 286e6e6 commit c93aea9
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 34 deletions.
6 changes: 4 additions & 2 deletions metrics_collector/disk_collector.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package metricscollector

import (
longhorn "github.com/longhorn/longhorn-manager/k8s/pkg/apis/longhorn/v1beta2"
"strings"

"github.com/prometheus/client_golang/prometheus"
"github.com/sirupsen/logrus"
"strings"

"github.com/longhorn/longhorn-manager/datastore"

longhorn "github.com/longhorn/longhorn-manager/k8s/pkg/apis/longhorn/v1beta2"
)

type DiskCollector struct {
Expand Down
19 changes: 10 additions & 9 deletions upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,25 @@ import (
"github.com/sirupsen/logrus"
"golang.org/x/mod/semver"

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"
clientset "k8s.io/client-go/kubernetes"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/tools/leaderelection"
"k8s.io/client-go/tools/leaderelection/resourcelock"

longhorn "github.com/longhorn/longhorn-manager/k8s/pkg/apis/longhorn/v1beta2"
lhclientset "github.com/longhorn/longhorn-manager/k8s/pkg/client/clientset/versioned"
"github.com/longhorn/longhorn-manager/types"
upgradeutil "github.com/longhorn/longhorn-manager/upgrade/util"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clientset "k8s.io/client-go/kubernetes"
restclient "k8s.io/client-go/rest"

"github.com/longhorn/longhorn-manager/meta"
"github.com/longhorn/longhorn-manager/types"
"github.com/longhorn/longhorn-manager/upgrade/v15xto160"
"github.com/longhorn/longhorn-manager/upgrade/v1beta1"

longhorn "github.com/longhorn/longhorn-manager/k8s/pkg/apis/longhorn/v1beta2"
lhclientset "github.com/longhorn/longhorn-manager/k8s/pkg/client/clientset/versioned"
upgradeutil "github.com/longhorn/longhorn-manager/upgrade/util"
)

const (
Expand Down
16 changes: 9 additions & 7 deletions upgrade/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@ import (
"github.com/pkg/errors"
"github.com/sirupsen/logrus"

v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/labels"

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/labels"
clientset "k8s.io/client-go/kubernetes"

longhorn "github.com/longhorn/longhorn-manager/k8s/pkg/apis/longhorn/v1beta2"
lhclientset "github.com/longhorn/longhorn-manager/k8s/pkg/client/clientset/versioned"
"github.com/longhorn/longhorn-manager/meta"
"github.com/longhorn/longhorn-manager/types"

longhorn "github.com/longhorn/longhorn-manager/k8s/pkg/apis/longhorn/v1beta2"
lhclientset "github.com/longhorn/longhorn-manager/k8s/pkg/client/clientset/versioned"
)

const (
Expand Down Expand Up @@ -90,7 +92,7 @@ func (pm *ProgressMonitor) GetCurrentProgress() (int, int, float64) {
return pm.currentValue, pm.targetValue, pm.currentProgressInPercentage
}

func ListShareManagerPods(namespace string, kubeClient *clientset.Clientset) ([]v1.Pod, error) {
func ListShareManagerPods(namespace string, kubeClient *clientset.Clientset) ([]corev1.Pod, error) {
smPodsList, err := kubeClient.CoreV1().Pods(namespace).List(context.Background(), metav1.ListOptions{
LabelSelector: labels.Set(types.GetShareManagerComponentLabel()).String(),
})
Expand All @@ -100,7 +102,7 @@ func ListShareManagerPods(namespace string, kubeClient *clientset.Clientset) ([]
return smPodsList.Items, nil
}

func ListIMPods(namespace string, kubeClient *clientset.Clientset) ([]v1.Pod, error) {
func ListIMPods(namespace string, kubeClient *clientset.Clientset) ([]corev1.Pod, error) {
imPodsList, err := kubeClient.CoreV1().Pods(namespace).List(context.Background(), metav1.ListOptions{
LabelSelector: fmt.Sprintf("%s=%s", types.GetLonghornLabelComponentKey(), types.LonghornLabelInstanceManager),
})
Expand All @@ -110,7 +112,7 @@ func ListIMPods(namespace string, kubeClient *clientset.Clientset) ([]v1.Pod, er
return imPodsList.Items, nil
}

func ListManagerPods(namespace string, kubeClient *clientset.Clientset) ([]v1.Pod, error) {
func ListManagerPods(namespace string, kubeClient *clientset.Clientset) ([]corev1.Pod, error) {
managerPodsList, err := kubeClient.CoreV1().Pods(namespace).List(context.TODO(), metav1.ListOptions{
LabelSelector: labels.Set(types.GetManagerLabels()).String(),
})
Expand Down
8 changes: 4 additions & 4 deletions upgrade/util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import (
"sync"
"testing"

"github.com/stretchr/testify/require"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

longhorn "github.com/longhorn/longhorn-manager/k8s/pkg/apis/longhorn/v1beta2"
lhclientset "github.com/longhorn/longhorn-manager/k8s/pkg/client/clientset/versioned"
"github.com/longhorn/longhorn-manager/meta"
"github.com/longhorn/longhorn-manager/types"

longhorn "github.com/longhorn/longhorn-manager/k8s/pkg/apis/longhorn/v1beta2"
lhclientset "github.com/longhorn/longhorn-manager/k8s/pkg/client/clientset/versioned"
lhfake "github.com/longhorn/longhorn-manager/k8s/pkg/client/clientset/versioned/fake"

"github.com/stretchr/testify/require"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion upgrade/v15xto160/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clientset "k8s.io/client-go/kubernetes"

"github.com/longhorn/longhorn-manager/types"

longhorn "github.com/longhorn/longhorn-manager/k8s/pkg/apis/longhorn/v1beta2"
lhclientset "github.com/longhorn/longhorn-manager/k8s/pkg/client/clientset/versioned"
"github.com/longhorn/longhorn-manager/types"
upgradeutil "github.com/longhorn/longhorn-manager/upgrade/util"
)

Expand Down
6 changes: 4 additions & 2 deletions upgrade/v1beta1/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ import (
"github.com/pkg/errors"
"github.com/sirupsen/logrus"

"k8s.io/apimachinery/pkg/runtime"

apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
restclient "k8s.io/client-go/rest"

"github.com/longhorn/longhorn-manager/types"

longhornV1beta1 "github.com/longhorn/longhorn-manager/k8s/pkg/apis/longhorn/v1beta1"
lhclientset "github.com/longhorn/longhorn-manager/k8s/pkg/client/clientset/versioned"
"github.com/longhorn/longhorn-manager/types"
)

const (
Expand Down
10 changes: 6 additions & 4 deletions util/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import (
"github.com/rancher/wrangler/pkg/clients"
"github.com/rancher/wrangler/pkg/schemes"

v1 "k8s.io/api/apps/v1"
apiextensionsclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
"k8s.io/client-go/informers"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"

corev1 "k8s.io/api/apps/v1"
apiextensionsclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
clientset "k8s.io/client-go/kubernetes"

"github.com/longhorn/longhorn-manager/datastore"

lhclientset "github.com/longhorn/longhorn-manager/k8s/pkg/client/clientset/versioned"
lhinformers "github.com/longhorn/longhorn-manager/k8s/pkg/client/informers/externalversions"
)
Expand All @@ -26,7 +28,7 @@ type Client struct {
}

func NewClient(ctx context.Context, config *rest.Config, namespace string, needDataStore bool) (*Client, error) {
if err := schemes.Register(v1.AddToScheme); err != nil {
if err := schemes.Register(corev1.AddToScheme); err != nil {
return nil, err
}

Expand Down
3 changes: 2 additions & 1 deletion util/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package util

import (
"bufio"
"github.com/pkg/errors"
"os/exec"
"strings"

"github.com/pkg/errors"
)

func CmdOutLines(cmd *exec.Cmd, cancel <-chan interface{}) (<-chan string, <-chan error) {
Expand Down
3 changes: 2 additions & 1 deletion util/daemon/daemon.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package daemon

import (
"github.com/sirupsen/logrus"
"os"
"os/signal"
"syscall"

"github.com/sirupsen/logrus"
)

func WaitForExit() error {
Expand Down
7 changes: 4 additions & 3 deletions util/server/server.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package server

import (
"github.com/docker/go-connections/sockets"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"net/http"
"os"
"path/filepath"

"github.com/docker/go-connections/sockets"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)

type UnixServer struct {
Expand Down

0 comments on commit c93aea9

Please sign in to comment.