Пример #1
0
 def test_configuration_option(self):
     toml_provider = TomlProvider()
     click_option = configuration_option(provider=toml_provider)
     clc = click_option(self.Dummy())
     self.assertEqual(clc.__click_params__[0].is_eager, True)
     self.assertEqual(
         clc.__click_params__[0].help,
         "This is a hidden click option whose callback function loads configuration parameters.",
     )
     self.assertEqual(clc.__click_params__[0].hidden, True)
     self.assertEqual(clc.__click_params__[0].expose_value, False)
     self.assertEqual(clc.__click_params__[0].callback.args,
                      (None, None, None, toml_provider))
Пример #2
0
    def get_command(self, ctx, cmd_name):

        """
        gets the Click Commands underneath a service name

        Parameters
        ----------
        ctx: Context
            context object passed in
        cmd_name: string
            the service name
        Returns
        -------
        cmd: Click.Command
            the Click Commands that can be called from the CLI
        """

        if cmd_name not in self.subcmd_definition:
            return None
        parameters = []
        for param_name in self.subcmd_definition[cmd_name][self.TAGS].keys():
            default = self.subcmd_definition[cmd_name][self.TAGS][param_name]["default"]
            parameters.append(
                click.Option(
                    ["--{}".format(param_name)],
                    default=default,
                    help="Specify the {} name you'd like, otherwise the default = {}".format(param_name, default),
                )
            )

        command_callback = functools.partial(
            self.cmd_implementation, self.events_lib, self.top_level_cmd_name, cmd_name
        )

        config = get_ctx_defaults(
            cmd_name=cmd_name,
            provider=TomlProvider(section="parameters"),
            ctx=ctx,
            config_env_name=samconfig.DEFAULT_ENV,
        )

        cmd = click.Command(
            name=cmd_name,
            short_help=self.subcmd_definition[cmd_name]["help"],
            context_settings={"default_map": config},
            params=parameters,
            callback=command_callback,
        )

        cmd = debug_option(cmd)
        return cmd
Пример #3
0
 your file system containing the Lambda Function code. This could be the project's root directory for interpreted
 languages like Node & Python, or a build directory that stores your compiled artifacts or a JAR file. If you are using
 a interpreted language, local changes will be available immediately in Docker container on every invoke. For more
 compiled languages or projects requiring complex packing support, we recommended you run your own building solution
and point SAM to the directory or file containing build artifacts.
"""


@click.command(
    "start-api",
    help=HELP_TEXT,
    short_help=
    "Sets up a local endpoint you can use to test your API. Supports hot-reloading "
    "so you don't need to restart this service when you make changes to your function.",
)
@configuration_option(provider=TomlProvider(section="parameters"))
@service_common_options(3000)
@click.option(
    "--static-dir",
    "-s",
    default="public",
    help=
    "Any static assets (e.g. CSS/Javascript/HTML) files located in this directory "
    "will be presented at /",
)
@invoke_common_options
@warm_containers_common_options
@cli_framework_options
@aws_creds_options  # pylint: disable=R0914
@pass_context
@track_command
Пример #4
0
 def test_toml_valid_with_invalid_version(self):
     config_dir = tempfile.gettempdir()
     configpath = Path(config_dir, "samconfig.toml")
     configpath.write_text("version='abc'\n[config_env.topic.parameters]\nword='clarity'\n")
     with self.assertRaises(ConfigException):
         TomlProvider(section=self.parameters)(config_dir, self.config_env, [self.cmd_name])
Пример #5
0
 def setUp(self):
     self.toml_provider = TomlProvider()
     self.config_env = "config_env"
     self.parameters = "parameters"
     self.cmd_name = "topic"
CONFIG_SECTION = "parameters"
LOG = logging.getLogger(__name__)


@click.command(
    "deploy",
    short_help=SHORT_HELP,
    context_settings={
        "ignore_unknown_options": False,
        "allow_interspersed_args": True,
        "allow_extra_args": True
    },
    help=HELP_TEXT,
)
@configuration_option(provider=TomlProvider(section=CONFIG_SECTION))
@click.option(
    "--guided",
    "-g",
    required=False,
    is_flag=True,
    is_eager=True,
    help=
    "Specify this flag to allow SAM CLI to guide you through the deployment using guided prompts.",
)
@template_click_option(include_build=True)
@click.option(
    "--stack-name",
    required=False,
    callback=guided_deploy_stack_name,
    help="The name of the AWS CloudFormation stack you're deploying to. "