Skip to content

Commit 5a55245

Browse files
committed
always use remote repo build mode in provider
1 parent b3b0cb8 commit 5a55245

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

docs/resources/cached_image.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ The cached image resource can be used to retrieve a cached image produced by env
4141
- `git_username` (String) (Envbuilder option) The username to use for Git authentication. This is optional.
4242
- `ignore_paths` (List of String) (Envbuilder option) The comma separated list of paths to ignore when building the workspace.
4343
- `insecure` (Boolean) (Envbuilder option) Bypass TLS verification when cloning and pulling from container registries.
44-
- `remote_repo_build_mode` (Boolean) (Envbuilder option) RemoteRepoBuildMode uses the remote repository as the source of truth when building the image. Enabling this option ignores user changes to local files and they will not be reflected in the image. This can be used to improve cache utilization when multiple users are working on the same repository.
44+
- `remote_repo_build_mode` (Boolean) (Envbuilder option) RemoteRepoBuildMode uses the remote repository as the source of truth when building the image. Enabling this option ignores user changes to local files and they will not be reflected in the image. This can be used to improve cache utilization when multiple users are working on the same repository. (NOTE: The Terraform provider will **always** use remote repo build mode for probing the cache repo.)
4545
- `ssl_cert_base64` (String) (Envbuilder option) The content of an SSL cert file. This is useful for self-signed certificates.
4646
- `verbose` (Boolean) (Envbuilder option) Enable verbose output.
4747
- `workspace_folder` (String) (Envbuilder option) path to the workspace folder that will be built. This is optional.

internal/provider/cached_image_resource.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ func (r *CachedImageResource) Schema(ctx context.Context, req resource.SchemaReq
208208
Optional: true,
209209
},
210210
"remote_repo_build_mode": schema.BoolAttribute{
211-
MarkdownDescription: "(Envbuilder option) RemoteRepoBuildMode uses the remote repository as the source of truth when building the image. Enabling this option ignores user changes to local files and they will not be reflected in the image. This can be used to improve cache utilization when multiple users are working on the same repository.",
211+
MarkdownDescription: "(Envbuilder option) RemoteRepoBuildMode uses the remote repository as the source of truth when building the image. Enabling this option ignores user changes to local files and they will not be reflected in the image. This can be used to improve cache utilization when multiple users are working on the same repository. (NOTE: The Terraform provider will **always** use remote repo build mode for probing the cache repo.)",
212212
Optional: true,
213213
PlanModifiers: []planmodifier.Bool{
214214
boolplanmodifier.RequiresReplace(),
@@ -341,6 +341,9 @@ func (r *CachedImageResource) Read(ctx context.Context, req resource.ReadRequest
341341
if !data.GitPassword.IsNull() {
342342
data.Env = appendKnownEnvToList(data.Env, "ENVBUILDER_GIT_PASSWORD", data.GitPassword)
343343
}
344+
if !data.RemoteRepoBuildMode.IsNull() {
345+
data.Env = appendKnownEnvToList(data.Env, "ENVBUILDER_REMOTE_REPO_BUILD_MODE", data.GitPassword)
346+
}
344347

345348
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
346349
}
@@ -390,6 +393,9 @@ func (r *CachedImageResource) Create(ctx context.Context, req resource.CreateReq
390393
if !data.GitPassword.IsNull() {
391394
data.Env = appendKnownEnvToList(data.Env, "ENVBUILDER_GIT_PASSWORD", data.GitPassword)
392395
}
396+
if !data.RemoteRepoBuildMode.IsNull() {
397+
data.Env = appendKnownEnvToList(data.Env, "ENVBUILDER_REMOTE_REPO_BUILD_MODE", data.GitPassword)
398+
}
393399

394400
// Save data into Terraform state
395401
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
@@ -490,7 +496,7 @@ func (r *CachedImageResource) runCacheProbe(ctx context.Context, data CachedImag
490496
GitPassword: data.GitPassword.ValueString(),
491497
GitSSHPrivateKeyPath: data.GitSSHPrivateKeyPath.ValueString(),
492498
GitHTTPProxyURL: data.GitHTTPProxyURL.ValueString(),
493-
RemoteRepoBuildMode: data.RemoteRepoBuildMode.ValueBool(),
499+
RemoteRepoBuildMode: true, // Cache probes are always done based on the remote state.
494500
SSLCertBase64: data.SSLCertBase64.ValueString(),
495501

496502
// Other options

0 commit comments

Comments
 (0)