commit f9a6bcadefecd6f0376a3e689407b207d51b141a
parent 21a350fcc97999a3e6d922617e333efccc2ba22d
Author: Sean Enck <sean@ttypty.com>
Date: Thu, 27 Jul 2023 19:07:22 -0400
move platforms to a simple var
Diffstat:
4 files changed, 6 insertions(+), 14 deletions(-)
diff --git a/internal/inputs/core.go b/internal/inputs/core.go
@@ -85,16 +85,6 @@ func shlex(in string) ([]string, error) {
return shell.Fields(in, os.Getenv)
}
-// PlatformSet returns the list of possible platforms
-func PlatformSet() []string {
- return []string{
- MacOSPlatform,
- LinuxWaylandPlatform,
- LinuxXPlatform,
- WindowsLinuxPlatform,
- }
-}
-
func environOrDefault(envKey, defaultValue string) string {
val := os.Getenv(envKey)
if strings.TrimSpace(val) == "" {
diff --git a/internal/inputs/core_test.go b/internal/inputs/core_test.go
@@ -8,7 +8,7 @@ import (
)
func TestPlatformSet(t *testing.T) {
- if len(inputs.PlatformSet()) != 4 {
+ if len(inputs.Platforms) != 4 {
t.Error("invalid platform set")
}
}
@@ -30,7 +30,7 @@ func TestKeyValue(t *testing.T) {
}
func TestNewPlatform(t *testing.T) {
- for _, item := range inputs.PlatformSet() {
+ for _, item := range inputs.Platforms {
os.Setenv("LOCKBOX_PLATFORM", item)
s, err := inputs.NewPlatform()
if err != nil {
diff --git a/internal/inputs/vars.go b/internal/inputs/vars.go
@@ -32,6 +32,8 @@ const (
)
var (
+ // Platforms represent the platforms that lockbox understands to run on
+ Platforms = []string{MacOSPlatform, WindowsLinuxPlatform, LinuxXPlatform, LinuxWaylandPlatform}
// TOTPDefaultColorWindow is the default coloring rules for totp
TOTPDefaultColorWindow = []ColorWindow{{Start: 0, End: 5}, {Start: 30, End: 35}}
// TOTPDefaultBetween is the default color window as a string
@@ -57,7 +59,7 @@ var (
// EnvTOTPToken is the leaf token to use to store TOTP tokens
EnvTOTPToken = EnvironmentString{environmentBase: environmentBase{key: prefixKey + "TOTP", desc: "attribute name to store TOTP tokens within the database"}, allowed: []string{"string"}, canDefault: true, defaultValue: "totp"}
// EnvPlatform is the platform that the application is running on
- EnvPlatform = EnvironmentString{environmentBase: environmentBase{key: prefixKey + "PLATFORM", desc: "override the detected platform"}, defaultValue: detectedValue, allowed: []string{MacOSPlatform, WindowsLinuxPlatform, LinuxXPlatform, LinuxWaylandPlatform}, canDefault: false}
+ EnvPlatform = EnvironmentString{environmentBase: environmentBase{key: prefixKey + "PLATFORM", desc: "override the detected platform"}, defaultValue: detectedValue, allowed: Platforms, canDefault: false}
// EnvStore is the location of the keepass file/store
EnvStore = EnvironmentString{environmentBase: environmentBase{key: prefixKey + "STORE", desc: "directory to the database file", requirement: "must be set"}, canDefault: false, allowed: []string{"file"}}
// EnvHookDir is the directory of hooks to execute
diff --git a/internal/platform/clipboard_test.go b/internal/platform/clipboard_test.go
@@ -55,7 +55,7 @@ func TestClipboardInstances(t *testing.T) {
os.Setenv("LOCKBOX_NOCLIP", "no")
os.Setenv("LOCKBOX_CLIP_MAX", "")
os.Setenv("LOCKBOX_CLIP_OSC52", "no")
- for _, item := range inputs.PlatformSet() {
+ for _, item := range inputs.Platforms {
os.Setenv("LOCKBOX_PLATFORM", item)
_, err := platform.NewClipboard()
if err != nil {