Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Mizu
Commits
2dffbba9
Commit
2dffbba9
authored
3 years ago
by
Igor Gov
Browse files
Options
Download
Email Patches
Plain Diff
Supporting Mizu view from given url
parent
90040798
view_url
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cli/cmd/view.go
+3
-0
cli/cmd/view.go
cli/cmd/viewRunner.go
+27
-22
cli/cmd/viewRunner.go
cli/config/configStructs/viewConfig.go
+2
-0
cli/config/configStructs/viewConfig.go
with
32 additions
and
22 deletions
+32
-22
cli/cmd/view.go
+
3
-
0
View file @
2dffbba9
...
...
@@ -25,4 +25,7 @@ func init() {
defaults
.
Set
(
&
defaultViewConfig
)
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
)
}
This diff is collapsed.
Click to expand it.
cli/cmd/viewRunner.go
+
27
-
22
View file @
2dffbba9
...
...
@@ -24,34 +24,39 @@ func runMizuView() {
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancel
()
exists
,
err
:=
kubernetesProvider
.
DoesServicesExist
(
ctx
,
config
.
Config
.
MizuResourcesNamespace
,
mizu
.
ApiServerPodName
)
if
err
!=
nil
{
logger
.
Log
.
Errorf
(
"Failed to found mizu service %v"
,
err
)
cancel
()
return
}
if
!
exists
{
logger
.
Log
.
Infof
(
"%s service not found, you should run `mizu tap` command first"
,
mizu
.
ApiServerPodName
)
cancel
()
return
}
url
:=
config
.
Config
.
View
.
Url
url
:=
GetApiServerUrl
()
if
url
==
""
{
exists
,
err
:=
kubernetesProvider
.
DoesServicesExist
(
ctx
,
config
.
Config
.
MizuResourcesNamespace
,
mizu
.
ApiServerPodName
)
if
err
!=
nil
{
logger
.
Log
.
Errorf
(
"Failed to found mizu service %v"
,
err
)
cancel
()
return
}
if
!
exists
{
logger
.
Log
.
Infof
(
"%s service not found, you should run `mizu tap` command first"
,
mizu
.
ApiServerPodName
)
cancel
()
return
}
response
,
err
:=
http
.
Get
(
fmt
.
Sprintf
(
"%s/"
,
url
))
if
err
==
nil
&&
response
.
StatusCode
==
200
{
logger
.
Log
.
Infof
(
"Found a running service %s and open port %d"
,
mizu
.
ApiServerPodName
,
config
.
Config
.
View
.
GuiPort
)
return
}
logger
.
Log
.
Infof
(
"Establishing connection to k8s cluster..."
)
go
startProxyReportErrorIfAny
(
kubernetesProvider
,
cancel
)
url
:=
GetApiServerUrl
()
if
err
:=
apiserver
.
Provider
.
InitAndTestConnection
(
GetApiServerUrl
());
err
!=
nil
{
logger
.
Log
.
Errorf
(
uiUtils
.
Error
,
fmt
.
Sprintf
(
"Couldn't connect to API server, for more info check logs at %s"
,
logger
.
GetLogFilePath
()))
return
response
,
err
:=
http
.
Get
(
fmt
.
Sprintf
(
"%s/"
,
url
))
if
err
==
nil
&&
response
.
StatusCode
==
200
{
logger
.
Log
.
Infof
(
"Found a running service %s and open port %d"
,
mizu
.
ApiServerPodName
,
config
.
Config
.
View
.
GuiPort
)
return
}
logger
.
Log
.
Infof
(
"Establishing connection to k8s cluster..."
)
go
startProxyReportErrorIfAny
(
kubernetesProvider
,
cancel
)
if
err
:=
apiserver
.
Provider
.
InitAndTestConnection
(
GetApiServerUrl
());
err
!=
nil
{
logger
.
Log
.
Errorf
(
uiUtils
.
Error
,
fmt
.
Sprintf
(
"Couldn't connect to API server, for more info check logs at %s"
,
logger
.
GetLogFilePath
()))
return
}
}
logger
.
Log
.
Infof
(
"Mizu is available at %s
\n
"
,
url
)
openBrowser
(
url
)
if
isCompatible
,
err
:=
version
.
CheckVersionCompatibility
();
err
!=
nil
{
logger
.
Log
.
Errorf
(
"Failed to check versions compatibility %v"
,
err
)
...
...
This diff is collapsed.
Click to expand it.
cli/config/configStructs/viewConfig.go
+
2
-
0
View file @
2dffbba9
...
...
@@ -2,8 +2,10 @@ package configStructs
const
(
GuiPortViewName
=
"gui-port"
UrlViewName
=
"url"
)
type
ViewConfig
struct
{
GuiPort
uint16
`yaml:"gui-port" default:"8899"`
Url
string
`yaml:"url,omitempty" readonly:""`
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help