Skip to content

Commit 74d4580

Browse files
committed
add repo mode
1 parent baebf86 commit 74d4580

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

internal/provider/cached_image_data_source.go

+17
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
kconfig "github.com/GoogleContainerTools/kaniko/pkg/config"
1414
"github.com/coder/envbuilder"
1515
"github.com/coder/envbuilder/constants"
16+
ebgit "github.com/coder/envbuilder/git"
1617
eblog "github.com/coder/envbuilder/log"
1718
eboptions "github.com/coder/envbuilder/options"
1819
"github.com/go-git/go-billy/v5/osfs"
@@ -315,6 +316,22 @@ func (d *CachedImageDataSource) Read(ctx context.Context, req datasource.ReadReq
315316
SkipRebuild: false,
316317
}
317318

319+
cloneOpts, err := ebgit.CloneOptionsFromOptions(opts)
320+
if err != nil {
321+
resp.Diagnostics.AddError("Failed to create git clone options", err.Error())
322+
return
323+
}
324+
325+
w := ebgit.ProgressWriter(func(line string) { tflog.Info(ctx, line) })
326+
defer w.Close()
327+
cloneOpts.Progress = w
328+
329+
err = ebgit.ShallowCloneRepo(ctx, cloneOpts)
330+
if err != nil {
331+
resp.Diagnostics.AddError("Failed to clone git repository", err.Error())
332+
return
333+
}
334+
318335
image, err := envbuilder.RunCacheProbe(ctx, opts)
319336
data.Exists = types.BoolValue(err == nil)
320337
if err != nil {

0 commit comments

Comments
 (0)