cleaning up
parent
543f9837ff
commit
7cf9fe6c8b
|
|
@ -45,7 +45,7 @@ type APIClient struct {
|
|||
metricsAPI bool
|
||||
}
|
||||
|
||||
// NewTestAPIClient for testing ONLY!!
|
||||
// NewTestClient for testing ONLY!!
|
||||
func NewTestClient() *APIClient {
|
||||
return &APIClient{
|
||||
config: NewConfig(nil),
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
// K9sViewConfigFile represents the location for the views configuration.
|
||||
var K9sViewConfigFile = filepath.Join(K9sHome, "views.yml")
|
||||
|
||||
// ViewConfigListener represents a view config listener.
|
||||
|
|
@ -15,15 +16,17 @@ type ViewConfigListener interface {
|
|||
ViewSettingsChanged(ViewSetting)
|
||||
}
|
||||
|
||||
// ViewSetting represents a view configuration.
|
||||
type ViewSetting struct {
|
||||
Columns []string `yaml:"columns"`
|
||||
}
|
||||
|
||||
// ViewSettings represent a collection of view configurations.
|
||||
type ViewSettings struct {
|
||||
Fuck string `yaml:"fuck"`
|
||||
Views map[string]ViewSetting `yaml:"views"`
|
||||
}
|
||||
|
||||
// NewViewSettings returns a new configuration.
|
||||
func NewViewSettings() ViewSettings {
|
||||
return ViewSettings{
|
||||
Views: make(map[string]ViewSetting),
|
||||
|
|
@ -36,6 +39,7 @@ type CustomView struct {
|
|||
listeners map[string]ViewConfigListener
|
||||
}
|
||||
|
||||
// NewCustomView returns a views configuration.
|
||||
func NewCustomView() *CustomView {
|
||||
return &CustomView{
|
||||
K9s: NewViewSettings(),
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ func (d *Deployment) Pod(fqn string) (string, error) {
|
|||
return podFromSelector(d.Factory, dp.Namespace, dp.Spec.Selector.MatchLabels)
|
||||
}
|
||||
|
||||
// GetInstance returns a deployment instance.
|
||||
// Load returns a deployment instance.
|
||||
func (*Deployment) Load(f Factory, fqn string) (*appsv1.Deployment, error) {
|
||||
o, err := f.Get("apps/v1/deployments", fqn, false, labels.Everything())
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -21,20 +21,7 @@ type ReplicaSet struct {
|
|||
Resource
|
||||
}
|
||||
|
||||
// BOZO!!
|
||||
// // IsHappy check for happy deployments.
|
||||
// func (*ReplicaSet) IsHappy(rs appsv1.ReplicaSet) bool {
|
||||
// if rs.Status.Replicas == 0 && rs.Status.Replicas != rs.Status.ReadyReplicas {
|
||||
// return false
|
||||
// }
|
||||
|
||||
// if rs.Status.Replicas != 0 && rs.Status.Replicas != rs.Status.ReadyReplicas {
|
||||
// return false
|
||||
// }
|
||||
|
||||
// return true
|
||||
// }
|
||||
|
||||
// Load returns a given instance.
|
||||
func (r *ReplicaSet) Load(f Factory, path string) (*v1.ReplicaSet, error) {
|
||||
o, err := f.Get("apps/v1/replicasets", path, true, labels.Everything())
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -167,6 +167,7 @@ func gatherMetrics(co *v1.Container, mx *mv1beta1.ContainerMetrics) (c, p, l met
|
|||
return
|
||||
}
|
||||
|
||||
// ToContainerPorts returns container ports as a string.
|
||||
func ToContainerPorts(pp []v1.ContainerPort) string {
|
||||
ports := make([]string, len(pp))
|
||||
for i, p := range pp {
|
||||
|
|
@ -182,6 +183,7 @@ func ToContainerPorts(pp []v1.ContainerPort) string {
|
|||
return strings.Join(ports, ",")
|
||||
}
|
||||
|
||||
// ToContainerState returns container state as a string.
|
||||
func ToContainerState(s v1.ContainerState) string {
|
||||
switch {
|
||||
case s.Waiting != nil:
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ func (h Header) HasAge() bool {
|
|||
return h.IndexOf(ageCol, true) != -1
|
||||
}
|
||||
|
||||
// AgeCol checks if given column index is the age column.
|
||||
// IsAgeCol checks if given column index is the age column.
|
||||
func (h Header) IsAgeCol(col int) bool {
|
||||
if !h.HasAge() || col >= len(h) {
|
||||
return false
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ func (r RowEvent) Diff(re RowEvent, ageCol int) bool {
|
|||
// RowEvents a collection of row events.
|
||||
type RowEvents []RowEvent
|
||||
|
||||
// Customize returns custom row events based on columns layout.
|
||||
func (r RowEvents) Customize(cols []int) RowEvents {
|
||||
ee := make(RowEvents, 0, len(cols))
|
||||
for _, re := range r {
|
||||
|
|
|
|||
|
|
@ -131,6 +131,7 @@ func toIPs(svcType v1.ServiceType, ips []string) string {
|
|||
return strings.Join(ips, ",")
|
||||
}
|
||||
|
||||
// ToPorts returns service ports as a string.
|
||||
func ToPorts(pp []v1.ServicePort) string {
|
||||
ports := make([]string, len(pp))
|
||||
for i, p := range pp {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ func NewTableData() *TableData {
|
|||
return &TableData{}
|
||||
}
|
||||
|
||||
// Customize returns a new model with customized column layout.
|
||||
func (t *TableData) Customize(cols []string, wide bool) TableData {
|
||||
res := TableData{
|
||||
Namespace: t.Namespace,
|
||||
|
|
|
|||
|
|
@ -152,6 +152,7 @@ func (a *App) InCmdMode() bool {
|
|||
return a.Cmd().InCmdMode()
|
||||
}
|
||||
|
||||
// HasAction checks if key matches a registered binding.
|
||||
func (a *App) HasAction(key tcell.Key) (KeyAction, bool) {
|
||||
act, ok := a.actions[key]
|
||||
return act, ok
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ func (c *Configurator) CustomViewsWatcher(ctx context.Context, s synchronizer) e
|
|||
return w.Add(config.K9sViewConfigFile)
|
||||
}
|
||||
|
||||
// RefreshCustomView load view configuration changes.
|
||||
// RefreshCustomViews load view configuration changes.
|
||||
func (c *Configurator) RefreshCustomViews() {
|
||||
if c.CustomView == nil {
|
||||
c.CustomView = config.NewCustomView()
|
||||
|
|
|
|||
|
|
@ -128,6 +128,7 @@ func (t *Table) Styles() *config.Styles {
|
|||
return t.styles
|
||||
}
|
||||
|
||||
// FilterInput filters user commands.
|
||||
func (t *Table) FilterInput(r rune) bool {
|
||||
if !t.cmdBuff.IsActive() {
|
||||
return false
|
||||
|
|
|
|||
Loading…
Reference in New Issue