MCPcopy
hub / github.com/hashicorp/packer / RunContext

Method RunContext

command/sbom_generate.go:116–140  ·  view source on GitHub ↗
(ctx context.Context, cfg *sbom.Config)

Source from the content-addressed store, hash-verified

114}
115
116func (cmd *SBOMGenerateCommand) RunContext(ctx context.Context, cfg *sbom.Config) int {
117 fmt.Fprintf(os.Stderr, "Generating %s SBOM for %s...\n", cfg.Format, cfg.ScanPath)
118
119 // Create generator
120 generator := sbom.NewGenerator(*cfg)
121
122 // Generate SBOM
123 sbomData, err := generator.Generate(ctx)
124 if err != nil {
125 cmd.Ui.Error(fmt.Sprintf("SBOM generation failed: %s", err))
126 return 1
127 }
128
129 // Write to stdout (will be redirected to file via > operator)
130 _, err = os.Stdout.Write(sbomData)
131 if err != nil {
132 cmd.Ui.Error(fmt.Sprintf("Failed to write SBOM: %s", err))
133 return 1
134 }
135
136 fmt.Fprintln(os.Stderr, "✓ SBOM generation completed")
137
138 return 0
139
140}
141func (c *SBOMGenerateCommand) Synopsis() string {
142 return "Generate SBOM for the local system (internal use)"
143}

Callers 1

RunMethod · 0.95

Calls 4

GenerateMethod · 0.95
NewGeneratorFunction · 0.92
ErrorMethod · 0.65
WriteMethod · 0.65

Tested by

no test coverage detected