forked from concourse/concourse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Be able to specify team worker without the need of restart Concourse c…
…oncourse#3551 Implementation of concourse#3551
- Loading branch information
Showing
5 changed files
with
131 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/github.com/concourse/flag/yaml_team_authorized_keys.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package flag | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
|
||
"gopkg.in/yaml.v2" | ||
) | ||
|
||
//type YamlTeamAuthorizedKeys []struct { | ||
// Team string `yaml:"team"` | ||
// //Keys []ssh.PublicKey `yaml:"ssh_keys,flow"` | ||
// Keys []string `yaml:"ssh_keys,flow"` | ||
//} | ||
type TeamAuthorizedKey struct { | ||
Team string `yaml:"team"` | ||
//Keys []ssh.PublicKey `yaml:"ssh_keys,flow"` | ||
Keys []string `yaml:"ssh_keys,flow"` | ||
} | ||
|
||
type YamlTeamAuthorizedKeys struct { | ||
File string | ||
TeamAuthorizedKeys []TeamAuthorizedKey | ||
} | ||
|
||
func (f *YamlTeamAuthorizedKeys) UnmarshalFlag(value string) error { | ||
//func (f *YamlTeamAuthorizedKeys) UnmarshalFlag(value string) error { | ||
authorizedKeysBytes, err := ioutil.ReadFile(value) | ||
if err != nil { | ||
return fmt.Errorf("failed to read yaml authorized keys: %s", err) | ||
} | ||
|
||
f.File = value | ||
|
||
err = yaml.Unmarshal([]byte(authorizedKeysBytes), &f.TeamAuthorizedKeys) | ||
if err != nil { | ||
return fmt.Errorf("failed to parse yaml authorized keys: %s", err) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (f *YamlTeamAuthorizedKeys) Reload() error { | ||
return f.UnmarshalFlag(f.File) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters