Merge pull request #13425 from wy65701436/robot-prefix

add robot name prefix
This commit is contained in:
stonezdj(Daojun Zhang) 2020-11-04 11:48:42 +08:00 committed by GitHub
commit 7c1ad11763
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 0 deletions

View File

@ -151,6 +151,7 @@ var (
{Name: common.WithNotary, Scope: SystemScope, Group: BasicGroup, EnvKey: "WITH_NOTARY", DefaultValue: "false", ItemType: &BoolType{}, Editable: true},
// the unit of expiration is minute, 43200 minutes = 30 days
{Name: common.RobotTokenDuration, Scope: UserScope, Group: BasicGroup, EnvKey: "ROBOT_TOKEN_DURATION", DefaultValue: "43200", ItemType: &IntType{}, Editable: true},
{Name: common.RobotNamePrefix, Scope: UserScope, Group: BasicGroup, EnvKey: "ROBOT_NAME_PREFIX", DefaultValue: "robot$", ItemType: &StringType{}, Editable: true},
{Name: common.NotificationEnable, Scope: UserScope, Group: BasicGroup, EnvKey: "NOTIFICATION_ENABLE", DefaultValue: "true", ItemType: &BoolType{}, Editable: true},
{Name: common.MetricEnable, Scope: SystemScope, Group: BasicGroup, EnvKey: "METRIC_ENABLE", DefaultValue: "false", ItemType: &BoolType{}, Editable: true},
{Name: common.MetricPort, Scope: SystemScope, Group: BasicGroup, EnvKey: "METRIC_PORT", DefaultValue: "9090", ItemType: &IntType{}, Editable: true},

View File

@ -136,6 +136,8 @@ const (
DefaultRegistryCtlURL = "http://registryctl:8080"
// Use this prefix to distinguish harbor user, the prefix contains a special character($), so it cannot be registered as a harbor user.
RobotPrefix = "robot$"
// System admin defined the robot name prefix.
RobotNamePrefix = "robot_name_prefix"
// Use this prefix to index user who tries to login with web hook token.
AuthProxyUserNamePrefix = "tokenreview$"
CoreConfigPath = "/api/internal/configurations"

View File

@ -64,6 +64,7 @@ var defaultConfig = map[string]interface{}{
common.JobServiceURL: "http://myjob:8888/",
common.ReadOnly: false,
common.NotaryURL: "http://notary-server:4443",
common.RobotNamePrefix: "robot$",
}
// GetDefaultConfigMap returns the defailt config map for easier modification.

View File

@ -128,6 +128,7 @@ func GetUnitTestConfig() map[string]interface{} {
common.TokenServiceURL: "http://core:8080/service/token",
common.RegistryURL: fmt.Sprintf("http://%s:5000", ipAddress),
common.ReadOnly: false,
common.RobotNamePrefix: "robot$",
}
}

View File

@ -488,6 +488,11 @@ func GetGCTimeWindow() int64 {
return common.DefaultGCTimeWindowHours
}
// RobotPrefix user defined robot name prefix.
func RobotPrefix() string {
return cfgMgr.Get(common.RobotNamePrefix).GetString()
}
// Metric returns the overall metric settings
func Metric() *models.Metric {
return &models.Metric{

View File

@ -190,6 +190,7 @@ func TestConfig(t *testing.T) {
assert.True(NotificationEnable())
assert.Equal(int64(0), GetGCTimeWindow())
assert.Equal("robot$", RobotPrefix())
}