- 
                Notifications
    
You must be signed in to change notification settings  - Fork 13
 
[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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,105 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| package commands | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 
     | 
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "fmt" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 
     | 
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "github.com/platformsh/cli/internal/config" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "github.com/spf13/cobra" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "github.com/upsun/clonsun/api" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "github.com/upsun/lib-sun/entity" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| utils "github.com/upsun/lib-sun/utility" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| orderedmap "github.com/wk8/go-ordered-map/v2" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 
     | 
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func innerCloneProjectCommand(cnf *config.Config) Command { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| noInteractionOption := NoInteractionOption(cnf) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 
     | 
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return Command{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Name: CommandName{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Namespace: "project", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Command: "clone", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Usage: []string{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cnf.Application.Executable + " project:clone", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Aliases: []string{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "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: "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
        
    
 | 
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
AI
    
    
    
      Aug 18, 2025 
    
  
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.
Hard-coded project ID should be replaced with dynamic input from command arguments. This makes the command unusable for other projects.
| "zrkopp7gsvzwa", | |
| if len(args) < 1 { | |
| return fmt.Errorf("missing required project ID argument") | |
| } | |
| projectID := args[0] | |
| projectFrom := entity.MakeProjectContext( | |
| "platform", | |
| projectID, | 
    
      
    
      Copilot
AI
    
    
    
      Aug 18, 2025 
    
  
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.
Commented out argument validation should either be implemented or removed. The command currently accepts any number of arguments without validation.
| "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
AI
    
    
    
      Aug 18, 2025 
    
  
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.
Hard-coded email value "Mick" should be replaced with dynamic input. This appears to be test data left in production code.
| projectTo.OrgEmail = "Mick" | |
| projectTo.OrgEmail = orgEmail | 
    
      
    
      Copilot
AI
    
    
    
      Aug 18, 2025 
    
  
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.
Hard-coded project values should be replaced with dynamic input from command arguments. This makes the command non-functional for real usage.
| //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 | 
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.
Empty Help field should contain detailed help documentation for the clone command.