mirror of
https://github.com/redhat-actions/podman-login.git
synced 2025-04-02 07:07:46 +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**
|
| 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`
|
| 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 |
|
| 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
|
## Examples
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,10 @@ inputs:
|
||||||
auth_file_path:
|
auth_file_path:
|
||||||
description: 'Path of the authentication file, this will override the default auth file path in podman'
|
description: 'Path of the authentication file, this will override the default auth file path in podman'
|
||||||
required: false
|
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:
|
logout:
|
||||||
description: |
|
description: |
|
||||||
'By default, the action logs out of the container image registry at the end
|
'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.
|
* Default: None.
|
||||||
*/
|
*/
|
||||||
AUTH_FILE_PATH = "auth_file_path",
|
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
|
* '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'
|
* 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 password = core.getInput(Inputs.PASSWORD, { required: true });
|
||||||
const logout = core.getInput(Inputs.LOGOUT) || "true";
|
const logout = core.getInput(Inputs.LOGOUT) || "true";
|
||||||
const authFilePath = core.getInput(Inputs.AUTH_FILE_PATH);
|
const authFilePath = core.getInput(Inputs.AUTH_FILE_PATH);
|
||||||
|
const disableDockerIntegration = core.getInput(Inputs.DISABLE_DOCKER_INTEGRATION) || "false";
|
||||||
|
|
||||||
stateHelper.setRegistry(registry);
|
stateHelper.setRegistry(registry);
|
||||||
stateHelper.setLogout(logout);
|
stateHelper.setLogout(logout);
|
||||||
|
stateHelper.setDisableDockerIntegration(disableDockerIntegration);
|
||||||
|
|
||||||
const args = [
|
const args = [
|
||||||
"login",
|
"login",
|
||||||
|
@ -78,12 +80,14 @@ async function run(): Promise<void> {
|
||||||
const podmanConfig = JSON.parse(podmanConfigJson);
|
const podmanConfig = JSON.parse(podmanConfigJson);
|
||||||
const generatedAuth = podmanConfig.auths[registry];
|
const generatedAuth = podmanConfig.auths[registry];
|
||||||
|
|
||||||
core.info(`✍️ Writing registry credentials to "${dockerConfigPath}"`);
|
if (!disableDockerIntegration) {
|
||||||
const dockerConfig = JSON.parse(await getDockerConfigJson());
|
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> {
|
async function registryLogout(): Promise<void> {
|
||||||
|
@ -92,10 +96,12 @@ async function registryLogout(): Promise<void> {
|
||||||
}
|
}
|
||||||
await execute(await getPodmanPath(), [ "logout", stateHelper.registry ]);
|
await execute(await getPodmanPath(), [ "logout", stateHelper.registry ]);
|
||||||
|
|
||||||
const dockerConfig = JSON.parse(await getDockerConfigJson());
|
if (!stateHelper.disableDockerIntegration) {
|
||||||
core.info(`Removing registry credentials from "${dockerConfigPath}"`);
|
const dockerConfig = JSON.parse(await getDockerConfigJson());
|
||||||
delete dockerConfig.auths[registry];
|
core.info(`Removing registry credentials from "${dockerConfigPath}"`);
|
||||||
await fs.writeFile(dockerConfigPath, JSON.stringify(dockerConfig, undefined, 8), "utf-8");
|
delete dockerConfig.auths[registry];
|
||||||
|
await fs.writeFile(dockerConfigPath, JSON.stringify(dockerConfig, undefined, 8), "utf-8");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stateHelper.IsPost) {
|
if (!stateHelper.IsPost) {
|
||||||
|
|
|
@ -2,6 +2,7 @@ import * as core from "@actions/core";
|
||||||
|
|
||||||
export const IsPost = !!process.env.STATE_isPost;
|
export const IsPost = !!process.env.STATE_isPost;
|
||||||
export const registry = process.env.STATE_registry || "";
|
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 const logout = /true/i.test(process.env.STATE_logout || "");
|
||||||
|
|
||||||
export function setRegistry(inputRegistry: string): void {
|
export function setRegistry(inputRegistry: string): void {
|
||||||
|
@ -12,6 +13,10 @@ export function setLogout(registryLogout: string): void {
|
||||||
core.saveState("logout", registryLogout);
|
core.saveState("logout", registryLogout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setDisableDockerIntegration(inputDisableDockerIntegration: string): void {
|
||||||
|
core.saveState("disableDockerIntegration", inputDisableDockerIntegration);
|
||||||
|
}
|
||||||
|
|
||||||
if (!IsPost) {
|
if (!IsPost) {
|
||||||
core.saveState("isPost", "true");
|
core.saveState("isPost", "true");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue