provider

package
v0.0.0-...-ad6d8b1 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionDownload    = "ActionDownload"
	ActionSearch      = "ActionSearch"
	ActionSetMetadata = "ActionSetMetadata"
	ActionUpload      = "ActionUpload"
)
View Source
const (
	ProviderTypeDocker = "docker"
	ProviderTypeGithub = "github"

	// special provider type for storing files locally.
	ProviderTypeLocal = "local"
)

Additional provider types should be added, matching those from this list: https://github.com/package-url/purl-spec/blob/master/PURL-TYPES.rst

Variables

View Source
var (
	// DefaultGithubProviderConfig can be used if you don't want to think about options.
	DefaultGithubProviderConfig = &GithubProviderConfig{
		Host:   "",
		UseSSL: true,
	}
)

Functions

func NewLocalPackageUrl

func NewLocalPackageUrl(localPath string) *packageurl.PackageURL

Types

type BaseProvider

type BaseProvider struct{}

type ConfigInterface

type ConfigInterface interface {
	Get(key string) interface{}
	GetString(key string) string
	GetBool(key string) bool
	GetInt(key string) int
	GetInt32(key string) int32
	GetInt64(key string) int64
	GetUint(key string) uint
	GetUint32(key string) uint32
	GetUint64(key string) uint64
	GetFloat64(key string) float64
	GetStringMap(key string) map[string]interface{}
	GetStringMapString(key string) map[string]string
	GetStringMapStringSlice(key string) map[string][]string
	GetSizeInBytes(key string) uint
	UnmarshalKey(key string, rawVal interface{}, opts ...viper.DecoderConfigOption) error
	Unmarshal(rawVal interface{}, opts ...viper.DecoderConfigOption) error
	Set(key string, value interface{})
	SetDefault(key string, value interface{})
	MergeConfig(in io.Reader) error
	AllKeys() []string
}

Create mock using: mockgen -source=pkg/provider/interface.go -destination=pkg/provider/mock/mock_config.go

type GithubProvider

type GithubProvider struct {
	*BaseProvider
	Name   string
	Client *github.Client
	Config *GithubProviderConfig
}

func DefaultGithubProvider

func DefaultGithubProvider() (*GithubProvider, error)

func NewGithubProvider

func NewGithubProvider(providerName string, cfg *GithubProviderConfig) (*GithubProvider, error)

func (*GithubProvider) ArtifactDownload

func (p *GithubProvider) ArtifactDownload(downloadFolderPath string, artifactPurl *packageurl.PackageURL) ([]string, []*packageurl.PackageURL, error)

func (*GithubProvider) ArtifactSearch

func (p *GithubProvider) ArtifactSearch(artifactPurl *packageurl.PackageURL) ([]*models.QueryResult, error)

func (*GithubProvider) ArtifactSetMetadata

func (p *GithubProvider) ArtifactSetMetadata(metadata map[string]string, destArtifactPurl *packageurl.PackageURL) error

func (*GithubProvider) ArtifactUpload

func (p *GithubProvider) ArtifactUpload(artifactCachePath string, sourceArtifactPurl *packageurl.PackageURL, destArtifactPurl *packageurl.PackageURL) error

func (*GithubProvider) Close

func (p *GithubProvider) Close()

func (*GithubProvider) IsAuthenticatedProvider

func (p *GithubProvider) IsAuthenticatedProvider() bool

func (*GithubProvider) IsSupportedArtifactType

func (p *GithubProvider) IsSupportedArtifactType(actionType string, artifactType string) bool

func (*GithubProvider) ValidateAuth

func (p *GithubProvider) ValidateAuth() error

type GithubProviderConfig

type GithubProviderConfig struct {
	Host     string `mapstructure:"hostname"`
	Password string `mapstructure:"password"`
	Port     string `mapstructure:"port"`
	Token    string `mapstructure:"token"`
	UseSSL   bool   `mapstructure:"use_ssl"`
	Username string `mapstructure:"username"`
	// contains filtered or unexported fields
}

type Interface

type Interface interface {
	ValidateAuth() error
	Close()

	IsAuthenticatedProvider() bool
	IsSupportedArtifactType(actionType string, artifactType string) bool

	//given a single purl, may return multiple purl's (one for each sub artifact)
	ArtifactSearch(artifactPurl *packageurl.PackageURL) ([]*models.QueryResult, error)

	ArtifactUpload(cachePath string, sourceArtifactPurl *packageurl.PackageURL, destArtifactPurl *packageurl.PackageURL) error
	ArtifactDownload(basePath string, artifactPurl *packageurl.PackageURL) ([]string, []*packageurl.PackageURL, error)

	ArtifactSetMetadata(metadata map[string]string, destArtifactPurl *packageurl.PackageURL) error
}

func CreateDefault

func CreateDefault(providerType string) (Interface, error)

type LocalProvider

type LocalProvider struct {
	*BaseProvider
	Name string
}

func DefaultLocalProvider

func DefaultLocalProvider() (*LocalProvider, error)

func NewLocalProvider

func NewLocalProvider(providerName string) (*LocalProvider, error)

func (*LocalProvider) ArtifactDownload

func (p *LocalProvider) ArtifactDownload(downloadFolderPath string, artifactPurl *packageurl.PackageURL) ([]string, []*packageurl.PackageURL, error)

func (*LocalProvider) ArtifactSearch

func (p *LocalProvider) ArtifactSearch(artifactPurl *packageurl.PackageURL) ([]*models.QueryResult, error)

func (*LocalProvider) ArtifactSetMetadata

func (p *LocalProvider) ArtifactSetMetadata(metadata map[string]string, destArtifactPurl *packageurl.PackageURL) error

func (*LocalProvider) ArtifactUpload

func (p *LocalProvider) ArtifactUpload(artifactCachePath string, sourceArtifactPurl *packageurl.PackageURL, destArtifactPurl *packageurl.PackageURL) error

func (*LocalProvider) Close

func (p *LocalProvider) Close()

func (*LocalProvider) IsAuthenticatedProvider

func (p *LocalProvider) IsAuthenticatedProvider() bool

func (*LocalProvider) IsSupportedArtifactType

func (p *LocalProvider) IsSupportedArtifactType(actionType string, artifactType string) bool

func (*LocalProvider) ValidateAuth

func (p *LocalProvider) ValidateAuth() error

Jump to

Keyboard shortcuts

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