feat: add noLatestRevCheck config option (#1874)
* feat: add noLatestRevCheck flag to configure whether k9s should fetch the latest rev from the Github repo. * refactor: rename "noLatestRevCheck" to more appropriate "skipLatestRevCheck"mine
parent
f552ffd72b
commit
530d067110
|
|
@ -311,6 +311,8 @@ K9s uses aliases to navigate most K8s resources.
|
|||
noExitOnCtrlC: false
|
||||
# Toggles icons display as not all terminal support these chars.
|
||||
noIcons: false
|
||||
# Toggles whether k9s should check for the latest revision from the Github repository releases. Default is false.
|
||||
skipLatestRevCheck: false
|
||||
# Logs configuration
|
||||
logger:
|
||||
# Defines the number of lines to return. Default 100
|
||||
|
|
|
|||
|
|
@ -286,6 +286,7 @@ var expectedConfig = `k9s:
|
|||
readOnly: true
|
||||
noExitOnCtrlC: false
|
||||
noIcons: false
|
||||
skipLatestRevCheck: false
|
||||
logger:
|
||||
tail: 500
|
||||
buffer: 800
|
||||
|
|
@ -381,6 +382,7 @@ var resetConfig = `k9s:
|
|||
readOnly: false
|
||||
noExitOnCtrlC: false
|
||||
noIcons: false
|
||||
skipLatestRevCheck: false
|
||||
logger:
|
||||
tail: 200
|
||||
buffer: 2000
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ type K9s struct {
|
|||
ReadOnly bool `yaml:"readOnly"`
|
||||
NoExitOnCtrlC bool `yaml:"noExitOnCtrlC"`
|
||||
NoIcons bool `yaml:"noIcons"`
|
||||
SkipLatestRevCheck bool `yaml:"skipLatestRevCheck"`
|
||||
Logger *Logger `yaml:"logger"`
|
||||
CurrentContext string `yaml:"currentContext"`
|
||||
CurrentCluster string `yaml:"currentCluster"`
|
||||
|
|
|
|||
|
|
@ -69,22 +69,24 @@ func (c ClusterMeta) Deltas(n ClusterMeta) bool {
|
|||
|
||||
// ClusterInfo models cluster metadata.
|
||||
type ClusterInfo struct {
|
||||
cluster *Cluster
|
||||
factory dao.Factory
|
||||
data ClusterMeta
|
||||
version string
|
||||
listeners []ClusterInfoListener
|
||||
cache *cache.LRUExpireCache
|
||||
cluster *Cluster
|
||||
factory dao.Factory
|
||||
data ClusterMeta
|
||||
version string
|
||||
skipLatestRevCheck bool
|
||||
listeners []ClusterInfoListener
|
||||
cache *cache.LRUExpireCache
|
||||
}
|
||||
|
||||
// NewClusterInfo returns a new instance.
|
||||
func NewClusterInfo(f dao.Factory, v string) *ClusterInfo {
|
||||
func NewClusterInfo(f dao.Factory, v string, skipLatestRevCheck bool) *ClusterInfo {
|
||||
c := ClusterInfo{
|
||||
factory: f,
|
||||
cluster: NewCluster(f),
|
||||
data: NewClusterMeta(),
|
||||
version: v,
|
||||
cache: cache.NewLRUExpireCache(cacheSize),
|
||||
factory: f,
|
||||
cluster: NewCluster(f),
|
||||
data: NewClusterMeta(),
|
||||
version: v,
|
||||
skipLatestRevCheck: skipLatestRevCheck,
|
||||
cache: cache.NewLRUExpireCache(cacheSize),
|
||||
}
|
||||
|
||||
return &c
|
||||
|
|
@ -130,7 +132,14 @@ func (c *ClusterInfo) Refresh() {
|
|||
}
|
||||
}
|
||||
data.K9sVer = c.version
|
||||
v1, v2 := NewSemVer(data.K9sVer), NewSemVer(c.fetchK9sLatestRev())
|
||||
v1 := NewSemVer(data.K9sVer)
|
||||
|
||||
var latestRev string
|
||||
if !c.skipLatestRevCheck {
|
||||
latestRev = c.fetchK9sLatestRev()
|
||||
}
|
||||
v2 := NewSemVer(latestRev)
|
||||
|
||||
data.K9sVer, data.K9sLatest = v1.String(), v2.String()
|
||||
if v1.IsCurrent(v2) {
|
||||
data.K9sLatest = ""
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ func (a *App) bindKeys() {
|
|||
}
|
||||
}
|
||||
|
||||
// BailOut exists the application.
|
||||
// BailOut exits the application.
|
||||
func (a *App) BailOut() {
|
||||
a.Stop()
|
||||
os.Exit(0)
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ func (a *App) Init(version string, rate int) error {
|
|||
}
|
||||
a.initFactory(ns)
|
||||
|
||||
a.clusterModel = model.NewClusterInfo(a.factory, a.version)
|
||||
a.clusterModel = model.NewClusterInfo(a.factory, a.version, a.Config.K9s.SkipLatestRevCheck)
|
||||
a.clusterModel.AddListener(a.clusterInfo())
|
||||
a.clusterModel.AddListener(a.statusIndicator())
|
||||
if a.Conn().ConnectionOK() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue