(src *support.Bundle, dest *zip.Writer)
| 437 | } |
| 438 | |
| 439 | func writeBundle(src *support.Bundle, dest *zip.Writer) error { |
| 440 | // We JSON-encode the following: |
| 441 | for k, v := range map[string]any{ |
| 442 | "agent/agent.json": src.Agent.Agent, |
| 443 | "agent/listening_ports.json": src.Agent.ListeningPorts, |
| 444 | "agent/manifest.json": src.Agent.Manifest, |
| 445 | "agent/peer_diagnostics.json": src.Agent.PeerDiagnostics, |
| 446 | "agent/ping_result.json": src.Agent.PingResult, |
| 447 | "deployment/buildinfo.json": src.Deployment.BuildInfo, |
| 448 | "deployment/config.json": src.Deployment.Config, |
| 449 | "deployment/experiments.json": src.Deployment.Experiments, |
| 450 | "deployment/health.json": src.Deployment.HealthReport, |
| 451 | "deployment/stats.json": src.Deployment.Stats, |
| 452 | "deployment/entitlements.json": src.Deployment.Entitlements, |
| 453 | "deployment/health_settings.json": src.Deployment.HealthSettings, |
| 454 | "deployment/workspaces.json": src.Deployment.Workspaces, |
| 455 | "network/connection_info.json": src.Network.ConnectionInfo, |
| 456 | "network/netcheck.json": src.Network.Netcheck, |
| 457 | "network/interfaces.json": src.Network.Interfaces, |
| 458 | "workspace/template.json": src.Workspace.Template, |
| 459 | "workspace/template_version.json": src.Workspace.TemplateVersion, |
| 460 | "workspace/parameters.json": src.Workspace.Parameters, |
| 461 | "workspace/workspace.json": src.Workspace.Workspace, |
| 462 | } { |
| 463 | f, err := dest.Create(k) |
| 464 | if err != nil { |
| 465 | return xerrors.Errorf("create file %q in archive: %w", k, err) |
| 466 | } |
| 467 | enc := json.NewEncoder(f) |
| 468 | enc.SetIndent("", " ") |
| 469 | if err := enc.Encode(v); err != nil { |
| 470 | return xerrors.Errorf("write json to %q: %w", k, err) |
| 471 | } |
| 472 | } |
| 473 | |
| 474 | // Include named template artifacts (if requested) |
| 475 | if src.NamedTemplate.Template.ID != uuid.Nil { |
| 476 | name := src.NamedTemplate.Template.Name |
| 477 | // JSON files |
| 478 | for k, v := range map[string]any{ |
| 479 | "templates/" + name + "/template.json": src.NamedTemplate.Template, |
| 480 | "templates/" + name + "/template_version.json": src.NamedTemplate.TemplateVersion, |
| 481 | } { |
| 482 | f, err := dest.Create(k) |
| 483 | if err != nil { |
| 484 | return xerrors.Errorf("create file %q in archive: %w", k, err) |
| 485 | } |
| 486 | enc := json.NewEncoder(f) |
| 487 | enc.SetIndent("", " ") |
| 488 | if err := enc.Encode(v); err != nil { |
| 489 | return xerrors.Errorf("write json to %q: %w", k, err) |
| 490 | } |
| 491 | } |
| 492 | // Binary template file (zip) |
| 493 | if namedZipBytes, err := base64.StdEncoding.DecodeString(src.NamedTemplate.TemplateFileBase64); err == nil { |
| 494 | k := "templates/" + name + "/template_file.zip" |
| 495 | f, err := dest.Create(k) |
| 496 | if err != nil { |
no test coverage detected