-
Notifications
You must be signed in to change notification settings - Fork 5
Copier App: Support for cross-org copy #84
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
cbullinger
commented
Oct 15, 2025
- Support cross-org copying
- Add debug logging
- Remove legacy code
- Bugfixes for timeout issue; respecting direct commit strategy; correctly passing values for all defined named variables; and support for multiple, non-main branches
- Test and doc updates to reflect latest changes
The FileStateService was not being cleared after files were uploaded and deprecation files were updated. This caused files to accumulate in the service across multiple webhook events, leading to duplicate uploads and stale data. Changes: - Added ClearFilesToUpload() call after AddFilesToTargetRepoBranch() - Added ClearFilesToDeprecate() call after UpdateDeprecationFile() This ensures the FileStateService is properly reset after each webhook processing cycle, preventing file accumulation.
Previously the code was using the constant name 'GOOGLE_CLOUD_PROJECT_ID' instead of reading the actual environment variable value, causing the error: 'projects/GOOGLE_CLOUD_PROJECT_ID is not a valid resource name' Changes: - Read projectId from os.Getenv(configs.GoogleCloudProjectId) - Read logName from os.Getenv(configs.CopierLogName) - Add validation to disable cloud logging if projectId is not set - Add fallback default for logName if not set
The target repo is specified as 'owner/repo' (e.g., 'mongodb/atlas-architecture-go-sdk')
but the code was using repoOwner() which returns the SOURCE repo owner ('10gen'),
resulting in malformed paths like '10gen/mongodb/atlas-architecture-go-sdk'.
Changes:
- Added parseRepoPath() function to split 'owner/repo' into separate components
- Updated all GitHub API calls to use parsed owner and repo name
- Fixes 404 errors when accessing target repositories
Affected functions:
- createPullRequest
- createBranch
- createCommitTree
- createCommit
- mergePR
- deleteBranchIfExists
The new pattern-matching system stores commit strategy in UploadFileContent.CommitStrategy, but the code was only checking the legacy Configs.CopierCommitStrategy, causing all uploads to use 'direct' strategy regardless of the YAML config. Changes: - Check value.CommitStrategy first (from new pattern-matching system) - Fallback to legacy commitStrategy(cfg) if not set - Also respect value.CommitMessage, value.PRTitle, and value.AutoMergePR - Add logging to show which strategy is being used - Fixes issue where pull_request strategy was ignored
Removed all legacy code that is no longer used: 1. Removed webhook_handler.go (legacy webhook handler) - ParseWebhookDataWithConfig and related functions - iterateFilesForCopyWithConfig - Legacy file processing logic 2. Simplified AddFilesToTargetRepoBranch - Removed ConfigFileType parameter (now takes no parameters) - Removed findConfig and commitStrategy helper functions - Now only uses UploadFileContent fields (from pattern-matching system) - Cleaner, simpler code that only supports the new YAML config 3. Removed legacy config loading - Removed convertLegacyToYAML function - Removed JSON config support - Config loader now only supports YAML format 4. Removed legacy functions from github_read.go - Removed RetrieveAndParseConfigFile (JSON config loader) - Removed retrieveJsonFile helper All code now uses the new pattern-matching system with YAML configuration. The app only uses HandleWebhookWithContainer (new system).
- Re-added encoding/json import to config_loader.go (needed for ExportConfigAsJSON) - Fixed UpdateDeprecationFile to fetch file directly instead of using removed retrieveJsonFile - Removed web_server.go (legacy, not used anywhere)
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.
I've had a look through all the files, but this is a lot of changes, so I'm not sure I haven't missed something. Overall LGTM! You've added some key pieces of functionality here so I'm really happy to see this - nice work! 🎉
| │ ├── .env # Environment config | ||
| │ ├── .env.example.new # Environment template | ||
| │ └── config.example.yaml # Config template | ||
| │ ├── env.yaml.example # Environment template |
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.
Hmm, I was just looking in the config folder from what got merged recently and it looks like we've also got some other files in here, including a env.yaml.production: https://github.com/mongodb/code-example-tooling/blob/main/examples-copier/configs/env.yaml.production
Wasn't sure if that was intentional, and/or if we should update this README to exhaustively list what was intended to be here or if it's not exhaustive because this is only a "QUICK-REFERENCE.md" - not the proper "README.md"
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.
i'll update
| } | ||
| } | ||
|
|
||
| // Note: Comprehensive testing of github_auth.go would require: |
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.
Ugh.
| } | ||
| } | ||
|
|
||
| // Note: Comprehensive testing of UpdateDeprecationFile would require: |
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.
Are we leaving this here as a thing we eventually want to do? I'm wondering if we do/should have a Jira ticket to capture this as future work?
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.
good idea. i'd like to get this done eventually, so i'll change to a TODO with accompanying Jira ticket (here and the other instances)