add ssh-key command

This commit is contained in:
edualb 2020-09-18 18:27:27 -03:00 committed by Mislav Marohnić
parent b5366c6ebf
commit e26a1b98a1
8 changed files with 490 additions and 22 deletions

View file

@ -203,9 +203,10 @@ func (c Client) HasMinimumScopes(hostname string) error {
}
search := map[string]bool{
"repo": false,
"read:org": false,
"admin:org": false,
"repo": false,
"read:org": false,
"admin:org": false,
"read:public_key": false,
}
for _, s := range strings.Split(scopesHeader, ",") {
search[strings.TrimSpace(s)] = true
@ -220,6 +221,10 @@ func (c Client) HasMinimumScopes(hostname string) error {
missingScopes = append(missingScopes, "read:org")
}
if !search["read:public_key"] && !search["admin:public_key"] {
missingScopes = append(missingScopes, "read:public_key")
}
if len(missingScopes) > 0 {
return &MissingScopesError{MissingScopes: missingScopes}
}