Documentation
¶
Index ¶
- Constants
- Variables
- func GetFlags(flags *pflag.FlagSet) (string, bool, error)
- type AuthResponse
- type Client
- func (c *Client) DeleteRepository(image string) error
- func (c *Client) DescribeRepository(image string) (*Repository, error)
- func (c *Client) GetAuthToken() (string, error)
- func (c *Client) GetAvgTagsSize(image string) (float64, error)
- func (c *Client) GetLatestTag(image string) (string, error)
- func (c *Client) GetTagsCount(image string) (int, error)
- func (c *Client) ListRepositories() (repos []*Repository, err error)
- func (c *Client) ListTags(image string) ([]*Tag, error)
- func (c *Client) NewRequest(method, url string, payload io.Reader) (*http.Request, error)
- func (c *Client) RenewDockerImage(image string) error
- func (c *Client) TruncateTags(image string, truncateInactive bool, regularExpression string) error
- type Image
- type Repository
- type RepositoryList
- type Tag
- type TagList
Constants ¶
const BaseURL = "https://hub.docker.com/v2/"
BaseURL represents Docker Hub endpoint
Variables ¶
BG returns bold green color
BR returns bold red color
BW returns bold white color
BY returns bold yellow color
var RepositoriesURL = BaseURL + "repositories"
RepositoriesURL represents Docker Hub repositories endpoint
Functions ¶
Types ¶
type AuthResponse ¶
type AuthResponse struct {
Token string `json:"token"`
}
AuthResponse represents auth response
type Client ¶
Client represents new HTTP client
func (*Client) DeleteRepository ¶
DeleteRepository delete docker repository from docker hub
curl \ -H "Authorization: JWT ${TOKEN}" \ -X DELETE \ https://hub.docker.com/v2/repositories/${ORG}/${IMAGE}/
func (*Client) DescribeRepository ¶
func (c *Client) DescribeRepository(image string) (*Repository, error)
DescribeRepository print details about docker repository from docker hub
func (*Client) GetAuthToken ¶
GetAuthToken returns JWT Token from docker hub login page
curl --silent \ -H "Content-Type: application/json" \ -X POST \ -d '{"username": "'${DOCKERHUB_USERNAME}'", "password": "'${DOCKERHUB_PASSWORD}'"}' \ https://hub.docker.com/v2/users/login/ | jq -r .token
func (*Client) GetAvgTagsSize ¶
GetAvgTagsSize returns size docker image tag from docker hub for selected repository
func (*Client) GetLatestTag ¶
GetLatestTag returns latest (by LastUpdated field) docker image tag from docker hub
func (*Client) GetTagsCount ¶
GetTagsCount returns count docker image tag from docker hub for selected repository
func (*Client) ListRepositories ¶
func (c *Client) ListRepositories() (repos []*Repository, err error)
ListRepositories returns list of docker images from docker hub
func (*Client) ListTags ¶
ListTags returns list of docker image tags for selected image from docker hub
func (*Client) NewRequest ¶
NewRequest prepare request to docker hub
func (*Client) RenewDockerImage ¶
RenewDockerImage renew docker image tags older than 20 days from docker hub
type Image ¶
type Image struct { Architecture string `json:"architecture"` Features string `json:"features"` Variant string `json:"variant"` Digest string `json:"digest"` OS string `json:"os"` OSFeatures string `json:"os_features"` OSVersion string `json:"os_version"` Size int `json:"size"` Status string `json:"status"` LastPulled time.Time `json:"last_pulled"` PastPushed time.Time `json:"last_pushed"` }
Image represents docker image information returned from hub.docker.com
type Repository ¶
type Repository struct { User string `json:"user"` Name string `json:"name"` Namespace string `json:"namespace"` RepositoryType string `json:"repository_type"` Status int `json:"status"` Description string `json:"description"` IsPrivate bool `json:"is_private"` IsAutomated bool `json:"is_automated"` CanEdit bool `json:"can_edit"` StarCount int `json:"star_count"` PullCount int `json:"pull_count"` LastUpdated time.Time `json:"last_updated"` IsMigrated bool `json:"is_migrated"` CollaboratorCount int `json:"collaborator_count"` Affiliation string `json:"affiliation"` HubUser string `json:"hub_user"` }
Repository represents docker repository information returned from hub.docker.com
type RepositoryList ¶
type RepositoryList struct { Count int `json:"count"` Next string `json:"next"` Previous string `json:"previous"` Results []*Repository `json:"results"` }
RepositoryList represents the search repositories results from hub.docker.com
type Tag ¶
type Tag struct { Creator int64 `json:"creator"` ID int64 `json:"id"` ImageID string `json:"image_id"` Images []*Image `json:"images"` LastUpdated time.Time `json:"last_updated"` LastUpdater int64 `json:"last_updater"` LastUpdaterUser string `json:"last_updater_username"` Name string `json:"name"` Repository int64 `json:"repository"` FullSize int `json:"full_size"` V2 bool `json:"v2"` TagStatus string `json:"tag_status"` TagLastPulled time.Time `json:"tag_last_pulled"` TagLstaPushed time.Time `json:"tag_last_pushed"` }
Tag represents docker tag information returned from hub.docker.com