Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kubeadm: fix name of CA spell error #81002

Merged
merged 1 commit into from Aug 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/kubeadm/app/cmd/alpha/kubeconfig_test.go
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions cmd/kubeadm/app/phases/certs/certlist.go
Expand Up @@ -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,
Expand Down Expand Up @@ -146,7 +146,7 @@ func (t CertificateTree) CreateTree(ic *kubeadmapi.InitConfiguration) error {
return err
}

err = writeCertificateAuthorithyFilesIfNotExist(
err = writeCertificateAuthorityFilesIfNotExist(
ic.CertificatesDir,
ca.BaseName,
caCert,
Expand Down
6 changes: 3 additions & 3 deletions cmd/kubeadm/app/phases/certs/certs.go
Expand Up @@ -113,7 +113,7 @@ func CreateCACertAndKeyFiles(certSpec *KubeadmCert, cfg *kubeadmapi.InitConfigur
return err
}

return writeCertificateAuthorithyFilesIfNotExist(
return writeCertificateAuthorityFilesIfNotExist(
cfg.CertificatesDir,
certSpec.BaseName,
caCert,
Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions cmd/kubeadm/app/phases/certs/certs_test.go
Expand Up @@ -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)

Expand All @@ -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,
},
Expand Down Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions cmd/kubeadm/app/phases/kubeconfig/kubeconfig_test.go
Expand Up @@ -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{
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmd/kubeadm/app/phases/upgrade/staticpods_test.go
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions cmd/kubeadm/app/util/certs/util.go
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions cmd/kubeadm/test/util.go
Expand Up @@ -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 {
Expand Down