nexusrm

package
v0.59.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2020 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Overview

Package nexusrm provides a number of functions that interact with the Nexus Repository Manager REST API. All functions require a new RM instance which can be instantiated as such:

rm, err := nexusrm.New("http://localhost:8081", "username", "password")
if err != nil {
    panic(err)
}

Index

Examples

Constants

View Source
const (
	AccessLogDB = "accesslog"
	ComponentDB = "component"
	ConfigDB    = "config"
	SecurityDB  = "security"
)

Define database types

View Source
const (
	Unknown repositoryFormat = iota
	Maven
	Npm
	Nuget
	Apt
	Docker
	Golang
	Raw
	Rubygems
	Bower
	Pypi
	Yum
	GitLfs
)

Enumerates the formats which can be created as Repository Manager repositories

Variables

This section is empty.

Functions

func AssociateTag added in v0.37.0

func AssociateTag(rm RM, query QueryBuilder) error

AssociateTag associates a tag to any component which matches the search criteria

func CheckAllDatabases added in v0.24.0

func CheckAllDatabases(rm RM) (states map[string]DatabaseState, err error)

CheckAllDatabases returns state on all of the databases

func CreateBlobStoreGroup

func CreateBlobStoreGroup(rm RM, name string, blobStores []string) error

CreateBlobStoreGroup creates a blobstore

func CreateFileBlobStore

func CreateFileBlobStore(rm RM, name, path string) error

CreateFileBlobStore creates a blobstore

func CreateGroupRepository

func CreateGroupRepository(rm RM, format repositoryFormat, config repositoryGroup) error

CreateGroupRepository creates a group repository of the indicated format

func CreateHostedRepository

func CreateHostedRepository(rm RM, format repositoryFormat, config repositoryHosted) error

CreateHostedRepository creates a hosted repository of the indicated format

func CreateProxyRepository

func CreateProxyRepository(rm RM, format repositoryFormat, config repositoryProxy) error

CreateProxyRepository creates a proxy repository of the indicated format

func DeleteAssetByID added in v0.23.0

func DeleteAssetByID(rm RM, id string) error

DeleteAssetByID deletes the asset indicated by ID

func DeleteComponentByID

func DeleteComponentByID(rm RM, id string) error

DeleteComponentByID deletes the indicated component

func DisassociateTag added in v0.37.0

func DisassociateTag(rm RM, query QueryBuilder) error

DisassociateTag associates a tag to any component which matches the search criteria

func GetSupportZip added in v0.24.1

func GetSupportZip(rm RM, options SupportZipOptions) ([]byte, string, error)

GetSupportZip generates a support zip with the given options

func ScriptDelete

func ScriptDelete(rm RM, name string) error

ScriptDelete removes the name, uploaded script

func ScriptRun

func ScriptRun(rm RM, name string, arguments []byte) (string, error)

ScriptRun executes the named Script

func ScriptRunOnce

func ScriptRunOnce(rm RM, script Script, arguments []byte) (string, error)

ScriptRunOnce takes the given Script, uploads it, executes it, and deletes it

func ScriptUpdate

func ScriptUpdate(rm RM, script Script) error

ScriptUpdate update the contents of the given script

func ScriptUpload

func ScriptUpload(rm RM, script Script) error

ScriptUpload uploads the given Script to Repository Manager

func StagingDelete added in v0.37.0

func StagingDelete(rm RM, query QueryBuilder) error

StagingDelete removes components which have been staged

func StagingMove added in v0.37.0

func StagingMove(rm RM, query QueryBuilder) error

StagingMove promotes components which match a set of criteria

func StatusReadable added in v0.21.0

func StatusReadable(rm RM) (_ bool)

StatusReadable returns true if the RM instance can serve read requests

func StatusWritable added in v0.21.0

func StatusWritable(rm RM) (_ bool)

StatusWritable returns true if the RM instance can serve read requests

func UploadComponent

func UploadComponent(rm RM, repo string, component UploadComponentWriter) error

UploadComponent uploads a component to repository manager

Types

type BlobStoreS3

type BlobStoreS3 struct {
	Name, BucketName, AwsAccessKey, AwsSecret, AwsIamRole, AwsRegion string
}

BlobStoreS3 encapsulates the needed options for creating an S3 blob store

type DatabaseState added in v0.24.0

type DatabaseState struct {
	PageCorruption bool `json:"pageCorruption"`
	IndexErrors    int  `json:"indexErrors"`
}

DatabaseState contains state information about a given state

func CheckDatabase added in v0.24.0

func CheckDatabase(rm RM, dbName string) (DatabaseState, error)

CheckDatabase returns the state of the named database

type QueryBuilder added in v0.37.0

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

QueryBuilder allows you to build a search query

func NewQueryBuilder added in v0.37.0

func NewQueryBuilder() *QueryBuilder

NewQueryBuilder creates a new instance of QueryBuilder

func (*QueryBuilder) Build added in v0.37.0

func (b *QueryBuilder) Build() string

Build will build the assembled search query

func (*QueryBuilder) DockerContentDigest added in v0.37.0

func (b *QueryBuilder) DockerContentDigest(v string) *QueryBuilder

DockerContentDigest allows specifiying the digest of docker layers to filter by

func (*QueryBuilder) DockerImageName added in v0.37.0

func (b *QueryBuilder) DockerImageName(v string) *QueryBuilder

DockerImageName allows specifiying the name of a docker image to filter by

func (*QueryBuilder) DockerImageTag added in v0.37.0

func (b *QueryBuilder) DockerImageTag(v string) *QueryBuilder

DockerImageTag allows specifiying the tag of a docker image to filter by

func (*QueryBuilder) DockerLayerID added in v0.37.0

func (b *QueryBuilder) DockerLayerID(v string) *QueryBuilder

DockerLayerID allows specifiying the ID of a docker image layer to filter by

func (*QueryBuilder) Format added in v0.37.0

func (b *QueryBuilder) Format(v string) *QueryBuilder

Format allows specifiying the format to filter by

func (*QueryBuilder) Group added in v0.37.0

func (b *QueryBuilder) Group(v string) *QueryBuilder

Group allows specifiying a group to filter by

func (*QueryBuilder) MavenArtifactID added in v0.37.0

func (b *QueryBuilder) MavenArtifactID(v string) *QueryBuilder

MavenArtifactID allows specifiying the artifact id of maven component to filter by

func (*QueryBuilder) MavenBaseVersion added in v0.37.0

func (b *QueryBuilder) MavenBaseVersion(v string) *QueryBuilder

MavenBaseVersion allows specifiying the version of maven component to filter by

func (*QueryBuilder) MavenClassifier added in v0.37.0

func (b *QueryBuilder) MavenClassifier(v string) *QueryBuilder

MavenClassifier allows specifiying the classifier of maven component to filter by

func (*QueryBuilder) MavenExtension added in v0.37.0

func (b *QueryBuilder) MavenExtension(v string) *QueryBuilder

MavenExtension allows specifiying the extension of maven component to filter by

func (*QueryBuilder) MavenGroupID added in v0.37.0

func (b *QueryBuilder) MavenGroupID(v string) *QueryBuilder

MavenGroupID allows specifiying the group name/id of maven component to filter by

func (*QueryBuilder) Md5 added in v0.37.0

func (b *QueryBuilder) Md5(v string) *QueryBuilder

Md5 allows specifiying an md5 sum to filter by

func (*QueryBuilder) Name added in v0.37.0

func (b *QueryBuilder) Name(v string) *QueryBuilder

Name allows specifiying a name to filter by

func (*QueryBuilder) NpmScope added in v0.37.0

func (b *QueryBuilder) NpmScope(v string) *QueryBuilder

NpmScope allows specifiying the scope of an NPM component to filter by

func (*QueryBuilder) NugetID added in v0.37.0

func (b *QueryBuilder) NugetID(v string) *QueryBuilder

NugetID allows specifiying the ID/name of a Nuget component to filter by

func (*QueryBuilder) NugetTags added in v0.37.0

func (b *QueryBuilder) NugetTags(v string) *QueryBuilder

NugetTags allows specifiying the tags of a Nuget component to filter by

func (*QueryBuilder) Prerelease added in v0.37.0

func (b *QueryBuilder) Prerelease(v string) *QueryBuilder

Prerelease allows specifiying a prerelease qualifier to filter by

func (*QueryBuilder) PypiClassifiers added in v0.37.0

func (b *QueryBuilder) PypiClassifiers(v string) *QueryBuilder

PypiClassifiers allows specifiying the classifiers of a pypi component to filter by

func (*QueryBuilder) PypiDescription added in v0.37.0

func (b *QueryBuilder) PypiDescription(v string) *QueryBuilder

PypiDescription allows specifiying the description of a pypi component to filter by

func (*QueryBuilder) PypiKeywords added in v0.37.0

func (b *QueryBuilder) PypiKeywords(v string) *QueryBuilder

PypiKeywords allows specifiying the keywords of a pypi component to filter by

func (*QueryBuilder) PypiSummary added in v0.37.0

func (b *QueryBuilder) PypiSummary(v string) *QueryBuilder

PypiSummary allows specifiying the summary of a pypi component to filter by

func (*QueryBuilder) Q added in v0.37.0

func (b *QueryBuilder) Q(v string) *QueryBuilder

Q allows specifying a keyword search

func (*QueryBuilder) Repository added in v0.37.0

func (b *QueryBuilder) Repository(v string) *QueryBuilder

Repository allows specifying the repository to search

func (*QueryBuilder) RubygemsDescription added in v0.37.0

func (b *QueryBuilder) RubygemsDescription(v string) *QueryBuilder

RubygemsDescription allows specifiying the description of a ruby gem to filter by

func (*QueryBuilder) RubygemsPlatform added in v0.37.0

func (b *QueryBuilder) RubygemsPlatform(v string) *QueryBuilder

RubygemsPlatform allows specifiying the platform of a ruby gem to filter by

func (*QueryBuilder) RubygemsSummary added in v0.37.0

func (b *QueryBuilder) RubygemsSummary(v string) *QueryBuilder

RubygemsSummary allows specifiying the summary of a ruby gem to filter by

func (*QueryBuilder) Sha1 added in v0.37.0

func (b *QueryBuilder) Sha1(v string) *QueryBuilder

Sha1 allows specifiying an sha1 sum to filter by

func (*QueryBuilder) Sha256 added in v0.37.0

func (b *QueryBuilder) Sha256(v string) *QueryBuilder

Sha256 allows specifiying an sha256 sum to filter by

func (*QueryBuilder) Sha512 added in v0.37.0

func (b *QueryBuilder) Sha512(v string) *QueryBuilder

Sha512 allows specifiying an sha512 sum to filter by

func (*QueryBuilder) Tag added in v0.37.0

func (b *QueryBuilder) Tag(v string) *QueryBuilder

Tag allows specifiying a tag to filter by

func (*QueryBuilder) Version added in v0.37.0

func (b *QueryBuilder) Version(v string) *QueryBuilder

Version allows specifiying a version to filter by

func (*QueryBuilder) YumArchitecture added in v0.37.0

func (b *QueryBuilder) YumArchitecture(v string) *QueryBuilder

YumArchitecture allows specifiying the architecture of a Yum package to filter by

type RM

type RM interface {
	nexus.Client
}

RM is the interface which any Repository Manager implementation would need to satisfy

func New

func New(host, username, password string) (RM, error)

New creates a new Repository Manager instance

type ReadOnlyState added in v0.21.0

type ReadOnlyState struct {
	SystemInitiated bool   `json:"systemInitiated"`
	SummaryReason   string `json:"summaryReason"`
	Frozen          bool   `json:"frozen"`
}

ReadOnlyState returns information about the read-only state of an RM instance

func GetReadOnlyState added in v0.21.0

func GetReadOnlyState(rm RM) (state ReadOnlyState, err error)

GetReadOnlyState returns the read-only state of the RM instance

func ReadOnlyEnable added in v0.21.0

func ReadOnlyEnable(rm RM) (state ReadOnlyState, err error)

ReadOnlyEnable enables read-only mode for the RM instance

func ReadOnlyRelease added in v0.21.0

func ReadOnlyRelease(rm RM, force bool) (state ReadOnlyState, err error)

ReadOnlyRelease disables read-only mode for the RM instance

func (ReadOnlyState) String added in v0.21.0

func (s ReadOnlyState) String() string

type Repository

type Repository struct {
	Name       string `json:"name"`
	Format     string `json:"format"`
	Type       string `json:"type"`
	URL        string `json:"url"`
	Attributes struct {
		Proxy struct {
			RemoteURL string `json:"remoteUrl"`
		} `json:"proxy"`
	} `json:"attributes,omitempty"`
}

Repository collects the information returned by RM about a repository

func GetRepositories

func GetRepositories(rm RM) ([]Repository, error)

GetRepositories returns a list of components in the indicated repository

func GetRepositoryByName added in v0.19.0

func GetRepositoryByName(rm RM, name string) (repo Repository, err error)

GetRepositoryByName returns information on a named repository

type RepositoryItem

type RepositoryItem struct {
	ID         string                `json:"id"`
	Repository string                `json:"repository"`
	Format     string                `json:"format"`
	Group      string                `json:"group"`
	Name       string                `json:"name"`
	Version    string                `json:"version"`
	Assets     []RepositoryItemAsset `json:"assets"`
	Tags       []string              `json:"tags"`
}

RepositoryItem holds the data of a component in a repository

func GetComponentByID

func GetComponentByID(rm RM, id string) (RepositoryItem, error)

GetComponentByID returns a component by ID

func GetComponents

func GetComponents(rm RM, repo string) ([]RepositoryItem, error)

GetComponents returns a list of components in the indicated repository

Example
rm, err := New("http://localhost:8081", "username", "password")
if err != nil {
	panic(err)
}

items, err := GetComponents(rm, "maven-central")
if err != nil {
	panic(err)
}
fmt.Printf("%q\n", items)
Output:

func SearchComponents added in v0.22.0

func SearchComponents(rm RM, query nexus.SearchQueryBuilder) ([]RepositoryItem, error)

SearchComponents allows searching the indicated RM instance for specific components

Example
rm, err := New("http://localhost:8081", "username", "password")
if err != nil {
	panic(err)
}

query := NewSearchQueryBuilder().Repository("maven-releases")
components, err := SearchComponents(rm, query)
if err != nil {
	panic(err)
}

for _, c := range components {
	fmt.Println(c.Name)
}
Output:

func (*RepositoryItem) Hash

func (a *RepositoryItem) Hash() string

Hash is a hack which returns the most appopriate IQable hash of a repo item

type RepositoryItemAsset added in v0.22.0

type RepositoryItemAsset struct {
	DownloadURL string                       `json:"downloadUrl"`
	Path        string                       `json:"path"`
	ID          string                       `json:"id"`
	Repository  string                       `json:"repository"`
	Format      string                       `json:"format"`
	Checksum    repositoryItemAssetsChecksum `json:"checksum"`
}

RepositoryItemAsset describes the assets associated with a component

func GetAssetByID added in v0.23.0

func GetAssetByID(rm RM, id string) (items RepositoryItemAsset, err error)

GetAssetByID returns an asset by ID

func GetAssets

func GetAssets(rm RM, repo string) (items []RepositoryItemAsset, err error)

GetAssets returns a list of assets in the indicated repository

func SearchAssets added in v0.22.0

func SearchAssets(rm RM, query nexus.SearchQueryBuilder) ([]RepositoryItemAsset, error)

SearchAssets allows searching the indicated RM instance for specific assets

type Script

type Script struct {
	Name    string `json:"name"`
	Content string `json:"content"`
	Type    string `json:"type"`
}

Script encapsulates a Repository Manager script

func ScriptGet

func ScriptGet(rm RM, name string) (Script, error)

ScriptGet returns the named script

func ScriptList

func ScriptList(rm RM) ([]Script, error)

ScriptList lists all of the uploaded scripts in Repository Manager

type SearchQueryBuilder added in v0.22.0

type SearchQueryBuilder struct {
	QueryBuilder
	// contains filtered or unexported fields
}

SearchQueryBuilder allows you to build a search query

func NewSearchQueryBuilder added in v0.22.0

func NewSearchQueryBuilder() *SearchQueryBuilder

NewSearchQueryBuilder creates a new instance of SearchQueryBuilder

func (*SearchQueryBuilder) Build added in v0.22.0

func (b *SearchQueryBuilder) Build() string

Build will build the assembled search query

func (*SearchQueryBuilder) Direction added in v0.22.0

Direction allows specifying the direction to sort (Defaults to Asc)

func (*SearchQueryBuilder) Sort added in v0.22.0

Sort allows specifying how to sort the data (Defaults to "magic")

type SearchSort added in v0.22.0

type SearchSort int

SearchSort enumerates the sort options allowed

const (
	None SearchSort = iota
	Group
	Name
	Version
	Repo
)

Available sort options

type SearchSortDirection added in v0.22.0

type SearchSortDirection int

SearchSortDirection enumerates the direction of the sort

const (
	Asc SearchSortDirection = iota
	Desc
)

Can be ascending (Asc) or descending (Desc)

type SupportZipOptions added in v0.24.1

type SupportZipOptions struct {
	SystemInformation bool `json:"systemInformation"`
	ThreadDump        bool `json:"threadDump"`
	Metrics           bool `json:"metrics"`
	Configuration     bool `json:"configuration"`
	Security          bool `json:"security"`
	Log               bool `json:"log"`
	TaskLog           bool `json:"taskLog"`
	AuditLog          bool `json:"auditLog"`
	Jmx               bool `json:"jmx"`
	LimitFileSizes    bool `json:"limitFileSizes"`
	LimitZipSize      bool `json:"limitZipSize"`
}

SupportZipOptions encapsulates the various information you can toggle for inclusion in a support zip

func NewSupportZipOptions added in v0.24.1

func NewSupportZipOptions() (o SupportZipOptions)

NewSupportZipOptions creates a SupportZipOptions intance with all options enabled

type Tag added in v0.37.0

type Tag struct {
	Name         string   `json:"name"`
	Attributes   struct{} `json:"attributes,omitempty"`
	FirstCreated string   `json:"firstCreated,omitempty"`
	LastUpdated  string   `json:"lastUpdated,omitempty"`
}

Tag contains the information about a component tag

func AddTag added in v0.37.0

func AddTag(rm RM, tagName string, attributes map[string]string) (Tag, error)

AddTag adds a tag to the given instance

func GetTag added in v0.37.0

func GetTag(rm RM, tagName string) (Tag, error)

GetTag retrieve the named tag

func TagsList added in v0.37.0

func TagsList(rm RM) ([]Tag, error)

TagsList returns a list of tags in the given RM instance

type UploadAssetMaven

type UploadAssetMaven struct {
	File                  io.Reader
	Classifier, Extension string
}

UploadAssetMaven encapsulates data needed to upload an maven2 asset

type UploadAssetRaw added in v0.20.0

type UploadAssetRaw struct {
	File     io.Reader
	Filename string
}

UploadAssetRaw encapsulates data needed to upload a raw asset

type UploadAssetYum added in v0.20.0

type UploadAssetYum struct {
	File     io.Reader
	Filename string
}

UploadAssetYum encapsulates data needed to upload a raw asset

type UploadComponentApt added in v0.20.0

type UploadComponentApt struct {
	File io.Reader
	Tag  string
}

UploadComponentApt encapsulates data needed to upload an Apt component

type UploadComponentMaven

type UploadComponentMaven struct {
	GroupID, ArtifactID, Version, Packaging, Tag string
	GeneratePom                                  bool
	Assets                                       []UploadAssetMaven
}

UploadComponentMaven encapsulates data needed to upload an maven2 component

func NewUploadComponentMaven added in v0.20.0

func NewUploadComponentMaven(coordinate string, assets ...io.Reader) (comp UploadComponentMaven, err error)

NewUploadComponentMaven creates a new UploadComponentMaven struct with some defaults

type UploadComponentNpm

type UploadComponentNpm struct {
	File io.Reader
	Tag  string
}

UploadComponentNpm encapsulates data needed to upload an NPM component

type UploadComponentNuget added in v0.20.0

type UploadComponentNuget struct {
	File io.Reader
	Tag  string
}

UploadComponentNuget encapsulates data needed to upload an NuGet component

type UploadComponentPyPi added in v0.20.0

type UploadComponentPyPi struct {
	File io.Reader
	Tag  string
}

UploadComponentPyPi encapsulates data needed to upload an PyPi component

type UploadComponentRaw added in v0.20.0

type UploadComponentRaw struct {
	Directory, Tag string
	Assets         []UploadAssetRaw
}

UploadComponentRaw encapsulates data needed to upload a raw component

type UploadComponentRubyGems added in v0.20.0

type UploadComponentRubyGems struct {
	File io.Reader
	Tag  string
}

UploadComponentRubyGems encapsulates data needed to upload an RubyGems component

type UploadComponentWriter added in v0.20.0

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

UploadComponentWriter defines the interface which describes a component to upload

type UploadComponentYum added in v0.20.0

type UploadComponentYum struct {
	Directory, Tag string
	Assets         []UploadAssetYum
}

UploadComponentYum encapsulates data needed to upload a raw component

type User

type User struct {
	ID, FirstName, LastName, Password string
}

User encapsulates the information about a Repository Manager user

Jump to

Keyboard shortcuts

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