Skip to content

[WIP] Add ClonSun Integration #257

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Theosakamg
Copy link

No description provided.

@Theosakamg Theosakamg changed the title Add ClonSun Integration [WIP] Add ClonSun Integration Aug 1, 2025
@OriPekelman
Copy link

FYI: It seems there might be a bit of hardcoded stufff in there ... ? (see the //TODO: Dynamically from console arguments)

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds ClonSun integration to enable cloning Platform.sh projects to different regions or to Upsun. The integration introduces a new project:clone command that handles importing codebases, configurations, databases, and media files between platforms.

  • Adds ClonSun dependency and related libraries to go.mod
  • Implements a new project:clone command with clone functionality
  • Integrates the command into the CLI's command structure and help system

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 6 comments.

File Description
go.mod Updates Go version and adds ClonSun dependencies
commands/root.go Integrates clone command into root command structure
commands/list.go Adds clone command to command listing
commands/clone_project.go Implements the core clone project functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

projectTo.Region = "eu-3.platform.sh"
projectTo.OrgEmail = "Mick"

//TODO: Need on this command ?
Copy link
Preview

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard-coded project values should be replaced with dynamic input from command arguments. This makes the command non-functional for real usage.

Suggested change
//TODO: Need on this command ?
Short: "Clone a project from one provider to another.",
Aliases: []string{"clone"},
RunE: runCloneProject,
}
// Add flags for source project
cmd.Flags().String("from-provider", "", "Source provider (e.g. platform)")
cmd.Flags().String("from-project-id", "", "Source project ID")
cmd.Flags().String("from-branch", "master", "Source branch")
// Add flags for destination project
cmd.Flags().String("to-provider", "", "Destination provider (e.g. upsun)")
cmd.Flags().String("to-project-id", "", "Destination project ID (optional)")
cmd.Flags().String("to-branch", "master", "Destination branch")
cmd.Flags().String("to-region", "", "Destination region (e.g. eu-3.platform.sh)")
cmd.Flags().String("to-org-email", "", "Destination org email")
cmd.MarkFlagRequired("from-provider")
cmd.MarkFlagRequired("from-project-id")
cmd.MarkFlagRequired("to-provider")
cmd.MarkFlagRequired("to-region")
cmd.MarkFlagRequired("to-org-email")
return cmd
}
func runCloneProject(cmd *cobra.Command, args []string) error {
// Get source project flags
fromProvider, _ := cmd.Flags().GetString("from-provider")
fromProjectID, _ := cmd.Flags().GetString("from-project-id")
fromBranch, _ := cmd.Flags().GetString("from-branch")
// Get destination project flags
toProvider, _ := cmd.Flags().GetString("to-provider")
toProjectID, _ := cmd.Flags().GetString("to-project-id")
toBranch, _ := cmd.Flags().GetString("to-branch")
toRegion, _ := cmd.Flags().GetString("to-region")
toOrgEmail, _ := cmd.Flags().GetString("to-org-email")
projectFrom := entity.MakeProjectContext(
fromProvider,
fromProjectID,
fromBranch,
)
projectTo := entity.MakeProjectContext(
toProvider,
toProjectID,
toBranch,
)
projectTo.Region = toRegion
projectTo.OrgEmail = toOrgEmail

Copilot uses AI. Check for mistakes.

"master",
)
projectTo.Region = "eu-3.platform.sh"
projectTo.OrgEmail = "Mick"
Copy link
Preview

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard-coded email value "Mick" should be replaced with dynamic input. This appears to be test data left in production code.

Suggested change
projectTo.OrgEmail = "Mick"
projectTo.OrgEmail = orgEmail

Copilot uses AI. Check for mistakes.

//TODO: Dynamically from console arguments
projectFrom := entity.MakeProjectContext(
"platform",
"zrkopp7gsvzwa",
Copy link
Preview

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard-coded project ID should be replaced with dynamic input from command arguments. This makes the command unusable for other projects.

Suggested change
"zrkopp7gsvzwa",
if len(args) < 1 {
return fmt.Errorf("missing required project ID argument")
}
projectID := args[0]
projectFrom := entity.MakeProjectContext(
"platform",
projectID,

Copilot uses AI. Check for mistakes.

//TODO: Dynamically from console arguments
projectFrom := entity.MakeProjectContext(
"platform",
"zrkopp7gsvzwa",
Copy link
Preview

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented out argument validation should either be implemented or removed. The command currently accepts any number of arguments without validation.

Suggested change
"zrkopp7gsvzwa",
Use: "project:clone [PROJECT_ID]",
Short: "Clone the current project.",
Aliases: []string{"clone"},
Args: cobra.ExactArgs(1),
RunE: runCloneProject,
}
return cmd
}
func runCloneProject(cmd *cobra.Command, args []string) error {
// Use the provided argument for the source project ID
projectID := args[0]
projectFrom := entity.MakeProjectContext(
"platform",
projectID,

Copilot uses AI. Check for mistakes.

Examples: []Example{
{
Commandline: "",
Description: "Clone an existing Platform.sh project environment to a different region and/or to Upsun. Cloning will import and push your codebase, import & export project/environment configurations, import & export your sql databases, import & export your media files. If you selected to clone a project to Upsun the required config.yaml will be automatically generated and added to your project.",
Copy link
Preview

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty commandline example should be populated with actual usage examples to help users understand how to use the command.

Suggested change
Description: "Clone an existing Platform.sh project environment to a different region and/or to Upsun. Cloning will import and push your codebase, import & export project/environment configurations, import & export your sql databases, import & export your media files. If you selected to clone a project to Upsun the required config.yaml will be automatically generated and added to your project.",
Commandline: cnf.Application.Executable + " project:clone --from <source-project-id> --to <target-project-id> --region <target-region>",
Description: "Clone an existing Platform.sh project environment to a different region and/or to Upsun. Replace <source-project-id>, <target-project-id>, and <target-region> with your specific values.",

Copilot uses AI. Check for mistakes.

"convert",
},
Description: "Clone an existing Platform.sh project environment to a different region and/or to Upsun. Cloning will import and push your codebase, import & export project/environment configurations, import & export your sql databases, import & export your media files. If you selected to clone a project to Upsun the required config.yaml will be automatically generated and added to your project.",
Help: "",
Copy link
Preview

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty Help field should contain detailed help documentation for the clone command.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants