As of October 2024, this project has been deprecated and is now archived.
go-arty is a Go client library for accessing the Artifactory and Xray API.
import "github.com/target/go-arty/v2/artifactory"
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()
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")
import "github.com/target/go-arty/v2/xray"
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()
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")
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.
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
orxray
) 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.
This library was initially developed for internal applications at Target, so API methods will likely be added in the order that they are required.
We always welcome new PRs! See Contributing for further instructions.
Found something that doesn't seem right or have a feature request? Please open a new issue.
Copyright (c) 2018 Target Brands, Inc.