hand-off-lucas
Jenna Goldstrich 2 years ago
parent e50ae970dd
commit b548b99dff

@ -519,6 +519,7 @@ func (cfg *PackerConfig) getCoreBuildProvisioner(source SourceUseBlock, pb *Prov
if pb.PType == "hcp-sbom" {
provisioner = &packer.SBOMInternalProvisioner{
Provisioner: provisioner,
Name: pb.PName,
}
}

@ -246,6 +246,7 @@ func (bucket *Bucket) uploadSbom(ctx context.Context, buildName string, sbom pac
Body: &hcpPackerModels.HashicorpCloudPacker20230101UploadSbomBody{
CompressedSbom: sbom.CompressedData,
Format: sbom.Format,
Name: sbom.Name,
},
},
nil,

@ -57,6 +57,7 @@ type CoreBuild struct {
type SBOM struct {
Format string
CompressedData []byte
Name string
}
type BuildMetadata struct {
@ -315,6 +316,7 @@ func (b *CoreBuild) Run(ctx context.Context, originalUi packersdk.Ui) ([]packers
sbom := SBOM{
Format: sbomInternalProvisioner.SBOMFormat,
CompressedData: sbomInternalProvisioner.CompressedData,
Name: sbomInternalProvisioner.Name,
}
b.SBOMs = append(b.SBOMs, sbom)
}

@ -300,6 +300,7 @@ func (c *Core) generateCoreBuildProvisioner(rawP *template.Provisioner, rawName
if rawP.Type == "hcp-sbom" {
provisioner = &SBOMInternalProvisioner{
Provisioner: provisioner,
Name: rawName,
}
}

@ -249,6 +249,7 @@ type SBOMInternalProvisioner struct {
Provisioner packersdk.Provisioner
CompressedData []byte
SBOMFormat string
Name string
}
func (p *SBOMInternalProvisioner) ConfigSpec() hcldec.ObjectSpec { return p.ConfigSpec() }
@ -299,6 +300,7 @@ func (p *SBOMInternalProvisioner) Provision(
if err != nil {
return err
}
p.CompressedData = compressedData
p.SBOMFormat = sbomFormat
return nil

@ -31,6 +31,7 @@ type Config struct {
// needs to be downloaded.
// It can be a file path or a URL.
Source string `mapstructure:"source" required:"true"`
// Destination is an optional field that specifies the path where the SBOM
// file will be downloaded to for the user.
// The 'Destination' must be a writable location. If the destination is a file,
@ -41,7 +42,9 @@ type Config struct {
// a "Permission Denied" error will occur. If the source path is a file,
// it is recommended that the destination path be a file as well.
Destination string `mapstructure:"destination"`
ctx interpolate.Context
Name string
ctx interpolate.Context
}
type Provisioner struct {

@ -20,6 +20,7 @@ type FlatConfig struct {
PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables" hcl:"packer_sensitive_variables"`
Source *string `mapstructure:"source" required:"true" cty:"source" hcl:"source"`
Destination *string `mapstructure:"destination" cty:"destination" hcl:"destination"`
Name *string `mapstructure:"name" cty:"name" hcl:"name"`
}
// FlatMapstructure returns a new FlatConfig.
@ -44,6 +45,8 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
"packer_sensitive_variables": &hcldec.AttrSpec{Name: "packer_sensitive_variables", Type: cty.List(cty.String), Required: false},
"source": &hcldec.AttrSpec{Name: "source", Type: cty.String, Required: false},
"destination": &hcldec.AttrSpec{Name: "destination", Type: cty.String, Required: false},
"name": &hcldec.AttrSpec{Name: "name", Type: cty.String, Required: false},
}
return s
}

File diff suppressed because it is too large Load Diff

@ -29,6 +29,7 @@ build {
provisioner "hcp-sbom" {
source = "/tmp/sbom_cyclonedx.json"
destination = "sbom_cyclonedx.json"
name = "aaa"
}
provisioner "hcp-sbom" {

Loading…
Cancel
Save