From e9529ede44a71b34a7dd65bdfaaf9956d3f936cf Mon Sep 17 00:00:00 2001 From: Alex Crawford Date: Tue, 20 Jan 2015 13:45:52 -0800 Subject: [PATCH] config: add support for multiple github users --- config/user.go | 27 ++++++++++++++------------- initialize/config.go | 6 ++++++ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/config/user.go b/config/user.go index 44e959c..2bd22aa 100644 --- a/config/user.go +++ b/config/user.go @@ -17,17 +17,18 @@ package config type User struct { - Name string `yaml:"name"` - PasswordHash string `yaml:"passwd"` - SSHAuthorizedKeys []string `yaml:"ssh_authorized_keys"` - SSHImportGithubUser string `yaml:"coreos_ssh_import_github"` - SSHImportURL string `yaml:"coreos_ssh_import_url"` - GECOS string `yaml:"gecos"` - Homedir string `yaml:"homedir"` - NoCreateHome bool `yaml:"no_create_home"` - PrimaryGroup string `yaml:"primary_group"` - Groups []string `yaml:"groups"` - NoUserGroup bool `yaml:"no_user_group"` - System bool `yaml:"system"` - NoLogInit bool `yaml:"no_log_init"` + Name string `yaml:"name"` + PasswordHash string `yaml:"passwd"` + SSHAuthorizedKeys []string `yaml:"ssh_authorized_keys"` + SSHImportGithubUser string `yaml:"coreos_ssh_import_github"` + SSHImportGithubUsers []string `yaml:"coreos_ssh_import_github_users"` + SSHImportURL string `yaml:"coreos_ssh_import_url"` + GECOS string `yaml:"gecos"` + Homedir string `yaml:"homedir"` + NoCreateHome bool `yaml:"no_create_home"` + PrimaryGroup string `yaml:"primary_group"` + Groups []string `yaml:"groups"` + NoUserGroup bool `yaml:"no_user_group"` + System bool `yaml:"system"` + NoLogInit bool `yaml:"no_log_init"` } diff --git a/initialize/config.go b/initialize/config.go index 034ba97..c9b2069 100644 --- a/initialize/config.go +++ b/initialize/config.go @@ -87,6 +87,12 @@ func Apply(cfg config.CloudConfig, env *Environment) error { return err } } + for _, u := range user.SSHImportGithubUsers { + log.Printf("Authorizing github user %s SSH keys for CoreOS user '%s'", u, user.Name) + if err := SSHImportGithubUser(user.Name, u); err != nil { + return err + } + } if user.SSHImportURL != "" { log.Printf("Authorizing SSH keys for CoreOS user '%s' from '%s'", user.Name, user.SSHImportURL) if err := SSHImportKeysFromURL(user.Name, user.SSHImportURL); err != nil {