mirror of
https://github.com/redhat-actions/podman-login.git
synced 2025-06-07 22:21:12 +00:00
Add auth_file_path input and --verbose flag (#21)
Signed-off-by: divyansh42 <diagrawa@redhat.com>
This commit is contained in:
parent
43f863be90
commit
34f135348d
8 changed files with 34 additions and 9 deletions
23
src/index.ts
23
src/index.ts
|
@ -34,6 +34,7 @@ async function run(): Promise<void> {
|
|||
const username = core.getInput(Inputs.USERNAME, { required: true });
|
||||
const password = core.getInput(Inputs.PASSWORD, { required: true });
|
||||
const logout = core.getInput(Inputs.LOGOUT) || "true";
|
||||
const authFilePath = core.getInput(Inputs.AUTH_FILE_PATH);
|
||||
|
||||
stateHelper.setRegistry(registry);
|
||||
stateHelper.setLogout(logout);
|
||||
|
@ -46,17 +47,29 @@ async function run(): Promise<void> {
|
|||
"-p",
|
||||
password,
|
||||
];
|
||||
|
||||
args.push("--verbose");
|
||||
if (authFilePath) {
|
||||
args.push(`--authfile=${authFilePath}`);
|
||||
}
|
||||
await execute(await getPodmanPath(), args);
|
||||
core.info(`✅ Successfully logged in to ${registry} as ${username}`);
|
||||
|
||||
// Setting REGISTRY_AUTH_FILE environment variable as buildah needs
|
||||
// this environment variable to point to registry auth file
|
||||
let authFileDir = path.join("/", "tmp", `podman-run-${process.getuid()}`);
|
||||
if (process.env.XDG_RUNTIME_DIR) {
|
||||
authFileDir = process.env.XDG_RUNTIME_DIR;
|
||||
|
||||
let podmanAuthFilePath;
|
||||
if (authFilePath) {
|
||||
podmanAuthFilePath = authFilePath;
|
||||
}
|
||||
else {
|
||||
let authFileDir = path.join("/", "tmp", `podman-run-${process.getuid()}`);
|
||||
if (process.env.XDG_RUNTIME_DIR) {
|
||||
authFileDir = process.env.XDG_RUNTIME_DIR;
|
||||
}
|
||||
podmanAuthFilePath = path.join(authFileDir,
|
||||
"containers", "auth.json");
|
||||
}
|
||||
const podmanAuthFilePath = path.join(authFileDir,
|
||||
"containers", "auth.json");
|
||||
const REGISTRY_AUTH_ENVVAR = "REGISTRY_AUTH_FILE";
|
||||
core.info(`Exporting ${REGISTRY_AUTH_ENVVAR}=${podmanAuthFilePath}`);
|
||||
core.exportVariable(REGISTRY_AUTH_ENVVAR, podmanAuthFilePath);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue