refactor(go): Update Go commands and TUI controller

Update api-server and gen-keys main files

Update TUI controller commands, helpers, and settings
This commit is contained in:
Jeremie Fraeys 2026-02-23 14:13:14 -05:00
parent 6faa13aabf
commit abd27bf0a2
No known key found for this signature in database
5 changed files with 11 additions and 11 deletions

View file

@ -74,7 +74,7 @@ func runSecurityAudit(configFile string) {
if mode&0077 != 0 {
issues = append(issues, fmt.Sprintf("Config file %s is world/group readable (permissions: %04o)", configFile, mode))
} else {
fmt.Printf("Config file permissions: %04o (secure)\n", mode)
fmt.Printf("Config file permissions: %04o (secure)\n", mode)
}
} else {
warnings = append(warnings, fmt.Sprintf("Could not check config file: %v", err))
@ -91,14 +91,14 @@ func runSecurityAudit(configFile string) {
if len(exposedVars) > 0 {
warnings = append(warnings, fmt.Sprintf("Sensitive environment variables exposed: %v (will be cleared on startup)", exposedVars))
} else {
fmt.Println("No sensitive environment variables exposed")
fmt.Println("No sensitive environment variables exposed")
}
// Check 3: Running as root
if os.Getuid() == 0 {
issues = append(issues, "Running as root (UID 0) - should run as non-root user")
} else {
fmt.Printf("Running as non-root user (UID: %d)\n", os.Getuid())
fmt.Printf("Running as non-root user (UID: %d)\n", os.Getuid())
}
// Check 4: API key file permissions
@ -109,7 +109,7 @@ func runSecurityAudit(configFile string) {
if mode&0077 != 0 {
issues = append(issues, fmt.Sprintf("API key file %s is world/group readable (permissions: %04o)", apiKeyFile, mode))
} else {
fmt.Printf("API key file permissions: %04o (secure)\n", mode)
fmt.Printf("API key file permissions: %04o (secure)\n", mode)
}
}
}
@ -117,7 +117,7 @@ func runSecurityAudit(configFile string) {
// Report results
fmt.Println()
if len(issues) == 0 && len(warnings) == 0 {
fmt.Println("All security checks passed")
fmt.Println("All security checks passed")
} else {
if len(issues) > 0 {
fmt.Printf("✗ Found %d security issue(s):\n", len(issues))

View file

@ -43,7 +43,7 @@ func main() {
}
// Print summary
fmt.Printf("Generated Ed25519 signing keys\n")
fmt.Printf("Generated Ed25519 signing keys\n")
fmt.Printf(" Key ID: %s\n", *keyID)
fmt.Printf(" Private key: %s (permissions: 0600)\n", privKeyPath)
fmt.Printf(" Public key: %s\n", pubKeyPath)

View file

@ -264,7 +264,7 @@ func (c *Controller) queueJob(jobName string, args string) tea.Cmd {
c.logger.Info("job queued", "job_name", jobName, "task_id", task.ID[:8], "priority", priority)
resultChan <- model.StatusMsg{
Text: fmt.Sprintf("Queued: %s (ID: %s, P:%d)", jobName, task.ID[:8], priority),
Text: fmt.Sprintf("Queued: %s (ID: %s, P:%d)", jobName, task.ID[:8], priority),
Level: "success",
}
}()
@ -287,7 +287,7 @@ func (c *Controller) deleteJob(jobName string) tea.Cmd {
if _, err := c.server.Exec(cmd); err != nil {
return model.StatusMsg{Text: fmt.Sprintf("Failed to archive %s: %v", jobName, err), Level: "error"}
}
return model.StatusMsg{Text: fmt.Sprintf("Archived: %s", jobName), Level: "success"}
return model.StatusMsg{Text: fmt.Sprintf("Archived: %s", jobName), Level: "success"}
}
}
@ -309,7 +309,7 @@ func (c *Controller) cancelTask(taskID string) tea.Cmd {
return model.StatusMsg{Text: fmt.Sprintf("Cancel failed: %v", err), Level: "error"}
}
c.logger.Info("task cancelled", "task_id", taskID[:8])
return model.StatusMsg{Text: fmt.Sprintf("Cancelled: %s", taskID[:8]), Level: "success"}
return model.StatusMsg{Text: fmt.Sprintf("Cancelled: %s", taskID[:8]), Level: "success"}
}
}

View file

@ -53,7 +53,7 @@ func formatStatus(m model.State) string {
stats = append(stats, fmt.Sprintf("▶ %d", count))
}
if count := m.JobStats[model.StatusFinished]; count > 0 {
stats = append(stats, fmt.Sprintf("%d", count))
stats = append(stats, fmt.Sprintf("%d", count))
}
if count := m.JobStats[model.StatusFailed]; count > 0 {
stats = append(stats, fmt.Sprintf("✗ %d", count))

View file

@ -111,7 +111,7 @@ func getSettingsIndicator(m model.State, index int) string {
func getAPIKeyStatus(m model.State) string {
if m.APIKey != "" {
return "API Key is set\n" + maskAPIKey(m.APIKey)
return "API Key is set\n" + maskAPIKey(m.APIKey)
}
return "⚠ No API Key configured"
}