-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix buildah issue of using
overlay
as storage driver (#51)
Work around #45 Signed-off-by: divyansh42 <diagrawa@redhat.com>
- Loading branch information
1 parent
65f18d4
commit 6dbeb7e
Showing
9 changed files
with
140 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import * as ini from "ini"; | ||
import { promises as fs } from "fs"; | ||
import * as core from "@actions/core"; | ||
import * as path from "path"; | ||
import * as io from "@actions/io"; | ||
import * as os from "os"; | ||
|
||
async function findStorageDriver(filePaths: string[]): Promise<string> { | ||
let storageDriver = ""; | ||
for (const filePath of filePaths) { | ||
core.debug(`Checking if the storage file exists at ${filePath}`); | ||
if (await fileExists(filePath)) { | ||
core.debug(`Storage file exists at ${filePath}`); | ||
const fileContent = ini.parse(await fs.readFile(filePath, "utf-8")); | ||
if (fileContent.storage.driver) { | ||
storageDriver = fileContent.storage.driver; | ||
} | ||
} | ||
} | ||
return storageDriver; | ||
} | ||
|
||
export async function isStorageDriverOverlay(): Promise<boolean> { | ||
let xdgConfigHome = path.join(os.homedir(), ".config"); | ||
if (process.env.XDG_CONFIG_HOME) { | ||
xdgConfigHome = process.env.XDG_CONFIG_HOME; | ||
} | ||
const filePaths: string[] = [ | ||
"/etc/containers/storage.conf", | ||
path.join(xdgConfigHome, "containers/storage.conf"), | ||
]; | ||
const storageDriver = await findStorageDriver(filePaths); | ||
return (storageDriver === "overlay"); | ||
} | ||
|
||
async function fileExists(filePath: string): Promise<boolean> { | ||
try { | ||
await fs.access(filePath); | ||
return true; | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
} | ||
|
||
export async function findFuseOverlayfsPath(): Promise<string | undefined> { | ||
let fuseOverlayfsPath; | ||
try { | ||
fuseOverlayfsPath = await io.which("fuse-overlayfs"); | ||
} | ||
catch (err) { | ||
core.debug(err); | ||
} | ||
|
||
return fuseOverlayfsPath; | ||
} |