MCPcopy Index your code
hub / github.com/coder/coder / graph

Method graph

provisioner/terraform/executor.go:471–514  ·  view source on GitHub ↗

graph must only be called while the lock is held.

(ctx, killCtx context.Context)

Source from the content-addressed store, hash-verified

469
470// graph must only be called while the lock is held.
471func (e *executor) graph(ctx, killCtx context.Context) (string, error) {
472 ctx, span := e.server.startTrace(ctx, tracing.FuncName())
473 defer span.End()
474
475 if ctx.Err() != nil {
476 return "", ctx.Err()
477 }
478
479 ver, err := e.version(ctx)
480 if err != nil {
481 return "", err
482 }
483 args := []string{
484 "graph",
485 // TODO: When the plan is present, we should probably use it?
486 // "-plan=" + e.files.PlanFilePath(),
487 }
488
489 if ver.GreaterThanOrEqual(version170) {
490 args = append(args, "-type=plan")
491 }
492
493 var out strings.Builder
494 cmd := exec.CommandContext(killCtx, e.binaryPath, args...) // #nosec
495 cmd.Stdout = &out
496 cmd.Dir = e.files.WorkDirectory()
497 cmd.Env = e.basicEnv()
498
499 e.server.logger.Debug(ctx, "executing terraform command graph",
500 slog.F("binary_path", e.binaryPath),
501 slog.F("args", "graph"),
502 )
503 err = cmd.Start()
504 if err != nil {
505 return "", err
506 }
507 interruptCommandOnCancel(ctx, killCtx, e.logger, cmd)
508
509 err = cmd.Wait()
510 if err != nil {
511 return "", xerrors.Errorf("graph: %w", err)
512 }
513 return out.String(), nil
514}
515
516func (e *executor) apply(
517 ctx, killCtx context.Context,

Callers 1

GraphMethod · 0.45

Calls 12

versionMethod · 0.95
basicEnvMethod · 0.95
FuncNameFunction · 0.92
interruptCommandOnCancelFunction · 0.85
ErrMethod · 0.80
WorkDirectoryMethod · 0.80
CommandContextMethod · 0.65
StartMethod · 0.65
WaitMethod · 0.65
startTraceMethod · 0.45
ErrorfMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected