gofmt across the baord

Signed-off-by: Nathan McCauley <nathan.mccauley@docker.com>
This commit is contained in:
Nathan McCauley 2015-07-19 17:33:23 -07:00
parent de6f65b7e7
commit 38fe6bd45b
14 changed files with 32 additions and 47 deletions

View File

@ -49,7 +49,7 @@ test:
pwd: $BASE_STABLE pwd: $BASE_STABLE
# VET # VET
- gvm use stable && go vet ./...: - gvm use stable && test -z "$(go tool vet -printf=false . 2>&1 | grep -v Godeps/_workspace/src/ | tee /dev/stderr)":
pwd: $BASE_STABLE pwd: $BASE_STABLE
# LINT # LINT

View File

@ -44,10 +44,9 @@ func init() {
func passphraseRetriever(keyName, alias string, createNew bool, attempts int) (passphrase string, giveup bool, err error) { func passphraseRetriever(keyName, alias string, createNew bool, attempts int) (passphrase string, giveup bool, err error) {
//TODO(mccauley) Read from config once we have locked keys in notary-signer //TODO(mccauley) Read from config once we have locked keys in notary-signer
return "", false, nil; return "", false, nil
} }
func main() { func main() {
flag.Usage = usage flag.Usage = usage
flag.Parse() flag.Parse()

View File

@ -86,7 +86,6 @@ func init() {
fatalf("could not create Certificate X509FileStore: %v", err) fatalf("could not create Certificate X509FileStore: %v", err)
} }
//TODO(mccauley): Appears unused? Remove it? Or is it here for early failure? //TODO(mccauley): Appears unused? Remove it? Or is it here for early failure?
privKeyStore, err = trustmanager.NewKeyFileStore(finalPrivDir, privKeyStore, err = trustmanager.NewKeyFileStore(finalPrivDir,
func(string, string, bool, int) (string, bool, error) { return "", false, nil }) func(string, string, bool, int) (string, bool, error) { return "", false, nil })

View File

@ -14,9 +14,9 @@ import (
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/docker/docker/pkg/term" "github.com/docker/docker/pkg/term"
notaryclient "github.com/docker/notary/client" notaryclient "github.com/docker/notary/client"
"github.com/docker/notary/trustmanager"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/docker/notary/trustmanager"
) )
// FIXME: This should not be hardcoded // FIXME: This should not be hardcoded
@ -272,23 +272,17 @@ func verify(cmd *cobra.Command, args []string) {
return return
} }
func getNotaryPassphraseRetriever() (trustmanager.PassphraseRetriever) { func getNotaryPassphraseRetriever() trustmanager.PassphraseRetriever {
userEnteredTargetsSnapshotsPass := false userEnteredTargetsSnapshotsPass := false
targetsSnapshotsPass := "" targetsSnapshotsPass := ""
return func(keyID string, alias string, createNew bool, numAttempts int) (string, bool, error) { return func(keyID string, alias string, createNew bool, numAttempts int) (string, bool, error) {
fmt.Printf("userEnteredTargetsSnapshotsPass: %s\n", userEnteredTargetsSnapshotsPass)
fmt.Printf("targetsSnapshotsPass: %s\n", targetsSnapshotsPass)
fmt.Printf("keyID: %s\n", keyID)
fmt.Printf("alias: %s\n", alias)
fmt.Printf("numAttempts: %s\n", numAttempts)
if numAttempts == 0 && userEnteredTargetsSnapshotsPass && (alias == "snapshot" || alias == "targets") { if numAttempts == 0 && userEnteredTargetsSnapshotsPass && (alias == "snapshot" || alias == "targets") {
fmt.Println("return cached value") fmt.Println("return cached value")
return targetsSnapshotsPass, false, nil; return targetsSnapshotsPass, false, nil
} }
if (numAttempts > 3 && !createNew) { if numAttempts > 3 && !createNew {
return "", true, errors.New("Too many attempts") return "", true, errors.New("Too many attempts")
} }
@ -320,7 +314,7 @@ func getNotaryPassphraseRetriever() (trustmanager.PassphraseRetriever) {
userEnteredTargetsSnapshotsPass = true userEnteredTargetsSnapshotsPass = true
targetsSnapshotsPass = retPass targetsSnapshotsPass = retPass
} }
return string(passphrase), false, nil; return string(passphrase), false, nil
} }
if len(passphrase) < 8 { if len(passphrase) < 8 {

View File

@ -19,7 +19,6 @@ func TestCryptoService(t *testing.T) {
var passphraseretriever = func(string, string, bool, int) (string, bool, error) { return "", false, nil } var passphraseretriever = func(string, string, bool, int) (string, bool, error) { return "", false, nil }
func testCryptoService(t *testing.T, keyAlgo data.KeyAlgorithm, verifier signed.Verifier) { func testCryptoService(t *testing.T, keyAlgo data.KeyAlgorithm, verifier signed.Verifier) {
content := []byte("this is a secret") content := []byte("this is a secret")

View File

@ -11,7 +11,6 @@ import (
var passphraseRetriever = func(string, string, bool, int) (string, bool, error) { return "passphrase", false, nil } var passphraseRetriever = func(string, string, bool, int) (string, bool, error) { return "passphrase", false, nil }
func TestUnlockedSigner(t *testing.T) { func TestUnlockedSigner(t *testing.T) {
privKey, err := trustmanager.GenerateECDSAKey(rand.Reader) privKey, err := trustmanager.GenerateECDSAKey(rand.Reader)
assert.NoError(t, err, "could not generate key") assert.NoError(t, err, "could not generate key")

View File

@ -11,9 +11,9 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"fmt"
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/docker/notary/trustmanager" "github.com/docker/notary/trustmanager"
"fmt"
) )
var ( var (
@ -293,7 +293,6 @@ func (km *KeyStoreManager) ExportKeysByGUN(dest io.Writer, gun string, passphras
privNonRootKeysSubdir := filepath.Join(privDir, nonRootKeysSubdir) privNonRootKeysSubdir := filepath.Join(privDir, nonRootKeysSubdir)
// Create temporary keystore to use as a staging area // Create temporary keystore to use as a staging area
tempNonRootKeysPath := filepath.Join(tempBaseDir, privNonRootKeysSubdir) tempNonRootKeysPath := filepath.Join(tempBaseDir, privNonRootKeysSubdir)
tempNonRootKeyStore, err := trustmanager.NewKeyFileStore(tempNonRootKeysPath, passphraseRetriever) tempNonRootKeyStore, err := trustmanager.NewKeyFileStore(tempNonRootKeysPath, passphraseRetriever)

View File

@ -36,6 +36,7 @@ func createTestServer(t *testing.T) (*httptest.Server, *http.ServeMux) {
return ts, mux return ts, mux
} }
var oldPassphrase = "oldPassphrase" var oldPassphrase = "oldPassphrase"
var exportPassphrase = "exportPassphrase" var exportPassphrase = "exportPassphrase"
var oldPassphraseRetriever = func(string, string, bool, int) (string, bool, error) { return oldPassphrase, false, nil } var oldPassphraseRetriever = func(string, string, bool, int) (string, bool, error) { return oldPassphrase, false, nil }

View File

@ -25,7 +25,6 @@ var (
grpcServer *grpc.Server grpcServer *grpc.Server
void *pb.Void void *pb.Void
pr trustmanager.PassphraseRetriever pr trustmanager.PassphraseRetriever
) )
func init() { func init() {

View File

@ -4,9 +4,9 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/endophage/gotuf/data"
"errors" "errors"
"fmt" "fmt"
"github.com/endophage/gotuf/data"
) )
const ( const (
@ -103,7 +103,6 @@ func (s *KeyMemoryStore) GetKeyAlias(name string) (string, error) {
return getKeyAlias(s, name) return getKeyAlias(s, name)
} }
// ListKeys returns a list of unique PublicKeys present on the KeyFileStore. // ListKeys returns a list of unique PublicKeys present on the KeyFileStore.
// There might be symlinks associating Certificate IDs to Public Keys, so this // There might be symlinks associating Certificate IDs to Public Keys, so this
// method only returns the IDs that aren't symlinks // method only returns the IDs that aren't symlinks
@ -116,7 +115,6 @@ func (s *KeyMemoryStore) RemoveKey(name string) error {
return removeKey(s, name) return removeKey(s, name)
} }
func addKey(s LimitedFileStore, passphraseRetriever PassphraseRetriever, name, alias string, privKey data.PrivateKey) error { func addKey(s LimitedFileStore, passphraseRetriever PassphraseRetriever, name, alias string, privKey data.PrivateKey) error {
pemPrivKey, err := KeyToPEM(privKey) pemPrivKey, err := KeyToPEM(privKey)
if err != nil { if err != nil {

View File

@ -3,12 +3,12 @@ package trustmanager
import ( import (
"bytes" "bytes"
"crypto/rand" "crypto/rand"
"errors"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
"testing" "testing"
"errors"
) )
var passphraseRetriever = func(keyID string, alias string, createNew bool, numAttempts int) (string, bool, error) { var passphraseRetriever = func(keyID string, alias string, createNew bool, numAttempts int) (string, bool, error) {
@ -98,7 +98,6 @@ EMl3eFOJXjIch/wIesRSN+2dGOsl7neercjMh1i9RvpCwHDx/E0=
emptyPassphraseRetriever := func(string, string, bool, int) (string, bool, error) { return "", false, nil } emptyPassphraseRetriever := func(string, string, bool, int) (string, bool, error) { return "", false, nil }
// Temporary directory where test files will be created // Temporary directory where test files will be created
tempBaseDir, err := ioutil.TempDir("", "notary-test-") tempBaseDir, err := ioutil.TempDir("", "notary-test-")
if err != nil { if err != nil {
@ -226,7 +225,6 @@ func TestGetDecryptedWithTamperedCipherText(t *testing.T) {
func TestGetDecryptedWithInvalidPassphrase(t *testing.T) { func TestGetDecryptedWithInvalidPassphrase(t *testing.T) {
// Make a passphraseRetriever that always returns a different passphrase in order to test // Make a passphraseRetriever that always returns a different passphrase in order to test
// decryption failure // decryption failure
a := "a" a := "a"