diff --git a/cmd/kubeadm/test/BUILD b/cmd/kubeadm/test/BUILD index 584937d8283..a2eb8fc4320 100644 --- a/cmd/kubeadm/test/BUILD +++ b/cmd/kubeadm/test/BUILD @@ -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", ], ) diff --git a/cmd/kubeadm/test/cmd/util.go b/cmd/kubeadm/test/cmd/util.go index 2c33f99cbc5..95d4e119d0e 100644 --- a/cmd/kubeadm/test/cmd/util.go +++ b/cmd/kubeadm/test/cmd/util.go @@ -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 { diff --git a/cmd/kubeadm/test/util.go b/cmd/kubeadm/test/util.go index 104ba220e2b..14c8065d0ea 100644 --- a/cmd/kubeadm/test/util.go +++ b/cmd/kubeadm/test/util.go @@ -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" @@ -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 {