Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
esilva-everbridge committed Jul 16, 2018
1 parent 3563532 commit cce50a3
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions pki/pki.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,25 +187,33 @@ func (p *Pki) GetKeyByID(keyring openpgp.EntityList, id interface{}) *openpgp.En
return entity
}

for _, ident := range entity.Identities {
if id.(string) == ident.Name {
return entity
}
if id.(string) == ident.UserId.Email {
return entity
}
if id.(string) == ident.UserId.Name {
return entity
}
if id.(string) == ident.UserId.Id {
return entity
}
if checkIdentities(id.(string), entity) {
return entity
}
}

return nil
}

func checkIdentities(id string, entity *openpgp.Entity) bool {
for _, ident := range entity.Identities {
if id == ident.Name {
return true
}
if id == ident.UserId.Email {
return true
}
if id == ident.UserId.Name {
return true
}
if id == ident.UserId.Id {
return true
}
}

return false
}

// ExpandTilde does exactly what it says on the tin
func (p *Pki) ExpandTilde(path string) (string, error) {
if len(path) == 0 || path[0] != '~' {
Expand Down

0 comments on commit cce50a3

Please sign in to comment.