Skip to content
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

Add support for --no-use-container option #7745

Closed
wants to merge 1 commit into from

Conversation

jonife
Copy link
Contributor

@jonife jonife commented Nov 26, 2024

Why is this change necessary?

use-container currently doesn't have an opposite option called no-use-container, user wants to use the IDE toolkit which depends on samcli to set default behaviors but still wants the flexibility of using the opposite option to carry out different operation.

How does it address the issue?

Add support for no-use-container allow the cli to pass use-container = false in the samConfig file

What side effects does this change have?

no-use-container can result to use_container = false in samConfig
sam sync

Container Options:                        
                                    
    -u, --use-container / --no-use-container
                                    Build functions within an AWS Lambda-like container.
                                                                      

Mandatory Checklist

PRs will only be reviewed after checklist is complete

  • Add input/output type hints to new functions/methods
  • Write design document if needed (Do I need to write a design document?)
  • Write/update unit tests
  • Write/update integration tests
  • Write/update functional tests if needed
  • make pr passes
  • make update-reproducible-reqs if dependencies were changed
  • Write documentation

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@github-actions github-actions bot added pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Nov 27, 2024

LOG.debug(Path(config_path).read_text())
runner = CliRunner()
result = runner.invoke(cli, [])
Copy link
Contributor

Choose a reason for hiding this comment

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

What you probably want to check here is that the parameter in the command line gets picked up (--no-use-container, that you're adding). To test that, you need to pass it in this part. Like this line.

Otherwise, you're just testing that the samconfig works fine, not the command line argument. (Probably the same for sync below)

Copy link
Contributor Author

@jonife jonife Nov 27, 2024

Choose a reason for hiding this comment

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

Both tests are different. The use cases in the link you provided focus on testing overrides. For example, if my configuration includes "use_container": True, I can pass --no-use-container to override it, effectively setting "use_container": False.

This is a draft PR to validate whether make schema works. Please note that the PR is not complete as you review it. I have unit test coverage for overrides.

Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose we could have 1 unit test for testing the default config value as here and another one like @valerena mentioned about with use-container=True and override it with --no-use-container to assert it gets set to False. The sam sync test below could be updated with the latter case since both cases stem from the same click option anyways (we might not need duplicate tests for each command).

@@ -849,8 +849,10 @@ def resolve_image_repos_option(f):

def use_container_build_click_option():
return click.option(
"--use-container",
"--use-container/--no-use-container",
Copy link
Member

@roger-zhangg roger-zhangg Nov 27, 2024

Choose a reason for hiding this comment

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

If customer doesn't specify --use-container or --no-use-container, will sam cli still use the value from samconfig.toml after this change? E.g. If samconfig.toml has use_container=true, and customer run sam build without any flag, it should continue to use container to build right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This documentation might help answer your question: SAM CLI Configuration File Precedence.

Copy link
Member

@roger-zhangg roger-zhangg left a comment

Choose a reason for hiding this comment

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

if customer has use_container=true in sam config.toml, Will sam build --no-use-container --save-params update use_container=true in samconfig.toml to use_container=false ?

@jonife
Copy link
Contributor Author

jonife commented Nov 27, 2024

if customer has use_container=true in sam config.toml, Will sam build --no-use-container --save-params update use_container=true in samconfig.toml to use_container=false ?

yes

"-u",
required=False,
default=False,
is_flag=True,
Copy link
Member

Choose a reason for hiding this comment

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

Non-blocking, is_flag could be removed after this change.

@jonife
Copy link
Contributor Author

jonife commented Dec 3, 2024

closing this pr in favor of #7769 due to inability to rebase locally.

@jonife jonife closed this Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/internal stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants