mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
chore: implement persistent terraform directories (experimental) (#20563)
Prior to this, every workspace build ran `terraform init` in a fresh directory. This would mean the `modules` are downloaded fresh. If the module is not pinned, subsequent workspace builds would have different modules.
This commit is contained in:
@@ -41,7 +41,7 @@ type executor struct {
|
||||
// cachePath and files must not be used by multiple processes at once.
|
||||
cachePath string
|
||||
cliConfigPath string
|
||||
files tfpath.Layout
|
||||
files tfpath.Layouter
|
||||
// used to capture execution times at various stages
|
||||
timings *timingAggregator
|
||||
}
|
||||
@@ -536,7 +536,11 @@ func (e *executor) graph(ctx, killCtx context.Context) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
args := []string{"graph"}
|
||||
args := []string{
|
||||
"graph",
|
||||
// TODO: When the plan is present, we should probably use it?
|
||||
// "-plan=" + e.files.PlanFilePath(),
|
||||
}
|
||||
if ver.GreaterThanOrEqual(version170) {
|
||||
args = append(args, "-type=plan")
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ func parseModulesFile(filePath string) ([]*proto.Module, error) {
|
||||
// getModules returns the modules from the modules file if it exists.
|
||||
// It returns nil if the file does not exist.
|
||||
// Modules become available after terraform init.
|
||||
func getModules(files tfpath.Layout) ([]*proto.Module, error) {
|
||||
func getModules(files tfpath.Layouter) ([]*proto.Module, error) {
|
||||
filePath := files.ModulesFilePath()
|
||||
if _, err := os.Stat(filePath); os.IsNotExist(err) {
|
||||
return nil, nil
|
||||
|
||||
@@ -161,7 +161,7 @@ func (s *server) startTrace(ctx context.Context, name string, opts ...trace.Span
|
||||
))...)
|
||||
}
|
||||
|
||||
func (s *server) executor(files tfpath.Layout, stage database.ProvisionerJobTimingStage) *executor {
|
||||
func (s *server) executor(files tfpath.Layouter, stage database.ProvisionerJobTimingStage) *executor {
|
||||
return &executor{
|
||||
server: s,
|
||||
mut: s.execMut,
|
||||
|
||||
Reference in New Issue
Block a user