kubeadm: fix name of CA spell error

This commit is contained in:
alan 2019-08-06 12:01:28 +08:00
parent 65e5439faf
commit cd2ecefb80
8 changed files with 30 additions and 30 deletions

View File

@ -36,7 +36,7 @@ func TestKubeConfigSubCommandsThatWritesToOut(t *testing.T) {
defer os.RemoveAll(tmpdir)
// Adds a pki folder with a ca cert to the temp folder
pkidir := testutil.SetupPkiDirWithCertificateAuthorithy(t, tmpdir)
pkidir := testutil.SetupPkiDirWithCertificateAuthority(t, tmpdir)
// Retrieves ca cert for assertions
caCert, _, err := pkiutil.TryLoadCertAndKeyFromDisk(pkidir, kubeadmconstants.CACertAndKeyBaseName)

View File

@ -90,7 +90,7 @@ func (k *KubeadmCert) CreateAsCA(ic *kubeadmapi.InitConfiguration) (*x509.Certif
return nil, nil, errors.Wrapf(err, "couldn't generate %q CA certificate", k.Name)
}
err = writeCertificateAuthorithyFilesIfNotExist(
err = writeCertificateAuthorityFilesIfNotExist(
ic.CertificatesDir,
k.BaseName,
caCert,
@ -146,7 +146,7 @@ func (t CertificateTree) CreateTree(ic *kubeadmapi.InitConfiguration) error {
return err
}
err = writeCertificateAuthorithyFilesIfNotExist(
err = writeCertificateAuthorityFilesIfNotExist(
ic.CertificatesDir,
ca.BaseName,
caCert,

View File

@ -113,7 +113,7 @@ func CreateCACertAndKeyFiles(certSpec *KubeadmCert, cfg *kubeadmapi.InitConfigur
return err
}
return writeCertificateAuthorithyFilesIfNotExist(
return writeCertificateAuthorityFilesIfNotExist(
cfg.CertificatesDir,
certSpec.BaseName,
caCert,
@ -176,11 +176,11 @@ func LoadCertificateAuthority(pkiDir string, baseName string) (*x509.Certificate
return caCert, caKey, nil
}
// writeCertificateAuthorithyFilesIfNotExist write a new certificate Authority to the given path.
// writeCertificateAuthorityFilesIfNotExist write a new certificate Authority to the given path.
// If there already is a certificate file at the given path; kubeadm tries to load it and check if the values in the
// existing and the expected certificate equals. If they do; kubeadm will just skip writing the file as it's up-to-date,
// otherwise this function returns an error.
func writeCertificateAuthorithyFilesIfNotExist(pkiDir string, baseName string, caCert *x509.Certificate, caKey crypto.Signer) error {
func writeCertificateAuthorityFilesIfNotExist(pkiDir string, baseName string, caCert *x509.Certificate, caKey crypto.Signer) error {
// If cert or key exists, we should try to load them
if pkiutil.CertOrKeyExist(pkiDir, baseName) {

View File

@ -52,7 +52,7 @@ func createTestCSR(t *testing.T) (*x509.CertificateRequest, crypto.Signer) {
return csr, key
}
func TestWriteCertificateAuthorithyFilesIfNotExist(t *testing.T) {
func TestWriteCertificateAuthorityFilesIfNotExist(t *testing.T) {
setupCert, setupKey := certstestutil.CreateCACert(t)
caCert, caKey := certstestutil.CreateCACert(t)
@ -66,7 +66,7 @@ func TestWriteCertificateAuthorithyFilesIfNotExist(t *testing.T) {
},
{ // ca cert exists, is ca > existing ca used
setupFunc: func(pkiDir string) error {
return writeCertificateAuthorithyFilesIfNotExist(pkiDir, "dummy", setupCert, setupKey)
return writeCertificateAuthorityFilesIfNotExist(pkiDir, "dummy", setupCert, setupKey)
},
expectedCa: setupCert,
},
@ -100,13 +100,13 @@ func TestWriteCertificateAuthorithyFilesIfNotExist(t *testing.T) {
}
// executes create func
err := writeCertificateAuthorithyFilesIfNotExist(tmpdir, "dummy", caCert, caKey)
err := writeCertificateAuthorityFilesIfNotExist(tmpdir, "dummy", caCert, caKey)
if !test.expectedError && err != nil {
t.Errorf("error writeCertificateAuthorithyFilesIfNotExist failed when not expected to fail: %v", err)
t.Errorf("error writeCertificateAuthorityFilesIfNotExist failed when not expected to fail: %v", err)
continue
} else if test.expectedError && err == nil {
t.Error("error writeCertificateAuthorithyFilesIfNotExist didn't failed when expected")
t.Error("error writeCertificateAuthorityFilesIfNotExist didn't failed when expected")
continue
} else if test.expectedError {
continue

View File

@ -64,7 +64,7 @@ func TestGetKubeConfigSpecs(t *testing.T) {
defer os.RemoveAll(tmpdir)
// Adds a pki folder with a ca certs to the temp folder
pkidir := testutil.SetupPkiDirWithCertificateAuthorithy(t, tmpdir)
pkidir := testutil.SetupPkiDirWithCertificateAuthority(t, tmpdir)
// Creates InitConfigurations pointing to the pkidir folder
cfgs := []*kubeadmapi.InitConfiguration{
@ -185,7 +185,7 @@ func TestGetKubeConfigSpecs(t *testing.T) {
func TestBuildKubeConfigFromSpecWithClientAuth(t *testing.T) {
// Creates a CA
caCert, caKey := certstestutil.SetupCertificateAuthorithy(t)
caCert, caKey := certstestutil.SetupCertificateAuthority(t)
// Executes buildKubeConfigFromSpec passing a KubeConfigSpec with a ClientAuth
config := setupdKubeConfigWithClientAuth(t, caCert, caKey, "https://1.2.3.4:1234", "myClientName", "test-cluster", "myOrg1", "myOrg2")
@ -197,7 +197,7 @@ func TestBuildKubeConfigFromSpecWithClientAuth(t *testing.T) {
func TestBuildKubeConfigFromSpecWithTokenAuth(t *testing.T) {
// Creates a CA
caCert, _ := certstestutil.SetupCertificateAuthorithy(t)
caCert, _ := certstestutil.SetupCertificateAuthority(t)
// Executes buildKubeConfigFromSpec passing a KubeConfigSpec with a Token
config := setupdKubeConfigWithTokenAuth(t, caCert, "https://1.2.3.4:1234", "myClientName", "123456", "test-cluster")
@ -210,8 +210,8 @@ func TestBuildKubeConfigFromSpecWithTokenAuth(t *testing.T) {
func TestCreateKubeConfigFileIfNotExists(t *testing.T) {
// Creates a CAs
caCert, caKey := certstestutil.SetupCertificateAuthorithy(t)
anotherCaCert, anotherCaKey := certstestutil.SetupCertificateAuthorithy(t)
caCert, caKey := certstestutil.SetupCertificateAuthority(t)
anotherCaCert, anotherCaKey := certstestutil.SetupCertificateAuthority(t)
// build kubeconfigs (to be used to test kubeconfigs equality/not equality)
config := setupdKubeConfigWithClientAuth(t, caCert, caKey, "https://1.2.3.4:1234", "test-cluster", "myOrg1", "myOrg2")
@ -307,7 +307,7 @@ func TestCreateKubeconfigFilesAndWrappers(t *testing.T) {
defer os.RemoveAll(tmpdir)
// Adds a pki folder with a ca certs to the temp folder
pkidir := testutil.SetupPkiDirWithCertificateAuthorithy(t, tmpdir)
pkidir := testutil.SetupPkiDirWithCertificateAuthority(t, tmpdir)
// Creates an InitConfiguration pointing to the pkidir folder
cfg := &kubeadmapi.InitConfiguration{
@ -382,7 +382,7 @@ func TestWriteKubeConfig(t *testing.T) {
defer os.RemoveAll(tmpdir)
// Adds a pki folder with a ca cert to the temp folder
pkidir := testutil.SetupPkiDirWithCertificateAuthorithy(t, tmpdir)
pkidir := testutil.SetupPkiDirWithCertificateAuthority(t, tmpdir)
// Retrieves ca cert for assertions
caCert, _, err := pkiutil.TryLoadCertAndKeyFromDisk(pkidir, kubeadmconstants.CACertAndKeyBaseName)
@ -454,8 +454,8 @@ func TestWriteKubeConfig(t *testing.T) {
}
func TestValidateKubeConfig(t *testing.T) {
caCert, caKey := certstestutil.SetupCertificateAuthorithy(t)
anotherCaCert, anotherCaKey := certstestutil.SetupCertificateAuthorithy(t)
caCert, caKey := certstestutil.SetupCertificateAuthority(t)
anotherCaCert, anotherCaKey := certstestutil.SetupCertificateAuthority(t)
config := setupdKubeConfigWithClientAuth(t, caCert, caKey, "https://1.2.3.4:1234", "test-cluster", "myOrg1")
configWithAnotherClusterCa := setupdKubeConfigWithClientAuth(t, anotherCaCert, anotherCaKey, "https://1.2.3.4:1234", "test-cluster", "myOrg1")
@ -528,7 +528,7 @@ func TestValidateKubeconfigsForExternalCA(t *testing.T) {
}
// creates CA, write to pkiDir and remove ca.key to get into external CA condition
caCert, caKey := certstestutil.SetupCertificateAuthorithy(t)
caCert, caKey := certstestutil.SetupCertificateAuthority(t)
if err := pkiutil.WriteCertAndKey(pkiDir, kubeadmconstants.CACertAndKeyBaseName, caCert, caKey); err != nil {
t.Fatalf("failure while saving CA certificate and key: %v", err)
}
@ -540,7 +540,7 @@ func TestValidateKubeconfigsForExternalCA(t *testing.T) {
config := setupdKubeConfigWithClientAuth(t, caCert, caKey, "https://1.2.3.4:1234", "test-cluster", "myOrg1")
// create a config with another CA
anotherCaCert, anotherCaKey := certstestutil.SetupCertificateAuthorithy(t)
anotherCaCert, anotherCaKey := certstestutil.SetupCertificateAuthority(t)
configWithAnotherClusterCa := setupdKubeConfigWithClientAuth(t, anotherCaCert, anotherCaKey, "https://1.2.3.4:1234", "test-cluster", "myOrg1")
// create a config with another server URL

View File

@ -687,7 +687,7 @@ func TestCleanupDirs(t *testing.T) {
}
func TestRenewCertsByComponent(t *testing.T) {
caCert, caKey := certstestutil.SetupCertificateAuthorithy(t)
caCert, caKey := certstestutil.SetupCertificateAuthority(t)
tests := []struct {
name string

View File

@ -29,9 +29,9 @@ import (
pkiutil "k8s.io/kubernetes/cmd/kubeadm/app/util/pkiutil"
)
// SetupCertificateAuthorithy is a utility function for kubeadm testing that creates a
// CertificateAuthorithy cert/key pair
func SetupCertificateAuthorithy(t *testing.T) (*x509.Certificate, crypto.Signer) {
// SetupCertificateAuthority is a utility function for kubeadm testing that creates a
// CertificateAuthority cert/key pair
func SetupCertificateAuthority(t *testing.T) (*x509.Certificate, crypto.Signer) {
caCert, caKey, err := pkiutil.NewCertificateAuthority(&certutil.Config{CommonName: "kubernetes"})
if err != nil {
t.Fatalf("failure while generating CA certificate and key: %v", err)

View File

@ -95,11 +95,11 @@ func SetupEmptyFiles(t *testing.T, tmpdir string, fileNames ...string) {
}
}
// SetupPkiDirWithCertificateAuthorithy is a utility function for kubeadm testing that creates a
// CertificateAuthorithy cert/key pair into /pki subfolder of a given temporary directory.
// SetupPkiDirWithCertificateAuthority is a utility function for kubeadm testing that creates a
// CertificateAuthority cert/key pair into /pki subfolder of a given temporary directory.
// The function returns the path of the created pki.
func SetupPkiDirWithCertificateAuthorithy(t *testing.T, tmpdir string) string {
caCert, caKey := certtestutil.SetupCertificateAuthorithy(t)
func SetupPkiDirWithCertificateAuthority(t *testing.T, tmpdir string) string {
caCert, caKey := certtestutil.SetupCertificateAuthority(t)
certDir := filepath.Join(tmpdir, "pki")
if err := pkiutil.WriteCertAndKey(certDir, kubeadmconstants.CACertAndKeyBaseName, caCert, caKey); err != nil {