Skip to content

Commit

Permalink
Merge pull request #97452 from 249043822/br-cleanup-kubctl111
Browse files Browse the repository at this point in the history
remove unused funcs for kubeadm tests
  • Loading branch information
k8s-ci-robot committed Dec 24, 2020
2 parents 37352fb + 0abed09 commit 9858bc2
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 55 deletions.
1 change: 0 additions & 1 deletion cmd/kubeadm/test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ go_library(
"//cmd/kubeadm/app/util/certs:go_default_library",
"//cmd/kubeadm/app/util/config:go_default_library",
"//cmd/kubeadm/app/util/pkiutil:go_default_library",
"//vendor/github.com/lithammer/dedent:go_default_library",
],
)

Expand Down
11 changes: 0 additions & 11 deletions cmd/kubeadm/test/cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,6 @@ func RunSubCommand(t *testing.T, subCmds []*cobra.Command, command string, args
}
}

// AssertSubCommandHasFlags is a utility function for kubeadm testing that assert if a Cobra sub command has expected flags
func AssertSubCommandHasFlags(t *testing.T, subCmds []*cobra.Command, command string, flags ...string) {
subCmd := getSubCommand(t, subCmds, command)

for _, flag := range flags {
if subCmd.Flags().Lookup(flag) == nil {
t.Errorf("Could not find expecte flag %s for command %s", flag, command)
}
}
}

func getSubCommand(t *testing.T, subCmds []*cobra.Command, name string) *cobra.Command {
for _, subCmd := range subCmds {
if subCmd.Name() == name {
Expand Down
43 changes: 0 additions & 43 deletions cmd/kubeadm/test/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,11 @@ limitations under the License.
package test

import (
"fmt"
"html/template"
"io/ioutil"
"os"
"path/filepath"
"testing"

"github.com/lithammer/dedent"

kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
Expand All @@ -45,45 +41,6 @@ func SetupTempDir(t *testing.T) string {
return tmpdir
}

// SetupInitConfigurationFile is a utility function for kubeadm testing that writes a InitConfiguration file
// into /config subfolder of a given temporary directory.
// The function returns the path of the created InitConfiguration file.
func SetupInitConfigurationFile(t *testing.T, tmpdir string, cfg *kubeadmapi.InitConfiguration) string {

cfgPath := filepath.Join(tmpdir, "config/masterconfig.yaml")
if err := os.MkdirAll(filepath.Dir(cfgPath), os.FileMode(0755)); err != nil {
t.Fatalf("Couldn't create cfgDir")
}

cfgTemplate := template.Must(template.New("init").Parse(dedent.Dedent(fmt.Sprintf(`
apiVersion: kubeadm.k8s.io/v1beta2
kind: InitConfiguration
apiEndpoint:
advertiseAddress: {{.LocalAPIEndpoint.AdvertiseAddress}}
bindPort: {{.LocalAPIEndpoint.BindPort}}
nodeRegistration:
name: {{.NodeRegistration.Name}}
---
apiVersion: kubeadm.k8s.io/v1beta2
kind: ClusterConfiguration
certificatesDir: {{.CertificatesDir}}
kubernetesVersion: %s
`, kubeadmconstants.MinimumControlPlaneVersion))))

f, err := os.Create(cfgPath)
if err != nil {
t.Fatalf("error creating masterconfig file %s: %v", cfgPath, err)
}

err = cfgTemplate.Execute(f, cfg)
if err != nil {
t.Fatalf("error generating masterconfig file %s: %v", cfgPath, err)
}
f.Close()

return cfgPath
}

// SetupEmptyFiles is a utility function for kubeadm testing that creates one or more empty files (touch)
func SetupEmptyFiles(t *testing.T, tmpdir string, fileNames ...string) {
for _, fileName := range fileNames {
Expand Down

0 comments on commit 9858bc2

Please sign in to comment.