Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit e7c00a4

Browse files
authored
Merge branch 'master' into david/automated-github-releases
2 parents 6c7847f + c9be4a5 commit e7c00a4

8 files changed

Lines changed: 42 additions & 13 deletions

File tree

.circleci/config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
- run: go get golang.org/x/tools/cmd/goimports
2525
- run: "! goimports ./... 2>&1 | read"
2626
- run: "! go mod tidy ./... 2>&1 | read"
27+
- run: go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.17.1
28+
- run: "! golangci-lint 2>&1 | read"
2729
publish-github-release:
2830
docker:
2931
- image: circleci/golang:1.11
@@ -35,7 +37,6 @@ jobs:
3537
go get github.com/tcnksm/ghr
3638
export VERSION=`cat VERSION`-`git rev-parse --short HEAD`
3739
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${VERSION} ./bin/
38-
3940
workflows:
4041
version: 2
4142
build:

.golangci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
linters-settings:
2+
gocritic:
3+
disabled-checks:
4+
- ifElseChain
5+
- elseif
6+
7+
linters:
8+
enable:
9+
- gofmt
10+
- gocritic
11+
- unconvert
12+
- goconst
13+
- gocyclo
14+
- misspell
15+
- unparam
16+
- golint

.pre-commit-config.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
repos:
22
- repo: https://github.com/keybase/pre-commit-golang
3-
rev: b8194ff9d85455a702480677ada13ac4dbe94146
3+
rev: 314766a2c26b7f32641addbdb0e7e451320ff1f0
44
hooks:
55
- id: go-fmt
66
- id: go-vet
77
- id: go-lint
8+
- id: golangci-lint
89
- repo: https://github.com/troian/pre-commit-golang
910
rev: ab57c5db44bbeeae1031a2e9c2889367f8387d59
1011
hooks:
@@ -13,3 +14,7 @@ repos:
1314
rev: f16f18866390cba642e8af6073ed59504aeada5c
1415
hooks:
1516
- id: go-mod-tidy
17+
- repo: https://github.com/golangci/golangci-lint
18+
rev: v1.17.1
19+
hooks:
20+
- id: golangci-lint

src/cmd/keybaseca/keybaseca.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func backupAction(c *cli.Context) error {
100100
return err
101101
}
102102
if response != "yes" {
103-
return fmt.Errorf("Did not get confirmation of key export, aborting...")
103+
return fmt.Errorf("Did not get confirmation of key export, aborting")
104104
}
105105

106106
conf, err := loadServerConfig()
@@ -120,12 +120,11 @@ func backupAction(c *cli.Context) error {
120120

121121
// The action for the `keybaseca generate` subcommand
122122
func generateAction(c *cli.Context) error {
123-
conf, err := loadServerConfigAndWriteClientConfig()
123+
conf, err := loadServerConfig()
124124
if err != nil {
125125
return err
126126
}
127127
captureControlCToDeleteClientConfig(conf)
128-
defer deleteClientConfig(conf)
129128
err = sshutils.Generate(conf, c.Bool("overwrite-existing-key") || os.Getenv("FORCE_WRITE") == "true")
130129
if err != nil {
131130
return fmt.Errorf("Failed to generate a new key: %v", err)
@@ -140,12 +139,11 @@ func serviceAction(c *cli.Context) error {
140139
return err
141140
}
142141
captureControlCToDeleteClientConfig(conf)
143-
defer deleteClientConfig(conf)
144142
err = bot.StartBot(conf)
145143
if err != nil {
146144
return fmt.Errorf("CA chatbot crashed: %v", err)
147145
}
148-
return nil
146+
return deleteClientConfig(conf)
149147
}
150148

151149
// The action for the `keybaseca sign` subcommand

src/cmd/kssh/kssh.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,14 @@ func getConfig(botname string) (kssh.ConfigFile, error) {
248248
// No specified bot and no default bot, fallback and load all the configs
249249
configs, botnames, err := kssh.LoadConfigs()
250250
if err != nil {
251-
return empty, fmt.Errorf("Failed to load config file(s): %v\n", err)
251+
return empty, fmt.Errorf("Failed to load config file(s): %v", err)
252252
}
253-
if len(configs) == 0 {
253+
switch len(configs) {
254+
case 0:
254255
return empty, fmt.Errorf("Did not find any config files in KBFS (is `keybaseca service` running?)")
255-
} else if len(configs) == 1 {
256+
case 1:
256257
return configs[0], nil
257-
} else {
258+
default:
258259
noDefaultTeamMessage := fmt.Sprintf("Found %v config files (%s). No default bot is configured. \n"+
259260
"Either specify a team via `kssh --bot cabotname` or set a default bot via `kssh --set-default-bot cabotname`", len(configs), strings.Join(botnames, ", "))
260261
return empty, fmt.Errorf(noDefaultTeamMessage)

src/cmd/kssh/kssh_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ func BenchmarkLoadConfigs(b *testing.B) {
4949
b.ResetTimer()
5050

5151
for n := 0; n < b.N; n++ {
52-
getConfig("")
52+
_, err := getConfig("")
53+
require.NoError(b, err)
5354
}
5455
}

src/keybaseca/config/config.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ func validatePath(path string) error {
101101
if err != nil {
102102
return fmt.Errorf("path is not writable: %v", err)
103103
}
104-
constants.GetDefaultKBFSOperationsStruct().KBFSDelete(path)
104+
105+
err = constants.GetDefaultKBFSOperationsStruct().KBFSDelete(path)
106+
if err != nil {
107+
return fmt.Errorf("failed to delete temp file: %v", err)
108+
}
105109
return nil
106110
}
107111
_, err := os.Stat(path)

src/keybaseca/sshutils/sshutils.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ func ProcessSignatureRequest(conf config.Config, sr shared.SignatureRequest) (re
9292
log.Log(conf, fmt.Sprintf("Processing SignatureRequest from user=%s on device='%s' keyID:%s, principals:%s, expiration:%s, pubkey:%s",
9393
sr.Username, sr.DeviceName, keyID, principals, conf.GetKeyExpiration(), sr.SSHPublicKey))
9494
signature, err := SignKey(conf.GetCAKeyLocation(), keyID, principals, conf.GetKeyExpiration(), sr.SSHPublicKey)
95+
if err != nil {
96+
return
97+
}
9598

9699
return shared.SignatureResponse{SignedKey: signature, UUID: sr.UUID}, nil
97100
}

0 commit comments

Comments
 (0)