Skip to content

Commit d288bc9

Browse files
committed
add repo mode
1 parent f817274 commit d288bc9

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
@@ -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,22 @@ 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+
308+
w := ebgit.ProgressWriter(func(line string) { tflog.Info(ctx, line) })
309+
defer w.Close()
310+
cloneOpts.Progress = w
311+
312+
err = ebgit.ShallowCloneRepo(ctx, cloneOpts)
313+
if err != nil {
314+
resp.Diagnostics.AddError("Failed to clone git repository", err.Error())
315+
return
316+
}
317+
301318
image, err := envbuilder.RunCacheProbe(ctx, opts)
302319
data.Exists = types.BoolValue(err == nil)
303320
if err != nil {

0 commit comments

Comments
 (0)