Modify input format to newline

Signed-off-by: divyansh42 <diagrawa@redhat.com>
This commit is contained in:
divyansh42 2021-02-04 01:11:56 +05:30
parent 38bde145f1
commit dae1e56fb6
6 changed files with 27 additions and 7 deletions

View file

@ -74,7 +74,8 @@ Refer to the [`podman push`](http://docs.podman.io/en/latest/markdown/podman-man
<tr>
<td>extra-args</td>
<td>No</td>
<td>Extra args to be passed to push command when pushing image.</td>
<td>Extra args to be passed to podman push.
Separate arguments by newline. Do not use quotes.</td>
</tr>
</table>

View file

@ -32,7 +32,9 @@ inputs:
The contents of this file are the digest output.
required: false
extra-args:
description: 'Extra args to be passed to push command when pushing image'
description: |
Extra args to be passed to podman push.
Separate arguments by newline. Do not use quotes - @actions/exec will do the quoting for you.
required: false
outputs:

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

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;
@ -43,7 +44,15 @@ async function run(): Promise<void> {
const password = core.getInput("password", { required: true });
const tlsVerify = core.getInput("tls-verify");
const digestFileInput = core.getInput("digestfile");
const extraArgs = core.getInput("extra-args");
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[] = [];
@ -160,8 +169,8 @@ async function run(): Promise<void> {
registryPath,
];
if (extraArgs) {
args.push(extraArgs);
if (podmanExtraArgs.length > 0) {
args.push(...podmanExtraArgs);
}
// check if tls-verify is not set to null

8
src/util.ts Normal file
View file

@ -0,0 +1,8 @@
/***************************************************************************************************
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See LICENSE file in the project root for license information.
**************************************************************************************************/
export function splitByNewline(s: string): string[] {
return s.split(/\r?\n/);
}