Supporting Mizu view from given url (#312)

* Supporting Mizu view from given url
This commit is contained in:
Igor Gov 2021-10-05 12:24:50 +03:00 committed by GitHub
parent 90040798b8
commit 30fce5d765
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 22 deletions

View File

@ -25,4 +25,7 @@ func init() {
defaults.Set(&defaultViewConfig) defaults.Set(&defaultViewConfig)
viewCmd.Flags().Uint16P(configStructs.GuiPortViewName, "p", defaultViewConfig.GuiPort, "Provide a custom port for the web interface webserver") viewCmd.Flags().Uint16P(configStructs.GuiPortViewName, "p", defaultViewConfig.GuiPort, "Provide a custom port for the web interface webserver")
viewCmd.Flags().StringP(configStructs.UrlViewName, "u", defaultViewConfig.Url, "Provide a custom host")
viewCmd.Flags().MarkHidden(configStructs.UrlViewName)
} }

View File

@ -24,6 +24,9 @@ func runMizuView() {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
defer cancel() defer cancel()
url := config.Config.View.Url
if url == "" {
exists, err := kubernetesProvider.DoesServicesExist(ctx, config.Config.MizuResourcesNamespace, mizu.ApiServerPodName) exists, err := kubernetesProvider.DoesServicesExist(ctx, config.Config.MizuResourcesNamespace, mizu.ApiServerPodName)
if err != nil { if err != nil {
logger.Log.Errorf("Failed to found mizu service %v", err) logger.Log.Errorf("Failed to found mizu service %v", err)
@ -36,7 +39,7 @@ func runMizuView() {
return return
} }
url := GetApiServerUrl() url = GetApiServerUrl()
response, err := http.Get(fmt.Sprintf("%s/", url)) response, err := http.Get(fmt.Sprintf("%s/", url))
if err == nil && response.StatusCode == 200 { if err == nil && response.StatusCode == 200 {
@ -50,8 +53,10 @@ func runMizuView() {
logger.Log.Errorf(uiUtils.Error, fmt.Sprintf("Couldn't connect to API server, for more info check logs at %s", logger.GetLogFilePath())) logger.Log.Errorf(uiUtils.Error, fmt.Sprintf("Couldn't connect to API server, for more info check logs at %s", logger.GetLogFilePath()))
return return
} }
}
logger.Log.Infof("Mizu is available at %s\n", url) logger.Log.Infof("Mizu is available at %s\n", url)
openBrowser(url) openBrowser(url)
if isCompatible, err := version.CheckVersionCompatibility(); err != nil { if isCompatible, err := version.CheckVersionCompatibility(); err != nil {
logger.Log.Errorf("Failed to check versions compatibility %v", err) logger.Log.Errorf("Failed to check versions compatibility %v", err)

View File

@ -2,8 +2,10 @@ package configStructs
const ( const (
GuiPortViewName = "gui-port" GuiPortViewName = "gui-port"
UrlViewName = "url"
) )
type ViewConfig struct { type ViewConfig struct {
GuiPort uint16 `yaml:"gui-port" default:"8899"` GuiPort uint16 `yaml:"gui-port" default:"8899"`
Url string `yaml:"url,omitempty" readonly:""`
} }