From c0e39199f9fc71c0988aa5737c787661cbb698a5 Mon Sep 17 00:00:00 2001 From: Itxaka Date: Wed, 8 Oct 2025 12:14:44 +0200 Subject: [PATCH] feat: add customizable color scheme for interactive installer and disable advanced options (#987) --- go.sum | 4 ++++ internal/agent/TUIconstants.go | 31 +++++++++++++++++++++++++ internal/agent/TUIinstallOptionsPage.go | 18 ++++++++++---- 3 files changed, 48 insertions(+), 5 deletions(-) diff --git a/go.sum b/go.sum index 9f85124..dde00c1 100644 --- a/go.sum +++ b/go.sum @@ -635,6 +635,8 @@ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91 golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.27.0 h1:kb+q2PyFnEADO2IEF935ehFUXlWiNjJWtRNgBLSfbxQ= golang.org/x/mod v0.27.0/go.mod h1:rWI627Fq0DEoudcK+MBkNkCe0EetEaDSwJJkCcjpazc= +golang.org/x/mod v0.28.0 h1:gQBtGhjxykdjY9YhZpSlZIsbnaE2+PgjfLWUQTnoZ1U= +golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -736,6 +738,8 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg= golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s= +golang.org/x/tools v0.37.0 h1:DVSRzp7FwePZW356yEAChSdNcQo6Nsp+fex1SUW09lE= +golang.org/x/tools v0.37.0/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/internal/agent/TUIconstants.go b/internal/agent/TUIconstants.go index 4cfd81a..85946c0 100644 --- a/internal/agent/TUIconstants.go +++ b/internal/agent/TUIconstants.go @@ -5,6 +5,8 @@ import ( "strings" "github.com/charmbracelet/lipgloss" + "github.com/joho/godotenv" + "github.com/kairos-io/kairos-agent/v2/internal/kairos" ) var ( @@ -30,6 +32,35 @@ func init() { kairosBorder = lipgloss.Color("9") // Bright Red (matches highlight) checkMark = "*" // Use a check mark that works in most terminals } + // Check to see if there is a custom color scheme defined in a file + brandingFile := kairos.BrandingFile("interactive_install_colors") + if _, err := os.Stat(brandingFile); err == nil { + f, err := godotenv.Read(brandingFile) + if err == nil { + if v, ok := f["KAIROS_BG"]; ok { + kairosBg = lipgloss.Color(v) + } + if v, ok := f["KAIROS_TEXT"]; ok { + kairosText = lipgloss.Color(v) + } + if v, ok := f["KAIROS_HIGHLIGHT"]; ok { + kairosHighlight = lipgloss.Color(v) + } + if v, ok := f["KAIROS_HIGHLIGHT2"]; ok { + kairosHighlight2 = lipgloss.Color(v) + } + if v, ok := f["KAIROS_ACCENT"]; ok { + kairosAccent = lipgloss.Color(v) + } + if v, ok := f["KAIROS_BORDER"]; ok { + kairosBorder = lipgloss.Color(v) + } + if v, ok := f["CHECK_MARK"]; ok { + checkMark = v + } + } + } + } const ( diff --git a/internal/agent/TUIinstallOptionsPage.go b/internal/agent/TUIinstallOptionsPage.go index 3157a4a..0d9cb7d 100644 --- a/internal/agent/TUIinstallOptionsPage.go +++ b/internal/agent/TUIinstallOptionsPage.go @@ -2,9 +2,11 @@ package agent import ( "fmt" + "os" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" + "github.com/kairos-io/kairos-agent/v2/internal/kairos" ) // Install Options Page @@ -14,12 +16,18 @@ type installOptionsPage struct { } func newInstallOptionsPage() *installOptionsPage { + baseOptions := []string{ + "Start Install", + } + // Check if advanced customization is disabled via branding file + // If the file exists, we do NOT show the "Customize Further" option + // If the file does not exist, we show the option + if _, ok := os.Stat(kairos.BrandingFile("interactive_install_advanced_disabled")); ok != nil { + baseOptions = append(baseOptions, "Customize Further (User, SSH Keys, etc.)") + } return &installOptionsPage{ - options: []string{ - "Start Install", - "Customize Further (User, SSH Keys, etc.)", - }, - cursor: 0, + options: baseOptions, + cursor: 0, } }