hub-tool/pkg
Silvin Lubecki eae516cca7 Add windows-arm64 cross build
Bump all dependencies

Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
2024-02-27 14:10:37 +01:00
..
credentials Moving credentials from internal to pkg 2022-07-22 16:29:20 +02:00
hub Add windows-arm64 cross build 2024-02-27 14:10:37 +01:00
README.md Add help on using hub-tool as a library 2022-07-26 16:02:13 +02:00

README.md

Using tool as lib

You can use this tool as a library to make actions to Docker Hub.

Examples

Login

username := toto
password := pass

hubClient, err := hub.NewClient(
	hub.WithHubAccount(username),
	hub.WithPassword(password))
if err != nil {
	log.Fatalf("Can't initiate hubClient | %s", err.Error())
}

//Login to retrieve new token to Hub
token, _, err := hubClient.Login(username, password, func() (string, error) {
	return "2FA required, please provide the 6 digit code: ", nil
})
if err != nil {
	log.Fatalf("Can't get token from Docker Hub | %s", err.Error())
}

After a successfull login, it is quite easy to do any action possible and listed inside pkg/ directory.

Removing a tag

err = hubClient.RemoveTag("toto/myrepo", "v1.0.0")
if err != nil {
	log.Fatalf("Can't remove tag | %s", err.Error())
}