@@ -17,6 +17,7 @@ limitations under the License.
17
17
package main
18
18
19
19
import (
20
+ "bytes"
20
21
"fmt"
21
22
"github.com/golang/glog"
22
23
"github.com/spf13/cobra"
@@ -163,9 +164,9 @@ func RunUpdateCluster(f *util.Factory, clusterName string, out io.Writer, c *Upd
163
164
if isDryrun {
164
165
target := applyCmd .Target .(* fi.DryRunTarget )
165
166
if target .HasChanges () {
166
- fmt .Printf ( "Must specify --yes to apply changes\n " )
167
+ fmt .Fprintf ( out , "Must specify --yes to apply changes\n " )
167
168
} else {
168
- fmt .Printf ( "No changes need to be applied\n " )
169
+ fmt .Fprintf ( out , "No changes need to be applied\n " )
169
170
}
170
171
return nil
171
172
}
@@ -202,29 +203,36 @@ func RunUpdateCluster(f *util.Factory, clusterName string, out io.Writer, c *Upd
202
203
}
203
204
204
205
if ! hasKubecfg {
206
+ sb := new (bytes.Buffer )
207
+
205
208
// Assume initial creation
206
209
if c .Target == cloudup .TargetTerraform {
207
- fmt .Printf ( "\n " )
208
- fmt .Printf ( "Terraform output has been placed into %s\n " , c .OutDir )
209
- fmt .Printf ( "Run these commands to apply the configuration:\n " )
210
- fmt .Printf ( " cd %s\n " , c .OutDir )
211
- fmt .Printf ( " terraform plan\n " )
212
- fmt .Printf ( " terraform apply\n " )
213
- fmt .Printf ( "\n " )
210
+ fmt .Fprintf ( sb , "\n " )
211
+ fmt .Fprintf ( sb , "Terraform output has been placed into %s\n " , c .OutDir )
212
+ fmt .Fprintf ( sb , "Run these commands to apply the configuration:\n " )
213
+ fmt .Fprintf ( sb , " cd %s\n " , c .OutDir )
214
+ fmt .Fprintf ( sb , " terraform plan\n " )
215
+ fmt .Fprintf ( sb , " terraform apply\n " )
216
+ fmt .Fprintf ( sb , "\n " )
214
217
} else {
215
- fmt .Printf ( "\n " )
216
- fmt .Printf ( "Cluster is starting. It should be ready in a few minutes.\n " )
217
- fmt .Printf ( "\n " )
218
+ fmt .Fprintf ( sb , "\n " )
219
+ fmt .Fprintf ( sb , "Cluster is starting. It should be ready in a few minutes.\n " )
220
+ fmt .Fprintf ( sb , "\n " )
218
221
}
219
- fmt .Printf ( "Suggestions:\n " )
220
- fmt .Printf ( " * list nodes: kubectl get nodes --show-labels\n " )
222
+ fmt .Fprintf ( sb , "Suggestions:\n " )
223
+ fmt .Fprintf ( sb , " * list nodes: kubectl get nodes --show-labels\n " )
221
224
if cluster .Spec .Topology .Masters == kops .TopologyPublic {
222
- fmt .Printf ( " * ssh to the master: ssh -i ~/.ssh/id_rsa admin@%s\n " , cluster .Spec .MasterPublicName )
225
+ fmt .Fprintf ( sb , " * ssh to the master: ssh -i ~/.ssh/id_rsa admin@%s\n " , cluster .Spec .MasterPublicName )
223
226
} else {
224
- fmt .Printf (" * ssh to the bastion: ssh -i ~/.ssh/id_rsa admin@%s\n " , cluster .Spec .MasterPublicName )
227
+ fmt .Fprintf (sb , " * ssh to the bastion: ssh -i ~/.ssh/id_rsa admin@%s\n " , cluster .Spec .MasterPublicName )
228
+ }
229
+ fmt .Fprintf (sb , " * read about installing addons: https://github.com/kubernetes/kops/blob/master/docs/addons.md\n " )
230
+ fmt .Fprintf (sb , "\n " )
231
+
232
+ _ , err := out .Write (sb .Bytes ())
233
+ if err != nil {
234
+ return fmt .Errorf ("error writing to output: %v" , err )
225
235
}
226
- fmt .Printf (" * read about installing addons: https://github.com/kubernetes/kops/blob/master/docs/addons.md\n " )
227
- fmt .Printf ("\n " )
228
236
}
229
237
}
230
238
0 commit comments