@@ -141,14 +141,7 @@ func (o *DevOptions) runWithColors(ctx context.Context) error {
141141 fmt .Fprintf (o .Streams .ErrOut , "%s kube-bind dev command is in preview\n " , redText ("EXPERIMENTAL:" ))
142142 fmt .Fprintf (o .Streams .ErrOut , "Requirements: Docker must be installed and running\n \n " )
143143
144- hostEntryExisted := false
145- if err := o .setupHostEntries (ctx ); err != nil {
146- fmt .Fprintf (o .Streams .ErrOut , "⚠️ Host entry setup warning: %v\n " , err )
147- hostEntryExisted = false
148- } else {
149- fmt .Fprint (o .Streams .ErrOut , "✓ Host entry exists for kube-bind.dev.local\n " )
150- hostEntryExisted = true
151- }
144+ hostEntryExists := o .setupHostEntries (ctx )
152145
153146 if err := o .checkFileLimits (); err != nil {
154147 fmt .Fprintf (o .Streams .ErrOut , "⚠️ File limit check warning: %v\n " , err )
@@ -183,7 +176,7 @@ func (o *DevOptions) runWithColors(ctx context.Context) error {
183176 stepNum := 1
184177
185178 // Only show /etc/hosts step if entry didn't already exist
186- if ! hostEntryExisted {
179+ if ! hostEntryExists {
187180 fmt .Fprintf (o .Streams .ErrOut , "%d. Add to /etc/hosts (if not already done):\n " , stepNum )
188181 fmt .Fprintf (o .Streams .ErrOut , "%s\n \n " , blueCommand ("echo '127.0.0.1 kube-bind.dev.local' | sudo tee -a /etc/hosts" ))
189182 stepNum ++
@@ -208,23 +201,20 @@ func (o *DevOptions) Run(ctx context.Context) error {
208201 return o .runWithColors (ctx )
209202}
210203
211- // SetupHostEntries sets up the host entries for the dev environment
212- func (o * DevOptions ) SetupHostEntries (ctx context.Context ) error {
213- return o .setupHostEntries (ctx )
214- }
215-
216- func (o * DevOptions ) setupHostEntries (ctx context.Context ) error {
204+ func (o * DevOptions ) setupHostEntries (ctx context.Context ) bool {
217205 if err := addHostEntry ("kube-bind.dev.local" ); err != nil {
218206 fmt .Fprintf (o .Streams .ErrOut , "Warning: Could not automatically add host entry. Please run:\n " )
219207 if runtime .GOOS == "windows" {
220208 fmt .Fprintf (o .Streams .ErrOut , " echo 127.0.0.1 kube-bind.dev.local >> C:\\ Windows\\ System32\\ drivers\\ etc\\ hosts\n " )
221209 } else {
222210 fmt .Fprintf (o .Streams .ErrOut , " echo '127.0.0.1 kube-bind.dev.local' | sudo tee -a /etc/hosts\n " )
223211 }
224- } else {
225- fmt . Fprint ( o . Streams . ErrOut , "Host entry exists for kube-bind.dev.local \n " )
212+
213+ return false
226214 }
227- return nil
215+
216+ fmt .Fprint (o .Streams .ErrOut , "Host entry exists for kube-bind.dev.local\n " )
217+ return true
228218}
229219
230220func (o * DevOptions ) createCluster (ctx context.Context , clusterName , clusterConfig string , installKubeBind bool ) error {
0 commit comments