Skip to content

Commit 7cafcdf

Browse files
feat(devpod): add git clone strategy for workspace repository to environment template
1 parent 3809046 commit 7cafcdf

26 files changed

+1636
-758
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ require (
3030
github.com/gorilla/websocket v1.5.3
3131
github.com/joho/godotenv v1.5.1
3232
github.com/julienschmidt/httprouter v1.3.0
33-
github.com/loft-sh/agentapi/v4 v4.3.0-devpod.alpha.25
33+
github.com/loft-sh/agentapi/v4 v4.3.0-devpod.alpha.29
3434
github.com/loft-sh/analytics-client v0.0.0-20240219162240-2f4c64b2494e
35-
github.com/loft-sh/api/v4 v4.3.0-devpod.alpha.25
35+
github.com/loft-sh/api/v4 v4.3.0-devpod.alpha.29
3636
github.com/loft-sh/apiserver v0.0.0-20250206205835-422f1d472459
3737
github.com/loft-sh/log v0.0.0-20250409101748-50124f882858
3838
github.com/loft-sh/programming-language-detection v0.0.5

go.sum

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -422,16 +422,14 @@ github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhn
422422
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE=
423423
github.com/loft-sh/admin-apis v0.0.0-20250221182517-7499d86167d2 h1:om1MqUdW84ZQc0GMGGgFfPI6xpTbrF+6DwKVq+76R44=
424424
github.com/loft-sh/admin-apis v0.0.0-20250221182517-7499d86167d2/go.mod h1:WHCqWfljfD1hkwk41hLeqBhW2yeLvWipB1sH6vfnR7U=
425-
github.com/loft-sh/agentapi/v4 v4.3.0-devpod.alpha.25 h1:ZmHUIWlss9SUvMwxwI10lq5sirvyvaScomFDgT7pNys=
426-
github.com/loft-sh/agentapi/v4 v4.3.0-devpod.alpha.25/go.mod h1:UteiUdc6QeGt2uXIo5K5qlReRa366GbPY5QdDuPyFCs=
425+
github.com/loft-sh/agentapi/v4 v4.3.0-devpod.alpha.29 h1:AAbhuBMm6ZV3OXSx8VXqCqQ9o/mOl6Hh425qZsGNUqw=
426+
github.com/loft-sh/agentapi/v4 v4.3.0-devpod.alpha.29/go.mod h1:zkceRmB+KkkhDMHUQO1sQdcNfF2EPxl+RsSIEOAN/R8=
427427
github.com/loft-sh/analytics-client v0.0.0-20240219162240-2f4c64b2494e h1:JcPnMaoczikvpasi8OJ47dCkWZjfgFubWa4V2SZo7h0=
428428
github.com/loft-sh/analytics-client v0.0.0-20240219162240-2f4c64b2494e/go.mod h1:FFWcGASyM2QlWTDTCG/WBVM/XYr8btqYt335TFNRCFg=
429-
github.com/loft-sh/api/v4 v4.3.0-devpod.alpha.25 h1:2IxBDMU9ZxOyf+4uSYQIHGeUjK5DJLdpEO2ls4JF694=
430-
github.com/loft-sh/api/v4 v4.3.0-devpod.alpha.25/go.mod h1:egTWLOuRpG8x5thRmA9DqA2abB/cotoEsEGTRIj/Wzs=
429+
github.com/loft-sh/api/v4 v4.3.0-devpod.alpha.29 h1:0xlQGAMwluhI6UbiDarKT21v5j/AULpxpDADdPzDxxI=
430+
github.com/loft-sh/api/v4 v4.3.0-devpod.alpha.29/go.mod h1:X1ho9aS6qCBMSOtIvRfjVa5htDO5UDlYyDUAKpvtY+k=
431431
github.com/loft-sh/apiserver v0.0.0-20250206205835-422f1d472459 h1:6SrgBtT1S9ANsQMoO/O0Mq+hs9EbC5te5kPqOBfg5UI=
432432
github.com/loft-sh/apiserver v0.0.0-20250206205835-422f1d472459/go.mod h1:rung3jsKjaVAtykQN0vWmFHhx2A/umpRyAae8BJVSeE=
433-
github.com/loft-sh/log v0.0.0-20240219160058-26d83ffb46ac h1:Gz/7Lb7WgdgIv+KJz87ORA1zvQW52tUqKPGyunlp4dQ=
434-
github.com/loft-sh/log v0.0.0-20240219160058-26d83ffb46ac/go.mod h1:YImeRjXH34Yf5E79T7UHBQpDZl9fIaaFRgyZ/bkY+UQ=
435433
github.com/loft-sh/log v0.0.0-20250409101748-50124f882858 h1:MKlp3CvzXqd+a2plptpE/bKcVMb8t/7BrEuy6Yqmnaw=
436434
github.com/loft-sh/log v0.0.0-20250409101748-50124f882858/go.mod h1:YImeRjXH34Yf5E79T7UHBQpDZl9fIaaFRgyZ/bkY+UQ=
437435
github.com/loft-sh/programming-language-detection v0.0.5 h1:XiWlxtrf4t6Z7SQiob0JMKaCeMHCP3kWhB80wLt+EMY=

pkg/agent/workspace.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ func CloneRepositoryForWorkspace(
354354
}
355355

356356
// create client
357-
log.Infof("Cloning repository %s in platform...", source.GitRepository)
357+
log.Infof("Cloning repository %s in platform", source.GitRepository)
358358
_, err = devpod.NewRunnerClient(grpcClient).Clone(ctx, &devpod.CloneRequest{
359359
TargetPath: workspaceDir,
360360
Options: string(jsonOptions),
@@ -373,6 +373,9 @@ func CloneRepositoryForWorkspace(
373373
return fmt.Errorf("clone repository (with gitcache): %w", err)
374374
}
375375
} else {
376+
if options.Platform.GitCloneStrategy != "" {
377+
log.Info("Using a %s clone", options.Platform.GitCloneStrategy)
378+
}
376379
err := git.CloneRepositoryWithEnv(ctx, gitInfo, extraEnv, workspaceDir, helper, options.StrictHostKeyChecking, log, getGitOptions(options)...)
377380
if err != nil {
378381
// cleanup workspace dir if clone failed, otherwise we won't try to clone again when rebuilding this workspace
@@ -405,7 +408,13 @@ func CloneRepositoryForWorkspace(
405408
}
406409

407410
func getGitOptions(options provider2.CLIOptions) []git.Option {
408-
gitOpts := []git.Option{git.WithCloneStrategy(options.GitCloneStrategy)}
411+
gitOpts := []git.Option{}
412+
if options.GitCloneStrategy != "" {
413+
gitOpts = append(gitOpts, git.WithCloneStrategy(options.GitCloneStrategy))
414+
}
415+
if options.Platform.GitCloneStrategy != "" {
416+
gitOpts = append(gitOpts, git.WithCloneStrategy(git.CloneStrategy(options.Platform.GitCloneStrategy)))
417+
}
409418
if options.GitCloneRecursiveSubmodules {
410419
gitOpts = append(gitOpts, git.WithRecursiveSubmodules())
411420
}

vendor/github.com/loft-sh/agentapi/v4/pkg/apis/loft/cluster/v1/zz_generated.deepcopy.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/loft-sh/agentapi/v4/pkg/apis/loft/cluster/zz_generated.deepcopy.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/loft-sh/api/v4/pkg/apis/management/install/zz_generated.api.register.go

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/loft-sh/api/v4/pkg/apis/management/v1/config_types.go

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/loft-sh/api/v4/pkg/apis/management/v1/team_object_permissions_types.go

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/loft-sh/api/v4/pkg/apis/management/v1/team_permissions_types.go

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/loft-sh/api/v4/pkg/apis/management/v1/team_types.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)