mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-07 17:39:34 +02:00
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:
@@ -52,6 +52,8 @@ type Config struct {
|
||||
WALES3Bucket string `name:"wal_s3_bucket"`
|
||||
KubeIAMRole string `name:"kube_iam_role"`
|
||||
DebugLogging bool `name:"debug_logging" default:"false"`
|
||||
EnableDBAccess bool `name:"enable_db_access" default:"true"`
|
||||
EnableTeamsAPI bool `name:"enable_teams_api" default:"true"`
|
||||
DNSNameFormat string `name:"dns_name_format" default:"%s.%s.%s"`
|
||||
Workers uint32 `name:"workers" default:"4"`
|
||||
}
|
||||
|
||||
@@ -42,13 +42,15 @@ type TeamsAPI struct {
|
||||
httpClient *http.Client
|
||||
logger *logrus.Entry
|
||||
RefreshTokenAction func() (string, error)
|
||||
enabled bool
|
||||
}
|
||||
|
||||
func NewTeamsAPI(url string, log *logrus.Logger) *TeamsAPI {
|
||||
func NewTeamsAPI(url string, log *logrus.Logger, enabled bool) *TeamsAPI {
|
||||
t := TeamsAPI{
|
||||
url: strings.TrimRight(url, "/"),
|
||||
httpClient: &http.Client{},
|
||||
logger: log.WithField("pkg", "teamsapi"),
|
||||
enabled: enabled,
|
||||
}
|
||||
|
||||
return &t
|
||||
@@ -56,6 +58,10 @@ func NewTeamsAPI(url string, log *logrus.Logger) *TeamsAPI {
|
||||
|
||||
func (t *TeamsAPI) TeamInfo(teamId string) (*Team, error) {
|
||||
// TODO: avoid getting a new token on every call to the Teams API.
|
||||
if !t.enabled {
|
||||
t.logger.Debug("Team API is disabled, returning empty list of members")
|
||||
return &Team{}, nil
|
||||
}
|
||||
token, err := t.RefreshTokenAction()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user