aicura

module
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

README

Nexus Client Integration Checks codecov GitHub go.mod Go version

AICURA: A Sonatype Nexus API in Go

aicura is a client library for Sonatype Nexus Manager v3 API written in GoLang.

How to Use

The most straightforward way to use this library is creating a new Client and make calls to the API through services:

import   "github.com/m88i/aicura/nexus"

(...)

// New client with default credentials
client := nexus.NewClient("http://localhost:8081").WithCredentials("admin", "admin123").Build()
user, err := client.UserService.GetUserByID("admin")
if err != nil {
    return err
}
print(user.Name)
Fake Client

To use this library in your unit tests, create an instance of a "fake" Client instead:

import   "github.com/m88i/aicura/nexus"

(...)

client := nexus.NewFakeClient()

// all interfaces remain the same
user, err := client.UserService.GetUserByID("admin")
if err != nil {
    return err
}
print(user.Name) //will print nothing since there's no user in the cache, call client.UserService.Add(user) first :)

The fake Client is backed up by hash maps, so all write and read operations will work like in real scenarios.

Development

To run a local Nexus Server 3.x container with Podman:

$ podman run --rm -it -p 8081:8081 -e INSTALL4J_ADD_VM_PARAMS="-Dnexus.security.randompassword=false" docker.io/sonatype/nexus3

Use Postman or even the web browser to play around with the Nexus REST API at http://localhost:8081 endpoint. The default credentials are admin/admin123.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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