-
Notifications
You must be signed in to change notification settings - Fork 7
[AGENT-209] Refactor adding env vars from file #324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe changes refactor environment variable file handling by moving logic from various command files into a new Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI_Command
participant EnvUtil
participant API
User->>CLI_Command: Run (e.g., dev, cloud deploy, project import)
CLI_Command->>EnvUtil: ProcessEnvFiles(ctx, logger, dir, project, ...)
EnvUtil->>EnvUtil: Read .env and template files
alt TTY
EnvUtil->>User: Prompt for missing env vars
User->>EnvUtil: Provide values
EnvUtil->>EnvUtil: Update .env file
else non-TTY
EnvUtil->>CLI_Command: Output issues, exit(1)
end
EnvUtil->>API: Update project env vars (if needed)
API-->>EnvUtil: API response
EnvUtil-->>CLI_Command: Return updated env/project data
Assessment against linked issues
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🔭 Outside diff range comments (1)
cmd/cloud.go (1)
125-129:⚠️ Potential issueCompilation will fail – unused variables left behind
envTemplateFileNames,border, andredDiffwere only referenced by the now-deleted inline env-diff logic.
They are no longer used anywhere in this file, sogo vet/go buildwill abort with:cmd/cloud.go:125:6: envTemplateFileNames declared but not used cmd/cloud.go:127:6: border declared but not used cmd/cloud.go:128:6: redDiff declared but not usedDelete these definitions (and their imports, if any) or integrate them into the new
envutilflow.- var envTemplateFileNames = []string{".env.example", ".env.template"} - var border = lipgloss.NewStyle().Border(lipgloss.NormalBorder()).Padding(1).BorderForeground(lipgloss.AdaptiveColor{Light: "#999999", Dark: "#999999"}) - var redDiff = lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Light: "#990000", Dark: "#EE0000"})🧰 Tools
🪛 golangci-lint (1.64.8)
125-125: var
envTemplateFileNamesis unused(unused)
127-127: var
borderis unused(unused)
128-128: var
redDiffis unused(unused)
🧹 Nitpick comments (5)
cmd/project.go (1)
825-826: Process result fromenvutil.ProcessEnvFilesor add an explanatory comment
ProcessEnvFilesreturns an updated*deployer.EnvFileand potentially updated*project.ProjectData, yet both results are discarded.
Even if they are not currently required downstream, ignoring them may surprise future maintainers and makes it harder to notice silent failures inside the helper (e.g..envparsing errors that are swallowed after a refactor).- _, _ = envutil.ProcessEnvFiles(ctx, logger, context.Dir, context.Project, nil, context.APIURL, context.Token) + if _, _ = envutil.ProcessEnvFiles(ctx, logger, context.Dir, context.Project, nil, context.APIURL, context.Token); false { + // intentionally ignore for now – kept to document that return values + // are not needed in the import flow. + }Alternatively: capture the return values and log them at debug-level, or add a short comment explaining why they are intentionally ignored.
This prevents new-lint /staticcheckwarnings and aids readability.cmd/env.go (1)
227-231: Minor UI detail: resulting string length is nowmax + 3
util.MaxStringappends"..."after truncation, so the success message can be up to 43 chars whenmaxis 40.
If strict column alignment is important in TUI output, reduce themaxargument by three.No functional impact otherwise.
internal/envutil/envutil.go (3)
156-159: Remove unnecessary assignment to the blank identifier
This eliminates the gosimple S1005 warning and makes intent clearer.- var key string - for _key, _ := range keyvalue { - key = _key - } + var key string + for k := range keyvalue { + key = k + break // first (and only needed) key + }🧰 Tools
🪛 golangci-lint (1.64.8)
157-157: S1005: unnecessary assignment to the blank identifier
(gosimple)
82-82: Unused statement can be removed
The_ = filenameassignment is no longer required;filenameis already referenced above.
Removing it avoids dead code noise.
270-275: Duplicate string-truncation helper – reuse the shared util instead
internal/utilalready exposesMaxString; keeping a private copy violates DRY and risks inconsistent behaviour.-func maxString(val string, max int) string { - if len(val) > max { - return val[:max] + "..." - } - return val -} - ... - help = "Press enter to set as " + maxString(cstr.Mask(val), 30) + " from your .env file" + help = "Press enter to set as " + util.MaxString(cstr.Mask(val), 30) + " from your .env file" ... - help = "Press enter to set as " + maxString(cstr.Mask(val), 30) + " from your environment" + help = "Press enter to set as " + util.MaxString(cstr.Mask(val), 30) + " from your environment"After removing the local function, remember to tidy the imports (
goimports) if unused.Also applies to: 283-289
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting
📒 Files selected for processing (8)
cmd/cloud.go(2 hunks)cmd/dev.go(2 hunks)cmd/env.go(3 hunks)cmd/project.go(2 hunks)cmd/root.go(2 hunks)internal/envutil/envutil.go(1 hunks)internal/util/api.go(1 hunks)internal/util/strings.go(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (4)
cmd/env.go (2)
internal/envutil/envutil.go (1)
PromptForEnv(277-309)internal/util/strings.go (1)
MaxString(42-47)
cmd/root.go (1)
internal/envutil/envutil.go (1)
PromptForEnv(277-309)
cmd/cloud.go (1)
internal/envutil/envutil.go (1)
ProcessEnvFiles(34-58)
cmd/project.go (1)
internal/envutil/envutil.go (1)
ProcessEnvFiles(34-58)
🪛 golangci-lint (1.64.8)
internal/envutil/envutil.go
157-157: S1005: unnecessary assignment to the blank identifier
(gosimple)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Build and Test (macos-latest)
- GitHub Check: Build and Test (windows-latest)
- GitHub Check: Test CLI Upgrade Path (windows-latest)
- GitHub Check: Analyze (go)
🔇 Additional comments (10)
internal/util/api.go (1)
158-158: Minor spacing improvement.This additional blank line improves code readability by visually separating the error handling from the subsequent code flow.
internal/util/strings.go (1)
42-47: Good addition of reusable string truncation utility.The
MaxStringfunction provides a centralized approach to string truncation with ellipsis, supporting the refactoring effort by replacing duplicated truncation logic across the codebase.cmd/dev.go (2)
15-15: Appropriate import addition for the refactor.This import supports the refactoring effort by allowing access to the centralized environment utilities.
70-71: Consistent implementation of environment processing.This change integrates the centralized environment variable handling, aligning with the broader refactoring pattern in the codebase. The function call processes environment files and potentially updates the project with environment-specific configurations.
cmd/root.go (2)
15-15: Appropriate import addition for the refactor.This import supports the refactoring effort by allowing access to the centralized environment utilities.
186-186: Cohesive integration of environment variable prompting.The change replaces the local environment variable prompting function with the centralized implementation from the
envutilpackage, improving code consistency and reducing duplication across the codebase.cmd/env.go (3)
15-19: Good call – centralised helpers improve maintainabilityReplacing local helpers with
envutil/utilkeeps the CLI surface consistent and removes duplication.
No further action required.
221-223: Use ofenvutil.PromptForEnvlooks correctParameters match the helper’s signature and preserve previous behaviour (default/placeholder are empty).
396-397: Consistent truncation helper appliedSwitching to
util.MaxStringkeeps truncation logic uniform across commands.
Looks good.cmd/cloud.go (1)
231-232: 👍 Refactored env processing handled viaenvutilThe new call simplifies the deploy path and correctly threads the returned
envFile/projectDatainto later pre-flight checks.
jhaynie
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM except a couple of good suggestions from code rabbit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (2)
internal/envutil/envutil.go (2)
33-58: KeepenvFile.Envin sync after potential mutationsIn the
ProcessEnvFilesfunction, after callingHandleMissingProjectEnvswhich may modify the environment variables,envFile.Envis not updated to reflect these changes. This means downstream consumers won't see the new variables.
243-245: Restrict file permissions when writing secrets to.envWriting the file with
0644makes secrets world-readable on many systems. Use0600(or at least0640) to limit exposure.- if err := os.WriteFile(envfile, []byte(buf.String()), 0644); err != nil { + // 0600 => rw for owner only; helps prevent accidental disclosure of secrets + if err := os.WriteFile(envfile, []byte(buf.String()), 0600); err != nil {
🧹 Nitpick comments (5)
internal/envutil/envutil.go (5)
166-167: Remove unnecessary blank identifier in range operationThe blank identifier assignment is unnecessary when you only need the key from a map.
- for _key, _ := range keyvalue { + for _key := range keyvalue { key = _key }🧰 Tools
🪛 golangci-lint (1.64.8)
166-166: S1005: unnecessary assignment to the blank identifier
(gosimple)
281-286: Consider movingmaxStringto the utility packageThe
maxStringfunction is a generic string utility that could be used elsewhere. Since you already have a utility package with string functions (imported asutil), consider moving this function there to promote code reuse.// Remove from this file: -func maxString(val string, max int) string { - if len(val) > max { - return val[:max] + "..." - } - return val -} // Use from util package: if val, ok := localenv[key]; ok { - help = "Press enter to set as " + maxString(cstr.Mask(val), 30) + " from your .env file" + help = "Press enter to set as " + util.MaxString(cstr.Mask(val), 30) + " from your .env file"
288-320: Consider adding validation for required environment variablesThe
PromptForEnvfunction does a good job handling secrets and default values, but it doesn't enforce that a value is provided for potentially required environment variables.You might want to add a parameter for whether the environment variable is required and validate that a non-empty value is returned.
-func PromptForEnv(logger logger.Logger, key string, isSecret bool, localenv map[string]string, osenv map[string]string, defaultValue string, placeholder string) string { +func PromptForEnv(logger logger.Logger, key string, isSecret bool, localenv map[string]string, osenv map[string]string, defaultValue string, placeholder string, required bool) string { // Existing code... if value == "" && defaultValue != "" { value = defaultValue } + + // Ensure required variables have a value + if required && value == "" { + logger.Warn("A value is required for %s", key) + return PromptForEnv(logger, key, isSecret, localenv, osenv, defaultValue, placeholder, required) + } return value }
144-150: Simplify the conditional checks for existing environment variablesThe current code has separate checks for variables in
projectData.EnvandprojectData.Secrets. These can be combined for clarity.- if projectData != nil && projectData.Env != nil && projectData.Env[ev.Key] == ev.Val { - continue - } - if projectData != nil && projectData.Secrets != nil && projectData.Secrets[ev.Key] == cstr.Mask(ev.Val) { - continue - } + if projectData != nil { + if (projectData.Env != nil && projectData.Env[ev.Key] == ev.Val) || + (projectData.Secrets != nil && projectData.Secrets[ev.Key] == cstr.Mask(ev.Val)) { + continue + } + }
179-183: InitializeprojectData.Envmap once before the loopThe current code checks and initializes
projectData.Envinside the loop for each key. It's more efficient to do this check once before the loop.if force { + if projectData.Env == nil { + projectData.Env = make(map[string]string) + } for key, val := range keyvalue { - if projectData.Env == nil { - projectData.Env = make(map[string]string) - } projectData.Env[key] = val }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting
📒 Files selected for processing (4)
cmd/cloud.go(4 hunks)cmd/dev.go(3 hunks)cmd/project.go(3 hunks)internal/envutil/envutil.go(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- cmd/dev.go
- cmd/project.go
- cmd/cloud.go
🧰 Additional context used
🪛 golangci-lint (1.64.8)
internal/envutil/envutil.go
166-166: S1005: unnecessary assignment to the blank identifier
(gosimple)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Build and Test (macos-latest)
- GitHub Check: Build and Test (windows-latest)
- GitHub Check: Test CLI Upgrade Path (windows-latest)
- GitHub Check: Analyze (go)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
♻️ Duplicate comments (1)
internal/envutil/envutil.go (1)
161-163: Loop still iterates over map values, not keys
This was called out in the previous review:for _, key := range keyvalueranges over values, sokeyholds the value (the env var contents), not the variable name. Use the map keys instead:- for _, key := range keyvalue { + for key := range keyvalue {
🧹 Nitpick comments (1)
internal/envutil/envutil.go (1)
166-169: Unnecessary second range variable and unpredictable chosen keyThe loop only needs a single key and should break immediately to avoid non-deterministic selection:
-var key string -for _key, _ := range keyvalue { - key = _key -} +var key string +for k := range keyvalue { + key = k + break +}This removes the redundant blank identifier assignment flagged by
gosimpleand makes the behaviour explicit.🧰 Tools
🪛 golangci-lint (1.64.8)
167-167: S1005: unnecessary assignment to the blank identifier
(gosimple)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting
📒 Files selected for processing (4)
cmd/cloud.go(3 hunks)cmd/dev.go(3 hunks)cmd/project.go(3 hunks)internal/envutil/envutil.go(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- cmd/dev.go
- cmd/project.go
- cmd/cloud.go
🧰 Additional context used
🪛 golangci-lint (1.64.8)
internal/envutil/envutil.go
167-167: S1005: unnecessary assignment to the blank identifier
(gosimple)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Build and Test (windows-latest)
- GitHub Check: Test CLI Upgrade Path (windows-latest)
- GitHub Check: Analyze (go)
🔇 Additional comments (2)
internal/envutil/envutil.go (2)
54-56: 👍 State synchronisation now handled correctlyAssigning
envFile.Env = leafter the possible mutation keeps the returned struct in-sync with the slice that might have been rebuilt by earlier helpers. Thanks for closing the gap flagged in the previous round.
244-246: ✅ File written with restrictive0600permissionsGreat job tightening the permissions; secrets are no longer world-readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (2)
internal/envutil/envutil.go (2)
230-243: 🛠️ Refactor suggestion
Rawfallback missing – empty values are written to the file
AppendToEnvFileunconditionally writesev.Raw, but for entries created/updated at runtimeRawmay be an empty string (see previous comment). The resulting line in the.envfile becomesKEY=, silently discarding the provided value.- buf.WriteString(fmt.Sprintf("%s=%s\n", ev.Key, ev.Raw)) + raw := ev.Raw + if raw == "" { + raw = ev.Val + } + buf.WriteString(fmt.Sprintf("%s=%s\n", ev.Key, raw))Apply the same fallback for the loop that writes
envsa few lines below.Without this safeguard, users risk losing data every time the file is re-written.
103-113:⚠️ Potential issueMissing variables still not written to
.env– thecontinueprematurely skips persistenceWhen the user (or automation) is prompted and provides a value,
ev.Valbecomes non-empty.
Theif ev.Val != "" { continue }statement therefore bails out before the entry is appended toaddtoenvfile, so the newly supplied variable is never written to disk – the exact problem flagged in the previous review is still present.@@ - if ev.Val != "" { - continue - } - addtoenvfile = append(addtoenvfile, env.EnvLineComment{ + // Persist the captured value (mask if secret). + if ev.Raw == "" { + if isSecret { + ev.Raw = cstr.Mask(ev.Val) + } else { + ev.Raw = ev.Val + } + } + addtoenvfile = append(addtoenvfile, env.EnvLineComment{ EnvLine: env.EnvLine{ Key: ev.Key, Val: ev.Val, Raw: ev.Raw, },This removes the early
continue, ensuresRawis populated, and guarantees the variable is actually appended to – and later written into – the.envfile.
Failing to fix this means interactive values vanish after the run, forcing the user to re-enter them every time.
🧹 Nitpick comments (2)
internal/envutil/envutil.go (2)
165-170: Unnecessary assignment to blank identifier (_)The blank identifier on the right-hand side of the range statement is redundant and triggers
gosimple(S1005).- var key string - for _key, _ := range keyvalue { - key = _key - } + var key string + for k := range keyvalue { + key = k + }Pure readability / lint fix; no behavioural change.
🧰 Tools
🪛 golangci-lint (1.64.8)
167-167: S1005: unnecessary assignment to the blank identifier
(gosimple)
34-41: Handle the “template exists but .env doesn’t” scenario
ProcessEnvFilesskips all processing when.envis missing.
If a repository ships only a template (.env.example,.env.template) the CLI never offers to create a fresh.env, forcing users to craft one manually.Consider:
- Detecting the absence of an
.envfile when at least one template exists.- Offering to create the file (optionally pre-populated from the template) or doing so automatically when
--forceis supplied.This greatly improves onboarding and aligns with typical
.env.exampleworkflows.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting
📒 Files selected for processing (1)
internal/envutil/envutil.go(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
internal/envutil/envutil.go (6)
internal/project/project.go (1)
ProjectData(44-53)internal/deployer/deployer.go (1)
EnvFile(14-17)internal/util/io.go (1)
Exists(14-19)internal/errsystem/errorcodes.go (2)
ErrParseEnvironmentFile(41-44)ErrApiRequest(21-24)internal/errsystem/errsystem.go (2)
WithContextMessage(100-104)WithUserMessage(70-74)internal/util/strings.go (1)
Pluralize(32-40)
🪛 golangci-lint (1.64.8)
internal/envutil/envutil.go
167-167: S1005: unnecessary assignment to the blank identifier
(gosimple)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (3)
internal/envutil/envutil.go (3)
165-167: Simplify range loop by removing unnecessary blank identifierThis range loop assigns to a blank identifier but only needs the key.
- for _key, _ := range keyvalue { - key = _key - } + for key = range keyvalue { + break + }🧰 Tools
🪛 golangci-lint (1.64.8)
165-165: S1005: unnecessary assignment to the blank identifier
(gosimple)
284-289: Consider moving maxString to a utility packageThis function is a general string truncation utility that's not specific to environment handling. It might be better placed in the
utilpackage for broader reuse.This could be moved to
internal/util/strings.goand imported where needed, following the pattern used for other utility functions.
224-227: Consider handling the case when .env file doesn't existIf the .env file doesn't exist,
ParseEnvFileWithCommentswill return an error, but it might be expected to create the file in this case.Would you like me to suggest an implementation that handles the case when the .env file doesn't exist yet?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting
📒 Files selected for processing (1)
internal/envutil/envutil.go(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
internal/envutil/envutil.go (6)
internal/project/project.go (1)
ProjectData(44-53)internal/deployer/deployer.go (1)
EnvFile(14-17)internal/util/io.go (1)
Exists(14-19)internal/errsystem/errorcodes.go (2)
ErrParseEnvironmentFile(41-44)ErrApiRequest(21-24)internal/errsystem/errsystem.go (2)
WithContextMessage(100-104)WithUserMessage(70-74)internal/util/strings.go (1)
Pluralize(32-40)
🪛 golangci-lint (1.64.8)
internal/envutil/envutil.go
165-165: S1005: unnecessary assignment to the blank identifier
(gosimple)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Build and Test (windows-latest)
- GitHub Check: Test CLI Upgrade Path (windows-latest)
- GitHub Check: Analyze (go)
🔇 Additional comments (3)
internal/envutil/envutil.go (3)
246-246: Security-focused file permissions are correctly usedUsing
0600for file permissions when writing the .env file is a good security practice, as it ensures that only the owner can read and write the file, which helps protect sensitive secrets.
54-55: Good fix: Keeping envFile.Env in sync with leThe code correctly updates
envFile.Envwith the latest environment variables after processing, ensuring that downstream code sees all changes.
239-242: Good implementation of defensive check for Raw valuesThe defensive fallback for when
ev.Rawis empty correctly ensures that the env file always contains values, even for newly added variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
internal/envutil/envutil.go (3)
35-59: Consider handling the “.envmissing” scenario instead of returningnil.
ProcessEnvFilesonly proceeds when an existing.envfile is found (util.Exists(envfilename)), otherwise it returnsenvFile == nil. Many callers assume the helper will always return a usable*deployer.EnvFile; dereferencing the result without a nil-check will panic.Two common fixes:
- var envFile *deployer.EnvFile + // Always return a non-nil pointer to avoid nil-dereference surprises. + envFile := &deployer.EnvFile{Filepath: envfilename} if (tui.HasTTY || force) && util.Exists(envfilename) { … + } else if util.Exists(envfilename) == false && (tui.HasTTY || force) { + // Create an empty .env so further logic can still operate. + if err := os.WriteFile(envfilename, nil, 0600); err != nil { + return nil, projectData // bubble up the error instead if preferred + } + envFile.Env = []env.EnvLineComment{} + return envFile, projectData } - return envFile, projectData + + return envFile, projectDataThis guards downstream code and provides a consistent API surface.
167-171: Simplify loop & silencegosimplewarning.Iterating over both key and value when you only need the key triggers
S1005: unnecessary assignment to the blank identifier. Capture the first key directly:-var key string -for _key, _ := range keyvalue { - key = _key -} +var key string +for k := range keyvalue { + key = k + break // we only need one element +}🧰 Tools
🪛 golangci-lint (1.64.8)
169-169: S1005: unnecessary assignment to the blank identifier
(gosimple)
292-315: Duplicate helper – reuseutil.MaxStringinstead of definingmaxString.
internal/util/strings.goalready exposesMaxString; redefining it here:
- adds maintenance overhead,
- risks diverging behaviour.
You can delete lines 292-297 and call the shared helper:
- help = "Press enter to set as " + maxString(cstr.Mask(val), 30) + " from your .env file" + help = "Press enter to set as " + util.MaxString(cstr.Mask(val), 30) + " from your .env file"Do the same for the similar call a few lines below (
osenvbranch).After that, the local
maxStringfunction (lines 292-297) can be removed entirely.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting
📒 Files selected for processing (1)
internal/envutil/envutil.go(1 hunks)
🧰 Additional context used
🪛 golangci-lint (1.64.8)
internal/envutil/envutil.go
169-169: S1005: unnecessary assignment to the blank identifier
(gosimple)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Build and Test (macos-latest)
- GitHub Check: Build and Test (windows-latest)
- GitHub Check: Test CLI Upgrade Path (windows-latest)
- GitHub Check: Analyze (go)
🔇 Additional comments (1)
internal/envutil/envutil.go (1)
226-258: Nice security hardening with0600permissions.Good catch updating
os.WriteFileto restrict read access on secrets.
Refactor, yeah!
Summary by CodeRabbit
--forceflag to control environment file processing in multiple commands..envfiles, templates, and project settings.