fossa

package
v0.7.0-beta.8 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2018 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package fossa provides a high-level interface to the FOSSA API (by default, located at https://app.fossa.io).

Index

Constants

View Source
const BuildRevisionAPI = "/api/revisions/%s/build"
View Source
const BuildsAPI = "/api/builds/%s"
View Source
const IssuesAPI = "/api/issues/%s"
View Source
const RevisionsAPI = "/api/revisions/%s"

RevisionsAPI is the API endpoint for revisions.

Variables

View Source
var (
	ErrNoProject   = errors.New("no project provided for upload")
	ErrNoRevision  = errors.New("no revision provided for upload")
	ErrNoBuildData = errors.New("no build data to upload")
)

Errors related to preconditions.

View Source
var (
	ErrForbidden            = errors.New("authentication failed (is the API key correct?)")
	ErrRevisionDoesNotExist = errors.New("revision does not exist (are the project and revision correct and published in FOSSA?)")
)

Errors resulting from a bad API response.

View Source
var UsersAPI = "/api/users/%s"

Functions

func Get added in v0.7.0

func Get(endpoint string) (res string, statusCode int, err error)

Get makes a GET request to a FOSSA API endpoint.

func GetJSON added in v0.7.0

func GetJSON(endpoint string, v interface{}) (statusCode int, err error)

GetJSON makes a JSON GET request to a FOSSA API endpoint.

func GetOrganizationID added in v0.7.0

func GetOrganizationID() (string, error)

func Init added in v0.7.0

func Init(server, APIKey string) error

Init sets up an API instance.

func MustInit added in v0.7.0

func MustInit(server, APIKey string)

MustInit crashes and logs a fatal exception if `Init` fails.

func NormalizeGitURL

func NormalizeGitURL(project string) string

NormalizeGitURL normalizes all forms of git remote URLs to a single standard form.

func Post

func Post(endpoint string, body []byte) (res string, statusCode int, err error)

Post makes a POST request to a FOSSA API endpoint.

func PutJSON added in v0.7.0

func PutJSON(endpoint string, body []byte, v interface{}) (statusCode int, err error)

PutJSON makes a JSON PUT request to a FOSSA API endpoint.

func SourceUnitType added in v0.7.0

func SourceUnitType(t pkg.Type) (string, error)

SourceUnitType normalizes pkg.Types into SourceUnit types.

Types

type Build

type Build struct {
	ID    int
	Error string
	Task  struct {
		Status string
	}
}

A Build holds the FOSSA API response for the builds API.

func GetBuilds added in v0.7.0

func GetBuilds(locator Locator) ([]Build, error)

GetBuilds loads the build for a revision.

func QueueBuild added in v0.7.0

func QueueBuild(locator Locator) (Build, error)

type Issue added in v0.7.0

type Issue struct {
	PriorityString string
	Resolved       bool
	Revision       Revision
	Type           string
}

An Issue holds the FOSSA API response for the issue API.

func GetIssues added in v0.7.0

func GetIssues(locator Locator) ([]Issue, error)

GetIssues loads the issues for a project.

type License added in v0.7.0

type License struct {
	ID             int64
	LicenseID      string
	RevisionID     string
	LicenseGroupID int64
	Ignored        bool
	Title          string
	URL            string
	FullText       string
	Copyright      string
}

A License holds the FOSSA API response for the license API.

type Locator

type Locator struct {
	Fetcher  string `json:"fetcher"`
	Project  string `json:"package"`
	Revision string `json:"revision"`
}

Locator serializes FOSSA API locators.

func LocatorOf added in v0.7.0

func LocatorOf(id pkg.ID) Locator

LocatorOf returns the locator of a pkg.ID.

func ReadLocator

func ReadLocator(locator string) Locator

ReadLocator parses a string locator into a Locator.

func Upload

func Upload(fetcher, project, revision, title, branch string, data []SourceUnit) (Locator, error)

Upload uploads a project's analysis.

func (Locator) IsResolved

func (l Locator) IsResolved() bool

IsResolved returns true only if a locator is resolved.

func (Locator) String

func (l Locator) String() string

type Project added in v0.7.0

type Project struct {
	Title   string
	URL     string
	Public  bool
	Authors []string
}

A Project holds the FOSSA API response for the project API.

type Revision added in v0.7.0

type Revision struct {
	Locator  *Locator `json:"loc"`
	Licenses []License
	Project  *Project
	Meta     []RevisionMeta
	Issues   []Issue
}

A Revision holds the FOSSA API response for the revision API.

func GetRevision added in v0.7.0

func GetRevision(locator Locator) (Revision, error)

GetRevision loads a single revision.

func GetRevisions added in v0.7.0

func GetRevisions(locators []Locator) (revs []Revision, err error)

GetRevisions loads many revisions in batched requests.

type RevisionMeta added in v0.7.0

type RevisionMeta struct {
	LastScan string `json:"last_scan"`
}

A RevisionMeta holds metadata about a FOSSA API revision.

type SourceUnit

type SourceUnit struct {
	Name     string
	Type     string
	Manifest string
	Build    SourceUnitBuild
}

SourceUnit is the basic module unit of the FOSSA API.

func Normalize

func Normalize(modules []module.Module) ([]SourceUnit, error)

Normalize transforms module.Modules into SourceUnits.

type SourceUnitBuild added in v0.7.0

type SourceUnitBuild struct {
	Artifact string
	Context  interface{}

	Succeeded bool
	Error     error `json:",omitempty"`

	Imports      []string
	Dependencies []SourceUnitDependency
}

A SourceUnitBuild contains the build information of a SourceUnit.

type SourceUnitDependency added in v0.7.0

type SourceUnitDependency struct {
	// Location
	Locator string   `json:"locator"`
	Imports []string `json:"imports,omitempty"`

	// Metadata
	Data *json.RawMessage `json:"data,omitempty"`

	// Context
	Depth              int      `json:"depth,omitempty"`
	Parent             string   `json:"parent,omitempty"`
	UnresolvedLocators []string `json:"unresolved_locators,omitempty"`
}

A SourceUnitDependency contains the dependency information of a SourceUnit.

type User added in v0.7.0

type User struct {
	OrganizationID int
}

Jump to

Keyboard shortcuts

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