From cd2ecefb803c5b2efa4f4980b701c3a6a685daff Mon Sep 17 00:00:00 2001 From: alan Date: Tue, 6 Aug 2019 12:01:28 +0800 Subject: [PATCH] kubeadm: fix name of CA spell error --- cmd/kubeadm/app/cmd/alpha/kubeconfig_test.go | 2 +- cmd/kubeadm/app/phases/certs/certlist.go | 4 ++-- cmd/kubeadm/app/phases/certs/certs.go | 6 ++--- cmd/kubeadm/app/phases/certs/certs_test.go | 10 ++++----- .../app/phases/kubeconfig/kubeconfig_test.go | 22 +++++++++---------- .../app/phases/upgrade/staticpods_test.go | 2 +- cmd/kubeadm/app/util/certs/util.go | 6 ++--- cmd/kubeadm/test/util.go | 8 +++---- 8 files changed, 30 insertions(+), 30 deletions(-) diff --git a/cmd/kubeadm/app/cmd/alpha/kubeconfig_test.go b/cmd/kubeadm/app/cmd/alpha/kubeconfig_test.go index e2711b4453c..e80e9a652c5 100644 --- a/cmd/kubeadm/app/cmd/alpha/kubeconfig_test.go +++ b/cmd/kubeadm/app/cmd/alpha/kubeconfig_test.go @@ -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) diff --git a/cmd/kubeadm/app/phases/certs/certlist.go b/cmd/kubeadm/app/phases/certs/certlist.go index ea75be38939..2cd31b97527 100644 --- a/cmd/kubeadm/app/phases/certs/certlist.go +++ b/cmd/kubeadm/app/phases/certs/certlist.go @@ -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, diff --git a/cmd/kubeadm/app/phases/certs/certs.go b/cmd/kubeadm/app/phases/certs/certs.go index 8d6dfa0a0bf..c9a528ce0ca 100644 --- a/cmd/kubeadm/app/phases/certs/certs.go +++ b/cmd/kubeadm/app/phases/certs/certs.go @@ -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) { diff --git a/cmd/kubeadm/app/phases/certs/certs_test.go b/cmd/kubeadm/app/phases/certs/certs_test.go index 191f7aa950f..0703c2be654 100644 --- a/cmd/kubeadm/app/phases/certs/certs_test.go +++ b/cmd/kubeadm/app/phases/certs/certs_test.go @@ -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 diff --git a/cmd/kubeadm/app/phases/kubeconfig/kubeconfig_test.go b/cmd/kubeadm/app/phases/kubeconfig/kubeconfig_test.go index 3ab7c8f0ab2..06a0cff382f 100644 --- a/cmd/kubeadm/app/phases/kubeconfig/kubeconfig_test.go +++ b/cmd/kubeadm/app/phases/kubeconfig/kubeconfig_test.go @@ -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 diff --git a/cmd/kubeadm/app/phases/upgrade/staticpods_test.go b/cmd/kubeadm/app/phases/upgrade/staticpods_test.go index 9b95a3c0171..08dfa863f68 100644 --- a/cmd/kubeadm/app/phases/upgrade/staticpods_test.go +++ b/cmd/kubeadm/app/phases/upgrade/staticpods_test.go @@ -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 diff --git a/cmd/kubeadm/app/util/certs/util.go b/cmd/kubeadm/app/util/certs/util.go index e7881b8a3b3..9f96c046b7b 100644 --- a/cmd/kubeadm/app/util/certs/util.go +++ b/cmd/kubeadm/app/util/certs/util.go @@ -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) diff --git a/cmd/kubeadm/test/util.go b/cmd/kubeadm/test/util.go index a0bbc253f4a..104ba220e2b 100644 --- a/cmd/kubeadm/test/util.go +++ b/cmd/kubeadm/test/util.go @@ -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 {