Skip to content

Commit

Permalink
Refactored out repeated joining code
Browse files Browse the repository at this point in the history
Thanks for suggestion @chrisz100!
  • Loading branch information
justinsb committed Mar 19, 2019
1 parent 9e9e2a5 commit f024129
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions nodeup/pkg/model/etcd_manager_tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,16 @@ func (b *EtcdManagerTLSBuilder) buildKubeAPIServerKeypair() error {

certBytes := certutil.EncodeCertPEM(cert)

p := filepath.Join(dir, name)
{
p := filepath.Join(dir, name+".crt")
if err := ioutil.WriteFile(p, certBytes, 0644); err != nil {
return fmt.Errorf("error writing certificate key file %q: %v", p, err)
if err := ioutil.WriteFile(p+".crt", certBytes, 0644); err != nil {
return fmt.Errorf("error writing certificate key file %q: %v", p+".crt", err)
}
}

{
p := filepath.Join(dir, name+".key")
if err := ioutil.WriteFile(p, privateKeyBytes, 0600); err != nil {
return fmt.Errorf("error writing private key file %q: %v", p, err)
if err := ioutil.WriteFile(p+".key", privateKeyBytes, 0600); err != nil {
return fmt.Errorf("error writing private key file %q: %v", p+".key", err)
}
}

Expand Down

0 comments on commit f024129

Please sign in to comment.