mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-19 09:52:49 +00:00
remove unused funcs for kubeadm tests
This commit is contained in:
parent
c995039d62
commit
0abed09a6a
@ -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",
|
||||
],
|
||||
)
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user