Remove unused function in phases/certs

Signed-off-by: xin.li <xin.li@daocloud.io>
This commit is contained in:
xin.li 2024-06-22 18:47:28 +08:00
parent 7c780186d7
commit 71d3f9e249
2 changed files with 0 additions and 43 deletions

View File

@ -129,16 +129,6 @@ func CreateCACertAndKeyFiles(certSpec *KubeadmCert, cfg *kubeadmapi.InitConfigur
)
}
// NewCSR will generate a new CSR and accompanying key
func NewCSR(certSpec *KubeadmCert, cfg *kubeadmapi.InitConfiguration) (*x509.CertificateRequest, crypto.Signer, error) {
certConfig, err := certSpec.GetConfig(cfg)
if err != nil {
return nil, nil, errors.Wrap(err, "failed to retrieve cert configuration")
}
return pkiutil.NewCSRAndKey(certConfig)
}
// CreateCertAndKeyFilesWithCA loads the given certificate authority from disk, then generates and writes out the given certificate and key.
// The certSpec and caCertSpec should both be one of the variables from this package.
func CreateCertAndKeyFilesWithCA(certSpec *KubeadmCert, caCertSpec *KubeadmCert, cfg *kubeadmapi.InitConfiguration) error {

View File

@ -25,7 +25,6 @@ import (
"testing"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
certutil "k8s.io/client-go/util/cert"
@ -638,38 +637,6 @@ func TestValidateMethods(t *testing.T) {
}
}
func TestNewCSR(t *testing.T) {
kubeadmCert := KubeadmCertAPIServer()
cfg := testutil.GetDefaultInternalConfig(t)
certConfig, err := kubeadmCert.GetConfig(cfg)
if err != nil {
t.Fatalf("couldn't get cert config: %v", err)
}
csr, _, err := NewCSR(kubeadmCert, cfg)
if err != nil {
t.Errorf("invalid signature on CSR: %v", err)
}
assert.ElementsMatch(t, certConfig.Organization, csr.Subject.Organization, "organizations not equal")
if csr.Subject.CommonName != certConfig.CommonName {
t.Errorf("expected common name %q, got %q", certConfig.CommonName, csr.Subject.CommonName)
}
assert.ElementsMatch(t, certConfig.AltNames.DNSNames, csr.DNSNames, "dns names not equal")
assert.Len(t, csr.IPAddresses, len(certConfig.AltNames.IPs))
for i, ip := range csr.IPAddresses {
if !ip.Equal(certConfig.AltNames.IPs[i]) {
t.Errorf("[%d]: %v != %v", i, ip, certConfig.AltNames.IPs[i])
}
}
}
func TestCreateCertificateFilesMethods(t *testing.T) {
var tests = []struct {