Conversation
There was a problem hiding this comment.
Pull request overview
env-sync が同期に使う認証情報(トークン)や各種 ID を、従来の環境変数に加えて global / project の YAML config ファイルからも解決できるようにする変更です。Vercel/GitHub provider からの直接 os.Getenv 参照を排し、共通の設定ローダ/アクセサ経由に統一しています。
Changes:
- global(XDG 準拠)/ project の 2 つの config ファイルを読み込み、project > global の優先順位でマージする AppConfig を追加
- 認証情報・ID の解決優先順位を「環境変数 > config > 既存フォールバック」に統一し、各 provider を移行
- config の仕様/場所/優先順位/セキュリティ注意を README とコマンド doc/usage に追記し、単体テストを追加
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
internal/config/appconfig.go |
global/project の config ロード・マージと Resolve* アクセサを追加 |
internal/config/appconfig_test.go |
ロード/マージ/優先順位/警告など新規ロジックの単体テストを追加 |
internal/provider/vercel/vercel.go |
AppConfig 経由で Vercel の token/project/team を解決するよう移行 |
internal/provider/github/github.go |
AppConfig 経由で GitHub token/repo を解決し、repo 解決関数に AppConfig を注入 |
internal/provider/github/github_test.go |
repo 解決関数のシグネチャ変更に追従 |
cmd/env-sync/main.go |
パッケージ doc コメントと usage に config 情報を追記 |
README.md |
config の場所・スキーマ・優先順位・セキュリティ注意・例を追記 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+14
to
+18
| dir := t.TempDir() | ||
| t.Setenv("XDG_CONFIG_HOME", filepath.Join(dir, "xdg")) | ||
| if err := os.Chdir(dir); err != nil { | ||
| t.Fatal(err) | ||
| } |
Comment on lines
+272
to
+283
| origStderr := os.Stderr | ||
| r, w, err := os.Pipe() | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| os.Stderr = w | ||
|
|
||
| _, loadErr := config.LoadAppConfig() | ||
|
|
||
| w.Close() | ||
| os.Stderr = origStderr | ||
|
|
Comment on lines
+316
to
+327
| origStderr := os.Stderr | ||
| r, w, err := os.Pipe() | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| os.Stderr = w | ||
|
|
||
| _, loadErr := config.LoadAppConfig() | ||
|
|
||
| w.Close() | ||
| os.Stderr = origStderr | ||
|
|
Comment on lines
+275
to
+290
| // stderr をキャプチャして警告を確認 | ||
| origStderr := os.Stderr | ||
| r, w, err := os.Pipe() | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| os.Stderr = w | ||
| t.Cleanup(func() { | ||
| os.Stderr = origStderr | ||
| r.Close() | ||
| }) | ||
|
|
||
| _, loadErr := config.LoadAppConfig() | ||
|
|
||
| w.Close() | ||
|
|
Comment on lines
+321
to
+336
| // stderr をキャプチャして警告がないことを確認 | ||
| origStderr := os.Stderr | ||
| r, w, err := os.Pipe() | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| os.Stderr = w | ||
| t.Cleanup(func() { | ||
| os.Stderr = origStderr | ||
| r.Close() | ||
| }) | ||
|
|
||
| _, loadErr := config.LoadAppConfig() | ||
|
|
||
| w.Close() | ||
|
|
| } | ||
| token := appCfg.ResolveGitHubToken() | ||
| if !opts.DryRun && token == "" { | ||
| return fmt.Errorf("GITHUB_TOKEN が未設定です") |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
internal/provider/vercel/vercel.go:45
.vercel/project.jsonからのフォールバックがprojectID == ""の場合にしか実行されないため、VERCEL_PROJECT_ID/vercel.project_idだけを指定してVERCEL_TEAM_ID/vercel.team_idを省略した場合に、README/usage の説明どおり.vercel/project.jsonのorgIdからteamIDを補完できません。teamIDが空のときも project.json を読んで補完するよう条件を広げてください。
if projectID == "" {
pjText, err := os.ReadFile(".vercel/project.json")
if err != nil && !errors.Is(err, os.ErrNotExist) {
return fmt.Errorf(".vercel/project.json の読み込みに失敗: %s", err)
}
- internal/config/appconfig.go を新設し global/project 2 レベルの config ファイル (~/.config/env-sync/config.yaml, .env-sync.config.yaml) をマージして AppConfig を返す LoadAppConfig() を実装 - 解決優先順位: 環境変数 > project config > global config > 既存フォールバック - global config にトークンが含まれパーミッションが 0600 でない場合は stderr に警告 - vercel.go / github.go の os.Getenv 直呼びを AppConfig のアクセサ経由に置き換え - 単体テスト (appconfig_test.go) を追加し go test ./... が通ることを確認 - README と main.go doc コメント・printUsage を更新 Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- appconfig_test.go: os.Chdir 後の元ディレクトリ復元を t.Cleanup で保証(chdirCleanup ヘルパー導入) - appconfig_test.go: パーミッション警告テストで os.Stderr 復元と r.Close() を t.Cleanup で保証しリークを解消 - README.md: config 使用例のコマンド表記を `./env-sync` に統一 Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QEq5x914xFwa12yxPUP6QE
- appconfig_test.go: stderr キャプチャを LoadAppConfig 直後に復元し並列実行時の混入リスクを解消 - github.go/vercel.go: トークン未設定エラーメッセージに config ファイルでの指定方法を追記 Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QEq5x914xFwa12yxPUP6QE
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
タスク
env-sync が同期に使う認証情報・ID(現状すべて環境変数のみ)を、config ファイルでも管理できるようにする。
~/.config/env-sync/config.yaml(XDG_CONFIG_HOME を尊重).env-sync.config.yaml(定義ファイルenv-sync.yamlとは別ファイル)値の解決優先順位: 環境変数 > project config > global config > 既存フォールバック(
.vercel/project.json,git remote)完了条件
go test ./...が通る動作確認
go build ./...通過go test ./...通過(全パッケージ)変更ファイル
internal/config/appconfig.go— AppConfig/LoadAppConfig/Resolve* アクセサの新設internal/config/appconfig_test.go— 上記の単体テストinternal/provider/vercel/vercel.go— LoadAppConfig + ResolveVercel* に移行internal/provider/github/github.go— LoadAppConfig + ResolveGitHub* に移行cmd/env-sync/main.go— パッケージ doc コメントに config 情報追記README.md— config ファイルの場所・スキーマ・優先順位を追記品質チェック結果
なし(Warning/Info なし)
パフォーマンス診断
なし(ファイル読み込みの追加のみ、ホットパス外)