Documentation ¶
Index ¶
- Constants
- func DepLocksToDepLockMap(locks []DependencyLock) map[string]DependencyLock
- func MarshalDependencyLocks(locks []DependencyLock) ([]byte, error)
- func SerializeLocks(locks []DependencyLock) ([]byte, error)
- type DependencyLock
- type DependencyLocker
- func (l DependencyLocker) Alphabetize(locks []DependencyLock) []DependencyLock
- func (l DependencyLocker) LockNew(new ...DependencyLock) []DependencyLock
- func (l DependencyLocker) LockNewWithOld(new, old map[string]DependencyLock) []DependencyLock
- func (l DependencyLocker) VetLock(lock DependencyLock) *LockerError
- func (l DependencyLocker) VetLocks(final ...DependencyLock) []LockerError
- type DependencyLockerError
- type License
- type LicenseAuditError
- type LicenseAuditor
- type LicenseLock
- func (lock LicenseLock) Create(newLocks ...DependencyLock) error
- func (lock LicenseLock) Exists() bool
- func (lock LicenseLock) Lock(locks ...DependencyLock) error
- func (lock LicenseLock) OpenFileCreate() (*os.File, error)
- func (lock LicenseLock) OpenFileOverwrite() (*os.File, error)
- func (lock LicenseLock) OpenFileRead() (*os.File, error)
- func (lock LicenseLock) Overwrite(newLocks ...DependencyLock) error
- func (lock LicenseLock) Read() ([]DependencyLock, error)
- func (lock LicenseLock) VetLocks(locks ...DependencyLock) error
- func (lock LicenseLock) Write(writer prettyprinter.Writer, locks ...DependencyLock) error
- func (lock LicenseLock) WriteAndVetLocks(writer prettyprinter.Writer, locks ...DependencyLock) error
- type LicenseMineError
- type LicenseMiner
- func (lm LicenseMiner) DetermineLicenseText(path string) (string, error)
- func (lm LicenseMiner) DetermineMatch(matches ...licensedb.Match) (licensedb.Match, error)
- func (lm LicenseMiner) DetermineMatchFromEqualConfidences(m1, m2 licensedb.Match) (primary licensedb.Match)
- func (lm LicenseMiner) DetermineMultipleMatch(m1, m2 licensedb.Match) (licensedb.Match, error)
- func (lm LicenseMiner) DetermineSingleMatch(m licensedb.Match) error
- func (lm LicenseMiner) MeetsMinimumConfidence(a float32) error
- func (lm LicenseMiner) MeetsMinimumLead(a, b float32) error
- func (lm LicenseMiner) Mine(mines ...Mine) ([]DependencyLock, error)
- func (lm LicenseMiner) MineLicense(mine Mine) (License, error)
- type LicenseProspectingError
- type LicenseProspector
- type LicenseWhitelist
- type Locker
- type LockerError
- type MinConfidenceError
- type MinLeadError
- type Mine
- type Minimums
- type Prospect
- type Whitelist
Constants ¶
const ( MinConfErr = "does not meet minimum confidence: got %f lt %f" MinLeadErr = "does not meet minimum lead: %f - %f lt %f" LicProsErr = "error license prospecting: %v" LicMineErr = "error license mining: %v" LicAuditErr = "detected non-whitelisted licenses. Remove or Whitelist: %v" DepLockErr = "error locking dependencies %v:" )
const Confidence float32 = 0.85
Minimum required confidence for a probable license from text mining
const Lead float32 = 0.07
Minimum confidence difference of primary from secondary license matches
const LicenseLockName = "license.lock"
The filename for storing locked dependencies and their licenses
const NonWhitelistedLicenseErr = "non-whitelisted license: "
Message preface for a non-whitelisted license
const (
ReqEditField = "required editting of license field: "
)
Message preface for missing License fields
Variables ¶
This section is empty.
Functions ¶
func DepLocksToDepLockMap ¶
func DepLocksToDepLockMap( locks []DependencyLock, ) map[string]DependencyLock
Mutate a DependencyLock array to a DependencyLock map
func MarshalDependencyLocks ¶
func MarshalDependencyLocks( locks []DependencyLock, ) ([]byte, error)
Marshal a list of DependencyLock
func SerializeLocks ¶
func SerializeLocks( locks []DependencyLock, ) ([]byte, error)
Serialize a list of DependencyLocks for inclusion into a variable from golang -ldflags. Golang buildflags require no newlines or spaces
Types ¶
type DependencyLock ¶
type DependencyLock struct { Name string `json:"name"` Version string `json:"version"` ErrStr string `json:"err,omitempty"` License License `json:"license"` }
DependencyLock can be written directly to the license.lock file when finalized
func DeserializeLocks ¶
func DeserializeLocks( b []byte, ) ([]DependencyLock, error)
Deserialzed a list of DependencyLocks after inclusion into a variable from building with golang -ldflags
func MakeDependencyLock ¶
func MakeDependencyLock( name, version string, license License, ) DependencyLock
Create a DependencyLock
func UnmarshalDependencyLocks ¶
func UnmarshalDependencyLocks( bytes []byte, ) ([]DependencyLock, error)
Unmarshal a list of DependencyLock
func (*DependencyLock) AddErrStr ¶
func (lock *DependencyLock) AddErrStr( errStr string, )
Add error string
type DependencyLocker ¶
type DependencyLocker struct{}
DependencyLocker locks DependencyLocks. New locks with missing fields are merged with old locks when applicable
func (DependencyLocker) Alphabetize ¶
func (l DependencyLocker) Alphabetize( locks []DependencyLock, ) []DependencyLock
Alphabetize locks by name using mergesort
func (DependencyLocker) LockNew ¶
func (l DependencyLocker) LockNew( new ...DependencyLock, ) []DependencyLock
Lock new locks when no previous locks exist
func (DependencyLocker) LockNewWithOld ¶
func (l DependencyLocker) LockNewWithOld( new, old map[string]DependencyLock, ) []DependencyLock
Lock new locks with old. New locks take priority, and old locks not existing in the new list are deleted. New locks with missing License details are added from matching old locks. Return an alphabetized list by lock name
func (DependencyLocker) VetLock ¶
func (l DependencyLocker) VetLock( lock DependencyLock, ) *LockerError
Vet locks for missing License fields
func (DependencyLocker) VetLocks ¶
func (l DependencyLocker) VetLocks( final ...DependencyLock, ) []LockerError
Vet finalized locks for missing License fields. Return a list of LockerErrors for debugging printout
type DependencyLockerError ¶
type DependencyLockerError struct {
Locks []DependencyLock
}
func (DependencyLockerError) Error ¶
func (dle DependencyLockerError) Error() string
type License ¶
License holds license details of a golang module derived by licensedb and solved by Miner
type LicenseAuditError ¶
type LicenseAuditError struct {
Locks []DependencyLock
}
func (LicenseAuditError) Error ¶
func (lae LicenseAuditError) Error() string
type LicenseAuditor ¶
type LicenseAuditor struct {
// contains filtered or unexported fields
}
LicenseAuditor audits DependencyLocks for license types not included in the whitelist
func MakeLicenseAuditor ¶
func MakeLicenseAuditor( whitelist Whitelist, ) LicenseAuditor
Create a LicenseAuditor from specified Whitelist
func (LicenseAuditor) Audit ¶
func (auditor LicenseAuditor) Audit( locks ...DependencyLock, ) error
Audit a list of DependencyLocks for license types not included in the LicenseWhitelist. Return an error including a list of non-whitelist-license DependencyLocks for error printout
func (LicenseAuditor) AuditLock ¶
func (auditor LicenseAuditor) AuditLock( lock DependencyLock, ) error
Audit a DependencyLock's license type against the LicenseWhitelist
type LicenseLock ¶
type LicenseLock struct {
// contains filtered or unexported fields
}
LicenseLock is a file manager for locking dependencies and their licenses into an edittable file to save in a project's vcs
func MakeLicenseLock ¶
func MakeLicenseLock( dir string, ) LicenseLock
Create a LicenseLock with default values and providec directory to manage the lock file
func MakeLicenseLockFromRaw ¶
func MakeLicenseLockFromRaw( locker Locker, path string, printer prettyprinter.Printer, reader *reader.LimitedReader, ) LicenseLock
Create a LicenseLock from specified values
func (LicenseLock) Create ¶
func (lock LicenseLock) Create( newLocks ...DependencyLock, ) error
Create a lock file when one does not exist. Manual edits may be required
func (LicenseLock) Exists ¶
func (lock LicenseLock) Exists() bool
func (LicenseLock) Lock ¶
func (lock LicenseLock) Lock( locks ...DependencyLock, ) error
Lock DependencyLocks derived by adlr of a project's golang module dependencies into a lock file for vcs
func (LicenseLock) OpenFileCreate ¶
func (lock LicenseLock) OpenFileCreate() (*os.File, error)
func (LicenseLock) OpenFileOverwrite ¶
func (lock LicenseLock) OpenFileOverwrite() (*os.File, error)
func (LicenseLock) OpenFileRead ¶
func (lock LicenseLock) OpenFileRead() (*os.File, error)
func (LicenseLock) Overwrite ¶
func (lock LicenseLock) Overwrite( newLocks ...DependencyLock, ) error
Merge an existing lock file with new dependencies, giving new and updated dependencies priority. Manual edits may be required
func (LicenseLock) Read ¶
func (lock LicenseLock) Read() ( []DependencyLock, error, )
Read and unmarshal an existing lock file into memory
func (LicenseLock) VetLocks ¶
func (lock LicenseLock) VetLocks( locks ...DependencyLock, ) error
Vet finalized merge locks for missing fields unsolvable by merging. Return an error for required manual edits
func (LicenseLock) Write ¶
func (lock LicenseLock) Write( writer prettyprinter.Writer, locks ...DependencyLock, ) error
Write locks to lock file
func (LicenseLock) WriteAndVetLocks ¶
func (lock LicenseLock) WriteAndVetLocks( writer prettyprinter.Writer, locks ...DependencyLock, ) error
Write locks to the lock file. Vet locks after writing for missing fields that require manual edits
type LicenseMineError ¶
type LicenseMineError struct {
Mines []Mine
}
func (LicenseMineError) Error ¶
func (lme LicenseMineError) Error() string
type LicenseMiner ¶
type LicenseMiner struct {
// contains filtered or unexported fields
}
LicenseMiner attempts to automatically determine Licenses for Mines
func MakeLicenseMiner ¶
func MakeLicenseMiner() LicenseMiner
Create a LicenseMiner with default values
func MakeLicenseMinerFromRaw ¶
func MakeLicenseMinerFromRaw( minimums Minimums, reader *reader.LimitedReader, ) LicenseMiner
Create a LicenseMiner from specified values
func (LicenseMiner) DetermineLicenseText ¶
func (lm LicenseMiner) DetermineLicenseText( path string, ) (string, error)
Fetch license text from a golang module license file
func (LicenseMiner) DetermineMatch ¶
Attempt to automatically determine the correct licensedb.Match from a list
func (LicenseMiner) DetermineMatchFromEqualConfidences ¶ added in v1.4.0
func (lm LicenseMiner) DetermineMatchFromEqualConfidences( m1, m2 licensedb.Match, ) (primary licensedb.Match)
func (LicenseMiner) DetermineMultipleMatch ¶
Determine if the primary licensedb.Match meets confidence requirements to beat the secondary licensedb.Match
func (LicenseMiner) DetermineSingleMatch ¶
func (lm LicenseMiner) DetermineSingleMatch( m licensedb.Match, ) error
Determine if the singular licensedb.Match meets confidence requirement
func (LicenseMiner) MeetsMinimumConfidence ¶
func (lm LicenseMiner) MeetsMinimumConfidence( a float32, ) error
Determine whether a probable license confidence meets minimum
func (LicenseMiner) MeetsMinimumLead ¶
func (lm LicenseMiner) MeetsMinimumLead( a, b float32, ) error
Deteremine if the difference of the primary and secondary license confidences meets minimum
func (LicenseMiner) Mine ¶
func (lm LicenseMiner) Mine( mines ...Mine, ) ([]DependencyLock, error)
Attempt to automatically derive a License for a Mine from from the licensedb.Match(s) of a licensedb.Result from text mining a golang module directory. Return a list of DependencyLock. Returned error list can be printed for debugging, and are potentially recoverable by LicenseLock
func (LicenseMiner) MineLicense ¶
func (lm LicenseMiner) MineLicense( mine Mine, ) (License, error)
Attempt to automatically determine a License from for a Mine using its licensedb.Match(s)
type LicenseProspectingError ¶
type LicenseProspectingError struct {
Prospects []Prospect
}
func (LicenseProspectingError) Error ¶
func (lpe LicenseProspectingError) Error() string
type LicenseProspector ¶
type LicenseProspector struct{}
Text mine Prospects and return licensedb.Results
func MakeLicenseProspector ¶
func MakeLicenseProspector() LicenseProspector
Create a LicenseProspector
func (LicenseProspector) Prospect ¶
func (lp LicenseProspector) Prospect( prospects ...Prospect, ) ([]Mine, error)
Concurrently text mine a list of Prospect, and generate a a stable list of licensedb.Result. Return a stable list of Mine with its respective list of licensedb.Match from text mining. An error return occurs for missing directories or missing licenses, and should be treated as non-recoverable
func (LicenseProspector) ProspectLicenses ¶
func (lp LicenseProspector) ProspectLicenses( paths ...string, ) []licensedb.Result
Concurrently text mine paths and return a stable list of licensedb.Result
type LicenseWhitelist ¶
type LicenseWhitelist struct {
// contains filtered or unexported fields
}
LicenseWhitelist is a whitelist of automatically fulfillable licenses, with search by license type
func (LicenseWhitelist) Find ¶
func (lw LicenseWhitelist) Find( license string, ) bool
Search a whitelist of license types that a license exists
type Locker ¶
type Locker interface { LockNew(...DependencyLock) []DependencyLock LockNewWithOld(new, old map[string]DependencyLock) []DependencyLock VetLocks(...DependencyLock) []LockerError }
DependencyLocker implements the Locker interface
type LockerError ¶
type LockerError struct { Name string `json:"name"` Version string `json:"version"` Err []prettyprinter.FieldError `json:"errors"` }
func MakeLockerError ¶
func MakeLockerError( name, version string, errs ...error, ) LockerError
type MinConfidenceError ¶
type MinConfidenceError struct {
Got, MinConf float32
}
func (MinConfidenceError) Error ¶
func (mce MinConfidenceError) Error() string
type MinLeadError ¶
type MinLeadError struct {
Got1, Got2, MinLead float32
}
func (MinLeadError) Error ¶
func (mle MinLeadError) Error() string
type Mine ¶
Mines hold the data required to attempt to automatically determine a golang module's license
type Prospect ¶
Prospects hold the data required to text mine a golang module
func MakeProspect ¶
Create a Prospect
func MakeProspects ¶
Create a list of Prospect from a list of gotool.Module, carrying-over all important data