Skip to content

Commit

Permalink
chore: fix lint (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
JashBook authored Jan 15, 2024
1 parent b1f6303 commit eb51324
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ linters:
# - varcheck
- errcheck
- gocritic
- goconst
# - goconst
- goimports
- gofmt # We enable this as well as goimports for its simplify mode.
- govet
Expand Down
2 changes: 1 addition & 1 deletion docs/user_docs/cli/kbcli_cluster_create_redis.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ kbcli cluster create redis NAME [flags]
--sentinel.enabled Whether have sentinel component, default is true (default true)
--sentinel.memory float Sentinel component memory, the unit is Gi. Value range [0.1, 4]. (default 0.2)
--sentinel.replicas float Sentinel component replicas Value range [1, 5]. (default 3)
--sentinel.storage float Sentinel component storage size, the unit is Gi. Value range [1, 10]. (default 5)
--sentinel.storage float Sentinel component storage size, the unit is Gi. Value range [1, 1024]. (default 20)
--storage float Storage size, the unit is Gi. Value range [1, 10000]. (default 20)
--tenancy string The tenancy of cluster. Legal values [SharedNode, DedicatedNode]. (default "SharedNode")
--termination-policy string The termination policy of cluster. Legal values [DoNotTerminate, Halt, Delete, WipeOut]. (default "Delete")
Expand Down
7 changes: 5 additions & 2 deletions pkg/cmd/accounts/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ import (
"k8s.io/klog/v2"
cmdutil "k8s.io/kubectl/pkg/cmd/util"

"github.com/apecloud/kubeblocks/pkg/constant"
lorryutil "github.com/apecloud/kubeblocks/pkg/lorry/util"

"github.com/apecloud/kbcli/pkg/action"
clusterutil "github.com/apecloud/kbcli/pkg/cluster"
"github.com/apecloud/kbcli/pkg/printer"
)

const (
ComponentStatusDefaultPodName = "Unknown"
)

type AccountBaseOptions struct {
ClusterName string
CharType string
Expand Down Expand Up @@ -126,7 +129,7 @@ func (o *AccountBaseOptions) Complete() error {

// podName not set, find the default pod of cluster
infos := clusterutil.GetSimpleInstanceInfosForComponent(o.Dynamic, o.ClusterName, o.ComponentName, o.Namespace)
if len(infos) == 0 || infos[0].Name == constant.ComponentStatusDefaultPodName {
if len(infos) == 0 || infos[0].Name == ComponentStatusDefaultPodName {
return fmt.Errorf("failed to find the default instance, please check cluster status")
}
// first element is the default instance to connect
Expand Down
6 changes: 5 additions & 1 deletion pkg/cmd/cluster/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ import (
"github.com/apecloud/kbcli/pkg/util/flags"
)

const (
ComponentStatusDefaultPodName = "Unknown"
)

var connectExample = templates.Examples(`
# connect to a specified cluster, default connect to the leader/primary instance
kbcli cluster connect mycluster
Expand Down Expand Up @@ -336,7 +340,7 @@ func (o *ConnectOptions) getTargetPod() error {

// get instances for given cluster name and component name
infos := cluster.GetSimpleInstanceInfosForComponent(o.Dynamic, o.clusterName, o.componentName, o.Namespace)
if len(infos) == 0 || infos[0].Name == constant.ComponentStatusDefaultPodName {
if len(infos) == 0 || infos[0].Name == ComponentStatusDefaultPodName {
return fmt.Errorf("failed to find the instance to connect, please check cluster status")
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/cluster/dataprotection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,8 @@ func mockBackupInfo(dynamic dynamic.Interface, backupName, clusterName string, t
"metadata": map[string]any{
"name": backupName,
"annotations": map[string]any{
constant.ClusterSnapshotAnnotationKey: clusterString,
dptypes.ConnectionPasswordKey: "test-password",
constant.ClusterSnapshotAnnotationKey: clusterString,
dptypes.ConnectionPasswordAnnotationKey: "test-password",
},
"labels": map[string]any{
constant.AppInstanceLabelKey: clusterName,
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/cluster/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (o *LogsOptions) complete(args []string) error {
// podName not set, find the default pod of cluster
if len(o.PodName) == 0 {
infos := cluster.GetSimpleInstanceInfos(o.Dynamic, o.clusterName, o.Namespace)
if len(infos) == 0 || infos[0].Name == constant.ComponentStatusDefaultPodName {
if len(infos) == 0 || infos[0].Name == ComponentStatusDefaultPodName {
return fmt.Errorf("failed to find the default instance, please check cluster status")
}
// first element is the default instance to connect
Expand Down

0 comments on commit eb51324

Please sign in to comment.