4391a10d5a
* feat: use logger from context wherever possible Co-authored-by: Markus Wolf <markus.wolf@new-work.se> * feat: add step/job id and results to json logs Co-authored-by: Markus Wolf <markus.wolf@new-work.se> * test: value to be masked should not be hard-coded in the action Co-authored-by: Markus Wolf <markus.wolf@new-work.se> * fix: replace values following ::add-mask:: in evaluated strings Co-authored-by: Markus Wolf <markus.wolf@new-work.se> * feat: [DEBUG] identifier for debug logs to distinguish them Co-authored-by: Markus Wolf <markus.wolf@new-work.se> * feat: replace logger with step logger The container gets injected a job logger, but during the time that steps are run, we want to use the step logger. This commit wraps pre/main/post steps in an executor that replaces the job logger with a step logger. Co-authored-by: Markus Wolf <markus.wolf@new-work.se> * feat: add pre/post stage identifier fields to json log output Co-authored-by: Markus Wolf <markus.wolf@new-work.se> * feat: add job/step result status to skipped steps/jobs Co-authored-by: Markus Wolf <markus.wolf@new-work.se> Co-authored-by: Markus Wolf <markus.wolf@new-work.se> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
38 lines
1,018 B
Go
38 lines
1,018 B
Go
package container
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
|
|
"github.com/docker/cli/cli/config"
|
|
"github.com/docker/cli/cli/config/credentials"
|
|
"github.com/docker/docker/api/types"
|
|
"github.com/nektos/act/pkg/common"
|
|
)
|
|
|
|
func LoadDockerAuthConfig(ctx context.Context, image string) (types.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 types.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 types.AuthConfig{}, err
|
|
}
|
|
|
|
return types.AuthConfig(authConfig), nil
|
|
}
|