1
0
Fork 0
mirror of https://github.com/Mic92/sops-nix.git synced 2024-12-15 17:50:51 +00:00

make golangci-lint happy

This commit is contained in:
Jörg Thalheim 2020-07-19 23:30:28 +01:00
parent 16c3c3e39c
commit fd28d45f10
No known key found for this signature in database
GPG key ID: 003F2096411B5F92
3 changed files with 8 additions and 26 deletions

View file

@ -36,18 +36,18 @@ func TestShellHook(t *testing.T) {
cmd.Stderr = &stderrBuf
cmd.Dir = assets
err = cmd.Run()
stdout := string(stdoutBuf.Bytes())
stderr := string(stderrBuf.Bytes())
stdout := stdoutBuf.String()
stderr := stderrBuf.String()
fmt.Printf("$ %s\nstdout: \n%s\nstderr: \n%s\n", strings.Join(cmd.Args, " "), stdout, stderr)
ok(t, err)
expectedStdout := "SOPS_PGP_FP=C6DA56E69A7C756564A8AFEB4A6B05B714D13EFD,4EC40F8E04A945339F7F7C0032C5225271038E3F,7FB89715AADA920D65D25E63F9BA9DEBD03F57C0"
if strings.Index(stdout, expectedStdout) == -1 {
if !strings.Contains(stdout, expectedStdout) {
t.Fatalf("'%v' not in '%v'", expectedStdout, stdout)
}
expectedStderr := "./non-existing-key.gpg does not exists"
if strings.Index(stderr, expectedStderr) == -1 {
if !strings.Contains(stderr, expectedStderr) {
t.Fatalf("'%v' not in '%v'", expectedStderr, stdout)
}

View file

@ -25,7 +25,10 @@ func parseFlags(args []string) options {
f.StringVar(&opts.format, "format", "armor", "GPG format encoding (binary|armor)")
f.StringVar(&opts.in, "i", "-", "Input path. Reads by default from standard output")
f.StringVar(&opts.out, "o", "-", "Output path. Prints by default to standard output")
f.Parse(args[1:])
if err := f.Parse(args[1:]); err != nil {
// should never happen since flag.ExitOnError
panic(err)
}
return opts
}

View file

@ -12,27 +12,6 @@ import (
"golang.org/x/crypto/ssh"
)
func parsePublicKey(publicKey []byte) (*rsa.PublicKey, error) {
key, _, _, _, err := ssh.ParseAuthorizedKey(publicKey)
if err != nil {
return nil, fmt.Errorf("failed to parse public ssh key: %s", err)
}
cryptoPublicKey, ok := key.(ssh.CryptoPublicKey)
if !ok {
return nil, fmt.Errorf("Unsupported public key algo: %s", key.Type())
}
rsaKey, ok := cryptoPublicKey.CryptoPublicKey().(*rsa.PublicKey)
if !ok {
return nil, fmt.Errorf("Unsupported public key algo: %s", key.Type())
}
return rsaKey, nil
}
func parsePrivateKey(sshPrivateKey []byte) (*rsa.PrivateKey, error) {
privateKey, err := ssh.ParseRawPrivateKey(sshPrivateKey)
if err != nil {