Skip to content

Commit

Permalink
in case of failure use Fatalf (#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
havetisyan authored Sep 4, 2018
1 parent 07066d8 commit e87cd05
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions utils/zts-rolecert/zts-rolecert.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,33 +108,28 @@ func generateCSR(keySigner *signer, roleDomain, roleName, host, rfc822 string) (
return buf.String(), nil
}

func getRoleCertificate(client *zts.ZTSClient, keySigner *signer, host, rfc822, roleDomain, roleName, roleCertFile string) bool {
func getRoleCertificate(client *zts.ZTSClient, keySigner *signer, host, rfc822, roleDomain, roleName, roleCertFile string) {

var roleRequest = new(zts.RoleCertificateRequest)
csr, err := generateCSR(keySigner, roleDomain, roleName, host, rfc822)
if err != nil {
log.Printf("Unable to generate CSR for %s, err: %v\n", roleName, err)
return false
log.Fatalf("Unable to generate CSR for %s, err: %v\n", roleName, err)
}

roleRequest.Csr = csr
roleToken, err := client.PostRoleCertificateRequest(zts.DomainName(roleDomain), zts.EntityName(roleName), roleRequest)
if err != nil {
log.Printf("PostRoleCertificateRequest failed for %s, err: %v\n", roleName, err)
return false
log.Fatalf("PostRoleCertificateRequest failed for %s, err: %v\n", roleName, err)
}

if roleCertFile != "" {
err = ioutil.WriteFile(roleCertFile, []byte(roleToken.Token), 0444)
if err != nil {
log.Printf("Unable to save role token certificate in %s, err: %v\n", roleCertFile, err)
return false
log.Fatalf("Unable to save role token certificate in %s, err: %v\n", roleCertFile, err)
}
} else {
fmt.Println(roleToken.Token)
}

return true
}

func ztsClient(ztsURL, ztsHostName, keyFile, certFile, caFile string) (*zts.ZTSClient, error) {
Expand Down

0 comments on commit e87cd05

Please sign in to comment.