[Federation] Review comments fixed for dry run support in kubefed init

This commit is contained in:
Irfan Ur Rehman 2016-11-15 17:48:42 +05:30
parent 2309821c5c
commit b21cfdcd0f
2 changed files with 9 additions and 14 deletions

View File

@ -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) {

View File

@ -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 != "" {