appbom

package
v0.0.0-...-9159377 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

There are two ways to provide the Go executable hash to "appbom":

1. "go generate" and "embed" 2. "-ldflags"

Using "go generate" to hash the Go binary:

go generate ./... go generate github.com/slimtoolkit/slim/pkg/appbom

With "go generate" you also need to use embedding (enabled by default). If you can't use "embed" you can disable it with the "appbom_noembed" tag:

go build -tags appbom_noembed

If you disable embedding then you'll need to pass the Go executable hash using "-ldflags":

Mac:

go build -ldflags "-X github.com/slimtoolkit/slim/pkg/appbom.GoBinHash=sha256:$(shasum -a 256 $(go env GOROOT)/bin/go | head -c 64)"

Linux:

go build -ldflags "-X github.com/slimtoolkit/slim/pkg/appbom.GoBinHash=sha256:$(sha256sum $(go env GOROOT)/bin/go | head -c 64)"

You can use "-ldflags" instead of go generate/embed if that approach works better for you.

Index

Constants

View Source
const (
	SettingBuildMode = "-buildmode" // the buildmode flag used
	SettingCompiler  = "-compiler"  // the compiler toolchain flag used
	SettingTags      = "-tags"
	SettingTrimPath  = "-trimpath"
	SettingLdFlags   = "-ldflags"
	SettingMod       = "-mod"

	SettingEnvVarCgoEnabled  = "CGO_ENABLED"  // the effective CGO_ENABLED environment variable
	SettingEnvVarCgoCFlags   = "CGO_CFLAGS"   // the effective CGO_CFLAGS environment variable
	SettingEnvVarCgoCppFlags = "CGO_CPPFLAGS" // the effective CGO_CPPFLAGS environment variable
	SettingEnvVarCgoCxxFlags = "CGO_CXXFLAGS" // the effective CGO_CXXFLAGS environment variable
	SettingEnvVarCgoLdFlags  = "CGO_LDFLAGS"  // the effective CGO_LDFLAGS environment variable
	SettingEnvVarGoOs        = "GOOS"         // the operating system target
	SettingEnvVarGoArch      = "GOARCH"       // the architecture target

	// the architecture feature level for GOARCH
	SettingEnvVarGoAmd64  = "GOAMD64"
	SettingEnvVarGoArm64  = "GOARM64"
	SettingEnvVarGoArm    = "GOARM"
	SettingEnvVarGo386    = "GO386"
	SettingEnvVarGoPpc64  = "GOPPC64"
	SettingEnvVarGoMips   = "GOMIPS"
	SettingEnvVarGoMips64 = "GOMIPS64"
	SettingEnvVarGoWasm   = "GOWASM"

	SettingVcsType     = "vcs"          // the version control system for the source tree where the build ran
	SettingVcsRevision = "vcs.revision" // the revision identifier for the current commit or checkout
	SettingVcsTime     = "vcs.time"     // the modification time associated with vcs.revision, in RFC3339 format
	SettingVcsModified = "vcs.modified" // true or false indicating whether the source tree had local modifications
)

Known Settings key names

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildParams

type BuildParams struct {
	BuildMode   *ParamInfo `json:"build_mode,omitempty"`
	Compiler    *ParamInfo `json:"compiler,omitempty"`
	CgoEnabled  *ParamInfo `json:"cgo_enabled,omitempty"`
	CgoCFlags   *ParamInfo `json:"cgo_cflags,omitempty"`
	CgoCppFlags *ParamInfo `json:"cgo_cppflags,omitempty"`
	CgoCxxFlags *ParamInfo `json:"cgo_cxxflags,omitempty"`
	CgoLdFlags  *ParamInfo `json:"cgo_ldflags,omitempty"`
	Os          *ParamInfo `json:"os,omitempty"`
	Arch        *ParamInfo `json:"arch,omitempty"`
	ArchFeature *ParamInfo `json:"arch_feature,omitempty"`
}

type Info

type Info struct {
	BuilderHash   string             `json:"builder_hash,omitempty"`
	Runtime       string             `json:"runtime"`
	Entrypoint    MainPackageInfo    `json:"entrypoint"`
	BuildParams   BuildParams        `json:"build_params"`
	OtherParams   map[string]string  `json:"other_params,omitempty"`
	SourceControl *SourceControlInfo `json:"source_control,omitempty"`
	Includes      []*PackageInfo     `json:"includes,omitempty"`
}

func Get

func Get() *Info

type MainPackageInfo

type MainPackageInfo struct {
	Path    string `json:"path"` //todo: add 'main'
	Version string `json:"version"`
}

type PackageInfo

type PackageInfo struct {
	Name       string `json:"name"`
	Version    string `json:"version"`
	Hash       string `json:"hash"` // 'h1' algo is sha256: https://go.dev/ref/mod#go-sum-files
	Path       string `json:"path"`
	ReplacedBy string `json:"replaced_by,omitempty"`
}

type ParamInfo

type ParamInfo struct {
	Name        ParamName `json:"name"`
	Type        ParamType `json:"type"`
	Value       string    `json:"value"`
	Description string    `json:"description,omitempty"`
}

type ParamName

type ParamName string

type ParamType

type ParamType string
const (
	PTFlag   ParamType = "flag"
	PTEnvVar           = "envvar"
)

type SourceControlInfo

type SourceControlInfo struct {
	Type            string `json:"type"`
	Revision        string `json:"revision"`
	RevisionTime    string `json:"revision_time"`
	HasLocalChanges bool   `json:"has_local_changes"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL