chore: per template opt into cached terraform directories (#20609)

For experimental and dogfood purposes, this adds the ability to opt in a single template. 
Leaving the rest of the templates as is. 

For GA, this setting might be removed or changed.
This commit is contained in:
Steven Masley
2025-11-13 14:04:12 -06:00
committed by GitHub
parent edf056babc
commit fe3b825b86
22 changed files with 221 additions and 53 deletions
@@ -711,7 +711,10 @@ func (s *server) acquireProtoJob(ctx context.Context, job database.ProvisionerJo
ExternalAuthProviders: externalAuthProviders,
// If active and experiment is enabled, allow workspace reuse existing TF
// workspaces (directories) for a faster startup.
ExpReuseTerraformWorkspace: ptr.Ref(activeVersion && s.Experiments.Enabled(codersdk.ExperimentTerraformWorkspace)),
ExpReuseTerraformWorkspace: ptr.Ref(s.Experiments.Enabled(codersdk.ExperimentTerraformWorkspace) && // Experiment required
template.UseTerraformWorkspaceCache && // Template setting
activeVersion, // Only for active versions
),
Metadata: &sdkproto.Metadata{
CoderUrl: s.AccessURL.String(),
WorkspaceTransition: transition,