Skip to content

Commit

Permalink
Fix go vet errors related to string formats
Browse files Browse the repository at this point in the history
Stupid programmer errors.
  • Loading branch information
bobveznat committed Aug 21, 2016
1 parent ee8ac09 commit 3e9582a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (req *SigningRequest) PostToWeb(requestParameters url.Values) error {
defer resp.Body.Close()
if resp.StatusCode != 200 {
respBuf, _ := ioutil.ReadAll(resp.Body)
return fmt.Errorf("HTTP %d: %s", resp.Status, string(respBuf))
return fmt.Errorf("HTTP %s: %s", resp.Status, string(respBuf))
} else {
return nil
}
Expand All @@ -80,7 +80,7 @@ func (req *SigningRequest) DeleteToWeb(requestParameters url.Values) error {
defer resp.Body.Close()
if resp.StatusCode != 200 {
respBuf, _ := ioutil.ReadAll(resp.Body)
return fmt.Errorf("HTTP %d: %s", resp.Status, string(respBuf))
return fmt.Errorf("HTTP %s: %s", resp.Status, string(respBuf))
} else {
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions get_cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func getCert(c *cli.Context) error {
}
getRespBuf, err := ioutil.ReadAll(getResp.Body)
if err != nil {
return cli.NewExitError(fmt.Sprintf("Error reading response body", err), 1)
return cli.NewExitError(fmt.Sprintf("Error reading response body: %s", err), 1)
}
getResp.Body.Close()
if getResp.StatusCode != 200 {
Expand All @@ -68,7 +68,7 @@ func getCert(c *cli.Context) error {

pubKey, _, _, _, err := ssh.ParseAuthorizedKey(getRespBuf)
if err != nil {
return cli.NewExitError(fmt.Sprintf("Trouble parsing response", err), 1)
return cli.NewExitError(fmt.Sprintf("Trouble parsing response: %s", err), 1)
}
cert := pubKey.(*ssh.Certificate)
secondsRemaining := int64(cert.ValidBefore) - int64(time.Now().Unix())
Expand Down
10 changes: 5 additions & 5 deletions list_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ func listCerts(c *cli.Context) error {

getResp, err := http.Get(config.SignerUrl + "cert/requests")
if err != nil {
return cli.NewExitError(fmt.Sprintf("Didn't get a valid response", err), 1)
return cli.NewExitError(fmt.Sprintf("Didn't get a valid response: %s", err), 1)
}
getRespBuf, err := ioutil.ReadAll(getResp.Body)
if err != nil {
return cli.NewExitError(fmt.Sprintf("Error reading response body", err), 1)
return cli.NewExitError(fmt.Sprintf("Error reading response body: %s", err), 1)
}
getResp.Body.Close()
if getResp.StatusCode != 200 {
return cli.NewExitError(fmt.Sprintf("Error getting listing of certs", string(getRespBuf)), 1)
return cli.NewExitError(fmt.Sprintf("Error getting listing of certs: %s", string(getRespBuf)), 1)
}

certs := make(certRequestResponse)
Expand All @@ -71,11 +71,11 @@ func listCerts(c *cli.Context) error {
if showAll || !respElement.Signed {
rawCert, err := base64.StdEncoding.DecodeString(respElement.CertBlob)
if err != nil {
return cli.NewExitError(fmt.Sprintf("Trouble base64 decoding response:", err, respElement.CertBlob), 1)
return cli.NewExitError(fmt.Sprintf("Trouble base64 decoding response '%s': %s", err, respElement.CertBlob), 1)
}
pubKey, err := ssh.ParsePublicKey(rawCert)
if err != nil {
return cli.NewExitError(fmt.Sprintf("Trouble parsing response:", err), 1)
return cli.NewExitError(fmt.Sprintf("Trouble parsing response: %s", err), 1)
}
cert := *pubKey.(*ssh.Certificate)
env, ok := cert.Extensions["environment@cloudtools.github.io"]
Expand Down
4 changes: 2 additions & 2 deletions request_cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ func requestCert(c *cli.Context) error {
caRequest.SetPublicKey(signer.PublicKey(), pubKeyComment)
newCert, err := caRequest.EncodeAsCertificate()
if err != nil {
return cli.NewExitError(fmt.Sprintf("Error encoding certificate request:", err), 1)
return cli.NewExitError(fmt.Sprintf("Error encoding certificate request: %s", err), 1)
}
err = newCert.SignCert(rand.Reader, signer)
if err != nil {
return cli.NewExitError(fmt.Sprintf("Error signing:", err), 1)
return cli.NewExitError(fmt.Sprintf("Error signing: %s", err), 1)
}

certRequest := newCert.Marshal()
Expand Down
2 changes: 1 addition & 1 deletion sign_cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func signCert(c *cli.Context) error {
requestParameters["certRequestId"][0] = certRequestID
getResp, err := http.Get(config.SignerUrl + "cert/requests?" + requestParameters.Encode())
if err != nil {
return cli.NewExitError(fmt.Sprintf("Didn't get a valid response: %s"), 1)
return cli.NewExitError(fmt.Sprintf("Didn't get a valid response: %s", err), 1)
}
getRespBuf, err := ioutil.ReadAll(getResp.Body)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions sign_certd.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ func signCertd(c *cli.Context) error {
config := make(map[string]ssh_ca_util.SignerdConfig)
err := ssh_ca_util.LoadConfig(configPath, &config)
if err != nil {
return cli.NewExitError(fmt.Sprintf("Load Config failed:", err), 1)
return cli.NewExitError(fmt.Sprintf("Load Config failed: %s", err), 1)
}
err = runSignCertd(config)
return err
Expand All @@ -608,7 +608,7 @@ func runSignCertd(config map[string]ssh_ca_util.SignerdConfig) error {

sshAgentConn, err := net.Dial("unix", os.Getenv("SSH_AUTH_SOCK"))
if err != nil {
return cli.NewExitError(fmt.Sprintf("Dial failed:", err), 1)
return cli.NewExitError(fmt.Sprintf("Dial failed: %s", err), 1)
}
requestHandler := makeCertRequestHandler(config)
requestHandler.sshAgentConn = sshAgentConn
Expand Down

0 comments on commit 3e9582a

Please sign in to comment.