Skip to content

Commit

Permalink
Fix: platform parameter is not supported by buildah config (build-wit…
Browse files Browse the repository at this point in the history
…hout-containerfile) (#83)

Signed-off-by: James Addison <jay@jp-hosting.net>
  • Loading branch information
jayaddison committed Oct 18, 2021
1 parent 733d8e9 commit bb88487
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 12 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ After building your image, use [push-to-registry](https://github.com/redhat-acti
| Input Name | Description | Default |
| ---------- | ----------- | ------- |
| arch | Label the image with this architecture, instead of defaulting to the host architecture. Refer to [Multi arch builds](#multi-arch-builds) for more information. | None (host architecture)
| platform | Label the image with this platform, instead of defaulting to the host platform. Refer to [Multi arch builds](#multi-arch-builds) for more information. | None (host platform)
| base-image | The base image to use for the container. | **Required**
| content | Paths to files or directories to copy inside the container to create the file image. This is a multiline input to allow you to copy multiple files/directories.| None
| entrypoint | The entry point to set for the container. Separate arguments by newline. | None
Expand Down
4 changes: 3 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ inputs:
description: 'Alias for "arch". "arch" takes precedence if both are set.'
required: false
platform:
description: 'Label the image with this PLATFORM, instead of defaulting to the host platform.'
description: |
Label the image with this PLATFORM, instead of defaulting to the host platform.
Only supported for containerfile builds.
required: false
extra-args:
description: |
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions src/buildah.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export interface BuildahConfigSettings {
port?: string;
workingdir?: string;
arch?: string;
platform?: string;
}

interface Buildah {
Expand Down Expand Up @@ -140,10 +139,6 @@ export class BuildahCli implements Buildah {
args.push("--arch");
args.push(settings.arch);
}
if (settings.platform) {
args.push("--platform");
args.push(settings.platform);
}
if (settings.workingdir) {
args.push("--workingdir");
args.push(settings.workingdir);
Expand Down
1 change: 1 addition & 0 deletions src/generated/inputs-outputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export enum Inputs {
OCI = "oci",
/**
* Label the image with this PLATFORM, instead of defaulting to the host platform.
* Only supported for containerfile builds.
* Required: false
* Default: None.
*/
Expand Down
8 changes: 5 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ export async function run(): Promise<void> {
await doBuildUsingContainerFiles(cli, newImage, workspace, containerFiles, useOCI, arch, platform);
}
else {
await doBuildFromScratch(cli, newImage, useOCI, arch, platform);
if (platform) {
throw new Error("The --platform option is not supported for builds without containerfiles.");
}
await doBuildFromScratch(cli, newImage, useOCI, arch);
}

if (tagsList.length > 1) {
Expand Down Expand Up @@ -105,7 +108,7 @@ async function doBuildUsingContainerFiles(
}

async function doBuildFromScratch(
cli: BuildahCli, newImage: string, useOCI: boolean, arch: string, platform: string
cli: BuildahCli, newImage: string, useOCI: boolean, arch: string
): Promise<void> {
core.info(`Performing build from scratch`);

Expand All @@ -125,7 +128,6 @@ async function doBuildFromScratch(
workingdir: workingDir,
envs,
arch,
platform,
};
await cli.config(containerId, newImageConfig);
await cli.copy(containerId, content);
Expand Down

0 comments on commit bb88487

Please sign in to comment.