-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat: sam Commands Understand Local File Paths for AWS::Serverless::Function.ImageUri
#6930
feat: sam Commands Understand Local File Paths for AWS::Serverless::Function.ImageUri
#6930
Conversation
47ff20c
to
91879e1
Compare
I think in general, the code is very good here and I don't see many major flaws, I do think however this does need some testing both unit/integration test wise. For testing purposes, we should ideally have a test for each potential path, like the happy path and each error handling that we have, like if the image path returns multiple files for example. The unit testing itself should just have some simple assert validation on errors and the function being called. |
I agree and I'm happy to try. Much of the test code feels a bit beyond my current Python familiarity, so it could take me some time to figure it out. |
No worries take your time, I would be more than happy to take a look at your tests/ if you have any questions. |
As a summary, sam has learned to load an an image from a local archive before proceeding with the `build`, `package`, and `deploy` commands. When running `sam build` with an `ImageUri` pointing to a local file, sam will load that archive into an image, then write the ID of the image to the `ImageUri` property of the built template. ID works the same as a tag for the Docker API, so business continues as usual from here. The reason behind writing ID is that a loaded image could be associated with multiple tags, and selecting one arbtrarily leads to difficulties in the deploy command. The package and deploy commands have three kinds of value for `ImageUri` to consider. First, a value of the form `{repo}:{tag}`. This functions as it always has. Second, an image ID (in the form `sha256:{digest}`) which is probably the output of `sam build`. In this case, the tag translation uses the name of the as its input. Otherwise, they'd all end up with names starting with "sha256". Last, a local file. In this case, it proceeds as it does in the build command: Load the archive into an image first, then pass the resource name into tag translation. See: aws#6909
f239f2f
to
e38215a
Compare
Also, genericize unit tests a little. See: aws#6909
@jysheng123 When I go to run integration tests, will that perform deployments, or would only end-to-end tests do that? I need to know if I should have a scratch account ready to go so I don't get the hey what is happening cloudtrail is going crazy with deployments to us-east-1 or something kind of Slack messages. |
Some of our integration tests will perform deployments, they should be deleted after the tests are done but if you want to be safe and not touch your actual account, I would recommend using another account |
Great, thanks so much. I will work on getting that set up. |
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.
Looks good to me! Ill ask another developer to take a look at this, thanks for bringing up the PR
Hi @chrisoverzero thanks for this PR and the thorough testing! The integration tests you added seem to be failing because the template is in the incorrect location. For these tests the test data lives under the |
other than fixing the failing integration test and removing that one unused import the changes look good to me overall as well. Once thats fixed and we verify that the tests are all passing we can merge this in, thanks once again! |
As a summary, sam has learned to load an an image from a local archive before proceeding with the
build
,package
, anddeploy
commands.When running
sam build
with anImageUri
pointing to a local file, sam will load that archive into an image, then write the ID of the image to theImageUri
property of the built template. ID works the same as a tag for the Docker API, so business continues as usual from here. The reason behind writing ID is that a loaded image could be associated with multiple tags, and selecting one arbtrarily leads to difficulties in the deploy command.The package and deploy commands have three kinds of value for
ImageUri
to consider. First, a value of the form{repo}:{tag}
. This functions as it always has. Second, an image ID (in the formsha256:{digest}
) which is probably the output ofsam build
. In this case, the tag translation uses the name of the as its input. Otherwise, they'd all end up with names starting with "sha256". Last, a local file. In this case, it proceeds as it does in the build command: Load the archive into an image first, then pass the resource name into tag translation.See: #6909
Which issue(s) does this change fix?
#6909
Why is this change necessary?
From the initial ticket:
How does it address the issue?
sam has learned to load an an image from a local archive before proceeding with the
build
,package
, anddeploy
commands when such a local archive is the value ofImageUri
for anAWS::Serverless::Function
What side effects does this change have?
The kinds of values understood for
ImageUri
has increased: A docker tag, a docker ID, and a local file archive. Though I think that a docker ID would always have worked, but unpleasantly. Either way, it wasn't documented and presumably not supported. Now it would be.Mandatory Checklist
PRs will only be reviewed after checklist is complete
make pr
passesmake update-reproducible-reqs
if dependencies were changedBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.