mirror of
https://github.com/go-task/task.git
synced 2026-09-01 11:39:28 +02:00
refactor(remote): carry the auth headers as taskfile.HostHeaders
map[string]map[string]string named neither key. The type already existed in taskfile; package task reaches it through setup.go, so only an import was missing. Callers keep passing a plain map literal, which stays assignable to a named map type.
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/go-task/task/v3/internal/logger"
|
||||
"github.com/go-task/task/v3/internal/output"
|
||||
"github.com/go-task/task/v3/internal/sort"
|
||||
"github.com/go-task/task/v3/taskfile"
|
||||
"github.com/go-task/task/v3/taskfile/ast"
|
||||
)
|
||||
|
||||
@@ -36,7 +37,7 @@ type (
|
||||
Download bool
|
||||
Offline bool
|
||||
TrustedHosts []string
|
||||
RemoteAuth map[string]map[string]string
|
||||
RemoteAuth taskfile.HostHeaders
|
||||
Timeout time.Duration
|
||||
CacheExpiryDuration time.Duration
|
||||
RemoteCacheDir string
|
||||
@@ -280,12 +281,12 @@ func (o *trustedHostsOption) ApplyToExecutor(e *Executor) {
|
||||
|
||||
// WithRemoteAuth configures the [Executor] with the HTTP headers to send when
|
||||
// fetching a remote Taskfile, keyed by host.
|
||||
func WithRemoteAuth(remoteAuth map[string]map[string]string) ExecutorOption {
|
||||
func WithRemoteAuth(remoteAuth taskfile.HostHeaders) ExecutorOption {
|
||||
return &remoteAuthOption{remoteAuth}
|
||||
}
|
||||
|
||||
type remoteAuthOption struct {
|
||||
remoteAuth map[string]map[string]string
|
||||
remoteAuth taskfile.HostHeaders
|
||||
}
|
||||
|
||||
func (o *remoteAuthOption) ApplyToExecutor(e *Executor) {
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
"github.com/go-task/task/v3/experiments"
|
||||
"github.com/go-task/task/v3/internal/env"
|
||||
"github.com/go-task/task/v3/internal/sort"
|
||||
"github.com/go-task/task/v3/taskfile"
|
||||
"github.com/go-task/task/v3/taskfile/ast"
|
||||
"github.com/go-task/task/v3/taskrc"
|
||||
taskrcast "github.com/go-task/task/v3/taskrc/ast"
|
||||
@@ -79,7 +80,7 @@ var (
|
||||
Download bool
|
||||
Offline bool
|
||||
TrustedHosts []string
|
||||
RemoteAuth map[string]map[string]string
|
||||
RemoteAuth taskfile.HostHeaders
|
||||
ClearCache bool
|
||||
Timeout time.Duration
|
||||
CacheExpiryDuration time.Duration
|
||||
@@ -317,11 +318,11 @@ func (o *flagsOption) ApplyToExecutor(e *task.Executor) {
|
||||
|
||||
// remoteAuth flattens the configured entries into a lookup by host, the last
|
||||
// entry winning as it does when configuration files are merged.
|
||||
func remoteAuth(config *taskrcast.TaskRC) map[string]map[string]string {
|
||||
func remoteAuth(config *taskrcast.TaskRC) taskfile.HostHeaders {
|
||||
if config == nil || len(config.Remote.Auth) == 0 {
|
||||
return nil
|
||||
}
|
||||
byHost := make(map[string]map[string]string, len(config.Remote.Auth))
|
||||
byHost := make(taskfile.HostHeaders, len(config.Remote.Auth))
|
||||
for _, auth := range config.Remote.Auth {
|
||||
byHost[auth.Host] = auth.Headers
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user