Skip to content

Commit 1dea983

Browse files
style: normalize indentation from tabs to spaces
- Converted tab indentation to spaces across multiple files for consistency - Updated Go version to 1.25.3 and refreshed dependency versions - Replaced fmt.Errorf with errors.New for static error messages without formatting
1 parent 1e16c61 commit 1dea983

16 files changed

Lines changed: 564 additions & 250 deletions

cmd/create/repo.go

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,22 @@ Examples:
3535
}
3636

3737
func init() {
38-
CreateCmd.AddCommand(createRepoCmd)
38+
CreateCmd.AddCommand(createRepoCmd)
3939

4040
createRepoCmd.Flags().StringP("name", "n", "", "Repository name (default: directory name)")
4141
createRepoCmd.Flags().StringP("description", "d", "", "Repository description")
4242
createRepoCmd.Flags().BoolP("private", "p", false, "Make repository private")
4343
createRepoCmd.Flags().StringP("org", "o", "", "Create repository under an organization")
4444
createRepoCmd.Flags().String("remote", "origin", "Git remote name to use")
4545
createRepoCmd.Flags().String("branch", "main", "Default branch name")
46-
createRepoCmd.Flags().Bool("no-push", false, "Do not push to the remote after creation")
47-
createRepoCmd.Flags().Bool("dry-run", false, "Show planned actions without applying changes")
48-
createRepoCmd.Flags().Bool("non-interactive", false, "Disable interactive prompts")
49-
createRepoCmd.Flags().Bool("save-config", false, "Persist answers for future runs in .eos/create-repo.yaml")
46+
createRepoCmd.Flags().Bool("no-push", false, "Do not push to the remote after creation")
47+
createRepoCmd.Flags().Bool("dry-run", false, "Show planned actions without applying changes")
48+
createRepoCmd.Flags().Bool("non-interactive", false, "Disable interactive prompts")
49+
createRepoCmd.Flags().Bool("save-config", false, "Persist answers for future runs in .eos/create-repo.yaml")
50+
createRepoCmd.Flags().String("auth", "ssh", "Preferred auth for git remote: ssh or https")
51+
createRepoCmd.Flags().Bool("auto-fix-ownership", false, "If run with sudo, chown the repo to the original user")
52+
createRepoCmd.Flags().Bool("ssh-generate-key", true, "Generate an SSH key if missing when --auth=ssh")
53+
createRepoCmd.Flags().Bool("configure-credential-helper", true, "Configure git credential.helper for HTTPS when --auth=https")
5054
}
5155

5256
func runCreateRepo(rc *eos_io.RuntimeContext, cmd *cobra.Command, args []string) error {
@@ -164,28 +168,36 @@ func runCreateRepo(rc *eos_io.RuntimeContext, cmd *cobra.Command, args []string)
164168

165169
name, _ := cmd.Flags().GetString("name")
166170
description, _ := cmd.Flags().GetString("description")
167-
private, _ := cmd.Flags().GetBool("private")
168-
org, _ := cmd.Flags().GetString("org")
169-
remote, _ := cmd.Flags().GetString("remote")
170-
branch, _ := cmd.Flags().GetString("branch")
171-
noPush, _ := cmd.Flags().GetBool("no-push")
172-
dryRun, _ := cmd.Flags().GetBool("dry-run")
173-
// nonInteractive already parsed above for preflight checks
174-
saveConfig, _ := cmd.Flags().GetBool("save-config")
175-
176-
opts := &repository.RepoOptions{
177-
Path: absPath,
178-
Name: name,
179-
Description: description,
180-
Private: private,
181-
Organization: org,
182-
Remote: remote,
183-
Branch: branch,
184-
DryRun: dryRun,
185-
NoPush: noPush,
186-
NonInteractive: nonInteractive,
187-
SaveConfig: saveConfig,
188-
}
171+
private, _ := cmd.Flags().GetBool("private")
172+
org, _ := cmd.Flags().GetString("org")
173+
remote, _ := cmd.Flags().GetString("remote")
174+
branch, _ := cmd.Flags().GetString("branch")
175+
noPush, _ := cmd.Flags().GetBool("no-push")
176+
dryRun, _ := cmd.Flags().GetBool("dry-run")
177+
// nonInteractive already parsed above for preflight checks
178+
saveConfig, _ := cmd.Flags().GetBool("save-config")
179+
auth, _ := cmd.Flags().GetString("auth")
180+
autoFixOwnership, _ := cmd.Flags().GetBool("auto-fix-ownership")
181+
sshGenKey, _ := cmd.Flags().GetBool("ssh-generate-key")
182+
cfgCredHelper, _ := cmd.Flags().GetBool("configure-credential-helper")
183+
184+
opts := &repository.RepoOptions{
185+
Path: absPath,
186+
Name: name,
187+
Description: description,
188+
Private: private,
189+
Organization: org,
190+
Remote: remote,
191+
Branch: branch,
192+
DryRun: dryRun,
193+
NoPush: noPush,
194+
NonInteractive: nonInteractive,
195+
SaveConfig: saveConfig,
196+
Auth: strings.ToLower(strings.TrimSpace(auth)),
197+
AutoFixOwnership: autoFixOwnership,
198+
SSHGenerateKey: sshGenKey,
199+
ConfigureCredHelper: cfgCredHelper,
200+
}
189201

190202
prefsPath := repository.PreferencesPath(absPath)
191203
prefs, err := repository.LoadRepoPreferences(prefsPath)

cmd/read/consul_token.go

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,18 @@ func runConsulTokenRead(rc *eos_io.RuntimeContext, cmd *cobra.Command, args []st
8080

8181
// ASSESS - Get Vault client
8282
vaultClient, err := vault.GetVaultClient(rc)
83-
if err != nil {
84-
return eos_err.NewUserError(
85-
"Failed to connect to Vault.\n\n" +
86-
"The Consul bootstrap token is stored in Vault at:\n" +
87-
" secret/consul/bootstrap-token\n\n" +
88-
"Remediation:\n" +
89-
" - Ensure Vault is installed: eos create vault\n" +
90-
" - Ensure Vault is unsealed: vault status\n" +
91-
" - Check Vault agent is running: systemctl status vault-agent-eos\n\n" +
92-
fmt.Sprintf("Error: %v", err))
93-
}
83+
if err != nil {
84+
return eos_err.NewUserError(
85+
"Failed to connect to Vault.\n\n"+
86+
"The Consul bootstrap token is stored in Vault at:\n"+
87+
" secret/consul/bootstrap-token\n\n"+
88+
"Remediation:\n"+
89+
" - Ensure Vault is installed: eos create vault\n"+
90+
" - Ensure Vault is unsealed: vault status\n"+
91+
" - Check Vault agent is running: systemctl status vault-agent-eos\n\n"+
92+
"Error: %v",
93+
err)
94+
}
9495

9596
// Discover environment from Consul (required for Vault path)
9697
env, err := consulenv.DiscoverFromConsul(rc)
@@ -113,15 +114,16 @@ func runConsulTokenRead(rc *eos_io.RuntimeContext, cmd *cobra.Command, args []st
113114
logger.Info("Retrieving Consul bootstrap token from Vault")
114115

115116
token, err := consulacl.GetBootstrapTokenFromVault(rc, vaultClient, env)
116-
if err != nil {
117-
return eos_err.NewUserError(
118-
"Failed to retrieve Consul bootstrap token from Vault.\n\n" +
119-
"The token may not exist yet. Bootstrap ACLs first:\n" +
120-
" eos update consul --bootstrap-token\n\n" +
121-
"Or check if token exists in Vault:\n" +
122-
" vault kv get secret/consul/bootstrap-token\n\n" +
123-
fmt.Sprintf("Error: %v", err))
124-
}
117+
if err != nil {
118+
return eos_err.NewUserError(
119+
"Failed to retrieve Consul bootstrap token from Vault.\n\n"+
120+
"The token may not exist yet. Bootstrap ACLs first:\n"+
121+
" eos update consul --bootstrap-token\n\n"+
122+
"Or check if token exists in Vault:\n"+
123+
" vault kv get secret/consul/bootstrap-token\n\n"+
124+
"Error: %v",
125+
err)
126+
}
125127

126128
if token == "" {
127129
return eos_err.NewUserError(

cmd/update/consul.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -278,18 +278,18 @@ func runConsulUpdate(rc *eos_io.RuntimeContext, cmd *cobra.Command, args []strin
278278
return fmt.Errorf("failed to check existing environment in Consul: %w", err)
279279
}
280280

281-
if existing != nil {
282-
existingEnv := string(existing.Value)
283-
return eos_err.NewUserError(
284-
fmt.Sprintf("Environment already set to '%s' for node '%s'\n\n"+
285-
"Changing environment requires privilege escalation for security.\n"+
286-
"This prevents accidental environment changes that could expose production secrets.\n\n"+
287-
"To change environment:\n"+
288-
" 1. Delete existing key: consul kv delete %s\n"+
289-
" 2. Re-run: eos update consul --environment %s\n\n"+
290-
"WARNING: This is a security-critical operation. Ensure you understand the implications.",
291-
existingEnv, hostname, kvPath, consulEnvironment))
292-
}
281+
if existing != nil {
282+
existingEnv := string(existing.Value)
283+
return eos_err.NewUserError(
284+
"Environment already set to '%s' for node '%s'\n\n"+
285+
"Changing environment requires privilege escalation for security.\n"+
286+
"This prevents accidental environment changes that could expose production secrets.\n\n"+
287+
"To change environment:\n"+
288+
" 1. Delete existing key: consul kv delete %s\n"+
289+
" 2. Re-run: eos update consul --environment %s\n\n"+
290+
"WARNING: This is a security-critical operation. Ensure you understand the implications.",
291+
existingEnv, hostname, kvPath, consulEnvironment)
292+
}
293293

294294
// Confirm production changes
295295
if consulEnvironment == string(sharedvault.EnvironmentProduction) {

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/CodeMonkeyCybersecurity/eos
22

3-
go 1.25
3+
go 1.25.3
44

55
require (
66
code.gitea.io/sdk/gitea v0.22.1
@@ -12,7 +12,7 @@ require (
1212
github.com/charmbracelet/bubbletea v1.3.10
1313
github.com/charmbracelet/lipgloss v1.1.0
1414
github.com/cockroachdb/errors v1.12.0
15-
github.com/docker/docker v28.5.1+incompatible
15+
github.com/docker/docker v28.5.2+incompatible
1616
github.com/docker/go-connections v0.6.0
1717
github.com/emersion/go-sasl v0.0.0-20241020182733-b788ff22d5a6
1818
github.com/emersion/go-smtp v0.24.0
@@ -28,7 +28,7 @@ require (
2828
github.com/hashicorp/go-multierror v1.1.1
2929
github.com/hashicorp/go-version v1.7.0
3030
github.com/hashicorp/hcl/v2 v2.24.0
31-
github.com/hashicorp/nomad/api v0.0.0-20251104073108-6235838dbf30
31+
github.com/hashicorp/nomad/api v0.0.0-20251105172100-f20a01eda06e
3232
github.com/hashicorp/terraform-exec v0.24.0
3333
github.com/hashicorp/vault/api v1.22.0
3434
github.com/hashicorp/vault/api/auth/approle v0.11.0
@@ -37,7 +37,7 @@ require (
3737
github.com/joho/godotenv v1.5.1
3838
github.com/lib/pq v1.10.9
3939
github.com/olekukonko/tablewriter v1.1.0
40-
github.com/open-policy-agent/opa v1.10.0
40+
github.com/open-policy-agent/opa v1.10.1
4141
github.com/redis/go-redis/v9 v9.16.0
4242
github.com/sashabaranov/go-openai v1.41.2
4343
github.com/shirou/gopsutil/v4 v4.25.10

0 commit comments

Comments
 (0)