MakeBuildpackArchive makes a simple buildpack zip for a given stack.
(stackName string)
| 14 | |
| 15 | // MakeBuildpackArchive makes a simple buildpack zip for a given stack. |
| 16 | func MakeBuildpackArchive(stackName string) string { |
| 17 | archiveFile, err := os.CreateTemp("", "buildpack-archive-file-") |
| 18 | Expect(err).ToNot(HaveOccurred()) |
| 19 | err = archiveFile.Close() |
| 20 | Expect(err).ToNot(HaveOccurred()) |
| 21 | err = os.RemoveAll(archiveFile.Name()) |
| 22 | Expect(err).ToNot(HaveOccurred()) |
| 23 | |
| 24 | archiveName := archiveFile.Name() + ".zip" |
| 25 | |
| 26 | dir, err := os.MkdirTemp("", "buildpack-dir-") |
| 27 | Expect(err).ToNot(HaveOccurred()) |
| 28 | defer os.RemoveAll(dir) |
| 29 | |
| 30 | manifest := filepath.Join(dir, "manifest.yml") |
| 31 | err = os.WriteFile(manifest, []byte(fmt.Sprintf("stack: %s", stackName)), 0666) |
| 32 | Expect(err).ToNot(HaveOccurred()) |
| 33 | |
| 34 | err = Zipit(dir, archiveName, "") |
| 35 | Expect(err).ToNot(HaveOccurred()) |
| 36 | |
| 37 | return archiveName |
| 38 | } |
| 39 | |
| 40 | // BuildpackWithStack makes a simple buildpack for the given stack (using |
| 41 | // MakeBuildpackArchive) and yields it to the given function, removing the zip |
no test coverage detected