mirror of
https://github.com/redhat-actions/push-to-registry.git
synced 2025-04-02 07:27:47 +02:00
Merge e9018d36eb
into 9986a6552b
This commit is contained in:
commit
370a5575e8
3 changed files with 21 additions and 12 deletions
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
29
src/index.ts
29
src/index.ts
|
@ -43,6 +43,7 @@ async function getPodmanPath(): Promise<string> {
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
const DEFAULT_TAG = "latest";
|
const DEFAULT_TAG = "latest";
|
||||||
|
const registry = core.getInput(Inputs.REGISTRY);
|
||||||
const image = core.getInput(Inputs.IMAGE);
|
const image = core.getInput(Inputs.IMAGE);
|
||||||
const tags = core.getInput(Inputs.TAGS);
|
const tags = core.getInput(Inputs.TAGS);
|
||||||
// split tags
|
// split tags
|
||||||
|
@ -55,20 +56,28 @@ async function run(): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
const normalizedTagsList: string[] = [];
|
const normalizedTagsList: string[] = [];
|
||||||
let isNormalized = false;
|
let areTagsNormalized = false;
|
||||||
for (const tag of tagsList) {
|
for (const tag of tagsList) {
|
||||||
normalizedTagsList.push(tag.toLowerCase());
|
normalizedTagsList.push(tag.toLowerCase());
|
||||||
if (tag.toLowerCase() !== tag) {
|
if (tag.toLowerCase() !== tag) {
|
||||||
isNormalized = true;
|
areTagsNormalized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (areTagsNormalized) {
|
||||||
|
core.warning(`Reference to tag must be lowercase.`
|
||||||
|
+ ` Reference has been converted to be compliant with standard.`);
|
||||||
|
}
|
||||||
const normalizedImage = image.toLowerCase();
|
const normalizedImage = image.toLowerCase();
|
||||||
if (isNormalized || image !== normalizedImage) {
|
if (image !== normalizedImage) {
|
||||||
core.warning(`Reference to image and/or tag must be lowercase.`
|
core.warning(`Reference to image must be lowercase.`
|
||||||
|
+ ` Reference has been converted to be compliant with standard.`);
|
||||||
|
}
|
||||||
|
const normalizedRegistry = registry.toLowerCase();
|
||||||
|
if (registry !== normalizedRegistry) {
|
||||||
|
core.warning(`Reference to registry must be lowercase.`
|
||||||
+ ` Reference has been converted to be compliant with standard.`);
|
+ ` Reference has been converted to be compliant with standard.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const registry = core.getInput(Inputs.REGISTRY);
|
|
||||||
const username = core.getInput(Inputs.USERNAME);
|
const username = core.getInput(Inputs.USERNAME);
|
||||||
const password = core.getInput(Inputs.PASSWORD);
|
const password = core.getInput(Inputs.PASSWORD);
|
||||||
const tlsVerify = core.getInput(Inputs.TLS_VERIFY);
|
const tlsVerify = core.getInput(Inputs.TLS_VERIFY);
|
||||||
|
@ -83,15 +92,15 @@ async function run(): Promise<void> {
|
||||||
if (!normalizedImage) {
|
if (!normalizedImage) {
|
||||||
throw new Error(`Input "${Inputs.IMAGE}" must be provided when using non full name tags`);
|
throw new Error(`Input "${Inputs.IMAGE}" must be provided when using non full name tags`);
|
||||||
}
|
}
|
||||||
if (!registry) {
|
if (!normalizedRegistry) {
|
||||||
throw new Error(`Input "${Inputs.REGISTRY}" must be provided when using non full name tags`);
|
throw new Error(`Input "${Inputs.REGISTRY}" must be provided when using non full name tags`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const registryWithoutTrailingSlash = registry.replace(/\/$/, "");
|
const registryWithoutTrailingSlash = normalizedRegistry.replace(/\/$/, "");
|
||||||
const registryPath = `${registryWithoutTrailingSlash}/${normalizedImage}`;
|
const registryPath = `${registryWithoutTrailingSlash}/${normalizedImage}`;
|
||||||
core.info(`Combining image name "${normalizedImage}" and registry "${registry}" `
|
core.info(`Combining image name "${normalizedImage}" and registry "${normalizedRegistry}" `
|
||||||
+ `to form registry path "${registryPath}"`);
|
+ `to form registry path "${registryPath}"`);
|
||||||
if (normalizedImage.indexOf("/") > -1 && registry.indexOf("/") > -1) {
|
if (normalizedImage.indexOf("/") > -1 && normalizedRegistry.indexOf("/") > -1) {
|
||||||
core.warning(`"${registryPath}" does not seem to be a valid registry path. `
|
core.warning(`"${registryPath}" does not seem to be a valid registry path. `
|
||||||
+ `The registry path should not contain more than 2 slashes. `
|
+ `The registry path should not contain more than 2 slashes. `
|
||||||
+ `Refer to the Inputs section of the readme for naming image and registry.`);
|
+ `Refer to the Inputs section of the readme for naming image and registry.`);
|
||||||
|
@ -104,7 +113,7 @@ async function run(): Promise<void> {
|
||||||
if (normalizedImage) {
|
if (normalizedImage) {
|
||||||
core.warning(`Input "${Inputs.IMAGE}" is ignored when using full name tags`);
|
core.warning(`Input "${Inputs.IMAGE}" is ignored when using full name tags`);
|
||||||
}
|
}
|
||||||
if (registry) {
|
if (normalizedRegistry) {
|
||||||
core.warning(`Input "${Inputs.REGISTRY}" is ignored when using full name tags`);
|
core.warning(`Input "${Inputs.REGISTRY}" is ignored when using full name tags`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue