mirror of
https://github.com/redhat-actions/podman-login.git
synced 2025-03-31 22:27:47 +02:00
Add ability to disable Docker integration
This commit is contained in:
parent
8a0c05b53e
commit
640460915c
7 changed files with 32 additions and 10 deletions
|
@ -27,6 +27,7 @@ This action only runs on `Linux`, as it uses [podman](https://github.com/contain
|
|||
| password | Password, encrypted password, or access token for `username`. | **Must be provided**
|
||||
| logout | By default, the action logs out of the container image registry at the end of the job (for self-hosted runners). Set this to `false` to disable this behaviour. | `true`
|
||||
| auth_file_path | Path of the authentication file, this will override the default auth file path in podman | Default set in podman |
|
||||
| disable_docker_integration | By default the action stores the authentication info for the Docker daemon as well. Set to `true` if you only have Podman installed. | `false`
|
||||
|
||||
## Examples
|
||||
|
||||
|
|
|
@ -17,6 +17,10 @@ inputs:
|
|||
auth_file_path:
|
||||
description: 'Path of the authentication file, this will override the default auth file path in podman'
|
||||
required: false
|
||||
disable_docker_integration:
|
||||
description: 'Set to true if there is no Docker installed and you only want to use Podman'
|
||||
required: false
|
||||
default: 'false'
|
||||
logout:
|
||||
description: |
|
||||
'By default, the action logs out of the container image registry at the end
|
||||
|
|
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
|
@ -6,6 +6,12 @@ export enum Inputs {
|
|||
* Default: None.
|
||||
*/
|
||||
AUTH_FILE_PATH = "auth_file_path",
|
||||
/**
|
||||
* Set to true if there is no Docker installed and you only want to use Podman
|
||||
* Required: false
|
||||
* Default: "false"
|
||||
*/
|
||||
DISABLE_DOCKER_INTEGRATION = "disable_docker_integration",
|
||||
/**
|
||||
* 'By default, the action logs out of the container image registry at the end
|
||||
* of the job (for self-hosted runners). Set this to false to disable this behaviour'
|
||||
|
|
22
src/index.ts
22
src/index.ts
|
@ -35,9 +35,11 @@ async function run(): Promise<void> {
|
|||
const password = core.getInput(Inputs.PASSWORD, { required: true });
|
||||
const logout = core.getInput(Inputs.LOGOUT) || "true";
|
||||
const authFilePath = core.getInput(Inputs.AUTH_FILE_PATH);
|
||||
const disableDockerIntegration = core.getInput(Inputs.DISABLE_DOCKER_INTEGRATION) || "false";
|
||||
|
||||
stateHelper.setRegistry(registry);
|
||||
stateHelper.setLogout(logout);
|
||||
stateHelper.setDisableDockerIntegration(disableDockerIntegration);
|
||||
|
||||
const args = [
|
||||
"login",
|
||||
|
@ -78,12 +80,14 @@ async function run(): Promise<void> {
|
|||
const podmanConfig = JSON.parse(podmanConfigJson);
|
||||
const generatedAuth = podmanConfig.auths[registry];
|
||||
|
||||
core.info(`✍️ Writing registry credentials to "${dockerConfigPath}"`);
|
||||
const dockerConfig = JSON.parse(await getDockerConfigJson());
|
||||
if (!disableDockerIntegration) {
|
||||
core.info(`✍️ Writing registry credentials to "${dockerConfigPath}"`);
|
||||
const dockerConfig = JSON.parse(await getDockerConfigJson());
|
||||
|
||||
dockerConfig.auths[registry] = generatedAuth;
|
||||
dockerConfig.auths[registry] = generatedAuth;
|
||||
|
||||
await fs.writeFile(dockerConfigPath, JSON.stringify(dockerConfig, undefined, 8), "utf-8");
|
||||
await fs.writeFile(dockerConfigPath, JSON.stringify(dockerConfig, undefined, 8), "utf-8");
|
||||
}
|
||||
}
|
||||
|
||||
async function registryLogout(): Promise<void> {
|
||||
|
@ -92,10 +96,12 @@ async function registryLogout(): Promise<void> {
|
|||
}
|
||||
await execute(await getPodmanPath(), [ "logout", stateHelper.registry ]);
|
||||
|
||||
const dockerConfig = JSON.parse(await getDockerConfigJson());
|
||||
core.info(`Removing registry credentials from "${dockerConfigPath}"`);
|
||||
delete dockerConfig.auths[registry];
|
||||
await fs.writeFile(dockerConfigPath, JSON.stringify(dockerConfig, undefined, 8), "utf-8");
|
||||
if (!stateHelper.disableDockerIntegration) {
|
||||
const dockerConfig = JSON.parse(await getDockerConfigJson());
|
||||
core.info(`Removing registry credentials from "${dockerConfigPath}"`);
|
||||
delete dockerConfig.auths[registry];
|
||||
await fs.writeFile(dockerConfigPath, JSON.stringify(dockerConfig, undefined, 8), "utf-8");
|
||||
}
|
||||
}
|
||||
|
||||
if (!stateHelper.IsPost) {
|
||||
|
|
|
@ -2,6 +2,7 @@ import * as core from "@actions/core";
|
|||
|
||||
export const IsPost = !!process.env.STATE_isPost;
|
||||
export const registry = process.env.STATE_registry || "";
|
||||
export const disableDockerIntegration = process.env.STATE_disableDockerIntegration || false;
|
||||
export const logout = /true/i.test(process.env.STATE_logout || "");
|
||||
|
||||
export function setRegistry(inputRegistry: string): void {
|
||||
|
@ -12,6 +13,10 @@ export function setLogout(registryLogout: string): void {
|
|||
core.saveState("logout", registryLogout);
|
||||
}
|
||||
|
||||
export function setDisableDockerIntegration(inputDisableDockerIntegration: string): void {
|
||||
core.saveState("disableDockerIntegration", inputDisableDockerIntegration);
|
||||
}
|
||||
|
||||
if (!IsPost) {
|
||||
core.saveState("isPost", "true");
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue