grafana-backuper/pkg/git/signer.go

29 lines
465 B
Go
Raw Normal View History

package git
import (
"os"
"github.com/ProtonMail/go-crypto/openpgp"
"github.com/ProtonMail/go-crypto/openpgp/armor"
)
func getSigner(keyFile string) (*openpgp.Entity, error) {
file, err := os.Open(keyFile)
if err != nil {
return nil, err
}
defer file.Close()
block, err := armor.Decode(file)
if err != nil {
return nil, err
}
entityList, err := openpgp.ReadKeyRing(block.Body)
if err != nil {
return nil, err
}
return entityList[0], nil
}