spdx

package
v1.5.35 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Creator

type Creator struct {
	// Creator is the value of the [Creator] relationship.
	Creator string
	// CreatorType is the key of the [Creator] relationship.
	// In accordance to the SPDX v2 spec, CreatorType should be one of "Person", "Organization", or "Tool".
	CreatorType string
}

Creator describes the creator of the SPDX document that will be produced from the encoding.

type Encoder

type Encoder struct {
	// The target SPDX version in which to encode.
	Version Version
	// The data format in which to encode.
	Format Format
	// The SPDX document creator information.
	Creators []Creator
	// The SPDX document name field.
	DocumentName string
	// The SPDX document namespace field.
	DocumentNamespace string
	// The SPDX document comment field.
	DocumentComment string
}

Encoder defines an SPDX encoder and accepts certain values from the caller to use in the SPDX document.

func NewDefaultEncoder

func NewDefaultEncoder(options ...Option) *Encoder

NewDefaultEncoder creates an Encoder with default values and sets optional fields based on the provided options.

func (*Encoder) Encode

func (e *Encoder) Encode(ctx context.Context, w io.Writer, ir *claircore.IndexReport) error

Encode encodes a claircore.IndexReport that writes to w. We first convert the IndexReport to an SPDX doc of the latest version, then convert that doc to the specified version. We assume there's no data munging going from latest to the specified version.

type Format

type Format string

Format describes the data format for the SPDX document.

const JSONFormat Format = "json"

type Option

type Option func(*Encoder)

Option is a type for setting optional fields for the Encoder.

func WithDocumentComment

func WithDocumentComment(comment string) Option

WithDocumentComment is used to set the SPDX document comment field.

func WithDocumentName

func WithDocumentName(name string) Option

WithDocumentName is used to set the SPDX document name field.

func WithDocumentNamespace

func WithDocumentNamespace(namespace string) Option

WithDocumentNamespace is used to set the SPDX document namespace field.

type Version

type Version string

Version describes the SPDX version to target.

const (
	V2_3 Version = "v2.3"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳