From 62f6146c373f0759979d217b63427470389540ce Mon Sep 17 00:00:00 2001 From: Alex Goodman Date: Wed, 28 Oct 2020 15:58:54 -0400 Subject: [PATCH] do not include optional fields Signed-off-by: Alex Goodman --- syft/pkg/java_metadata.go | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/syft/pkg/java_metadata.go b/syft/pkg/java_metadata.go index 4cc9f842c..810234d2f 100644 --- a/syft/pkg/java_metadata.go +++ b/syft/pkg/java_metadata.go @@ -5,9 +5,9 @@ import "github.com/package-url/packageurl-go" // JavaMetadata encapsulates all Java ecosystem metadata for a package as well as an (optional) parent relationship. type JavaMetadata struct { VirtualPath string `json:"virtualPath"` - Manifest *JavaManifest `mapstructure:"Manifest" json:"manifest"` - PomProperties *PomProperties `mapstructure:"PomProperties" json:"pomProperties"` - Parent *Package `json:"parentPackage"` // TODO: should this be included in the json output? + Manifest *JavaManifest `mapstructure:"Manifest" json:"manifest,omitempty"` + PomProperties *PomProperties `mapstructure:"PomProperties" json:"pomProperties,omitempty"` + Parent *Package `json:"parentPackage,omitempty"` // TODO: should this be included in the json output? } // PomProperties represents the fields of interest extracted from a Java archive's pom.xml file. @@ -22,15 +22,16 @@ type PomProperties struct { // JavaManifest represents the fields of interest extracted from a Java archive's META-INF/MANIFEST.MF file. type JavaManifest struct { - Name string `mapstructure:"Name" json:"name"` - ManifestVersion string `mapstructure:"Manifest-Version" json:"manifestVersion"` - SpecTitle string `mapstructure:"Specification-Title" json:"specificationTitle"` - SpecVersion string `mapstructure:"Specification-Version" json:"specificationVersion"` - SpecVendor string `mapstructure:"Specification-Vendor" json:"specificationVendor"` - ImplTitle string `mapstructure:"Implementation-Title" json:"implementationTitle"` - ImplVersion string `mapstructure:"Implementation-Version" json:"implementationVersion"` - ImplVendor string `mapstructure:"Implementation-Vendor" json:"implementationVendor"` - Extra map[string]string `mapstructure:",remain" json:"extraFields"` + Name string `mapstructure:"Name" json:"name"` + ManifestVersion string `mapstructure:"Manifest-Version" json:"manifestVersion"` + SpecTitle string `mapstructure:"Specification-Title" json:"specificationTitle"` + SpecVersion string `mapstructure:"Specification-Version" json:"specificationVersion"` + SpecVendor string `mapstructure:"Specification-Vendor" json:"specificationVendor"` + ImplTitle string `mapstructure:"Implementation-Title" json:"implementationTitle"` + ImplVersion string `mapstructure:"Implementation-Version" json:"implementationVersion"` + ImplVendor string `mapstructure:"Implementation-Vendor" json:"implementationVendor"` + Extra map[string]string `mapstructure:",remain" json:"extraFields"` + Sections []map[string]string `json:"sections"` } func (m JavaMetadata) PackageURL() string {