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

Function TarWithOptions

provisioner/echo/serve.go:390–639  ·  view source on GitHub ↗

TarWithOptions returns a tar archive of responses to provisioner operations, but it gives more insight into the archiving process.

(ctx context.Context, logger slog.Logger, responses *Responses)

Source from the content-addressed store, hash-verified

388// TarWithOptions returns a tar archive of responses to provisioner operations,
389// but it gives more insight into the archiving process.
390func TarWithOptions(ctx context.Context, logger slog.Logger, responses *Responses) ([]byte, error) {
391 logger = logger.Named("echo_tar")
392
393 if responses == nil {
394 responses = &Responses{
395 Parse: ParseComplete,
396 ProvisionInit: InitComplete,
397 ProvisionPlan: PlanComplete,
398 ProvisionApply: ApplyComplete,
399 ProvisionGraph: GraphComplete,
400 ProvisionApplyMap: nil,
401 ProvisionPlanMap: nil,
402 ExtraFiles: nil,
403 }
404 }
405
406 // Apply sane defaults for missing responses.
407 if responses.Parse == nil {
408 responses.Parse = ParseComplete
409 }
410 if responses.ProvisionInit == nil {
411 responses.ProvisionInit = InitComplete
412 }
413 if responses.ProvisionPlan == nil {
414 responses.ProvisionPlan = PlanComplete
415
416 // If a graph response exists, make sure it matches the plan.
417 for _, resp := range responses.ProvisionGraph {
418 if resp.GetLog() != nil {
419 continue
420 }
421 if g := resp.GetGraph(); g != nil {
422 dailycost := int32(0)
423 for _, r := range g.GetResources() {
424 dailycost += r.DailyCost
425 }
426 responses.ProvisionPlan = []*proto.Response{{
427 Type: &proto.Response_Plan{
428 Plan: &proto.PlanComplete{
429 Plan: []byte("{}"),
430 //nolint:gosec // the number of resources will not exceed int32
431 AiTaskCount: int32(len(g.GetAiTasks())),
432 DailyCost: dailycost,
433 },
434 },
435 }}
436 break
437 }
438 }
439 }
440 if responses.ProvisionApply == nil {
441 responses.ProvisionApply = ApplyComplete
442 }
443 if responses.ProvisionGraph == nil {
444 responses.ProvisionGraph = GraphComplete
445 }
446
447 for _, resp := range responses.ProvisionPlan {

Callers 3

TarFunction · 0.85

Calls 15

ParameterTerraformFunction · 0.85
NamedMethod · 0.80
WriteStringMethod · 0.80
WriteMethod · 0.65
CloseMethod · 0.65
ValidMethod · 0.65
GetLogMethod · 0.45
GetGraphMethod · 0.45
GetResourcesMethod · 0.45
GetAiTasksMethod · 0.45
GetPlanMethod · 0.45
MarshalMethod · 0.45

Tested by 1