Skip to content

Commit

Permalink
fix(storage):remove cluster dep
Browse files Browse the repository at this point in the history
Signed-off-by: soulseen <zhuxiaoyang1996@gmail.com>
  • Loading branch information
soulseen committed Nov 28, 2020
1 parent 22a6f22 commit d954eda
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 251 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/go-kit/kit v0.10.0
github.com/go-logr/logr v0.2.1-0.20200730175230-ee2de8da5be6
github.com/go-redis/redis v6.15.9+incompatible
github.com/goharbor/harbor-cluster-operator v0.5.0
github.com/goharbor/harbor-cluster-operator v0.5.0 // indirect
github.com/goharbor/harbor/src v0.0.0-20200728051037-1d361a89a056
github.com/google/go-cmp v0.5.1
github.com/huandu/xstrings v1.3.2 // indirect
Expand Down
3 changes: 2 additions & 1 deletion pkg/cluster/controllers/cache/resource_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/goharbor/harbor-operator/apis/goharbor.io/v1alpha2"
redisOp "github.com/spotahome/redis-operator/api/redisfailover/v1"
"github.com/goharbor/harbor-operator/pkg/cluster/controllers/common"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -127,7 +128,7 @@ func (rm *RedisResourceManager) GetSecretName() string {
// GetSecret gets redis secret.
func (rm *RedisResourceManager) GetSecret() *corev1.Secret {
name := rm.GetSecretName()
passStr := RandomString(8, "a")
passStr := common.RandomString(8, "a")
return &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Expand Down
34 changes: 0 additions & 34 deletions pkg/cluster/controllers/cache/utils.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
package cache

import (
"bytes"
"math/rand"
"strings"
"time"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/resource"
Expand Down Expand Up @@ -62,35 +57,6 @@ func MergeLabels(allLabels ...map[string]string) map[string]string {
return lb
}

// RandomString returns random string.
func RandomString(randLength int, randType string) (result string) {
var (
num = "0123456789"
lower = "abcdefghijklmnopqrstuvwxyz"
upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
)

b := bytes.Buffer{}
if strings.Contains(randType, "0") {
b.WriteString(num)
} else if strings.Contains(randType, "A") {
b.WriteString(upper)
} else {
b.WriteString(lower)
}

var str = b.String()
var strLen = len(str)

rand.Seed(time.Now().UnixNano())
b = bytes.Buffer{}
for i := 0; i < randLength; i++ {
b.WriteByte(str[rand.Intn(strLen)])
}
result = b.String()
return
}

// IsEqual check two object is equal.
func IsEqual(obj1, obj2 interface{}) bool {
return equality.Semantic.DeepEqual(obj1, obj2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@ import (
"time"
)

const (
UpperStringRandomType = "A"
LowerStringRandomType = "a"
NumberRandomType = "0"
)

// RandomString returns random string.
func RandomString(randLength int, randType string) (result string) {
var num = "0123456789"
var lower = "abcdefghijklmnopqrstuvwxyz"
var upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
var (
num = "0123456789"
lower = "abcdefghijklmnopqrstuvwxyz"
upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
)

b := bytes.Buffer{}
if strings.Contains(randType, "0") {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/controllers/storage/provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

"github.com/pkg/errors"

"github.com/goharbor/harbor-cluster-operator/controllers/common"
goharborv1 "github.com/goharbor/harbor-operator/apis/goharbor.io/v1alpha2"
"github.com/goharbor/harbor-operator/pkg/cluster/controllers/common"
minio "github.com/goharbor/harbor-operator/pkg/cluster/controllers/storage/minio/api/v1"
"github.com/goharbor/harbor-operator/pkg/cluster/lcm"
corev1 "k8s.io/api/core/v1"
Expand Down

This file was deleted.

201 changes: 0 additions & 201 deletions vendor/github.com/goharbor/harbor-cluster-operator/LICENSE

This file was deleted.

1 change: 0 additions & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ github.com/gogo/protobuf/proto
github.com/gogo/protobuf/sortkeys
# github.com/goharbor/harbor-cluster-operator v0.5.0
## explicit
github.com/goharbor/harbor-cluster-operator/controllers/common
# github.com/goharbor/harbor/src v0.0.0-20200728051037-1d361a89a056
## explicit
github.com/goharbor/harbor/src/common
Expand Down

0 comments on commit d954eda

Please sign in to comment.