mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 03:57:41 +00:00
[Federation] Review comments fixed for dry run support in kubefed init
This commit is contained in:
parent
2309821c5c
commit
b21cfdcd0f
@ -230,10 +230,9 @@ func initFederation(cmdOut io.Writer, config util.AdminConfig, cmd *cobra.Comman
|
||||
|
||||
if !dryRun {
|
||||
return printSuccess(cmdOut, ips, hostnames)
|
||||
} else {
|
||||
_, err := fmt.Fprintf(cmdOut, "Federation control plane runs (dry run)\n")
|
||||
return err
|
||||
}
|
||||
_, err = fmt.Fprintf(cmdOut, "Federation control plane runs (dry run)\n")
|
||||
return err
|
||||
}
|
||||
|
||||
func createNamespace(clientset *client.Clientset, namespace string, dryRun bool) (*api.Namespace, error) {
|
||||
@ -374,10 +373,7 @@ func createControllerManagerKubeconfigSecret(clientset *client.Clientset, namesp
|
||||
certutil.EncodeCertPEM(entKeyPairs.controllerManager.Cert),
|
||||
)
|
||||
|
||||
if dryRun {
|
||||
return nil, nil
|
||||
}
|
||||
return util.CreateKubeconfigSecret(clientset, config, namespace, kubeconfigName, false)
|
||||
return util.CreateKubeconfigSecret(clientset, config, namespace, kubeconfigName, dryRun)
|
||||
}
|
||||
|
||||
func createPVC(clientset *client.Clientset, namespace, svcName, etcdPVCapacity string, dryRun bool) (*api.PersistentVolumeClaim, error) {
|
||||
|
@ -147,13 +147,13 @@ func TestInitFederation(t *testing.T) {
|
||||
cmd.Flags().Set("host-cluster-context", "substrate")
|
||||
cmd.Flags().Set("dns-zone-name", tc.dnsZoneName)
|
||||
cmd.Flags().Set("image", tc.image)
|
||||
if "" != tc.dnsProvider {
|
||||
if tc.dnsProvider != "" {
|
||||
cmd.Flags().Set("dns-provider", tc.dnsProvider)
|
||||
}
|
||||
if "" != tc.etcdPVCapacity {
|
||||
if tc.etcdPVCapacity != "" {
|
||||
cmd.Flags().Set("etcd-pv-capacity", tc.etcdPVCapacity)
|
||||
}
|
||||
if "valid-run" == tc.dryRun {
|
||||
if tc.dryRun == "valid-run" {
|
||||
cmd.Flags().Set("dry-run", "true")
|
||||
}
|
||||
|
||||
@ -163,12 +163,11 @@ func TestInitFederation(t *testing.T) {
|
||||
// uses the name from the federation, not the response
|
||||
// Actual data passed are tested in the fake secret and cluster
|
||||
// REST clients.
|
||||
want := ""
|
||||
if "" != tc.dryRun {
|
||||
want := fmt.Sprintf("Federation API server is running at: %s\n", tc.lbIP)
|
||||
if tc.dryRun != "" {
|
||||
want = fmt.Sprintf("Federation control plane runs (dry run)\n")
|
||||
} else {
|
||||
want = fmt.Sprintf("Federation API server is running at: %s\n", tc.lbIP)
|
||||
}
|
||||
|
||||
if got := buf.String(); got != want {
|
||||
t.Errorf("[%d] unexpected output: got: %s, want: %s", i, got, want)
|
||||
if cmdErrMsg != "" {
|
||||
|
Loading…
Reference in New Issue
Block a user