-
Notifications
You must be signed in to change notification settings - Fork 3
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
base: main
Are you sure you want to change the base?
Conversation
71d8457
to
a6c05a4
Compare
modal-js/src/app.ts
Outdated
|
||
async imageFromAwsEcr(tag: string, secret: Secret): Promise<Image> { | ||
if (!secret.secretId) { | ||
throw new Error("secret.secretId must not be null"); |
There was a problem hiding this comment.
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 a
secretId` here otherwise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 ✅
There was a problem hiding this 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:
- implement the same functionality in Go
- add tests to both secret and, ideally,
imageFromAwsEcr
- add examples
There was a problem hiding this 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.
modal-js/src/secret.ts
Outdated
|
||
export type SecretFromNameOptions = { | ||
namespace?: DeploymentNamespace; | ||
environment_name?: string; |
There was a problem hiding this comment.
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
modal-js/src/secret.ts
Outdated
export type SecretFromNameOptions = { | ||
namespace?: DeploymentNamespace; | ||
environment_name?: string; | ||
required_keys?: string[]; |
There was a problem hiding this comment.
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
modal-js/src/secret.ts
Outdated
namespace: | ||
options?.namespace ?? | ||
DeploymentNamespace.DEPLOYMENT_NAMESPACE_WORKSPACE, |
There was a problem hiding this comment.
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.
modal-js/src/image.ts
Outdated
}, | ||
namespace: DeploymentNamespace.DEPLOYMENT_NAMESPACE_WORKSPACE, | ||
builderVersion: "2024.10", // TODO: make this configurable | ||
builderVersion: process.env.MODAL_IMAGE_BUILDER_VERSION || "2024.10", |
There was a problem hiding this comment.
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.
modal-js/src/secret.ts
Outdated
this.secretId = secretId; | ||
} | ||
|
||
static async from_name( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use camelCase
modal-js/src/app.ts
Outdated
if (!secret.secretId) { | ||
throw new Error( | ||
"secret must be a reference to an existing Secret, e.g. `await Secret.from_name('my_secret')`", | ||
); | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
a0ba483
to
4bb7820
Compare
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! |
Adds support similar to modal.Image.from_aws_ecr(), related support for
Secret
s.