Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
postgres-operator
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
zalando
postgres-operator
Commits
58572bb4
Commit
58572bb4
authored
Aug 15, 2017
by
Murat Kabilov
Browse files
Options
Downloads
Patches
Plain Diff
move controller config to the spec package
parent
606d0000
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
cmd/main.go
+2
-1
2 additions, 1 deletion
cmd/main.go
pkg/controller/controller.go
+6
-16
6 additions, 16 deletions
pkg/controller/controller.go
pkg/controller/util_test.go
+1
-1
1 addition, 1 deletion
pkg/controller/util_test.go
pkg/spec/types.go
+12
-0
12 additions, 0 deletions
pkg/spec/types.go
with
21 additions
and
18 deletions
cmd/main.go
+
2
−
1
View file @
58572bb4
...
@@ -9,6 +9,7 @@ import (
...
@@ -9,6 +9,7 @@ import (
"syscall"
"syscall"
"github.com/zalando-incubator/postgres-operator/pkg/controller"
"github.com/zalando-incubator/postgres-operator/pkg/controller"
"github.com/zalando-incubator/postgres-operator/pkg/spec"
"github.com/zalando-incubator/postgres-operator/pkg/util/k8sutil"
"github.com/zalando-incubator/postgres-operator/pkg/util/k8sutil"
)
)
...
@@ -16,7 +17,7 @@ var (
...
@@ -16,7 +17,7 @@ var (
kubeConfigFile
string
kubeConfigFile
string
outOfCluster
bool
outOfCluster
bool
version
string
version
string
config
c
ontroller
.
Config
config
spec
.
C
ontrollerConfig
)
)
func
init
()
{
func
init
()
{
...
...
This diff is collapsed.
Click to expand it.
pkg/controller/controller.go
+
6
−
16
View file @
58572bb4
...
@@ -17,20 +17,9 @@ import (
...
@@ -17,20 +17,9 @@ import (
"github.com/zalando-incubator/postgres-operator/pkg/util/k8sutil"
"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
NoDatabaseAccess
bool
NoTeamsAPI
bool
ConfigMapName
spec
.
NamespacedName
Namespace
string
}
// Controller represents operator controller
// Controller represents operator controller
type
Controller
struct
{
type
Controller
struct
{
config
Config
config
spec
.
Controller
Config
opConfig
*
config
.
Config
opConfig
*
config
.
Config
logger
*
logrus
.
Entry
logger
*
logrus
.
Entry
...
@@ -45,22 +34,23 @@ type Controller struct {
...
@@ -45,22 +34,23 @@ type Controller struct {
podInformer
cache
.
SharedIndexInformer
podInformer
cache
.
SharedIndexInformer
podCh
chan
spec
.
PodEvent
podCh
chan
spec
.
PodEvent
clusterEventQueues
[]
*
cache
.
FIFO
clusterEventQueues
[]
*
cache
.
FIFO
// [workerID]Queue
lastClusterSyncTime
int64
lastClusterSyncTime
int64
}
}
// NewController creates a new controller
// NewController creates a new controller
func
NewController
(
controllerConfig
*
Config
)
*
Controller
{
func
NewController
(
controllerConfig
*
spec
.
Controller
Config
)
*
Controller
{
logger
:=
logrus
.
New
()
logger
:=
logrus
.
New
()
return
&
Controller
{
c
:=
&
Controller
{
config
:
*
controllerConfig
,
config
:
*
controllerConfig
,
opConfig
:
&
config
.
Config
{},
opConfig
:
&
config
.
Config
{},
logger
:
logger
.
WithField
(
"pkg"
,
"controller"
),
logger
:
logger
.
WithField
(
"pkg"
,
"controller"
),
clusters
:
make
(
map
[
spec
.
NamespacedName
]
*
cluster
.
Cluster
),
clusters
:
make
(
map
[
spec
.
NamespacedName
]
*
cluster
.
Cluster
),
stopChs
:
make
(
map
[
spec
.
NamespacedName
]
chan
struct
{}),
podCh
:
make
(
chan
spec
.
PodEvent
),
podCh
:
make
(
chan
spec
.
PodEvent
),
}
}
return
c
}
}
func
(
c
*
Controller
)
initClients
()
{
func
(
c
*
Controller
)
initClients
()
{
...
...
This diff is collapsed.
Click to expand it.
pkg/controller/util_test.go
+
1
−
1
View file @
58572bb4
...
@@ -48,7 +48,7 @@ func newMockKubernetesClient() k8sutil.KubernetesClient {
...
@@ -48,7 +48,7 @@ func newMockKubernetesClient() k8sutil.KubernetesClient {
}
}
func
newMockController
()
*
Controller
{
func
newMockController
()
*
Controller
{
controller
:=
NewController
(
&
Config
{})
controller
:=
NewController
(
&
spec
.
Controller
Config
{})
controller
.
opConfig
.
ClusterNameLabel
=
"cluster-name"
controller
.
opConfig
.
ClusterNameLabel
=
"cluster-name"
controller
.
opConfig
.
InfrastructureRolesSecretName
=
controller
.
opConfig
.
InfrastructureRolesSecretName
=
spec
.
NamespacedName
{
Namespace
:
v1
.
NamespaceDefault
,
Name
:
testInfrastructureRolesSecretName
}
spec
.
NamespacedName
{
Namespace
:
v1
.
NamespaceDefault
,
Name
:
testInfrastructureRolesSecretName
}
...
...
This diff is collapsed.
Click to expand it.
pkg/spec/types.go
+
12
−
0
View file @
58572bb4
...
@@ -7,6 +7,7 @@ import (
...
@@ -7,6 +7,7 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/rest"
)
)
// EventType contains type of the events for the TPRs and Pods received from Kubernetes
// EventType contains type of the events for the TPRs and Pods received from Kubernetes
...
@@ -72,6 +73,17 @@ type UserSyncer interface {
...
@@ -72,6 +73,17 @@ type UserSyncer interface {
ExecuteSyncRequests
(
req
[]
PgSyncUserRequest
,
db
*
sql
.
DB
)
error
ExecuteSyncRequests
(
req
[]
PgSyncUserRequest
,
db
*
sql
.
DB
)
error
}
}
// ControllerConfig describes configuration of the controller
type
ControllerConfig
struct
{
RestConfig
*
rest
.
Config
`json:"-"`
InfrastructureRoles
map
[
string
]
PgUser
NoDatabaseAccess
bool
NoTeamsAPI
bool
ConfigMapName
NamespacedName
Namespace
string
}
func
(
n
NamespacedName
)
String
()
string
{
func
(
n
NamespacedName
)
String
()
string
{
return
types
.
NamespacedName
(
n
)
.
String
()
return
types
.
NamespacedName
(
n
)
.
String
()
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment