MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / ResolveProfile

Function ResolveProfile

internal/profile/profile.go:16–34  ·  view source on GitHub ↗

ResolveProfile determines which profile to use based on command line flags, environment variables, and configuration defaults.

(flagProfile string, cfg *config.Config)

Source from the content-addressed store, hash-verified

14// ResolveProfile determines which profile to use based on command line flags,
15// environment variables, and configuration defaults.
16func ResolveProfile(flagProfile string, cfg *config.Config) (string, error) {
17 // Check command line flag first (highest priority)
18 if flagProfile != "" {
19 return flagProfile, nil
20 }
21
22 // Check environment variable
23 if envProfile := os.Getenv("PVETUI_PROFILE"); envProfile != "" {
24 return envProfile, nil
25 }
26
27 // Check configuration default (only if profiles exist)
28 if cfg.DefaultProfile != "" && len(cfg.Profiles) > 0 {
29 return cfg.DefaultProfile, nil
30 }
31
32 // No default set - return empty string to signal interactive selection is needed
33 return "", nil
34}
35
36// ValidateProfile ensures the selected profile exists and is valid.
37func ValidateProfile(profileName string, cfg *config.Config) error {

Callers 1

BootstrapFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected