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:40:48 +02:00
parent fb007b1622
commit 03064637f1
7 changed files with 40 additions and 14 deletions
+10
View File
@@ -19,12 +19,16 @@ var (
podNamespace string
configMapName spec.NamespacedName
OutOfCluster bool
noTeamsAPI bool
noDBAccess 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(&noDBAccess, "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 noDBAccess {
configMapData["enable_db_access"] = "false"
}
if noTeamsAPI {
configMapData["enable_teams_api"] = "false"
}
cfg := config.NewFromMap(configMapData)
log.Printf("Config: %s", cfg.MustMarshal())