mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-19 09:45:22 +02:00
remove unnecessary vars and funcs
This commit is contained in:
+23
-30
@@ -9,54 +9,41 @@ 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"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
KubeConfigFile string
|
KubeConfigFile string
|
||||||
podNamespace string
|
OutOfCluster bool
|
||||||
configMapName spec.NamespacedName
|
version string
|
||||||
OutOfCluster bool
|
|
||||||
noTeamsAPI bool
|
config controller.Config
|
||||||
noDatabaseAccess bool
|
|
||||||
version string
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
flag.StringVar(&KubeConfigFile, "kubeconfig", "", "Path to kubeconfig file with authorization and master location information.")
|
flag.StringVar(&KubeConfigFile, "kubeconfig", "", "Path to kubeconfig file with authorization and master location information.")
|
||||||
flag.BoolVar(&OutOfCluster, "outofcluster", false, "Whether the operator runs in- our outside of the Kubernetes cluster.")
|
flag.BoolVar(&OutOfCluster, "outofcluster", false, "Whether the operator runs in- our outside of the Kubernetes cluster.")
|
||||||
flag.BoolVar(&noDatabaseAccess, "nodatabaseaccess", false, "Disable all access to the database from the operator side.")
|
flag.BoolVar(&config.NoDatabaseAccess, "nodatabaseaccess", false, "Disable all access to the database from the operator side.")
|
||||||
flag.BoolVar(&noTeamsAPI, "noteamsapi", false, "Disable all access to the teams API")
|
flag.BoolVar(&config.NoTeamsAPI, "noteamsapi", false, "Disable all access to the teams API")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
podNamespace = os.Getenv("MY_POD_NAMESPACE")
|
config.Namespace = os.Getenv("MY_POD_NAMESPACE")
|
||||||
if podNamespace == "" {
|
if config.Namespace == "" {
|
||||||
podNamespace = "default"
|
config.Namespace = "default"
|
||||||
}
|
}
|
||||||
|
|
||||||
configMap := os.Getenv("CONFIG_MAP_NAME")
|
configMap := os.Getenv("CONFIG_MAP_NAME")
|
||||||
if configMap != "" {
|
if configMap != "" {
|
||||||
configMapName.Decode(configMap)
|
err := config.ConfigMapName.Decode(configMap)
|
||||||
}
|
if err != nil {
|
||||||
}
|
log.Fatalf("incorrect config map name")
|
||||||
|
}
|
||||||
func ControllerConfig() *controller.Config {
|
|
||||||
restConfig, err := k8sutil.RestConfig(KubeConfigFile, OutOfCluster)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("couldn't get REST config: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &controller.Config{
|
|
||||||
RestConfig: restConfig,
|
|
||||||
NoDatabaseAccess: noDatabaseAccess,
|
|
||||||
NoTeamsAPI: noTeamsAPI,
|
|
||||||
ConfigMapName: configMapName,
|
|
||||||
Namespace: podNamespace,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
var err error
|
||||||
|
|
||||||
log.SetOutput(os.Stdout)
|
log.SetOutput(os.Stdout)
|
||||||
log.Printf("Spilo operator %s\n", version)
|
log.Printf("Spilo operator %s\n", version)
|
||||||
|
|
||||||
@@ -66,7 +53,13 @@ func main() {
|
|||||||
|
|
||||||
wg := &sync.WaitGroup{} // Goroutines can add themselves to this to be waited on
|
wg := &sync.WaitGroup{} // Goroutines can add themselves to this to be waited on
|
||||||
|
|
||||||
c := controller.New(ControllerConfig())
|
config.RestConfig, err = k8sutil.RestConfig(KubeConfigFile, OutOfCluster)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("couldn't get REST config: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
c := controller.New(&config)
|
||||||
|
|
||||||
c.Run(stop, wg)
|
c.Run(stop, wg)
|
||||||
|
|
||||||
sig := <-sigs
|
sig := <-sigs
|
||||||
|
|||||||
Reference in New Issue
Block a user