nexus

package
v0.2.1-0...-d27708f Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2021 License: LGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ComponentsPath = "/components"
)

Variables

This section is empty.

Functions

func IsAuthenticationError

func IsAuthenticationError(err error) bool

IsAuthenticationError checks if the given error is related to authentication problems (403 or 401)

func IsNotFound

func IsNotFound(err error) bool

IsNotFound checks if the given error is a Not Found error (404)

func IsServerError

func IsServerError(err error) bool

IsServerError checks if the given error is a server error (500)

func NewBool

func NewBool(bln bool) *bool

NewBool is an easy access to the address of bool types

func NewString

func NewString(str string) *string

NewString copies the argument string and returns a pointer to it

Types

type Authentication

type Authentication struct {
	Type       string `json:"type,omitempty"`
	Username   string `json:"username,omitempty"`
	NtlmHost   string `json:"ntlmHost,omitempty"`
	NtlmDomain string `json:"ntlmDomain,omitempty"`
}

Authentication for a HTTPClient

type CleanUp

type CleanUp struct {
	PolicyNames []string `json:"policyNames,omitempty"`
}

CleanUp ...

type Client

type Client struct {
	UserService                 UserService
	MavenProxyRepositoryService MavenProxyRepositoryService
	MavenGroupRepositoryService MavenGroupRepositoryService
	MavenRepositoryService      MavenRepositoryService

	MavenComponentService MavenComponentService
	// contains filtered or unexported fields
}

Client base structure for the Nexus Client

func NewDefaultClient

func NewDefaultClient(baseURL string) *Client

NewDefaultClient creates a new raw, straight forward Nexus Client. For a more customizable client, use `NewClient` instead

func NewFakeClient

func NewFakeClient() *Client

NewFakeClient creates a mocked client for testing purposes. It's backed up by hashmaps, so if you insert a user for instance, you can list, update, or delete

func (*Client) ScriptsRequired

func (c *Client) ScriptsRequired() (bool, error)

ScriptsRequired checks if the target Nexus server has APIs capabilities without relying on Groovy scripts. This should be used if the caller is not sure if the server accepts the capabilities offered by this library, since for security reasons and to comply with Nexus Server default policy, it does not support Groovy scripts execution. If this function returns `true`, capabilities that otherwise requires Groovy scripts (like creating repos), won't work.

func (*Client) SetCredentials

func (c *Client) SetCredentials(username, password string)

SetCredentials sets the client username and password

func (*Client) SetPassword

func (c *Client) SetPassword(password string)

SetPassword sets the client password

func (*Client) SetUsername

func (c *Client) SetUsername(username string)

SetUsername sets the client username

type ClientBuilder

type ClientBuilder struct {
	*Client
}

ClientBuilder fluent API to build a new Nexus Client

func NewClient

func NewClient(baseURL string) *ClientBuilder

NewClient creates a new Nexus `ClientBuilder` for client applications to start interacting with a Nexus Server

func (*ClientBuilder) APIVersion

func (b *ClientBuilder) APIVersion(version string) *ClientBuilder

APIVersion sets the API version for the new Nexus Service API. Default to `beta`.

func (*ClientBuilder) Build

func (b *ClientBuilder) Build() *Client

Build returns the new Nexus Client

func (*ClientBuilder) Verbose

func (b *ClientBuilder) Verbose() *ClientBuilder

Verbose sets a higher logging level for the client

func (*ClientBuilder) WithCredentials

func (b *ClientBuilder) WithCredentials(username, password string) *ClientBuilder

WithCredentials defines the credentials to be used on each request to the Nexus Server.

func (*ClientBuilder) WithHTTPClient

func (b *ClientBuilder) WithHTTPClient(httpClient *http.Client) *ClientBuilder

WithHTTPClient defines a custom `http.Client` reference

type ClientError

type ClientError struct {
	HTTPStatusCode int
	ServerMessages []ServerMessage
	RawData        interface{}
	RequestBody    interface{}
	// contains filtered or unexported fields
}

ClientError describes a base structure for possible errors during Nexus Server REST API calls

func (*ClientError) Error

func (n *ClientError) Error() string

Error gets the error message

type Component

type Component struct {
	ID         string `json:"id,omitempty"`
	Repository string `json:"repository,omitempty"`
	Format     string `json:"format,omitempty"`
	Group      string `json:"group,omitempty"`
	Name       string `json:"name,omitempty"`
	Version    string `json:"version,omitempty"`
}

Component is the base structure for Nexus Component

type ComponentResponse

type ComponentResponse struct {
	Items             []Component `json:"items,omitempty"`
	ContinuationToken interface{} `json:"continuationToken,omitempty"`
}

type Connection

type Connection struct {
	Retries                 *int    `json:"retries,omitempty"`
	UserAgentSuffix         *string `json:"userAgentSuffix,omitempty"`
	Timeout                 *int32  `json:"timeout,omitempty"`
	EnableCircularRedirects bool    `json:"enableCircularRedirects,omitempty"`
	EnableCookies           bool    `json:"enableCookies,omitempty"`
}

Connection for a HTTPClient

type HTTPClient

type HTTPClient struct {
	AutoBlock      bool            `json:"autoBlock,omitempty"`
	Blocked        *bool           `json:"blocked,omitempty"`
	Connection     *Connection     `json:"connection,omitempty"`
	Authentication *Authentication `json:"authentication,omitempty"`
}

HTTPClient details of how to connect to a Maven Proxy Repository

type Maven

type Maven struct {
	VersionPolicy MavenVersionPolicy `json:"versionPolicy,omitempty"`
	LayoutPolicy  MavenLayoutPolicy  `json:"layoutPolicy,omitempty"`
}

Maven ...

type MavenComponentService

type MavenComponentService service

func (*MavenComponentService) ListAll

func (m *MavenComponentService) ListAll(repositoryName string) (*ComponentResponse, error)

type MavenGroup

type MavenGroup struct {
	MemberNames []string `json:"memberNames"`
}

MavenGroup describes a collection of Maven repositories in a given group

type MavenGroupRepository

type MavenGroupRepository struct {
	Repository `json:",inline"`
	Group      MavenGroup `json:"group"`
	Storage    Storage    `json:"storage,omitempty"`
}

MavenGroupRepository structure for Maven Group Repository

type MavenGroupRepositoryService

type MavenGroupRepositoryService interface {
	Update(repo MavenGroupRepository) error
	List() ([]MavenGroupRepository, error)
	GetRepoByName(name string) (*MavenGroupRepository, error)
}

MavenGroupRepositoryService service to handle all Maven Proxy Repositories operations

type MavenLayoutPolicy

type MavenLayoutPolicy string

MavenLayoutPolicy ...

const (
	// LayoutPolicyStrict ...
	LayoutPolicyStrict MavenLayoutPolicy = "STRICT"
	// LayoutPolicyPermissive ...
	LayoutPolicyPermissive MavenLayoutPolicy = "PERMISSIVE"
)

type MavenProxyRepository

type MavenProxyRepository struct {
	Repository    `json:",inline"`
	HTTPClient    HTTPClient    `json:"httpClient,omitempty"`
	Maven         Maven         `json:"maven,omitempty"`
	NegativeCache NegativeCache `json:"negativeCache,omitempty"`
	Proxy         Proxy         `json:"proxy,omitempty"`
	Storage       Storage       `json:"storage,omitempty"`
	CleanUp       *CleanUp      `json:"cleanup,omitempty"`
	RoutingRule   string        `json:"routingRule,omitempty"`
}

MavenProxyRepository basic structure for a Maven Proxy Repository

type MavenProxyRepositoryService

type MavenProxyRepositoryService interface {
	Add(repositories ...MavenProxyRepository) error
	List() ([]MavenProxyRepository, error)
	GetRepoByName(name string) (*MavenProxyRepository, error)
}

MavenProxyRepositoryService service to handle all Maven Proxy Repositories operations

type MavenRepositoryService

type MavenRepositoryService service

func (*MavenRepositoryService) ListAll

func (m *MavenRepositoryService) ListAll() ([]Repository, error)

type MavenVersionPolicy

type MavenVersionPolicy string

MavenVersionPolicy ...

const (
	// VersionPolicyRelease ...
	VersionPolicyRelease MavenVersionPolicy = "RELEASE"
	// VersionPolicyMixed ...
	VersionPolicyMixed MavenVersionPolicy = "MIXED"
	// VersionPolicySnapshot ...
	VersionPolicySnapshot MavenVersionPolicy = "SNAPSHOT"
)

type NegativeCache

type NegativeCache struct {
	Enabled    bool  `json:"enabled,omitempty"`
	TimeToLive int32 `json:"timeToLive,omitempty"`
}

NegativeCache ...

type Proxy

type Proxy struct {
	ContentMaxAge  int32  `json:"contentMaxAge,omitempty"`
	MetadataMaxAge int32  `json:"metadataMaxAge,omitempty"`
	RemoteURL      string `json:"remoteUrl,omitempty"`
}

Proxy ...

type Repository

type Repository struct {
	Name   string            `json:"name,omitempty"`
	Format *RepositoryFormat `json:"format,omitempty"`
	Type   *RepositoryType   `json:"type,omitempty"`
	URL    *string           `json:"url,omitempty"`
}

Repository is the base structure for Nexus repositories

type RepositoryFormat

type RepositoryFormat string

RepositoryFormat describes supported API repositories format

const (
	// RepositoryFormatMaven2 ...
	RepositoryFormatMaven2 RepositoryFormat = "maven2"
)

func NewRepositoryFormat

func NewRepositoryFormat(format RepositoryFormat) *RepositoryFormat

NewRepositoryFormat easy access to a pointer for RepositoryFormat

type RepositoryType

type RepositoryType string

RepositoryType ...

const (
	// RepositoryTypeHosted ...
	RepositoryTypeHosted RepositoryType = "hosted"
	// RepositoryTypeProxy ...
	RepositoryTypeProxy RepositoryType = "proxy"
	// RepositoryTypeGroup ...
	RepositoryTypeGroup RepositoryType = "group"
)

func NewRepositoryType

func NewRepositoryType(rType RepositoryType) *RepositoryType

NewRepositoryType easy access to a pointer for RepositoryType

type ServerMessage

type ServerMessage struct {
	ID      string `json:"id,omitempty"`
	Message string `json:"message,omitempty"`
}

ServerMessage describes a structure for a bad request error (4.x)

type Storage

type Storage struct {
	StrictContentTypeValidation bool   `json:"strictContentTypeValidation,omitempty"`
	BlobStoreName               string `json:"blobStoreName,omitempty"`
}

Storage ...

type User

type User struct {
	UserID        string   `json:"userId"`
	FirstName     string   `json:"firstName,omitempty"`
	LastName      string   `json:"lastName,omitempty"`
	Email         string   `json:"emailAddress,omitempty"`
	Source        string   `json:"source,omitempty"`
	ReadOnly      bool     `json:"readOnly,omitempty"`
	Roles         []string `json:"roles"`
	ExternalRoles []string `json:"externalRoles"`
	Status        string   `json:"status,omitempty"`
	Password      string   `json:"password,omitempty"`
}

User represents a Nexus user

type UserService

type UserService interface {
	List() ([]User, error)
	Update(user User) error
	GetUserByID(userID string) (*User, error)
	Add(user User) error
}

UserService contains all operations related to the User domain

Jump to

Keyboard shortcuts

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