From 349db2dce8ddf689f873bb460907043c5a30ec34 Mon Sep 17 00:00:00 2001 From: rainzm Date: Sun, 17 Jan 2021 19:23:58 +0800 Subject: [PATCH] feat(keystone): add options to set admin and domain admin role to notify --- pkg/keystone/driver/sql/sql.go | 4 ++-- pkg/keystone/options/options.go | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/keystone/driver/sql/sql.go b/pkg/keystone/driver/sql/sql.go index 86a88b3284..cc596bbeec 100644 --- a/pkg/keystone/driver/sql/sql.go +++ b/pkg/keystone/driver/sql/sql.go @@ -131,7 +131,7 @@ func fetchRoleId(name string) (string, error) { } func getAdminUserIds() ([]string, error) { - return getUserIdsWithRole("admin", "") + return getUserIdsWithRole(o.Options.AdminRoleToNotify, "") } func getUserIdsWithRole(roleName string, domainId string) ([]string, error) { @@ -152,7 +152,7 @@ func getUserIdsWithRole(roleName string, domainId string) ([]string, error) { } func getDomainAdminUserIds(domainId string) ([]string, error) { - return getUserIdsWithRole("domainadmin", domainId) + return getUserIdsWithRole(o.Options.DomainAdminRoleToNotify, domainId) } func (sql *SSQLDriver) Sync(ctx context.Context) error { diff --git a/pkg/keystone/options/options.go b/pkg/keystone/options/options.go index 3073134ec1..3eaaadaf9b 100644 --- a/pkg/keystone/options/options.go +++ b/pkg/keystone/options/options.go @@ -56,6 +56,9 @@ type SKeystoneOptions struct { AllowJoinProjectsAcrossDomains bool `help:"allow users/groups to join projects across domains" default:"false"` DefaultUserLanguage string `help:"default user language, default to zh-CN" default:"zh-CN"` + + DomainAdminRoleToNotify string `help:"domain admin role to notify" default:"domainadmin"` + AdminRoleToNotify string `help:"admin role to notify" default:"admin"` } var (