feat: support PlatformPicker
This commit is contained in:
parent
64cae197a4
commit
c6b8548d35
@ -299,9 +299,19 @@ func (rc *RunContext) platformImage(ctx context.Context) string {
|
|||||||
common.Logger(ctx).Errorf("'runs-on' key not defined in %s", rc.String())
|
common.Logger(ctx).Errorf("'runs-on' key not defined in %s", rc.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, runnerLabel := range job.RunsOn() {
|
runsOn := job.RunsOn()
|
||||||
platformName := rc.ExprEval.Interpolate(ctx, runnerLabel)
|
for i, v := range runsOn {
|
||||||
image := rc.Config.Platforms[strings.ToLower(platformName)]
|
runsOn[i] = rc.ExprEval.Interpolate(ctx, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
if pick := rc.Config.PlatformPicker; pick != nil {
|
||||||
|
if image := pick(runsOn); image != "" {
|
||||||
|
return image
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, runnerLabel := range runsOn {
|
||||||
|
image := rc.Config.Platforms[strings.ToLower(runnerLabel)]
|
||||||
if image != "" {
|
if image != "" {
|
||||||
return image
|
return image
|
||||||
}
|
}
|
||||||
|
@ -56,12 +56,13 @@ type Config struct {
|
|||||||
ReplaceGheActionWithGithubCom []string // Use actions from GitHub Enterprise instance to GitHub
|
ReplaceGheActionWithGithubCom []string // Use actions from GitHub Enterprise instance to GitHub
|
||||||
ReplaceGheActionTokenWithGithubCom string // Token of private action repo on GitHub.
|
ReplaceGheActionTokenWithGithubCom string // Token of private action repo on GitHub.
|
||||||
|
|
||||||
PresetGitHubContext *model.GithubContext // the preset github context, overrides some fields like DefaultBranch, Env, Secrets etc.
|
PresetGitHubContext *model.GithubContext // the preset github context, overrides some fields like DefaultBranch, Env, Secrets etc.
|
||||||
EventJSON string // the content of JSON file to use for event.json in containers, overrides EventPath
|
EventJSON string // the content of JSON file to use for event.json in containers, overrides EventPath
|
||||||
ContainerNamePrefix string // the prefix of container name
|
ContainerNamePrefix string // the prefix of container name
|
||||||
ContainerMaxLifetime time.Duration // the max lifetime of job containers
|
ContainerMaxLifetime time.Duration // the max lifetime of job containers
|
||||||
ContainerNetworkMode string // the network mode of job containers
|
ContainerNetworkMode string // the network mode of job containers
|
||||||
DefaultActionInstance string // the default actions web site
|
DefaultActionInstance string // the default actions web site
|
||||||
|
PlatformPicker func(labels []string) string // platform picker, it will take precedence over Platforms if isn't nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolves the equivalent host path inside the container
|
// Resolves the equivalent host path inside the container
|
||||||
|
Loading…
Reference in New Issue
Block a user