binman

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound   = errors.New("Release not found")
	ErrBadRequest = errors.New("Bad Request")
	ErrUnknown    = errors.New("Unknown Failure")
)
View Source
var (
	ErrNoVersionsFound = errors.New("No Versions detected for release")
)
View Source
var (
	ErrReleaseNotFound = errors.New("Requested release not found in config")
)
View Source
var (
	// ErrVersionsListNotSorted is returned when a list of versions is not sorted
	ErrVersionsListNotSorted = errors.New("Provided list of versions is not sorted")
)

Functions

func BuildOciImage added in v0.10.2

func BuildOciImage(config, repo, targetImageName, baseImage, imagePath string) error

func Clean added in v0.10.0

func Clean(dryrun, scan bool, threshold int, dbPath, config string) error

func CopyFile added in v0.5.0

func CopyFile(source string, target string) error

func CreateDirectory added in v0.3.0

func CreateDirectory(path string) error

func GetVersionFromPath added in v0.11.0

func GetVersionFromPath(repoPath string) []string

GetVersionFromPath will return a list of all synced versions in a directory path

func GunZipFile

func GunZipFile(gzipFile io.Reader) *gzip.Reader

unzip gzip file

func MakeExecuteable added in v0.4.0

func MakeExecuteable(path string) error

func OutputDbStatus added in v0.10.0

func OutputDbStatus() error

OutputDbStatus will output all keys and values

func PopulateLatestMap added in v0.11.0

func PopulateLatestMap(bm *BMConfig) map[string]BinmanRelease

func SetBaseConfig added in v0.2.0

func SetBaseConfig(configArg string) string

setBaseConfig will check for each of the possible config locations and return the correct value

func SetStopMessage added in v0.11.0

func SetStopMessage(out map[string][]BinmanMsg) string

Set the stop message based on work completed

func WatchServe added in v0.11.0

func WatchServe(bm *BMConfig)

func WriteStringtoFile added in v0.2.0

func WriteStringtoFile(path string, thestring string) error

func XunZipFile added in v0.11.0

func XunZipFile(xzipFile io.Reader) *xz.Reader

unzip xzip file

Types

type Action added in v0.1.5

type Action interface {
	// contains filtered or unexported methods
}

type BMConfig added in v0.11.0

type BMConfig struct {
	Config        BinmanConfig    `yaml:"config"`
	ConfigPath    string          `yaml:",omitempty"`
	Defaults      BinmanDefaults  `yaml:"defaults,omitempty"`
	Releases      []BinmanRelease `yaml:"releases"`
	Msgs          []BinmanMsg     `yaml:",omitempty"` // Output from execution
	OutputOptions *OutputOptions  `yaml:",omitempty"`

	Metrics *prometheus.GaugeVec
	// contains filtered or unexported fields
}

Type that rolls up the above types into one happy family

func NewBMConfig added in v0.11.0

func NewBMConfig(configPath string) *BMConfig

func NewBMSync added in v0.11.0

func NewBMSync(configPath string, table bool) *BMConfig

For running the default sync

func NewBMWatch added in v0.11.0

func NewBMWatch(configPath string) *BMConfig

For running the default sync

func NewGet added in v0.11.0

func NewGet(r ...BinmanRelease) *BMConfig

For running the get command

func NewQuery added in v0.11.0

func NewQuery(r ...BinmanRelease) *BMConfig

This is for when you want to query a single repo

func (*BMConfig) BMClose added in v0.11.0

func (config *BMConfig) BMClose()

BMClose will close all channels in use

func (*BMConfig) CollectData added in v0.11.0

func (config *BMConfig) CollectData()

Execute will collect data and execute any requested steps

func (*BMConfig) GetRelease added in v0.11.0

func (config *BMConfig) GetRelease(repo string) (BinmanRelease, error)

func (*BMConfig) SetConfig added in v0.11.0

func (config *BMConfig) SetConfig(merge bool) *BMConfig

setConfig will create the appropriate BMConfig and merge if required

func (*BMConfig) SetDefaults added in v0.11.0

func (config *BMConfig) SetDefaults()

SetDefaults will populate defaults, and required values

func (*BMConfig) WithDb added in v0.11.0

func (config *BMConfig) WithDb(dbConfig ...db.DbConfig) *BMConfig

func (*BMConfig) WithDownloader added in v0.11.0

func (config *BMConfig) WithDownloader() *BMConfig

func (*BMConfig) WithOutput added in v0.11.0

func (config *BMConfig) WithOutput(table, spinner bool) *BMConfig

WithOutput configures output for an operation

func (*BMConfig) WithWatch added in v0.11.0

func (config *BMConfig) WithWatch() *BMConfig

setWatchConfig sets config/releases for watch subcommand

type BinmanConfig added in v0.0.5

type BinmanConfig struct {
	CleanupArchive bool      `yaml:"cleanup,omitempty"`      // mark true if archive should be cleaned after extraction
	ReleasePath    string    `yaml:"releasepath,omitempty"`  // path to download/link releases from github
	BinPath        string    `yaml:"binpath,omitempty"`      // path to download/link binaries from github
	TokenVar       string    `yaml:"tokenvar,omitempty"`     // Github Auth Token
	NumWorkers     int       `yaml:"maxdownloads,omitempty"` // maximum number of concurrent downloads the user will allow
	UpxConfig      UpxConfig `yaml:"upx,omitempty"`          // Allow upx to shrink extracted
	Sources        []Source  `yaml:"sources,omitempty"`      // Sources to query. By default gitlab and github
	Watch          Watch     `yaml:"watch,omitempty"`        // Watch config object

	SourceMap map[string]*Source `yaml:"-"` // map of names to struct pointers for sources
}

BinmanConfig contains Global Config Options

type BinmanDefaults added in v0.0.5

type BinmanDefaults struct {
	Os     string `yaml:"os,omitempty"`     //OS to look for
	Arch   string `yaml:"arch,omitempty"`   //architecture to look for
	Source string `yaml:"source,omitempty"` //Set to binman to override all
}

BinmanDefaults contains default config options. If a value is unset in releases array these will be used. This should just be collapsed into BinmanConfig and this struct should be removed

type BinmanMsg added in v0.0.9

type BinmanMsg struct {
	Err error
	Rel BinmanRelease
}

BinmanMsg contains return messages for binman's concurrent workers

type BinmanQuery added in v0.11.0

type BinmanQuery struct {
	Architechure string `json:"architechure" binding:"required"`
	Repo         string `json:"repo" binding:"required"`
	Source       string `json:"source" binding:"required"`
	Version      string `json:"version"`
}

https://gin-gonic.com/docs/examples/binding-and-validation/

func (*BinmanQuery) SendQuery added in v0.11.0

func (q *BinmanQuery) SendQuery(bmurl string) (BinmanQueryResponse, error)

type BinmanQueryResponse added in v0.11.0

type BinmanQueryResponse struct {
	Repo    string
	DlUrl   string
	Version string `json:"version,omitempty"`
}

type BinmanRelease added in v0.0.5

type BinmanRelease struct {
	Os               string        `yaml:"os,omitempty"`
	Arch             string        `yaml:"arch,omitempty"`
	CheckSum         bool          `yaml:"checkSum,omitempty"`
	CleanupArchive   bool          `yaml:"cleanup,omitempty"`         // mark true if archive should be cleaned after extraction
	DownloadOnly     bool          `yaml:"downloadonly,omitempty"`    // Download but do not extract/find/link
	PostOnly         bool          `yaml:"postonly,omitempty"`        // Gather information from source, but perform no actions save os commands
	UpxConfig        UpxConfig     `yaml:"upx,omitempty"`             // Allow shrinking with Upx
	ExternalUrl      string        `yaml:"url,omitempty"`             // User provided external url to use with versions grabbed from GH. Note you must also set ReleaseFileName
	ExtractFileName  string        `yaml:"extractfilename,omitempty"` // The file within the release you want
	ReleaseFileName  string        `yaml:"releasefilename,omitempty"` // Specifc Release filename to look for. This is useful if a project publishes a binary and not a tarball.
	Repo             string        `yaml:"repo"`                      // The specific repo name in github. e.g achore/syft
	LinkName         string        `yaml:"linkname,omitempty"`        // Set what the final link will be. Defaults to project name.
	Version          string        `yaml:"version,omitempty"`         // Pull a specific version
	PostCommands     []PostCommand `yaml:"postcommands,omitempty"`
	QueryType        string        `yaml:"querytype,omitempty"`
	ReleasePath      string        `yaml:"releasepath,omitempty"`
	BinPath          string        `yaml:"binpath,omitempty"`
	SourceIdentifier string        `yaml:"source,omitempty"`      // Allow setting of source individually
	PublishPath      string        `yaml:"publishpath,omitempty"` // Path Release will be set up at. Typically only set by set commands or library use.
	ArtifactPath     string        `yaml:"-"`                     // Will be set by BinmanRelease.setPaths. This is the source path for the link aka the executable binary
	// contains filtered or unexported fields
}

BinmanRelease contains info on specifc releases to hunt for

func (*BinmanRelease) AddCleanArchive added in v0.6.0

func (r *BinmanRelease) AddCleanArchive() Action

func (*BinmanRelease) AddDownloadAction added in v0.1.5

func (r *BinmanRelease) AddDownloadAction() Action

func (*BinmanRelease) AddEndWorkAction added in v0.5.3

func (r *BinmanRelease) AddEndWorkAction() Action

func (*BinmanRelease) AddExtractAction added in v0.1.5

func (r *BinmanRelease) AddExtractAction() Action

func (*BinmanRelease) AddFindTargetAction added in v0.1.5

func (r *BinmanRelease) AddFindTargetAction() Action

func (*BinmanRelease) AddGetBinmanReleaseAction added in v0.11.0

func (r *BinmanRelease) AddGetBinmanReleaseAction() Action

func (*BinmanRelease) AddGetGHReleaseAction added in v0.3.0

func (r *BinmanRelease) AddGetGHReleaseAction(ghClient *github.Client) Action

func (*BinmanRelease) AddGetGLReleaseAction added in v0.8.0

func (r *BinmanRelease) AddGetGLReleaseAction(glClient *gitlab.Client) Action

func (*BinmanRelease) AddLinkFileAction added in v0.1.5

func (r *BinmanRelease) AddLinkFileAction() Action

func (*BinmanRelease) AddMakeExecuteableAction added in v0.1.5

func (r *BinmanRelease) AddMakeExecuteableAction() Action

func (*BinmanRelease) AddOsCommandAction added in v0.1.5

func (r *BinmanRelease) AddOsCommandAction(index int) Action

func (*BinmanRelease) AddReleaseStatusAction added in v0.3.0

func (r *BinmanRelease) AddReleaseStatusAction(releasePath string) Action

func (*BinmanRelease) AddSetArtifactPathAction added in v0.3.0

func (r *BinmanRelease) AddSetArtifactPathAction(releasePath, binPath string) Action

func (*BinmanRelease) AddSetFinalActions added in v0.5.3

func (r *BinmanRelease) AddSetFinalActions() Action

func (*BinmanRelease) AddSetOsActions added in v0.5.3

func (r *BinmanRelease) AddSetOsActions() Action

func (*BinmanRelease) AddSetPostActions added in v0.5.3

func (r *BinmanRelease) AddSetPostActions() Action

func (*BinmanRelease) AddSetUrlAction added in v0.3.0

func (r *BinmanRelease) AddSetUrlAction() Action

func (*BinmanRelease) AddUpdateDbAction added in v0.10.0

func (r *BinmanRelease) AddUpdateDbAction() Action

func (*BinmanRelease) AddWriteRelNotesAction added in v0.1.5

func (r *BinmanRelease) AddWriteRelNotesAction() Action

func (*BinmanRelease) FetchReleaseData added in v0.11.0

func (r *BinmanRelease) FetchReleaseData(versions ...string) error

FetchReleaseData will query the DB

func (*BinmanRelease) SetSource added in v0.11.0

func (r *BinmanRelease) SetSource(sourceMap map[string]*Source)

SetSource will set the source for a release, it will also trim the source prefix from repo if used

type CleanArchiveAction added in v0.6.0

type CleanArchiveAction struct {
	// contains filtered or unexported fields
}

Remove downloaded archive after extraction

type DownloadAction added in v0.1.5

type DownloadAction struct {
	// contains filtered or unexported fields
}

type EndWorkAction added in v0.5.3

type EndWorkAction struct {
	// contains filtered or unexported fields
}

type ExtractAction added in v0.1.5

type ExtractAction struct {
	// contains filtered or unexported fields
}

Extract

type FindTargetAction added in v0.1.5

type FindTargetAction struct {
	// contains filtered or unexported fields
}

FindTarget

type GetBinmanReleaseAction added in v0.11.0

type GetBinmanReleaseAction struct {
	// contains filtered or unexported fields
}

type GetGHReleaseAction added in v0.3.0

type GetGHReleaseAction struct {
	// contains filtered or unexported fields
}

type GetGLReleaseAction added in v0.8.0

type GetGLReleaseAction struct {
	// contains filtered or unexported fields
}

type LinkFileAction added in v0.1.5

type LinkFileAction struct {
	// contains filtered or unexported fields
}

type MakeExecuteableAction added in v0.1.5

type MakeExecuteableAction struct {
	// contains filtered or unexported fields
}

type OsCommandAction added in v0.1.5

type OsCommandAction struct {
	// contains filtered or unexported fields
}

type OutputOptions added in v0.11.0

type OutputOptions struct {
	Table   bool
	Spinner bool

	SpinChan chan string
	Swg      sync.WaitGroup
}

func NewOutputOptions added in v0.11.0

func NewOutputOptions(table, spinner bool) *OutputOptions

Set table for Table based output after since, if a spinner is needed by the operation set Spinner

func (*OutputOptions) SendSpin added in v0.11.0

func (o *OutputOptions) SendSpin(s string)

type PostCommand added in v0.1.5

type PostCommand struct {
	Command string   `yaml:"command"`
	Args    []string `yaml:"args,omitempty"`
}

type ReleaseStatusAction added in v0.3.0

type ReleaseStatusAction struct {
	// contains filtered or unexported fields
}

type SetArtifactPathAction added in v0.3.0

type SetArtifactPathAction struct {
	// contains filtered or unexported fields
}

type SetFinalActions added in v0.5.3

type SetFinalActions struct {
	// contains filtered or unexported fields
}

type SetOsActions added in v0.5.3

type SetOsActions struct {
	// contains filtered or unexported fields
}

type SetPostActions added in v0.5.3

type SetPostActions struct {
	// contains filtered or unexported fields
}

type SetUrlAction added in v0.3.0

type SetUrlAction struct {
	// contains filtered or unexported fields
}

type Source added in v0.8.0

type Source struct {
	Name     string `yaml:"name"`
	Tokenvar string `yaml:"tokenvar,omitempty"`
	URL      string `yaml:"url"`
	Apitype  string `yaml:"apitype"`
}

type UpdateDbAction added in v0.10.0

type UpdateDbAction struct {
	// contains filtered or unexported fields
}

type UpxConfig added in v0.0.10

type UpxConfig struct {
	Enabled string   `yaml:"enabled,omitempty"` // Using a string here instead of a boolean to deal with an unset boolean defaulting to false
	Args    []string `yaml:"args,omitempty"`
}

type Watch added in v0.9.0

type Watch struct {
	Sync             bool   `yaml:"sync,omitempty"`       // set to true if you want to also pull down releases
	Frequency        int    `yaml:"frequency,omitempty"`  // how often to query for new releases
	Port             string `yaml:"port,omitempty"`       // port to expose server mode on
	FileServer       bool   `yaml:"fileserver,omitempty"` // Start file server of configured release path, must be used in conjunction with sync
	LatestVersionMap map[string]BinmanRelease
	// contains filtered or unexported fields
}

type WriteRelNotesAction added in v0.1.5

type WriteRelNotesAction struct {
	// contains filtered or unexported fields
}

WriteReleaseNotes

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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