Skip to content

Commit

Permalink
Merge pull request #633 from paketo-buildpacks/no-temp
Browse files Browse the repository at this point in the history
Don't use Tempdir with system default
  • Loading branch information
Daniel Mikusa authored Apr 14, 2022
2 parents 668c8d9 + 98df89f commit 1401f2c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
15 changes: 5 additions & 10 deletions actions/draft-release/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,8 @@ func main() {
panic(err)
}

scratchDir, err := ioutil.TempDir("", "drafts")
if err != nil {
panic(err)
}

err = drafter.BuildAndWriteReleaseToFileDraftFromTemplate(
filepath.Join(scratchDir, "body"), templateContents, payload)
filepath.Join(".", "body"), templateContents, payload)
if err != nil {
panic(err)
}
Expand All @@ -56,7 +51,7 @@ func main() {
name = fmt.Sprintf("%s %s", payload.PrimaryBuildpack.Info.Name, payload.Release.Name)
}

err = ioutil.WriteFile(filepath.Join(scratchDir, "name"), []byte(name), 0644)
err = ioutil.WriteFile(filepath.Join(".", "name"), []byte(name), 0644)
if err != nil {
panic(err)
}
Expand All @@ -68,12 +63,12 @@ func main() {
"--method", "PATCH",
fmt.Sprintf("/repos/:owner/:repo/releases/%s", payload.Release.ID),
"--field", fmt.Sprintf("tag_name=%s", payload.Release.Tag),
"--field", fmt.Sprintf("name=@%s/name", scratchDir),
"--field", fmt.Sprintf("body=@%s/body", scratchDir),
"--field", "name=@./name",
"--field", "body=@./body",
},
}
if _, dryRun := inputs["dry_run"]; dryRun {
bits, err := ioutil.ReadFile(filepath.Join(scratchDir, "body"))
bits, err := ioutil.ReadFile(filepath.Join(".", "body"))
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion drafts/drafts.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func (r RegistryBuildpackLoader) LoadBuildpacks(uris []string) ([]Buildpack, err
}

func (r RegistryBuildpackLoader) LoadBuildpack(uri string) (Buildpack, error) {
tarFile, err := ioutil.TempFile("", "tarfiles")
tarFile, err := ioutil.TempFile(os.Getenv("RUNNER_TEMP"), "tarfiles")
if err != nil {
return Buildpack{}, fmt.Errorf("unable to create tempfile\n%w", err)
}
Expand Down

0 comments on commit 1401f2c

Please sign in to comment.