Add readonly configuration option
parent
7df87a80ab
commit
224c7bdb90
|
|
@ -6,12 +6,14 @@ const (
|
||||||
defaultRefreshRate = 2
|
defaultRefreshRate = 2
|
||||||
defaultLogRequestSize = 200
|
defaultLogRequestSize = 200
|
||||||
defaultLogBufferSize = 1000
|
defaultLogBufferSize = 1000
|
||||||
|
defaultReadOnly = false
|
||||||
)
|
)
|
||||||
|
|
||||||
// K9s tracks K9s configuration options.
|
// K9s tracks K9s configuration options.
|
||||||
type K9s struct {
|
type K9s struct {
|
||||||
RefreshRate int `yaml:"refreshRate"`
|
RefreshRate int `yaml:"refreshRate"`
|
||||||
Headless bool `yaml:"headless"`
|
Headless bool `yaml:"headless"`
|
||||||
|
ReadOnly bool `yaml:"readOnly"`
|
||||||
LogBufferSize int `yaml:"logBufferSize"`
|
LogBufferSize int `yaml:"logBufferSize"`
|
||||||
LogRequestSize int `yaml:"logRequestSize"`
|
LogRequestSize int `yaml:"logRequestSize"`
|
||||||
CurrentContext string `yaml:"currentContext"`
|
CurrentContext string `yaml:"currentContext"`
|
||||||
|
|
@ -20,6 +22,7 @@ type K9s struct {
|
||||||
Clusters map[string]*Cluster `yaml:"clusters,omitempty"`
|
Clusters map[string]*Cluster `yaml:"clusters,omitempty"`
|
||||||
manualRefreshRate int
|
manualRefreshRate int
|
||||||
manualHeadless *bool
|
manualHeadless *bool
|
||||||
|
manualReadOnly *bool
|
||||||
manualCommand *string
|
manualCommand *string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -27,6 +30,7 @@ type K9s struct {
|
||||||
func NewK9s() *K9s {
|
func NewK9s() *K9s {
|
||||||
return &K9s{
|
return &K9s{
|
||||||
RefreshRate: defaultRefreshRate,
|
RefreshRate: defaultRefreshRate,
|
||||||
|
ReadOnly: defaultReadOnly,
|
||||||
LogBufferSize: defaultLogBufferSize,
|
LogBufferSize: defaultLogBufferSize,
|
||||||
LogRequestSize: defaultLogRequestSize,
|
LogRequestSize: defaultLogRequestSize,
|
||||||
Clusters: make(map[string]*Cluster),
|
Clusters: make(map[string]*Cluster),
|
||||||
|
|
@ -43,6 +47,11 @@ func (k *K9s) OverrideHeadless(b bool) {
|
||||||
k.manualHeadless = &b
|
k.manualHeadless = &b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OverrideReadOnly set the readonly mode manually.
|
||||||
|
func (k *K9s) OverrideReadOnly(b bool) {
|
||||||
|
k.manualReadOnly = &b
|
||||||
|
}
|
||||||
|
|
||||||
// OverrideCommand set the command manually.
|
// OverrideCommand set the command manually.
|
||||||
func (k *K9s) OverrideCommand(cmd string) {
|
func (k *K9s) OverrideCommand(cmd string) {
|
||||||
k.manualCommand = &cmd
|
k.manualCommand = &cmd
|
||||||
|
|
@ -68,6 +77,15 @@ func (k *K9s) GetRefreshRate() int {
|
||||||
return rate
|
return rate
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetReadOnly returns the readonly setting.
|
||||||
|
func (k *K9s) GetReadOnly() bool {
|
||||||
|
readOnly := k.ReadOnly
|
||||||
|
if k.manualReadOnly != nil && *k.manualReadOnly {
|
||||||
|
readOnly = *k.manualReadOnly
|
||||||
|
}
|
||||||
|
return readOnly
|
||||||
|
}
|
||||||
|
|
||||||
// ActiveCluster returns the currently active cluster.
|
// ActiveCluster returns the currently active cluster.
|
||||||
func (k *K9s) ActiveCluster() *Cluster {
|
func (k *K9s) ActiveCluster() *Cluster {
|
||||||
if k.Clusters == nil {
|
if k.Clusters == nil {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue