Skip to content

Add App.imageFromAwsEcr for reading images from AWS ECR #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ehdr
Copy link

@ehdr ehdr commented May 27, 2025

Adds support similar to modal.Image.from_aws_ecr(), related support for Secrets.

@ehdr ehdr requested a review from freider May 27, 2025 11:28
@ehdr ehdr force-pushed the ehdr/add-image-from-aws-ecr branch from 71d8457 to a6c05a4 Compare May 27, 2025 11:31

async imageFromAwsEcr(tag: string, secret: Secret): Promise<Image> {
if (!secret.secretId) {
throw new Error("secret.secretId must not be null");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error could be a bit more helpful, like secret must be a reference to an existing Secret, e.g. await Secret.from_name("my_secret")or similar - I wouldn't expect users to know how to get an object with asecretId` here otherwise

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 ✅

Copy link
Member

@luiscape luiscape left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ehdr, can you make the following changes:

  1. implement the same functionality in Go
  2. add tests to both secret and, ideally, imageFromAwsEcr
  3. add examples

Copy link
Member

@ekzhang ekzhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm just need to follow some language conventions and add tests! I think you'd likely have noticed the camelCase naming thing after writing the examples / tests since they would be inconsistent with the code around it.

Also what Luis mentioned above, we're trying to keep the code as similar as possible between Go and TS and avoid it drifting.


export type SecretFromNameOptions = {
namespace?: DeploymentNamespace;
environment_name?: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

environment is the standard here — see LookupOptions

export type SecretFromNameOptions = {
namespace?: DeploymentNamespace;
environment_name?: string;
required_keys?: string[];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please name fields in the JS SDK with camelCase

Comment on lines 27 to 29
namespace:
options?.namespace ??
DeploymentNamespace.DEPLOYMENT_NAMESPACE_WORKSPACE,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no secrets in the global namespace. Please remove the option for simplicity and only set DeploymentNamespace.DEPLOYMENT_NAMESPACE_WORKSPACE here — global namespace is deprecated except for images and mounts.

},
namespace: DeploymentNamespace.DEPLOYMENT_NAMESPACE_WORKSPACE,
builderVersion: "2024.10", // TODO: make this configurable
builderVersion: process.env.MODAL_IMAGE_BUILDER_VERSION || "2024.10",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add this to config.ts so it reads from the profile as well, like with other config, rather than reading directly from environment.

this.secretId = secretId;
}

static async from_name(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use camelCase

Comment on lines 90 to 94
if (!secret.secretId) {
throw new Error(
"secret must be a reference to an existing Secret, e.g. `await Secret.from_name('my_secret')`",
);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this validation is needed or helpful since the Secret object, once constructed properly, must have a secret ID already.

Copy link
Author

@ehdr ehdr May 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it because it failed when I left out the await on Secret.from_name in await app.imageFromAwsEcr("alpine:3.21", await Secret.from_name("aws")). Do you think it makes sense, and/or is there a better way to guard for this?

@ehdr
Copy link
Author

ehdr commented May 27, 2025

Thanks @luiscape @ekzhang , great comments (and sorry for the Python casing... 🤦 ). I'll attend to these tomorrow.

@ehdr ehdr force-pushed the ehdr/add-image-from-aws-ecr branch from a0ba483 to 4bb7820 Compare May 28, 2025 12:37
@ehdr
Copy link
Author

ehdr commented May 28, 2025

I fixed most of the comments now. Will have to pause this for a bit for customer related work, but will add example and update Go client later before merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants