RunOpen executes the functionality "devspace open"
(f factory.Factory)
| 92 | |
| 93 | // RunOpen executes the functionality "devspace open" |
| 94 | func (cmd *OpenCmd) RunOpen(f factory.Factory) error { |
| 95 | // Set config root |
| 96 | cmd.log = f.GetLog() |
| 97 | configLoader, err := f.NewConfigLoader(cmd.ConfigPath) |
| 98 | if err != nil { |
| 99 | return err |
| 100 | } |
| 101 | configExists, err := configLoader.SetDevSpaceRoot(cmd.log) |
| 102 | if err != nil { |
| 103 | return err |
| 104 | } |
| 105 | |
| 106 | var ( |
| 107 | domain string |
| 108 | tls bool |
| 109 | ingressControllerWarning string |
| 110 | ) |
| 111 | |
| 112 | // Get kubernetes client |
| 113 | client, err := f.NewKubeClientFromContext(cmd.KubeContext, cmd.Namespace) |
| 114 | if err != nil { |
| 115 | return err |
| 116 | } |
| 117 | |
| 118 | // Load generated config if possible |
| 119 | var localCache localcache.Cache |
| 120 | if configExists { |
| 121 | log.StartFileLogging() |
| 122 | |
| 123 | localCache, err = configLoader.LoadLocalCache() |
| 124 | if err != nil { |
| 125 | return err |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | // If the current kube context or namespace is different from old, |
| 130 | // show warnings and reset kube client if necessary |
| 131 | client, err = kubectl.CheckKubeContext(client, localCache, cmd.NoWarn, cmd.SwitchContext, false, cmd.log) |
| 132 | if err != nil { |
| 133 | return err |
| 134 | } |
| 135 | |
| 136 | // create devspace context |
| 137 | ctx := devspacecontext.NewContext(context.Background(), nil, cmd.log). |
| 138 | WithKubeClient(client) |
| 139 | |
| 140 | // Execute plugin hook |
| 141 | err = hook.ExecuteHooks(ctx, nil, "open") |
| 142 | if err != nil { |
| 143 | return err |
| 144 | } |
| 145 | |
| 146 | namespace := client.Namespace() |
| 147 | ingressControllerWarning = ansi.Color(" ! an ingress controller must be installed in your cluster", "red+b") |
| 148 | |
| 149 | openingMode, err := cmd.log.Question(&survey.QuestionOptions{ |
| 150 | Question: "How do you want to open your application?", |
| 151 | DefaultValue: openLocalHostOption, |
no test coverage detected