Programmatic Access - docker/docker-credential-helpers

The client package in the docker-credential-helpers project provides functions for interacting with credential helpers from other command-line applications. It includes the following functions:

  1. NewClient: creates a new client for interacting with credential helpers.
  2. GetSecrets: retrieves secrets from the specified credential helper.
  3. StoreSecrets: stores secrets in the specified credential helper.
  4. ListHelpers: lists all available credential helpers.

Here are examples of how to use each function:

  1. Creating a new client:
client, err := client.NewClient("osxkeychain")
if err != nil {
// handle error
}
  1. Retrieving secrets:
secrets, err := client.GetSecrets("my.registry.com", "my-username", "my-password")
if err != nil {
// handle error
}
fmt.Println(secrets)
  1. Storing secrets:
err := client.StoreSecrets("my.registry.com", "my-username", "my-password")
if err != nil {
// handle error
}
  1. Listing available credential helpers:
helpers, err := client.ListHelpers()
if err != nil {
// handle error
}
fmt.Println(helpers)

These functions allow developers to interact with credential helpers programmatically, making it easier to manage credentials for different registries and applications.

Sources: