Skip to content

Commit

Permalink
Add imageName param to ECR image args
Browse files Browse the repository at this point in the history
This allows the user to manually choose the name of the underlying Pulumi Docker image resource

When not defined it will fall back to the original behavior (use the image tag as the name of the underlying resource)
  • Loading branch information
sav-valerio committed Apr 9, 2024
1 parent 0390f0d commit 85fdc9a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion awsx/ecr/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export function computeImageFromAsset(

pulumi.log.debug(`Building container image at '${JSON.stringify(dockerInputs)}'`, parent);

const imageName = imageTag ? imageTag : createUniqueImageName(dockerInputs);
const imageName = args.imageName ? args.imageName :
(imageTag ? imageTag : createUniqueImageName(dockerInputs));

// Note: the tag, if provided, is included in the image name.
const canonicalImageName = `${repositoryUrl}:${imageName}`;

Expand Down
1 change: 1 addition & 0 deletions awsx/schema-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export interface ImageArgs {
readonly cacheFrom?: pulumi.Input<pulumi.Input<string>[]>;
readonly context?: pulumi.Input<string>;
readonly dockerfile?: pulumi.Input<string>;
readonly imageName?: pulumi.Input<string>;
readonly imageTag?: pulumi.Input<string>;
readonly platform?: pulumi.Input<string>;
readonly registryId?: pulumi.Input<string>;
Expand Down
4 changes: 4 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2154,6 +2154,10 @@
"type": "string",
"description": "dockerfile may be used to override the default Dockerfile name and/or location. By default, it is assumed to be a file named Dockerfile in the root of the build context."
},
"imageName": {
"type": "string",
"description": "Custom name for the underlying Docker image resource. If omitted, the image tag assigned by the provider will be used"
},
"imageTag": {
"type": "string",
"description": "Custom image tag for the resulting docker image. If omitted a random string will be used"
Expand Down
6 changes: 6 additions & 0 deletions schemagen/pkg/gen/ecr.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,12 @@ func dockerBuildProperties(dockerSpec schema.PackageSpec) map[string]schema.Prop
Type: "string",
},
},
"imageName": {
Description: "Custom name for the underlying Docker image resource. If omitted, the image tag assigned by the provider will be used",
TypeSpec: schema.TypeSpec{
Type: "string",
},
},
"imageTag": {
Description: "Custom image tag for the resulting docker image. If omitted a random string will be used",
TypeSpec: schema.TypeSpec{
Expand Down
5 changes: 5 additions & 0 deletions sdk/nodejs/ecr/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export class Image extends pulumi.ComponentResource {
resourceInputs["cacheFrom"] = args ? args.cacheFrom : undefined;
resourceInputs["context"] = args ? args.context : undefined;
resourceInputs["dockerfile"] = args ? args.dockerfile : undefined;
resourceInputs["imageName"] = args ? args.imageName : undefined;
resourceInputs["imageTag"] = args ? args.imageTag : undefined;
resourceInputs["platform"] = args ? args.platform : undefined;
resourceInputs["registryId"] = args ? args.registryId : undefined;
Expand Down Expand Up @@ -87,6 +88,10 @@ export interface ImageArgs {
* dockerfile may be used to override the default Dockerfile name and/or location. By default, it is assumed to be a file named Dockerfile in the root of the build context.
*/
dockerfile?: pulumi.Input<string>;
/**
* Custom name for the underlying Docker image resource. If omitted, the image tag assigned by the provider will be used
*/
imageName?: pulumi.Input<string>;
/**
* Custom image tag for the resulting docker image. If omitted a random string will be used
*/
Expand Down

0 comments on commit 85fdc9a

Please sign in to comment.