wip: login to docker to avoid rate limiting #139
@ -4,3 +4,5 @@ go env -w GOPRIVATE=coopcloud.tech
|
|||||||
# export HCLOUD_TOKEN=$(pass show logins/hetzner/cicd/api_key)
|
# export HCLOUD_TOKEN=$(pass show logins/hetzner/cicd/api_key)
|
||||||
# export CAPSUL_TOKEN=...
|
# export CAPSUL_TOKEN=...
|
||||||
# export GITEA_TOKEN=...
|
# export GITEA_TOKEN=...
|
||||||
|
# export DOCKER_USERNAME=...
|
||||||
|
# export DOCKER_PASSWORD=...
|
||||||
|
@ -1,15 +1,20 @@
|
|||||||
package client
|
package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
"os"
|
||||||
|
|
||||||
"coopcloud.tech/abra/pkg/web"
|
"coopcloud.tech/abra/pkg/web"
|
||||||
"github.com/docker/distribution/reference"
|
"github.com/docker/distribution/reference"
|
||||||
"github.com/hashicorp/go-retryablehttp"
|
"github.com/hashicorp/go-retryablehttp"
|
||||||
|
dockerClient "github.com/docker/docker/client"
|
||||||
|
"github.com/docker/docker/api/types"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RawTag struct {
|
type RawTag struct {
|
||||||
@ -84,6 +89,20 @@ func GetTagDigest(image reference.Named) (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dClient := dockerClient.Client{}
|
||||||
|
|
||||||
|
username, username_ok := os.LookupEnv("DOCKER_USERNAME")
|
||||||
|
password, password_ok := os.LookupEnv("DOCKER_PASSWORD")
|
||||||
|
if username_ok && password_ok {
|
||||||
|
logrus.Debugf("docker login: %s, %s", username, password)
|
||||||
|
dClient.RegistryLogin(context.Background(), types.AuthConfig{
|
||||||
|
Username: username,
|
||||||
|
Password: password,
|
||||||
|
ServerAddress: "docker.io",
|
||||||
|
})
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
|
||||||
token, err := getRegv2Token(image)
|
token, err := getRegv2Token(image)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user