Skip to content

Commit

Permalink
bugfixes
Browse files Browse the repository at this point in the history
- fix more defer panics
- don't create empty files
  • Loading branch information
tomdoherty committed Oct 1, 2020
1 parent 64e5c2e commit cddd545
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/adssl/adssl.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,13 @@ func getCaCert(endpoint string, username string, password string) (string, error

crtURL := "https://" + endpoint + "/certsrv/certnew.cer?ReqID=CACert&Enc=b64&Mode=inst&" + renewal
resp, err = makeRequest(crtURL, username, password, "")
defer resp.Body.Close()

if err != nil {
return "", fmt.Errorf("failed to request %s: %v", crtURL, err)
}

defer resp.Body.Close()

dataInBytes, err = ioutil.ReadAll(resp.Body)
return string(dataInBytes), err

Expand Down Expand Up @@ -170,12 +171,12 @@ func genCertRequest(csr string, endpoint string, username string, password strin
func fetchCertResult(resURL string, username string, password string) (string, error) {
resp, err := makeRequest(resURL, username, password, "")

defer resp.Body.Close()

if err != nil {
return "", fmt.Errorf("failed to fetch resulting cert: %v", err)
}

defer resp.Body.Close()

dataInBytes, err := ioutil.ReadAll(resp.Body)
return string(dataInBytes), err
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/gobblah/gobblah.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ func (c *Config) Run(args []string) error {
var res Result
var err error
res.Cacrt, res.Tlskey, res.Tlscrt, err = adssl.CreateCertificates(c.Endpoint, c.Username, c.Password, c.Hosts)
if err != nil {
log.Fatal(err)
}
if ctx.Bool("k8s-secret") {
kubernetes.OutputSecret(res.Cacrt, res.Tlskey, res.Tlscrt)
} else {
Expand Down

0 comments on commit cddd545

Please sign in to comment.