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
小 白蛋
K9s
Commits
565cd12f
Commit
565cd12f
authored
5 years ago
by
derailed
Browse files
Options
Download
Email Patches
Plain Diff
oops missed a few files. My bad!
parent
aab46f6a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
internal/dao/registry.go
+1
-1
internal/dao/registry.go
internal/view/helpers.go
+12
-2
internal/view/helpers.go
internal/view/pod.go
+13
-13
internal/view/pod.go
internal/watch/factory.go
+2
-1
internal/watch/factory.go
with
28 additions
and
17 deletions
+28
-17
internal/dao/registry.go
+
1
-
1
View file @
565cd12f
...
...
@@ -43,7 +43,7 @@ func AccessorFor(f Factory, gvr client.GVR) (Accessor, error) {
r
,
ok
:=
m
[
gvr
]
if
!
ok
{
r
=
&
Generic
{}
log
.
Warn
()
.
Msgf
(
"No DAO registry entry for %q. Using factory!"
,
gvr
)
log
.
Debug
()
.
Msgf
(
"No DAO registry entry for %q. Using factory!"
,
gvr
)
}
r
.
Init
(
f
,
gvr
)
...
...
This diff is collapsed.
Click to expand it.
internal/view/helpers.go
+
12
-
2
View file @
565cd12f
...
...
@@ -101,7 +101,7 @@ func showPods(app *App, path, labelSel, fieldSel string) {
app
.
switchNS
(
""
)
v
:=
NewPod
(
client
.
NewGVR
(
"v1/pods"
))
v
.
SetContextFn
(
podCtx
(
path
,
labelSel
,
fieldSel
))
v
.
SetContextFn
(
podCtx
(
app
,
path
,
labelSel
,
fieldSel
))
v
.
GetTable
()
.
SetColorerFn
(
render
.
Pod
{}
.
ColorerFunc
())
ns
,
_
:=
client
.
Namespaced
(
path
)
...
...
@@ -113,10 +113,20 @@ func showPods(app *App, path, labelSel, fieldSel string) {
}
}
func
podCtx
(
path
,
labelSel
,
fieldSel
string
)
ContextFunc
{
func
podCtx
(
app
*
App
,
path
,
labelSel
,
fieldSel
string
)
ContextFunc
{
return
func
(
ctx
context
.
Context
)
context
.
Context
{
ctx
=
context
.
WithValue
(
ctx
,
internal
.
KeyPath
,
path
)
ctx
=
context
.
WithValue
(
ctx
,
internal
.
KeyLabels
,
labelSel
)
ns
,
_
:=
client
.
Namespaced
(
path
)
log
.
Debug
()
.
Msgf
(
"POD METRICS in NS %q"
,
ns
)
mx
:=
client
.
NewMetricsServer
(
app
.
factory
.
Client
())
nmx
,
err
:=
mx
.
FetchPodsMetrics
(
ns
)
if
err
!=
nil
{
log
.
Warn
()
.
Err
(
err
)
.
Msgf
(
"No pods metrics"
)
}
ctx
=
context
.
WithValue
(
ctx
,
internal
.
KeyMetrics
,
nmx
)
return
context
.
WithValue
(
ctx
,
internal
.
KeyFields
,
fieldSel
)
}
}
...
...
This diff is collapsed.
Click to expand it.
internal/view/pod.go
+
13
-
13
View file @
565cd12f
...
...
@@ -32,7 +32,7 @@ func NewPod(gvr client.GVR) ResourceViewer {
p
.
SetBindKeysFn
(
p
.
bindKeys
)
p
.
GetTable
()
.
SetEnterFn
(
p
.
showContainers
)
p
.
GetTable
()
.
SetColorerFn
(
render
.
Pod
{}
.
ColorerFunc
())
p
.
SetContextFn
(
p
.
pod
MX
Context
)
p
.
SetContextFn
(
p
.
podContext
)
return
&
p
}
...
...
@@ -53,31 +53,31 @@ func (p *Pod) bindKeys(aa ui.KeyActions) {
})
}
func
(
p
*
Pod
)
podMXContext
(
ctx
context
.
Context
)
context
.
Context
{
func
(
p
*
Pod
)
showContainers
(
app
*
App
,
ns
,
gvr
,
path
string
)
{
log
.
Debug
()
.
Msgf
(
"SHOW CONTAINERS %q -- %q -- %q"
,
gvr
,
ns
,
path
)
co
:=
NewContainer
(
client
.
NewGVR
(
"containers"
))
co
.
SetContextFn
(
p
.
coContext
)
if
err
:=
app
.
inject
(
co
);
err
!=
nil
{
app
.
Flash
()
.
Err
(
err
)
}
}
func
(
p
*
Pod
)
podContext
(
ctx
context
.
Context
)
context
.
Context
{
ns
,
ok
:=
ctx
.
Value
(
internal
.
KeyNamespace
)
.
(
string
)
if
!
ok
{
log
.
Error
()
.
Err
(
fmt
.
Errorf
(
"Expecting context namespace"
))
}
log
.
Debug
()
.
Msgf
(
"POD METRICS in NS %q"
,
ns
)
mx
:=
client
.
NewMetricsServer
(
p
.
App
()
.
factory
.
Client
())
nmx
,
err
:=
mx
.
FetchPodsMetrics
(
ns
)
if
err
!=
nil
{
log
.
Warn
()
.
Err
(
err
)
.
Msgf
(
"No pods metrics"
)
}
return
context
.
WithValue
(
ctx
,
internal
.
KeyMetrics
,
nmx
)
}
func
(
p
*
Pod
)
showContainers
(
app
*
App
,
ns
,
gvr
,
path
string
)
{
log
.
Debug
()
.
Msgf
(
"SHOW CONTAINERS %q -- %q -- %q"
,
gvr
,
ns
,
path
)
co
:=
NewContainer
(
client
.
NewGVR
(
"containers"
))
co
.
SetContextFn
(
p
.
podContext
)
if
err
:=
app
.
inject
(
co
);
err
!=
nil
{
app
.
Flash
()
.
Err
(
err
)
}
}
func
(
p
*
Pod
)
podContext
(
ctx
context
.
Context
)
context
.
Context
{
func
(
p
*
Pod
)
coContext
(
ctx
context
.
Context
)
context
.
Context
{
return
context
.
WithValue
(
ctx
,
internal
.
KeyPath
,
p
.
GetTable
()
.
GetSelectedItem
())
}
...
...
This diff is collapsed.
Click to expand it.
internal/watch/factory.go
+
2
-
1
View file @
565cd12f
...
...
@@ -110,10 +110,11 @@ func (f *Factory) waitForCacheSync(ns string) {
c
:=
make
(
chan
struct
{})
go
func
(
c
chan
struct
{})
{
<-
time
.
After
(
dur
)
log
.
Warn
()
.
Msgf
(
"Wait for sync timed out!"
)
log
.
Debug
()
.
Msgf
(
"Wait for sync timed out!"
)
close
(
c
)
}(
c
)
fac
.
WaitForCacheSync
(
c
)
log
.
Debug
()
.
Msgf
(
"Sync completed for ns %q"
,
ns
)
}
}
...
...
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