nexusrm

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

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

func AssociateTag(rm RM, query QueryBuilder) error

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

func CheckAllDatabases

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

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

func DisassociateTag(rm RM, query QueryBuilder) error

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

func GetSupportZip

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

func StagingDelete(rm RM, query QueryBuilder) error

StagingDelete removes components which have been staged

func StagingMove

func StagingMove(rm RM, query QueryBuilder) error

StagingMove promotes components which match a set of criteria

func StatusReadable

func StatusReadable(rm RM) (_ bool)

StatusReadable returns true if the RM instance can serve read requests

func StatusWritable

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

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

DatabaseState contains state information about a given state

func CheckDatabase

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

CheckDatabase returns the state of the named database

type QueryBuilder

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

QueryBuilder allows you to build a search query

func NewQueryBuilder

func NewQueryBuilder() *QueryBuilder

NewQueryBuilder creates a new instance of QueryBuilder

func (*QueryBuilder) Build

func (b *QueryBuilder) Build() string

Build will build the assembled search query

func (*QueryBuilder) DockerContentDigest

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

DockerContentDigest allows specifiying the digest of docker layers to filter by

func (*QueryBuilder) DockerImageName

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

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

func (*QueryBuilder) DockerImageTag

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

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

func (*QueryBuilder) DockerLayerID

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

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

func (*QueryBuilder) Format

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

Format allows specifiying the format to filter by

func (*QueryBuilder) Group

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

Group allows specifiying a group to filter by

func (*QueryBuilder) MavenArtifactID

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

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

func (*QueryBuilder) MavenBaseVersion

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

MavenBaseVersion allows specifiying the version of maven component to filter by

func (*QueryBuilder) MavenClassifier

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

MavenClassifier allows specifiying the classifier of maven component to filter by

func (*QueryBuilder) MavenExtension

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

MavenExtension allows specifiying the extension of maven component to filter by

func (*QueryBuilder) MavenGroupID

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

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

func (*QueryBuilder) Md5

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

Md5 allows specifiying an md5 sum to filter by

func (*QueryBuilder) Name

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

Name allows specifiying a name to filter by

func (*QueryBuilder) NpmScope

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

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

func (*QueryBuilder) NugetID

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

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

func (*QueryBuilder) NugetTags

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

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

func (*QueryBuilder) Prerelease

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

Prerelease allows specifiying a prerelease qualifier to filter by

func (*QueryBuilder) PypiClassifiers

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

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

func (*QueryBuilder) PypiDescription

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

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

func (*QueryBuilder) PypiKeywords

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

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

func (*QueryBuilder) PypiSummary

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

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

func (*QueryBuilder) Q

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

Q allows specifying a keyword search

func (*QueryBuilder) Repository

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

Repository allows specifying the repository to search

func (*QueryBuilder) RubygemsDescription

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

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

func (*QueryBuilder) RubygemsPlatform

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

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

func (*QueryBuilder) RubygemsSummary

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

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

func (*QueryBuilder) Sha1

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

Sha1 allows specifiying an sha1 sum to filter by

func (*QueryBuilder) Sha256

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

Sha256 allows specifiying an sha256 sum to filter by

func (*QueryBuilder) Sha512

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

Sha512 allows specifiying an sha512 sum to filter by

func (*QueryBuilder) Tag

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

Tag allows specifiying a tag to filter by

func (*QueryBuilder) Version

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

Version allows specifiying a version to filter by

func (*QueryBuilder) YumArchitecture

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

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

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

GetReadOnlyState returns the read-only state of the RM instance

func ReadOnlyEnable

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

ReadOnlyEnable enables read-only mode for the RM instance

func ReadOnlyRelease

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

ReadOnlyRelease disables read-only mode for the RM instance

func (ReadOnlyState) String

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

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

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

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

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

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

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

SearchQueryBuilder allows you to build a search query

func NewSearchQueryBuilder

func NewSearchQueryBuilder() *SearchQueryBuilder

NewSearchQueryBuilder creates a new instance of SearchQueryBuilder

func (*SearchQueryBuilder) Build

func (b *SearchQueryBuilder) Build() string

Build will build the assembled search query

func (*SearchQueryBuilder) Direction

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

func (*SearchQueryBuilder) Sort

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

type SearchSort

type SearchSort int

SearchSort enumerates the sort options allowed

const (
	None SearchSort = iota
	Group
	Name
	Version
	Repo
)

Available sort options

type SearchSortDirection

type SearchSortDirection int

SearchSortDirection enumerates the direction of the sort

const (
	Asc SearchSortDirection = iota
	Desc
)

Can be ascending (Asc) or descending (Desc)

type SupportZipOptions

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

func NewSupportZipOptions() (o SupportZipOptions)

NewSupportZipOptions creates a SupportZipOptions intance with all options enabled

type Tag

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

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

AddTag adds a tag to the given instance

func GetTag

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

GetTag retrieve the named tag

func TagsList

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

type UploadAssetRaw struct {
	File     io.Reader
	Filename string
}

UploadAssetRaw encapsulates data needed to upload a raw asset

type UploadAssetYum

type UploadAssetYum struct {
	File     io.Reader
	Filename string
}

UploadAssetYum encapsulates data needed to upload a raw asset

type UploadComponentApt

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

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

type UploadComponentNuget struct {
	File io.Reader
	Tag  string
}

UploadComponentNuget encapsulates data needed to upload an NuGet component

type UploadComponentPyPi

type UploadComponentPyPi struct {
	File io.Reader
	Tag  string
}

UploadComponentPyPi encapsulates data needed to upload an PyPi component

type UploadComponentRaw

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

UploadComponentRaw encapsulates data needed to upload a raw component

type UploadComponentRubyGems

type UploadComponentRubyGems struct {
	File io.Reader
	Tag  string
}

UploadComponentRubyGems encapsulates data needed to upload an RubyGems component

type UploadComponentWriter

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

UploadComponentWriter defines the interface which describes a component to upload

type UploadComponentYum

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