mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-10-20 10:38:34 +00:00
feat: add customizable color scheme for interactive installer and disable advanced options (#987)
This commit is contained in:
4
go.sum
4
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=
|
||||
|
@@ -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 (
|
||||
|
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user