refactor(git): split / improve clone function
This commit is contained in:
parent
55c59e0164
commit
4aad919153
3 changed files with 189 additions and 88 deletions
35
pkg/git/sign_key.go
Normal file
35
pkg/git/sign_key.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package git
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/ProtonMail/go-crypto/openpgp"
|
||||
"github.com/ProtonMail/go-crypto/openpgp/armor"
|
||||
)
|
||||
|
||||
type SignKey struct {
|
||||
KeyFile string
|
||||
|
||||
entity *openpgp.Entity
|
||||
}
|
||||
|
||||
func (s *SignKey) ReadKeyFile() error {
|
||||
file, err := os.Open(s.KeyFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
block, err := armor.Decode(file)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
entityList, err := openpgp.ReadKeyRing(block.Body)
|
||||
if err != nil || len(entityList) < 1 {
|
||||
return err
|
||||
}
|
||||
|
||||
s.entity = entityList[0]
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue