Skip to content

Commit 10ae1db

Browse files
authored
Merge pull request kubernetes#125636 from my-git9/certsunused
kubeadm: Remove unused function in phases/certs
2 parents 498f888 + 71d3f9e commit 10ae1db

File tree

2 files changed

+0
-43
lines changed

2 files changed

+0
-43
lines changed

cmd/kubeadm/app/phases/certs/certs.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,6 @@ func CreateCACertAndKeyFiles(certSpec *KubeadmCert, cfg *kubeadmapi.InitConfigur
129129
)
130130
}
131131

132-
// NewCSR will generate a new CSR and accompanying key
133-
func NewCSR(certSpec *KubeadmCert, cfg *kubeadmapi.InitConfiguration) (*x509.CertificateRequest, crypto.Signer, error) {
134-
certConfig, err := certSpec.GetConfig(cfg)
135-
if err != nil {
136-
return nil, nil, errors.Wrap(err, "failed to retrieve cert configuration")
137-
}
138-
139-
return pkiutil.NewCSRAndKey(certConfig)
140-
}
141-
142132
// CreateCertAndKeyFilesWithCA loads the given certificate authority from disk, then generates and writes out the given certificate and key.
143133
// The certSpec and caCertSpec should both be one of the variables from this package.
144134
func CreateCertAndKeyFilesWithCA(certSpec *KubeadmCert, caCertSpec *KubeadmCert, cfg *kubeadmapi.InitConfiguration) error {

cmd/kubeadm/app/phases/certs/certs_test.go

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"testing"
2626

2727
"github.com/pkg/errors"
28-
"github.com/stretchr/testify/assert"
2928

3029
utilerrors "k8s.io/apimachinery/pkg/util/errors"
3130
certutil "k8s.io/client-go/util/cert"
@@ -638,38 +637,6 @@ func TestValidateMethods(t *testing.T) {
638637
}
639638
}
640639

641-
func TestNewCSR(t *testing.T) {
642-
kubeadmCert := KubeadmCertAPIServer()
643-
cfg := testutil.GetDefaultInternalConfig(t)
644-
645-
certConfig, err := kubeadmCert.GetConfig(cfg)
646-
if err != nil {
647-
t.Fatalf("couldn't get cert config: %v", err)
648-
}
649-
650-
csr, _, err := NewCSR(kubeadmCert, cfg)
651-
652-
if err != nil {
653-
t.Errorf("invalid signature on CSR: %v", err)
654-
}
655-
656-
assert.ElementsMatch(t, certConfig.Organization, csr.Subject.Organization, "organizations not equal")
657-
658-
if csr.Subject.CommonName != certConfig.CommonName {
659-
t.Errorf("expected common name %q, got %q", certConfig.CommonName, csr.Subject.CommonName)
660-
}
661-
662-
assert.ElementsMatch(t, certConfig.AltNames.DNSNames, csr.DNSNames, "dns names not equal")
663-
664-
assert.Len(t, csr.IPAddresses, len(certConfig.AltNames.IPs))
665-
666-
for i, ip := range csr.IPAddresses {
667-
if !ip.Equal(certConfig.AltNames.IPs[i]) {
668-
t.Errorf("[%d]: %v != %v", i, ip, certConfig.AltNames.IPs[i])
669-
}
670-
}
671-
}
672-
673640
func TestCreateCertificateFilesMethods(t *testing.T) {
674641

675642
var tests = []struct {

0 commit comments

Comments
 (0)