fix: don't allow -self-hosted
mode as container image (#1783)
* fix: don't allow `-self-hosted` mode as container image * fix: jobcontainer in hostmode platform * Update run_context.go --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
568124ca69
commit
ca9b783491
1 changed files with 18 additions and 3 deletions
|
@ -420,8 +420,9 @@ func (rc *RunContext) startContainer() common.Executor {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rc *RunContext) IsHostEnv(ctx context.Context) bool {
|
func (rc *RunContext) IsHostEnv(ctx context.Context) bool {
|
||||||
image := rc.platformImage(ctx)
|
platform := rc.runsOnImage(ctx)
|
||||||
return strings.EqualFold(image, "-self-hosted")
|
image := rc.containerImage(ctx)
|
||||||
|
return image == "" && strings.EqualFold(platform, "-self-hosted")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rc *RunContext) stopContainer() common.Executor {
|
func (rc *RunContext) stopContainer() common.Executor {
|
||||||
|
@ -474,7 +475,7 @@ func (rc *RunContext) Executor() common.Executor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rc *RunContext) platformImage(ctx context.Context) string {
|
func (rc *RunContext) containerImage(ctx context.Context) string {
|
||||||
job := rc.Run.Job()
|
job := rc.Run.Job()
|
||||||
|
|
||||||
c := job.Container()
|
c := job.Container()
|
||||||
|
@ -482,6 +483,12 @@ func (rc *RunContext) platformImage(ctx context.Context) string {
|
||||||
return rc.ExprEval.Interpolate(ctx, c.Image)
|
return rc.ExprEval.Interpolate(ctx, c.Image)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rc *RunContext) runsOnImage(ctx context.Context) string {
|
||||||
|
job := rc.Run.Job()
|
||||||
|
|
||||||
if job.RunsOn() == nil {
|
if job.RunsOn() == nil {
|
||||||
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())
|
||||||
}
|
}
|
||||||
|
@ -497,6 +504,14 @@ func (rc *RunContext) platformImage(ctx context.Context) string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (rc *RunContext) platformImage(ctx context.Context) string {
|
||||||
|
if containerImage := rc.containerImage(ctx); containerImage != "" {
|
||||||
|
return containerImage
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc.runsOnImage(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
func (rc *RunContext) options(ctx context.Context) string {
|
func (rc *RunContext) options(ctx context.Context) string {
|
||||||
job := rc.Run.Job()
|
job := rc.Run.Job()
|
||||||
c := job.Container()
|
c := job.Container()
|
||||||
|
|
Loading…
Reference in a new issue