Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emoji replacements with k9s.json config strings #2814

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func run(cmd *cobra.Command, args []string) error {
}

func loadConfiguration() (*config.Config, error) {
log.Info().Msg("🐶 K9s starting up...")
log.Info().Msg(config.Config.K9s.UI.Icons.startupIcon + " K9s starting up...")

k8sCfg := client.NewConfig(k8sFlags)
k9sCfg := config.NewConfig(k8sCfg)
Expand All @@ -150,7 +150,7 @@ func loadConfiguration() (*config.Config, error) {
errs = errors.Join(errs, fmt.Errorf("k8s connection failed for context: %s", k9sCfg.K9s.ActiveContextName()))
}

log.Info().Msg("✅ Kubernetes connectivity")
log.Info().Msg(config.Config.K9s.UI.Icons.okIcon + " Kubernetes connectivity")
if err := k9sCfg.Save(false); err != nil {
log.Error().Err(err).Msg("Config save")
errs = errors.Join(errs, err)
Expand Down
41 changes: 41 additions & 0 deletions internal/config/json/schemas/k9s.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,47 @@
"logoless": {"type": "boolean"},
"crumbsless": {"type": "boolean"},
"noIcons": {"type": "boolean"},
"icons": {
"type": "object",
"properties": {
"clusterRolesIcon": {"type": "string", "default": "👩‍"},
"commandBufferIcon": {"type": "string", "default": "🐶"},
"configMapsIcon": {"type": "string", "default": "🗺 "},
"containersIcon": {"type": "string", "default": "🐳"},
"daemonSetsIcon": {"type": "string", "default": "😈"},
"defaultIcon": {"type": "string", "default": "📎"},
"deploymentsIcon": {"type": "string", "default": "🪂"},
"dirIcon": {"type": "string", "default": "🦄 "},
"errIcon": {"type": "string", "default": "😡"},
"folderIcon": {"type": "string", "default": "📁 "},
"horizontalPodAutoScalersIcon": {"type": "string", "default": "♎️"},
"infoIcon": {"type": "string", "default": "😎"},
"issue0Icon": {"type": "string", "default": "👍"},
"issue1Icon": {"type": "string", "default": "🔊"},
"issue2Icon": {"type": "string", "default": "☣️ "},
"issue3Icon": {"type": "string", "default": "🧨"},
"logCanceledIcon": {"type": "string", "default": "🏁"},
"namespacesIcon": {"type": "string", "default": "🗂 "},
"networkPoliciesIcon": {"type": "string", "default": "📕"},
"nodesIcon": {"type": "string", "default": "🖥 "},
"okIcon": {"type": "string", "default": "✅"},
"otherBufferIcon": {"type": "string", "default": "🐩"},
"persistentVolumeClaimsIcon": {"type": "string", "default": "🎟 "},
"persistentVolumesIcon": {"type": "string", "default": "📚"},
"podDisruptionBudgetsIcon": {"type": "string", "default": "🏷 "},
"podSecurityPoliciesIcon": {"type": "string", "default": "👮‍♂️"},
"podsIcon": {"type": "string", "default": "🚛"},
"replicaSetsIcon": {"type": "string", "default": "👯‍♂️"},
"reportIcon": {"type": "string", "default": "🧼"},
"rolesIcon": {"type": "string", "default": "👨🏻‍"},
"secretsIcon": {"type": "string", "default": "🔒"},
"serviceAccountsIcon": {"type": "string", "default": "💳"},
"servicesIcon": {"type": "string", "default": "💁‍♀️"},
"startupIcon": {"type": "string", "default": "🐶"},
"statefulSetsIcon": {"type": "string", "default": "🎎"},
"warnIcon": {"type": "string", "default": "😗"}
}
},
"reactive": {"type": "boolean"},
"skin": {"type": "string"},
"defaultsToFullScreen": {"type": "boolean"}
Expand Down
5 changes: 3 additions & 2 deletions internal/render/dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"fmt"
"os"

"github.com/derailed/k9s/internal/config"
"github.com/derailed/k9s/internal/model1"
"github.com/derailed/tcell/v2"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -43,9 +44,9 @@
return fmt.Errorf("expected DirRes, but got %T", o)
}

name := "🦄 "
name := config.Config.K9s.UI.Icons.okIcon

Check failure on line 47 in internal/render/dir.go

View workflow job for this annotation

GitHub Actions / build

config.Config.K9s undefined (type "github.com/derailed/k9s/internal/config".Config has no method K9s)
if d.Entry.IsDir() {
name = "📁 "
name = config.Config.K9s.UI.Icons.folderIcon

Check failure on line 49 in internal/render/dir.go

View workflow job for this annotation

GitHub Actions / build

config.Config.K9s undefined (type "github.com/derailed/k9s/internal/config".Config has no method K9s)
}
name += d.Entry.Name()
r.ID, r.Fields = d.Path, append(r.Fields, name)
Expand Down
7 changes: 4 additions & 3 deletions internal/ui/flash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"testing"
"time"

"github.com/derailed/k9s/internal/config"
"github.com/derailed/k9s/internal/config/mock"
"github.com/derailed/k9s/internal/model"
"github.com/derailed/k9s/internal/ui"
Expand All @@ -20,9 +21,9 @@ func TestFlash(t *testing.T) {
l model.FlashLevel
i, e string
}{
"info": {l: model.FlashInfo, i: "hello", e: "😎 hello\n"},
"warn": {l: model.FlashWarn, i: "hello", e: "😗 hello\n"},
"err": {l: model.FlashErr, i: "hello", e: "😡 hello\n"},
"info": {l: model.FlashInfo, i: "hello", e: config.Config.K9s.UI.Icons.infoIcon + " hello\n"},
"warn": {l: model.FlashWarn, i: "hello", e: config.Config.K9s.UI.Icons.warnIcon + " hello\n"},
"err": {l: model.FlashErr, i: "hello", e: config.Config.K9s.UI.Icons.errIcon + " hello\n"},
}

a := ui.NewApp(mock.NewMockConfig(), "test")
Expand Down
2 changes: 1 addition & 1 deletion internal/view/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (l *Log) InCmdMode() bool {
// LogCanceled indicates no more logs are coming.
func (l *Log) LogCanceled() {
log.Debug().Msgf("LOGS_CANCELED!!!")
l.Flush([][]byte{[]byte("\n🏁 [red::b]Stream exited! No more logs...")})
l.Flush([][]byte{[]byte("\n" + Config.config.K9s.UI.Icons.logCanceledIcon + "Stream exited! No more logs...")})
}

// LogStop disables log flushes.
Expand Down
Loading