grim/hgkeeper

ignore the build binaries

22 months ago, Gary Kramlich
ef4ae04808d3
ignore the build binaries
package authorized_keys
import (
"fmt"
"strings"
log "github.com/sirupsen/logrus"
"keep.imfreedom.org/grim/hgkeeper/access"
"keep.imfreedom.org/grim/hgkeeper/globals"
)
type Command struct {
FingerPrint string `kong:"arg,help='The fingerprint of the calling user'"`
HGKeeperExec string `kong:"flag,help='The path to hgkeeper executable',default='hgkeeper'"`
}
func (c *Command) Run(g *globals.Globals) error {
// we're generating output for another command so we need to turn off our
// normal logging.
log.SetLevel(log.FatalLevel)
if err := access.Setup(g.ReposPath, g.AdminRepo); err != nil {
return err
}
defer access.Teardown()
pubkey, err := access.PubkeyFromFingerprint(c.FingerPrint)
if err != nil {
return err
}
username, err := access.UsernameFromFingerprint(c.FingerPrint)
if err != nil {
return err
}
options := []string{
fmt.Sprintf("command=\"%s once %s\"", c.HGKeeperExec, username),
"restrict",
fmt.Sprintf("environment=\"HGK_REPOS_PATH=%s\"", g.ReposPath),
}
fmt.Printf("%s %s", strings.Join(options, ","), pubkey)
return nil
}