Documentation ¶
Index ¶
- Constants
- func IsAuthenticationError(err error) bool
- func IsForbiddenError(err error) bool
- func IsInvalidTokenError(err error) bool
- func IsNotFoundError(err error) bool
- func SetURLs(newFirst, newSecond string)
- type Account
- type Client
- func (c *Client) CreateToken(description string) (*Token, error)
- func (c *Client) GetHubPlan(accountID string) (*Plan, error)
- func (c *Client) GetMembers(organization string) ([]Member, error)
- func (c *Client) GetMembersCount(organization string) (int, error)
- func (c *Client) GetMembersPerTeam(organization, team string) ([]Member, error)
- func (c *Client) GetOrgConsumption(org string) (*Consumption, error)
- func (c *Client) GetOrganizationInfo(orgname string) (*Account, error)
- func (c *Client) GetOrganizations(ctx context.Context) ([]Organization, error)
- func (c *Client) GetRateLimits() (*RateLimits, error)
- func (c *Client) GetRepositories(account string) ([]Repository, int, error)
- func (c *Client) GetTags(repository string, reqOps ...RequestOp) ([]Tag, int, error)
- func (c *Client) GetTeams(organization string) ([]Team, error)
- func (c *Client) GetTeamsCount(organization string) (int, error)
- func (c *Client) GetToken(tokenUUID string) (*Token, error)
- func (c *Client) GetTokens() ([]Token, int, error)
- func (c *Client) GetUserConsumption(user string) (*Consumption, error)
- func (c *Client) GetUserInfo() (*Account, error)
- func (c *Client) Login(username string, password string, twoFactorCodeProvider func() (string, error)) (string, string, error)
- func (c *Client) RemoveRepository(repository string) error
- func (c *Client) RemoveTag(repository, tag string) error
- func (c *Client) RemoveToken(tokenUUID string) error
- func (c *Client) Update(ops ...ClientOp) error
- func (c *Client) UpdateToken(tokenUUID, description string, isActive bool) (*Token, error)
- type ClientOp
- func WithAllElements() ClientOp
- func WithContext(ctx context.Context) ClientOp
- func WithHTTPClient(client *http.Client) ClientOp
- func WithHubAccount(account string) ClientOp
- func WithHubToken(token string) ClientOp
- func WithInStream(in io.Reader) ClientOp
- func WithOutStream(out io.Writer) ClientOp
- func WithPassword(password string) ClientOp
- func WithRefreshToken(refreshToken string) ClientOp
- type Consumption
- type Image
- type Instance
- type Limits
- type Member
- type Organization
- type Plan
- type RateLimits
- type Repository
- type RepositoryType
- type RequestOp
- type Tag
- type Team
- type Token
Constants ¶
const ( // LoginURL path to the Hub login URL LoginURL = "/v2/users/login?refresh_token=true" // TwoFactorLoginURL path to the 2FA TwoFactorLoginURL = "/v2/users/2fa-login?refresh_token=true" // SecondFactorDetailMessage returned by login if 2FA is enabled SecondFactorDetailMessage = "Require secondary authentication on MFA enabled account" )
const ( //MembersURL path to the Hub API listing the members in an organization MembersURL = "/v2/orgs/%s/members/" //MembersPerTeamURL path to the Hub API listing the members in a team MembersPerTeamURL = "/v2/orgs/%s/groups/%s/members/" )
const ( // OrganizationsURL path to the Hub API listing the organizations OrganizationsURL = "/v2/user/orgs/" // OrganizationInfoURL path to the Hub API returning organization info OrganizationInfoURL = "/v2/orgs/%s" )
const ( //HubPlanURL path to the billing API returning the account hub plan HubPlanURL = "/api/billing/v4/accounts/%s/hub-plan" //TeamPlan refers to a hub team paid account TeamPlan = "team" //ProPlan refers to a hub individual paid account ProPlan = "pro" //FreePlan refers to a hub non-paid account FreePlan = "free" )
const ( // TagsURL path to the Hub API listing the tags TagsURL = "/v2/repositories/%s/tags/" // DeleteTagURL path to the Hub API to remove a tag DeleteTagURL = "/v2/repositories/%s/tags/%s/" )
const ( // TokensURL path to the Hub API listing the Personal Access Tokens TokensURL = "/v2/api_tokens" // TokenURL path to the Hub API Personal Access Token TokenURL = "/v2/api_tokens/%s" )
const (
//GroupsURL path to the Hub API listing the groups in an organization
GroupsURL = "/v2/orgs/%s/groups/"
)
const ( //ImageType is the classic image type ImageType = RepositoryType("image") )
const (
// RepositoriesURL is the Hub API base URL
RepositoriesURL = "/v2/repositories/"
)
const (
//UserURL path to user informations
UserURL = "/v2/user/"
)
Variables ¶
This section is empty.
Functions ¶
func IsAuthenticationError ¶
IsAuthenticationError check if the error type is an authentication error
func IsForbiddenError ¶
IsForbiddenError check if the error type is a forbidden error
func IsInvalidTokenError ¶
IsInvalidTokenError check if the error type is an invalid token error
func IsNotFoundError ¶ added in v0.4.5
IsNotFoundError check if the error type is a not found error
Types ¶
type Account ¶
type Account struct { ID string Name string FullName string Location string Company string Joined time.Time }
Account represents a user or organization information
type Client ¶
type Client struct { AuthConfig registry.AuthConfig Ctx context.Context // contains filtered or unexported fields }
Client sends authenticated calls to the Hub API
func NewClient ¶
NewClient logs the user to the hub and returns a client which can send authenticated requests to the Hub API
func (*Client) CreateToken ¶
CreateToken creates a Personal Access Token and returns the token field only once
func (*Client) GetHubPlan ¶
GetHubPlan returns an account current Hub plan
func (*Client) GetMembers ¶
GetMembers lists all the members in an organization
func (*Client) GetMembersCount ¶
GetMembersCount return the number of members in an organization
func (*Client) GetMembersPerTeam ¶
GetMembersPerTeam returns the members of a team in an organization
func (*Client) GetOrgConsumption ¶
func (c *Client) GetOrgConsumption(org string) (*Consumption, error)
GetOrgConsumption return the current organization consumption
func (*Client) GetOrganizationInfo ¶
GetOrganizationInfo returns organization info
func (*Client) GetOrganizations ¶
func (c *Client) GetOrganizations(ctx context.Context) ([]Organization, error)
GetOrganizations lists all the organizations a user has joined
func (*Client) GetRateLimits ¶
func (c *Client) GetRateLimits() (*RateLimits, error)
GetRateLimits returns the rate limits for the user
func (*Client) GetRepositories ¶
func (c *Client) GetRepositories(account string) ([]Repository, int, error)
GetRepositories lists all the repositories a user can access
func (*Client) GetTeamsCount ¶
GetTeamsCount returns the number of teams in an organization
func (*Client) GetTokens ¶
GetTokens calls the hub repo API and returns all the information on all tokens
func (*Client) GetUserConsumption ¶
func (c *Client) GetUserConsumption(user string) (*Consumption, error)
GetUserConsumption return the current user consumption
func (*Client) GetUserInfo ¶
GetUserInfo returns the information on the user retrieved from Hub
func (*Client) Login ¶
func (c *Client) Login(username string, password string, twoFactorCodeProvider func() (string, error)) (string, string, error)
Login tries to authenticate, it will call the twoFactorCodeProvider if the user has 2FA activated
func (*Client) RemoveRepository ¶
RemoveRepository removes a repository on Hub
func (*Client) RemoveToken ¶
RemoveToken deletes a token from personal access token
type ClientOp ¶
ClientOp represents an option given to NewClient constructor to customize client behavior.
func WithAllElements ¶
func WithAllElements() ClientOp
WithAllElements makes the client fetch all the elements it can find, enabling pagination.
func WithContext ¶
WithContext set the client context
func WithHTTPClient ¶ added in v0.4.4
WithHTTPClient sets the *http.Client for the client
func WithHubAccount ¶
WithHubAccount sets the current account name
func WithHubToken ¶
WithHubToken sets the bearer token to the client
func WithOutStream ¶
WithOutStream sets the output stream
func WithPassword ¶
WithPassword sets the password to the client
func WithRefreshToken ¶
WithRefreshToken sets the refresh token to the client
type Consumption ¶
Consumption represents current user or org consumption
type Image ¶
type Image struct { Digest string Architecture string Os string Variant string Size int LastPulled time.Time LastPushed time.Time Status string }
Image represents the metadata of a manifest
type Organization ¶
type Organization struct { Namespace string FullName string Role string Teams []Team Members []Member }
Organization represents a Docker Hub organization
type RateLimits ¶
type RateLimits struct { Limit *int `json:",omitempty"` LimitWindow *int `json:",omitempty"` Remaining *int `json:",omitempty"` RemainingWindow *int `json:",omitempty"` Source *string `json:",omitempty"` }
RateLimits ...
type Repository ¶
type Repository struct { Name string Description string LastUpdated time.Time PullCount int StarCount int IsPrivate bool }
Repository represents a Docker Hub repository
type RepositoryType ¶
type RepositoryType string
RepositoryType lists all the different repository types handled by the Docker Hub
type RequestOp ¶
RequestOp represents an option to customize the request sent to the Hub API
func WithSortingOrder ¶
WithSortingOrder adds a sorting order query parameter to the request
type Tag ¶
type Tag struct { Name string FullSize int LastUpdated time.Time LastUpdaterUserName string Images []Image LastPulled time.Time LastPushed time.Time Status string }
Tag can point to a manifest or manifest list
type Token ¶
type Token struct { UUID uuid.UUID ClientID string CreatorIP string CreatorUA string CreatedAt time.Time LastUsed time.Time GeneratedBy string IsActive bool Token string Description string }
Token is a personal access token. The token field will only be filled at creation and can never been accessed again.