Merge pull request #4 from zalando-incubator/disable_teams_api_db_access_flags

Allow disabling access to the DB and the Teams API.

Command-line options --nodatabaseaccess and --noteamsapi disable all
teams api interaction and access to the Postgres database. This is
useful for debugging purposes when the operator runs out of cluster
(with --outofcluster flag).

The same effect can be achieved by setting enable_db_access and/or
enable_teams_api to false.
This commit is contained in:
Oleksii Kliukin
2017-05-12 17:52:34 +02:00
committed by GitHub
9 changed files with 57 additions and 31 deletions
+15 -5
View File
@@ -15,16 +15,20 @@ import (
)
var (
KubeConfigFile string
podNamespace string
configMapName spec.NamespacedName
OutOfCluster bool
version string
KubeConfigFile string
podNamespace string
configMapName spec.NamespacedName
OutOfCluster bool
noTeamsAPI bool
noDatabaseAccess bool
version string
)
func init() {
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(&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.Parse()
podNamespace = os.Getenv("MY_POD_NAMESPACE")
@@ -87,6 +91,12 @@ func main() {
if configMapData["namespace"] == "" { // Namespace in ConfigMap has priority over env var
configMapData["namespace"] = podNamespace
}
if noDatabaseAccess {
configMapData["enable_database_access"] = "false"
}
if noTeamsAPI {
configMapData["enable_teams_api"] = "false"
}
cfg := config.NewFromMap(configMapData)
log.Printf("Config: %s", cfg.MustMarshal())