Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func printInfo(*cobra.Command, []string) error {
printTuple(fmat, "Custom Views", config.AppViewsFile, color.Cyan)
printTuple(fmat, "Plugins", config.AppPluginsFile, color.Cyan)
printTuple(fmat, "Hotkeys", config.AppHotKeysFile, color.Cyan)
printTuple(fmat, "Jumpers", config.AppJumpersFile, color.Cyan)
printTuple(fmat, "Aliases", config.AppAliasesFile, color.Cyan)
printTuple(fmat, "Skins", config.AppSkinsDir, color.Cyan)
printTuple(fmat, "Context Configs", config.AppContextsDir, color.Cyan)
Expand Down
1 change: 1 addition & 0 deletions config/samples
Submodule samples added at 7dface
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ require (
github.com/fsnotify/fsnotify v1.9.0
github.com/fvbommel/sortorder v1.1.0
github.com/go-errors/errors v1.5.1
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/itchyny/gojq v0.12.17
github.com/lmittmann/tint v1.0.7
github.com/mattn/go-colorable v0.1.14
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,8 @@ github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/s2a-go v0.1.8 h1:zZDs9gcbt9ZPLV0ndSyQk6Kacx2g/X+SKYovpnz3SMM=
github.com/google/s2a-go v0.1.8/go.mod h1:6iNWHTpQ+nfNRN5E00MSdfDwVesa8hhS32PhPO8deJA=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
Expand Down
10 changes: 10 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ func (c *Config) ContextPluginsPath() (string, error) {
return AppContextPluginsFile(ct.GetClusterName(), c.K9s.activeContextName), nil
}

// ContextJumperPath returns a context specific jumper file spec.
func (c *Config) ContextJumperPath() (string, error) {
ct, err := c.K9s.ActiveContext()
if err != nil {
return "", err
}

return AppContextJumpersFile(ct.GetClusterName(), c.K9s.activeContextName), nil
}

func setK8sTimeout(flags *genericclioptions.ConfigFlags, d time.Duration) {
v := d.String()
flags.Timeout = &v
Expand Down
10 changes: 10 additions & 0 deletions internal/config/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ var (

// AppHotKeysFile tracks hotkeys config file.
AppHotKeysFile string

// AppJumpersFile tracks jumpers config file.
AppJumpersFile string
)

// InitLogLoc initializes K9s logs location.
Expand Down Expand Up @@ -155,6 +158,7 @@ func initK9sEnvLocs() error {
AppAliasesFile = filepath.Join(AppConfigDir, "aliases.yaml")
AppPluginsFile = filepath.Join(AppConfigDir, "plugins.yaml")
AppViewsFile = filepath.Join(AppConfigDir, "views.yaml")
AppJumpersFile = filepath.Join(AppConfigDir, "jumpers.yaml")

return nil
}
Expand All @@ -176,6 +180,7 @@ func initXDGLocs() error {
AppAliasesFile = filepath.Join(AppConfigDir, "aliases.yaml")
AppPluginsFile = filepath.Join(AppConfigDir, "plugins.yaml")
AppViewsFile = filepath.Join(AppConfigDir, "views.yaml")
AppJumpersFile = filepath.Join(AppConfigDir, "jumpers.yaml")

AppSkinsDir = filepath.Join(AppConfigDir, "skins")
if e := data.EnsureFullPath(AppSkinsDir, data.DefaultDirMod); e != nil {
Expand Down Expand Up @@ -230,6 +235,11 @@ func AppContextHotkeysFile(cluster, context string) string {
return filepath.Join(AppContextsDir, data.SanitizeContextSubpath(cluster, context), "hotkeys.yaml")
}

// AppContextJumpersFile generates a valid context specific jumpers file path.
func AppContextJumpersFile(cluster, context string) string {
return filepath.Join(AppContextsDir, data.SanitizeContextSubpath(cluster, context), "jumpers.yaml")
}

// AppContextConfig generates a valid context config file path.
func AppContextConfig(cluster, context string) string {
return filepath.Join(AppContextDir(cluster, context), data.MainConfigFile)
Expand Down
63 changes: 63 additions & 0 deletions internal/config/json/schemas/jumper-multi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "K9s jumper-multi schema",
"type": "object",
"additionalProperties": {
"properties": {
"shortCut": { "type": "string" },
"override": { "type": "boolean" },
"description": { "type": "string" },
"scopes": {
"type": "array",
"items": { "type": "string" }
},
"view": { "type": "string" },
"filters": {
"type": "array",
"items": { "type": "string" }
},
"labels":{
"type": "array",
"items": { "type": "string" }
},
"variables": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"name": { "type": "string" },
"source": {
"type": "string",
"enum": ["script", "static"]
},
"command": { "type": "string" },
"args": {
"type": "array",
"items": { "type": "string" }
},
"pipes": {
"type": "array",
"items": { "type": "string" }
},
"display": {
"type": "string",
"enum": ["none", "text", "select"]
}
},
"required": [
"name",
"source",
"display"
]
}
}
},
"required": [
"shortCut",
"description",
"scopes",
"view"
]
}
}
62 changes: 62 additions & 0 deletions internal/config/json/schemas/jumper.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "K9s jumper schema",
"type": "object",
"additionalProperties": false,
"properties": {
"shortCut": { "type": "string" },
"override": { "type": "boolean" },
"description": { "type": "string" },
"scopes": {
"type": "array",
"items": { "type": "string" }
},
"view": { "type": "string" },
"filters": {
"type": "array",
"items": { "type": "string" }
},
"labels": {
"type": "array",
"items": { "type": "string" }
},
"variables": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"name": { "type": "string" },
"source": {
"type": "string",
"enum": ["script", "static"]
},
"command": { "type": "string" },
"args": {
"type": "array",
"items": { "type": "string" }
},
"pipes": {
"type": "array",
"items": { "type": "string" }
},
"display": {
"type": "string",
"enum": ["none", "text", "select"]
}
},
"required": [
"name",
"source",
"display"
]
}
}
},
"required": [
"shortCut",
"description",
"scopes",
"view"
]
}
71 changes: 71 additions & 0 deletions internal/config/json/schemas/jumpers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "K9s jumpers schema",
"type": "object",
"additionalProperties": false,
"properties": {
"jumpers": {
"type": "object",
"additionalProperties": {
"properties": {
"shortCut": { "type": "string" },
"override": { "type": "boolean" },
"description": { "type": "string" },
"scopes": {
"type": "array",
"items": { "type": "string" }
},
"view": { "type": "string" },
"filters": {
"type": "array",
"items": { "type": "string" }
},
"labels": {
"type": "array",
"items": { "type": "string" }
},
"variables": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"name": { "type": "string" },
"source": {
"type": "string",
"enum": ["script", "static"]
},
"command": { "type": "string" },
"args": {
"type": "array",
"items": { "type": "string" }
},
"pipes": {
"type": "array",
"items": { "type": "string" }
},
"display": {
"type": "string",
"enum": ["none", "text", "select"]
}
},
"required": [
"name",
"source",
"display"
]
}
}
},
"required": [
"shortCut",
"description",
"scopes",
"view"
]
},
"required": []
}
},
"required": ["jumpers"]
}
32 changes: 32 additions & 0 deletions internal/config/json/schemas/plugin-multi.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,38 @@
"args": {
"type": "array",
"items": { "type": ["string", "number"] }
},
"variables": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"name": { "type": "string" },
"source": {
"type": "string",
"enum": ["script", "static"]
},
"command": { "type": "string" },
"args": {
"type": "array",
"items": { "type": "string" }
},
"pipes": {
"type": "array",
"items": { "type": "string" }
},
"display": {
"type": "string",
"enum": ["none", "text", "select"]
}
},
"required": [
"name",
"source",
"display"
]
}
}
},
"required": ["shortCut", "description", "scopes", "command"]
Expand Down
32 changes: 32 additions & 0 deletions internal/config/json/schemas/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,38 @@
"args": {
"type": "array",
"items": { "type": ["string", "number"] }
},
"variables": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"name": { "type": "string" },
"source": {
"type": "string",
"enum": ["script", "static"]
},
"command": { "type": "string" },
"args": {
"type": "array",
"items": { "type": "string" }
},
"pipes": {
"type": "array",
"items": { "type": "string" }
},
"display": {
"type": "string",
"enum": ["none", "text", "select"]
}
},
"required": [
"name",
"source",
"display"
]
}
}
},
"required": ["shortCut", "description", "scopes", "command"]
Expand Down
32 changes: 32 additions & 0 deletions internal/config/json/schemas/plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,38 @@
"args": {
"type": "array",
"items": { "type": ["string", "number"] }
},
"variables": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"name": { "type": "string" },
"source": {
"type": "string",
"enum": ["script", "static"]
},
"command": { "type": "string" },
"args": {
"type": "array",
"items": { "type": "string" }
},
"pipes": {
"type": "array",
"items": { "type": "string" }
},
"display": {
"type": "string",
"enum": ["none", "text", "select"]
}
},
"required": [
"name",
"source",
"display"
]
}
}
},
"required": ["shortCut", "description", "scopes", "command"]
Expand Down
Loading
Loading