1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-09-15 18:57:01 +00:00

chore: panic if a random name cannot be created (#853)

If that happens so much will go wrong that there is no point in continuing to do anything. It simplifies the requirements of the caller: it may be a function that is assumed to never error.

<!--start release-notes-assistant-->
<!--URL:https://code.forgejo.org/forgejo/runner-->
- other
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/853): <!--number 853 --><!--line 0 --><!--description Y2hvcmU6IHBhbmljIGlmIGEgcmFuZG9tIG5hbWUgY2Fubm90IGJlIGNyZWF0ZWQ=-->chore: panic if a random name cannot be created<!--description-->
<!--end release-notes-assistant-->

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/853
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.code.forgejo.org>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
This commit is contained in:
Earl Warren 2025-08-14 15:46:01 +00:00 committed by earl-warren
parent 987efff021
commit 0ff1ec4c04
No known key found for this signature in database
GPG key ID: F128CBE6AB3A7201
4 changed files with 14 additions and 18 deletions

View file

@ -283,10 +283,7 @@ func (rc *RunContext) startHostEnvironment() common.Executor {
return true
})
cacheDir := rc.ActionCacheDir()
randName, err := common.RandName(8)
if err != nil {
return err
}
randName := common.MustRandName(8)
miscpath := filepath.Join(cacheDir, randName)
actPath := filepath.Join(miscpath, "act")
if err := os.MkdirAll(actPath, 0o777); err != nil {
@ -624,10 +621,7 @@ func (rc *RunContext) sh(ctx context.Context, script string) (stdout, stderr str
env[k] = v
}
base, err := common.RandName(8)
if err != nil {
return "", "", err
}
base := common.MustRandName(8)
name := base + ".sh"
oldStdout, oldStderr := rc.JobContainer.ReplaceLogWriter(hout, herr)
err = rc.JobContainer.Copy(rc.JobContainer.GetActPath(), &container.FileEntry{