mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-08-31 18:30:58 +00:00
Just fixes the build, not sure if this actually enables any functionality (yet) on FreeBSD. However, it does seem to at least start: ``` time="2025-08-18T01:02:58-04:00" level=info msg="Starting runner daemon" ``` <!--start release-notes-assistant--> <!--URL:https://code.forgejo.org/forgejo/runner--> - bug fixes - [PR](https://code.forgejo.org/forgejo/runner/pulls/882): <!--number 882 --><!--line 0 --><!--description Zml4OiBmaXhlcyB0aGUgYnVpbGQgb24gRnJlZUJTRCBbc2tpcCBjYXNjYWRlXQ==-->fix: fixes the build on FreeBSD [skip cascade]<!--description--> <!--end release-notes-assistant--> Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/882 Reviewed-by: earl-warren <earl-warren@noreply.code.forgejo.org> Co-authored-by: Daniel Morante <daniel@morante.net> Co-committed-by: Daniel Morante <daniel@morante.net>
61 lines
1.7 KiB
Go
61 lines
1.7 KiB
Go
//go:build !(WITHOUT_DOCKER || !(linux || darwin || windows || netbsd || freebsd))
|
|
|
|
package container
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
|
|
"code.forgejo.org/forgejo/runner/v9/act/common"
|
|
"github.com/docker/cli/cli/config"
|
|
"github.com/docker/cli/cli/config/credentials"
|
|
"github.com/docker/docker/api/types/registry"
|
|
)
|
|
|
|
func LoadDockerAuthConfig(ctx context.Context, image string) (registry.AuthConfig, error) {
|
|
logger := common.Logger(ctx)
|
|
config, err := config.Load(config.Dir())
|
|
if err != nil {
|
|
logger.Warnf("Could not load docker config: %v", err)
|
|
return registry.AuthConfig{}, err
|
|
}
|
|
|
|
if !config.ContainsAuth() {
|
|
config.CredentialsStore = credentials.DetectDefaultStore(config.CredentialsStore)
|
|
}
|
|
|
|
hostName := "index.docker.io"
|
|
index := strings.IndexRune(image, '/')
|
|
if index > -1 && (strings.ContainsAny(image[:index], ".:") || image[:index] == "localhost") {
|
|
hostName = image[:index]
|
|
}
|
|
|
|
authConfig, err := config.GetAuthConfig(hostName)
|
|
if err != nil {
|
|
logger.Warnf("Could not get auth config from docker config: %v", err)
|
|
return registry.AuthConfig{}, err
|
|
}
|
|
|
|
return registry.AuthConfig(authConfig), nil
|
|
}
|
|
|
|
func LoadDockerAuthConfigs(ctx context.Context) map[string]registry.AuthConfig {
|
|
logger := common.Logger(ctx)
|
|
config, err := config.Load(config.Dir())
|
|
if err != nil {
|
|
logger.Warnf("Could not load docker config: %v", err)
|
|
return nil
|
|
}
|
|
|
|
if !config.ContainsAuth() {
|
|
config.CredentialsStore = credentials.DetectDefaultStore(config.CredentialsStore)
|
|
}
|
|
|
|
creds, _ := config.GetAllCredentials()
|
|
authConfigs := make(map[string]registry.AuthConfig, len(creds))
|
|
for k, v := range creds {
|
|
authConfigs[k] = registry.AuthConfig(v)
|
|
}
|
|
|
|
return authConfigs
|
|
}
|