Skip to content

Commit

Permalink
change user key to "email" from "name" (#242)
Browse files Browse the repository at this point in the history
- change configuration user key from name to email to match the API
  • Loading branch information
BruceMacD committed Sep 14, 2021
1 parent 92ed620 commit c2a7a29
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ groups:
- web
users:
- name: admin@example.com # user email
- email: admin@example.com # user email
groups: # manually assign groups this user belongs to
- developers
roles:
Expand Down
8 changes: 4 additions & 4 deletions internal/registry/_testdata/infra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ groups:
- name: cluster-CCC

users:
- name: woz@example.com
- email: woz@example.com
groups:
- ios-developers
- mac-admins
- name: admin@example.com
- email: admin@example.com
roles:
- name: admin
kind: cluster-role
Expand All @@ -85,7 +85,7 @@ users:
- name: cluster-CCC
namespaces:
- infrahq
- name: user@example.com
- email: user@example.com
groups:
- ios-developers
roles:
Expand All @@ -94,7 +94,7 @@ users:
clusters:
- name: cluster-AAA
- name: cluster-UNKNOWN
- name: unknown@example.com
- email: unknown@example.com
groups:
- adversaries
roles:
Expand Down
4 changes: 2 additions & 2 deletions internal/registry/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type ConfigGroupMapping struct {
}

type ConfigUserMapping struct {
Name string `yaml:"name"`
Email string `yaml:"email"`
Roles []ConfigRoleKubernetes `yaml:"roles"`
Groups []string `yaml:"groups"`
}
Expand Down Expand Up @@ -153,7 +153,7 @@ func ApplyGroupMappings(db *gorm.DB, configGroups []ConfigGroupMapping) (groupId
func ApplyUserMapping(db *gorm.DB, users []ConfigUserMapping) error {
for _, u := range users {
var user User
usrReadErr := db.Where(&User{Email: u.Name}).First(&user).Error
usrReadErr := db.Where(&User{Email: u.Email}).First(&user).Error
if usrReadErr != nil {
if errors.Is(usrReadErr, gorm.ErrRecordNotFound) {
// skip this user, if they're created these roles will be added later
Expand Down

0 comments on commit c2a7a29

Please sign in to comment.