Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.
/ go-arty Public archive

Go client library for Artifactory and Xray

License

Notifications You must be signed in to change notification settings

target/go-arty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deprecation Warning

As of October 2024, this project has been deprecated and is now archived.

go-arty

GoDoc Go Report Card codecov

go-arty is a Go client library for accessing the Artifactory and Xray API.

Artifactory

Usage

With Go Modules

import "github.com/target/go-arty/v2/artifactory"

Without Go Modules

import "github.com/target/go-arty/artifactory"

Construct a new Artifactory client, then use the various services on the client to access different parts of the Artifactory API. For example:

client, _ := artifactory.NewClient("artifactory.company.com", nil)

// list all users from the artifactory server
users, _, err := client.Users.GetAllSecurity()

Authentication

The artifactory package allows you to pass basic auth or an API Key.

Example using basic auth:

client, _ := artifactory.NewClient("artifactory.company.com", nil)

client.Authentication.SetBasicAuth("username", "password")

Example using API Key:

client, _ := artifactory.NewClient("artifactory.company.com", nil)

client.Authentication.SetTokenAuth("token")

Xray

Usage

With Go Modules

import "github.com/target/go-arty/v2/xray"

Without Go Modules

import "github.com/target/go-arty/xray"

Construct a new Xray client, then use the various services on the client to access different parts of the Xray API. For example:

client, _ := xray.NewClient("artifactory.company.com", nil)

// list all users from the xray server
users, _, err := client.Users.GetAll()

Authentication

The xray package allows you to pass basic auth or a token.

NOTE: To get the token for Xray, you have to hit an API endpoint that returns the token. See the docs for more info.

Example using basic auth:

client, _ := xray.NewClient("xray.company.com", nil)

client.Authentication.SetBasicAuth("username", "password")

Example using token:

client, _ := xray.NewClient("xray.company.com", nil)

client.Authentication.SetTokenAuth("token")

Creating/Updating Resources

All structs in this library use pointer values for all non-repeated fields. This allows distinguishing between unset fields and those set to a zero-value. Helper functions have been provided to easily create these pointers for string, bool, and int values. For example:

// create a new user named "admin"
user := &artifactory.SecurityUser{
	Name:     artifactory.String("admin"),
	Email:    artifactory.String("[email protected]"),
	Password: artifactory.String("secretPassword"),
	Admin:    artifactory.Bool(true),
}

client.Users.CreateSecurity(user)

Users who have worked with protocol buffers should find this pattern familiar.

Versioning

In general, go-arty follows semantic versioning as closely as we can for tagging releases of the package. For self-contained libraries, the application of semantic versioning is relatively straightforward and generally understood. But because go-arty is a client library for the Artifactory API and the Xray API, which both change behavior frequently, we've adopted the following versioning policy:

  • We increment the major version with any incompatible change to either package (artifactory or xray) in this library, including changes to the exported Go API surface or behavior of the API.
  • We increment the minor version with any backwards-compatible changes to functionality.
  • We increment the patch version with any backwards-compatible bug fixes.

Road map

This library was initially developed for internal applications at Target, so API methods will likely be added in the order that they are required.

Contributing

We always welcome new PRs! See Contributing for further instructions.

Bugs and Feature Requests

Found something that doesn't seem right or have a feature request? Please open a new issue.

Copyright and License

license

Copyright (c) 2018 Target Brands, Inc.