Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
feat(env): PLAN03-1 PR2 devbase env import#15
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
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5809377
chore: PLAN03-1 PR2 Draft PR 作成 (import 実装)
takemi-ohama 381dfed
feat(env): PLAN03-1 PR2 devbase env import (Local + Stdio)
takemi-ohama 62363d7
fix(env): import の merge/rollback/GC 安全性を改善
takemi-ohama 6125737
fix(env): import の二重エスケープ / rollback / tmp 残骸 / completion を修正
takemi-ohama fbfbe88
fix(env): import の merge でコメントを保持し $ をエスケープする
takemi-ohama 7ab664c
refactor(env): _plan_env_merge の重複を _build_merge_plan に共通化
takemi-ohama 73e6697
fix(env): コメントのみ既存 .env を merge 経路に通す + env i 短縮維持
takemi-ohama 454425e
fix(env): import の sys を先頭 import に / TTY 時 getpass.getpass でエコー抑止
takemi-ohama dfd0964
fix(env): export 側にも TTY エコー抑止と先頭 import を適用 (import と対称化)
takemi-ohama 46ebdae
refactor(env): _unescape_double_quoted を re.sub + 逆引き辞書に書き換え
takemi-ohama File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -36,7 +36,7 @@ | ||
| # Subcommand map for prefix resolution: {(aliases...): [subcmds]} | ||
| SUBCMD_MAP = { | ||
| ('container', 'ct'): ['up', 'down', 'ps', 'login', 'logs', 'scale', 'build'], | ||
| ('env',): ['init', 'sync', 'list', 'set', 'get', 'delete', 'edit', 'project', 'export'], | ||
| ('env',): ['init', 'sync', 'list', 'set', 'get', 'delete', 'edit', 'project', 'export', 'import'], | ||
takemi-ohama marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| ('plugin', 'pl'): ['list', 'install', 'uninstall', 'update', 'info', 'sync', 'repo'], | ||
| ('snapshot', 'ss'): ['create', 'list', 'restore', 'copy', 'delete', 'rotate'], | ||
| } | ||
| @@ -47,6 +47,9 @@ | ||
| SUBCMD_PREFIX_PREFERENCES = { | ||
| ('env',): { | ||
| 'e': 'edit', | ||
| # `import` 追加で `i` が `init` / `import` の両方にマッチして ambiguous に | ||
| # なるため、既存ショートカット (`devbase env i` → `init`) を維持する。 | ||
| 'i': 'init', | ||
| }, | ||
| } | ||
| @@ -149,6 +152,55 @@ def _add_env_parser(subparsers): | ||
| help='Write as plaintext tar.gz (rejected by default; ' | ||
| 'warns when sensitive keys are detected)') | ||
| env_import = env_sub.add_parser( | ||
| 'import', | ||
| help='Import .env files from a bundle (age-encrypted or plaintext tar.gz)', | ||
| ) | ||
| env_import.add_argument('source', | ||
| help="Bundle path or '-' for stdin") | ||
| env_import.add_argument('--merge', choices=['keep-existing', 'prefer-incoming'], | ||
| default='keep-existing', | ||
| help=("Key-level merge mode. keep-existing (default) keeps " | ||
| "existing keys and adds new ones; prefer-incoming " | ||
| "overwrites with bundle values")) | ||
| env_import.add_argument('--replace-keys', metavar='KEYS', default='', | ||
| help=("Comma-separated keys to force-overwrite from bundle " | ||
| "(other keys behave like keep-existing). " | ||
| "Cannot be combined with --replace")) | ||
| env_import.add_argument('--replace', action='store_true', | ||
| help='Replace each target .env file wholesale (backup is taken)') | ||
| env_import.add_argument('--dry-run', action='store_true', | ||
| help='Show planned diff without writing') | ||
| env_import.add_argument('--identity', action='append', default=[], | ||
| metavar='FILE', dest='identities', | ||
| help=("age / OpenSSH private key file (repeatable). " | ||
| "Default: ~/.ssh/id_ed25519, then ~/.ssh/id_rsa " | ||
| "(first existing one)")) | ||
| env_import.add_argument('--passphrase-env', metavar='VAR', default=None, | ||
| help='Read passphrase from environment variable VAR') | ||
| env_import.add_argument('--passphrase-stdin', action='store_true', | ||
| help='Read passphrase from the first line of stdin') | ||
| env_import.add_argument('--include-project', action='append', default=None, | ||
| metavar='NAME', dest='include_projects', | ||
| help='Limit to specified project (repeatable)') | ||
| env_import.add_argument('--exclude-project', action='append', default=[], | ||
| metavar='NAME', dest='exclude_projects', | ||
| help='Exclude project (repeatable)') | ||
| env_import.add_argument('--no-global', action='store_true', | ||
| help='Do not import $DEVBASE_ROOT/.env') | ||
| env_import.add_argument('--no-metadata', action='store_true', | ||
| help='Do not import $DEVBASE_ROOT/.env.sources.yml ' | ||
| '(default behavior is reference-only copy; this fully ignores it)') | ||
| env_import.add_argument('--merge-metadata', action='store_true', | ||
| help='Merge new source entries into existing .env.sources.yml ' | ||
| '(machine-specific fields are preserved as-is from bundle; ' | ||
| 'run `devbase env sync` after import to refresh)') | ||
| env_import.add_argument('--backup-dir', metavar='DIR', default=None, | ||
| help='Override backup directory ' | ||
| '(default: $DEVBASE_ROOT/backups/env-import/<ts>)') | ||
| env_import.add_argument('--keep-last', type=int, default=10, metavar='N', | ||
| help='Keep only the last N backup directories (default: 10, 0 to disable)') | ||
| def _add_plugin_parser(subparsers): | ||
| """Plugin group parser""" | ||
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
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Uh oh!
There was an error while loading. Please reload this page.