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

Expand parameter overrides #7876

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Support file:// for parameter-overrides
  • Loading branch information
sigJoe committed Feb 5, 2025
commit 77bc0959d4df57be70463dcb227836c6a46fbf78
15 changes: 15 additions & 0 deletions samcli/cli/types.py
Original file line number Diff line number Diff line change
@@ -6,10 +6,12 @@
import logging
import re
from json import JSONDecodeError
from pathlib import Path
from typing import Dict, List, Optional, Union

import click

from samcli.lib.config.file_manager import FILE_MANAGER_MAPPER
from samcli.lib.package.ecr_utils import is_ecr_url

PARAM_AND_METADATA_KEY_REGEX = """([A-Za-z0-9\\"\']+)"""
@@ -97,6 +99,19 @@ def convert(self, value, param, ctx):

value = (value,) if isinstance(value, str) else value
for val in value:
if val.startswith('file://'):
filepath = Path(val[7:])
if not filepath.is_file():
return self.fail(f"{val} was not found or is a directory", param, ctx)
file_manager = FILE_MANAGER_MAPPER.get(filepath.suffix, None)
if not file_manager:
return self.fail(f"{val} uses an unsupported extension", param, ctx)
try:
parameters = file_manager.read(filepath)
except Exception as e:
return self.fail(str(e), param, ctx)
result |= parameters
continue
# Add empty string to start of the string to help match `_pattern2`
normalized_val = " " + val.strip()