refact pdb
parent
125e70ebb6
commit
d3478d9c63
7
go.sum
7
go.sum
|
|
@ -17,7 +17,9 @@ github.com/Azure/go-autorest/tracing v0.1.0 h1:TRBxC5Pj/fIuh4Qob0ZpkggbfT8RC0Sub
|
|||
github.com/Azure/go-autorest/tracing v0.1.0/go.mod h1:ROEEAFwXycQw7Sn3DXNtEedEvdeRAgDr0izn4z5Ij88=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
|
||||
github.com/PuerkitoBio/purell v1.0.0 h1:0GoNN3taZV6QI81IXgCbxMyEaJDXMSIjArYBCYzVVvs=
|
||||
github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2 h1:JCHLVE3B+kJde7bIEo5N4J+ZbLhp0J1Fs+ulyRws4gE=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
||||
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
|
||||
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
|
||||
|
|
@ -61,9 +63,13 @@ github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2H
|
|||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1 h1:wSt/4CYxs70xbATrGXhokKF1i0tZjENLOo1ioIO13zk=
|
||||
github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0=
|
||||
github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9 h1:tF+augKRWlWx0J0B7ZyyKSiTyV6E1zZe+7b3qQlcEf8=
|
||||
github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg=
|
||||
github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501 h1:C1JKChikHGpXwT5UQDFaryIpDtyyGL/CR6C2kB7F1oc=
|
||||
github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc=
|
||||
github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87 h1:zP3nY8Tk2E6RTkqGYrarZXuzh+ffyLDljLxCy1iJw80=
|
||||
github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
|
|
@ -122,6 +128,7 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
|||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/lucasb-eyer/go-colorful v0.0.0-20181028223441-12d3b2882a08 h1:5MnxBC15uMxFv5FY/J/8vzyaBiArCOkMdFT9Jsw78iY=
|
||||
github.com/lucasb-eyer/go-colorful v0.0.0-20181028223441-12d3b2882a08/go.mod h1:NXg0ArsFk0Y01623LgUqoqcouGDB+PwCCQlrwrG6xJ4=
|
||||
github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a h1:TpvdAwDAt1K4ANVOfcihouRdvP+MgAfDWwBuct4l6ZY=
|
||||
github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y=
|
||||
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"github.com/derailed/k9s/internal/k8s"
|
||||
"github.com/rs/zerolog/log"
|
||||
v1beta1 "k8s.io/api/policy/v1beta1"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
)
|
||||
|
||||
// PodDisruptionBudget that can be displayed in a table and interacted with.
|
||||
|
|
@ -96,20 +97,10 @@ func (r *PodDisruptionBudget) Fields(ns string) Row {
|
|||
ff = append(ff, i.Namespace)
|
||||
}
|
||||
|
||||
min := NAValue
|
||||
if i.Spec.MinAvailable != nil {
|
||||
min = strconv.Itoa(int(i.Spec.MinAvailable.IntVal))
|
||||
}
|
||||
|
||||
max := NAValue
|
||||
if i.Spec.MaxUnavailable != nil {
|
||||
max = strconv.Itoa(int(i.Spec.MaxUnavailable.IntVal))
|
||||
}
|
||||
|
||||
return append(ff,
|
||||
i.Name,
|
||||
min,
|
||||
max,
|
||||
numbToStr(i.Spec.MinAvailable),
|
||||
numbToStr(i.Spec.MaxUnavailable),
|
||||
strconv.Itoa(int(i.Status.PodDisruptionsAllowed)),
|
||||
strconv.Itoa(int(i.Status.CurrentHealthy)),
|
||||
strconv.Itoa(int(i.Status.DesiredHealthy)),
|
||||
|
|
@ -117,3 +108,12 @@ func (r *PodDisruptionBudget) Fields(ns string) Row {
|
|||
toAge(i.ObjectMeta.CreationTimestamp),
|
||||
)
|
||||
}
|
||||
|
||||
// Helpers...
|
||||
|
||||
func numbToStr(n *intstr.IntOrString) string {
|
||||
if n == nil {
|
||||
return NAValue
|
||||
}
|
||||
return strconv.Itoa(int(n.IntVal))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,24 +118,27 @@ func (v *containerView) portForward(lport, cport string) {
|
|||
}
|
||||
|
||||
log.Debug().Msgf(">>> Starting port forward %q %v", *v.path, ports)
|
||||
go func(f *portforward.PortForwarder) {
|
||||
v.app.QueueUpdateDraw(func() {
|
||||
v.app.forwarders = append(v.app.forwarders, pf)
|
||||
v.app.flash().infof("PortForward activated %s:%s", pf.Path(), pf.Ports()[0])
|
||||
v.dismissModal()
|
||||
})
|
||||
pf.SetActive(true)
|
||||
if err := f.ForwardPorts(); err == nil {
|
||||
return
|
||||
go v.runForward(pf, fw)
|
||||
}
|
||||
|
||||
func (v *containerView) runForward(pf *k8s.PortForward, f *portforward.PortForwarder) {
|
||||
v.app.QueueUpdateDraw(func() {
|
||||
v.app.forwarders = append(v.app.forwarders, pf)
|
||||
v.app.flash().infof("PortForward activated %s:%s", pf.Path(), pf.Ports()[0])
|
||||
v.dismissModal()
|
||||
})
|
||||
|
||||
pf.SetActive(true)
|
||||
if err := f.ForwardPorts(); err == nil {
|
||||
v.app.flash().err(err)
|
||||
return
|
||||
}
|
||||
v.app.QueueUpdateDraw(func() {
|
||||
if len(v.app.forwarders) > 0 {
|
||||
v.app.forwarders = v.app.forwarders[:len(v.app.forwarders)-1]
|
||||
}
|
||||
v.app.QueueUpdateDraw(func() {
|
||||
if len(v.app.forwarders) > 0 {
|
||||
v.app.forwarders = v.app.forwarders[:len(v.app.forwarders)-1]
|
||||
}
|
||||
pf.SetActive(false)
|
||||
v.app.flash().errf("PortForward failed %s", err)
|
||||
})
|
||||
}(fw)
|
||||
pf.SetActive(false)
|
||||
})
|
||||
}
|
||||
|
||||
func (v *containerView) dismissModal() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue