Add feature to pass extra args when pushing image (#19)

If a user wants to pass few extra args to push
command when pushing image, then they can pass
using 'extra-args' input parameter.

Signed-off-by: divyansh42 <diagrawa@redhat.com>
This commit is contained in:
Divyanshu Agrawal 2021-02-08 20:07:42 +05:30 committed by GitHub
parent e7b5c08b38
commit 870f44bc9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 41 additions and 3 deletions

View file

@ -3,6 +3,7 @@ import * as exec from "@actions/exec";
import * as io from "@actions/io";
import * as fs from "fs";
import * as path from "path";
import { splitByNewline } from "./util";
interface ExecResult {
exitCode: number;
@ -44,6 +45,15 @@ async function run(): Promise<void> {
const tlsVerify = core.getInput("tls-verify");
const digestFileInput = core.getInput("digestfile");
const inputExtraArgsStr = core.getInput("extra-args");
let podmanExtraArgs: string[] = [];
if (inputExtraArgsStr) {
// transform the array of lines into an array of arguments
// by splitting over lines, then over spaces, then trimming.
const lines = splitByNewline(inputExtraArgsStr);
podmanExtraArgs = lines.flatMap((line) => line.split(" ")).map((arg) => arg.trim());
}
imageToPush = `${imageInput}`;
const registryPathList: string[] = [];
@ -159,6 +169,10 @@ async function run(): Promise<void> {
registryPath,
];
if (podmanExtraArgs.length > 0) {
args.push(...podmanExtraArgs);
}
// check if tls-verify is not set to null
if (tlsVerify) {
args.push(`--tls-verify=${tlsVerify}`);