-
Notifications
You must be signed in to change notification settings - Fork 14
Add envs to ldcli config, replacing flags-usage's static env fallback #743
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
Draft
davidbrackbill
wants to merge
2
commits into
db/flagpls-usage
Choose a base branch
from
db/flagpls-envs
base: db/flagpls-usage
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| // Package repoconfig persists `flags usage` settings that are inherently | ||
| // per-repository (which wrapper module/definitions dir a monorepo uses) rather | ||
| // than per-user, so they don't belong in ldcli's global ~/.config/ldcli/config.yml. | ||
| // Unlike the global config, this file lives at the scanned repo's root and is | ||
| // safe to check into version control so a team shares the same settings. | ||
| package repoconfig | ||
|
|
||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
|
|
||
| "gopkg.in/yaml.v3" | ||
| ) | ||
|
|
||
| // Filename is the repo-local config file, written at the repo root. | ||
| const Filename = ".ldcli-flags-usage.yml" | ||
|
|
||
| // Config is the subset of `flags usage` flags that make sense to pin per-repo. | ||
| type Config struct { | ||
| WrapperModules string `yaml:"wrapper-modules,omitempty"` | ||
| Definitions string `yaml:"definitions,omitempty"` | ||
| } | ||
|
|
||
| // FindRepoRoot walks up from dir looking for a `.git` entry (directory or file, | ||
| // the latter for git worktrees) and returns its parent. ok is false if none is | ||
| // found before reaching the filesystem root. | ||
| func FindRepoRoot(dir string) (root string, ok bool) { | ||
| dir, err := filepath.Abs(dir) | ||
| if err != nil { | ||
| return "", false | ||
| } | ||
| for { | ||
| if _, err := os.Stat(filepath.Join(dir, ".git")); err == nil { | ||
| return dir, true | ||
| } | ||
| parent := filepath.Dir(dir) | ||
| if parent == dir { | ||
| return "", false | ||
| } | ||
| dir = parent | ||
| } | ||
| } | ||
|
|
||
| // Load reads the repo-local config at repoRoot. A missing file is not an | ||
| // error — it returns a zero-value Config, since most repos won't have one. | ||
| func Load(repoRoot string) (Config, error) { | ||
| data, err := os.ReadFile(filepath.Join(repoRoot, Filename)) | ||
| if err != nil { | ||
| if os.IsNotExist(err) { | ||
| return Config{}, nil | ||
| } | ||
| return Config{}, err | ||
| } | ||
|
|
||
| var c Config | ||
| if err := yaml.Unmarshal(data, &c); err != nil { | ||
| return Config{}, err | ||
| } | ||
| return c, nil | ||
| } | ||
|
|
||
| // Save writes cfg to repoRoot, creating the file only when called — `flags | ||
| // usage` never writes it implicitly, only when the caller passes --save. | ||
| func Save(repoRoot string, cfg Config) error { | ||
| data, err := yaml.Marshal(cfg) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| return os.WriteFile(filepath.Join(repoRoot, Filename), data, 0o644) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Silent default env resolution change
Medium Severity
Omitting
--envsnow live-discovers critical environments via the API instead of relying on the prior implicitDefaultCriticalEnvsbehavior, changing which environments appear inflags usageoutput. The command only prints a stderr notice when discovery fails, not when the default resolution path changes on success.Triggered by learned rule: Breaking CLI default changes require transitional stderr warnings
Reviewed by Cursor Bugbot for commit 82aa923. Configure here.