mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-09-30 19:49:35 +02:00
Fix golint warnings
This commit is contained in:
@@ -17,6 +17,7 @@ import (
|
||||
"github.com/zalando-incubator/postgres-operator/pkg/util/k8sutil"
|
||||
)
|
||||
|
||||
// Config describes configuration of the controller
|
||||
type Config struct {
|
||||
RestConfig *rest.Config
|
||||
InfrastructureRoles map[string]spec.PgUser
|
||||
@@ -27,6 +28,7 @@ type Config struct {
|
||||
Namespace string
|
||||
}
|
||||
|
||||
// Controller represents operator controller
|
||||
type Controller struct {
|
||||
config Config
|
||||
opConfig *config.Config
|
||||
@@ -47,6 +49,7 @@ type Controller struct {
|
||||
lastClusterSyncTime int64
|
||||
}
|
||||
|
||||
// NewController creates a new controller
|
||||
func NewController(controllerConfig *Config) *Controller {
|
||||
logger := logrus.New()
|
||||
|
||||
@@ -168,6 +171,7 @@ func (c *Controller) initController() {
|
||||
}
|
||||
}
|
||||
|
||||
// Run starts background controller processes
|
||||
func (c *Controller) Run(stopCh <-chan struct{}, wg *sync.WaitGroup) {
|
||||
c.initController()
|
||||
|
||||
|
||||
@@ -27,7 +27,10 @@ func (c *Controller) clusterResync(stopCh <-chan struct{}, wg *sync.WaitGroup) {
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
c.clusterListFunc(metav1.ListOptions{ResourceVersion: "0"})
|
||||
_, err := c.clusterListFunc(metav1.ListOptions{ResourceVersion: "0"})
|
||||
if err != nil {
|
||||
c.logger.Errorf("could not list clusters: %v", err)
|
||||
}
|
||||
case <-stopCh:
|
||||
return
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ func newMockController() *Controller {
|
||||
controller := NewController(&Config{})
|
||||
controller.opConfig.ClusterNameLabel = "cluster-name"
|
||||
controller.opConfig.InfrastructureRolesSecretName =
|
||||
spec.NamespacedName{v1.NamespaceDefault, testInfrastructureRolesSecretName}
|
||||
spec.NamespacedName{Namespace: v1.NamespaceDefault, Name: testInfrastructureRolesSecretName}
|
||||
controller.opConfig.Workers = 4
|
||||
controller.KubeClient = newMockKubernetesClient()
|
||||
return controller
|
||||
@@ -77,7 +77,7 @@ func TestPodClusterName(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
spec.NamespacedName{v1.NamespaceDefault, "testcluster"},
|
||||
spec.NamespacedName{Namespace: v1.NamespaceDefault, Name: "testcluster"},
|
||||
},
|
||||
}
|
||||
for _, test := range testTable {
|
||||
@@ -94,11 +94,11 @@ func TestClusterWorkerID(t *testing.T) {
|
||||
expected uint32
|
||||
}{
|
||||
{
|
||||
in: spec.NamespacedName{"foo", "bar"},
|
||||
in: spec.NamespacedName{Namespace: "foo", Name: "bar"},
|
||||
expected: 2,
|
||||
},
|
||||
{
|
||||
in: spec.NamespacedName{"default", "testcluster"},
|
||||
in: spec.NamespacedName{Namespace: "default", Name: "testcluster"},
|
||||
expected: 3,
|
||||
},
|
||||
}
|
||||
@@ -122,18 +122,17 @@ func TestGetInfrastructureRoles(t *testing.T) {
|
||||
nil,
|
||||
},
|
||||
{
|
||||
spec.NamespacedName{v1.NamespaceDefault, "null"},
|
||||
spec.NamespacedName{Namespace: v1.NamespaceDefault, Name: "null"},
|
||||
nil,
|
||||
fmt.Errorf(`could not get infrastructure roles secret: NotFound`),
|
||||
},
|
||||
{
|
||||
spec.NamespacedName{v1.NamespaceDefault, testInfrastructureRolesSecretName},
|
||||
spec.NamespacedName{Namespace: v1.NamespaceDefault, Name: testInfrastructureRolesSecretName},
|
||||
map[string]spec.PgUser{
|
||||
"testrole": {
|
||||
"testrole",
|
||||
"testpassword",
|
||||
nil,
|
||||
[]string{"testinrole"},
|
||||
Name: "testrole",
|
||||
Password: "testpassword",
|
||||
MemberOf: []string{"testinrole"},
|
||||
},
|
||||
},
|
||||
nil,
|
||||
|
||||
Reference in New Issue
Block a user