Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ada14b5

Browse files
committedAug 1, 2024·
add repo mode
1 parent f817274 commit ada14b5

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
 

‎internal/provider/cached_image_data_source.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212

1313
kconfig "github.com/GoogleContainerTools/kaniko/pkg/config"
1414
"github.com/coder/envbuilder"
15+
ebgit "github.com/coder/envbuilder/git"
1516
eblog "github.com/coder/envbuilder/log"
1617
eboptions "github.com/coder/envbuilder/options"
1718
"github.com/go-git/go-billy/v5/osfs"
@@ -298,6 +299,23 @@ func (d *CachedImageDataSource) Read(ctx context.Context, req datasource.ReadReq
298299
SkipRebuild: false,
299300
}
300301

302+
cloneOpts, err := ebgit.CloneOptionsFromOptions(opts)
303+
if err != nil {
304+
resp.Diagnostics.AddError("Failed to create git clone options", err.Error())
305+
return
306+
}
307+
_ = cloneOpts
308+
309+
w := ebgit.ProgressWriter(func(line string) { tflog.Info(ctx, line) })
310+
defer w.Close()
311+
cloneOpts.Progress = w
312+
313+
err = ebgit.ShallowCloneRepo(ctx, cloneOpts)
314+
if err != nil {
315+
resp.Diagnostics.AddError("Failed to clone git repository", err.Error())
316+
return
317+
}
318+
301319
image, err := envbuilder.RunCacheProbe(ctx, opts)
302320
data.Exists = types.BoolValue(err == nil)
303321
if err != nil {

0 commit comments

Comments
 (0)
Please sign in to comment.