Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
23 changes: 11 additions & 12 deletions src/datacustomcode/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,7 @@ def zip(path: str, network: str):
default=None,
help="SF CLI org alias or username. Fetches credentials via `sf org display`.",
)
@click.option(
"--use-in-feature",
default="SearchIndexChunking",
help="Feature where this function will be used.",
)
@click.option("--use-in-feature", default=None, hidden=True, deprecated=True)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We don't need this as well - right?

def deploy(
path: str,
name: str,
Expand Down Expand Up @@ -248,17 +244,20 @@ def deploy(
)

if package_type == "function":
# Try to infer use_in_feature from function signature; fall back to
# the explicit flag value (defaults to SearchIndexChunking)
# Infer use_in_feature from function signature
entrypoint_path = os.path.join(path, ENTRYPOINT_FILE)
inferred = infer_use_in_feature(entrypoint_path)
if inferred:
use_in_feature = inferred
use_in_feature = infer_use_in_feature(entrypoint_path)
if use_in_feature:
logger.info(f"Inferred use_in_feature: {use_in_feature}")
else:
logger.info(f"Using use_in_feature: {use_in_feature}")
click.secho(
"Error: Function signature does not match a supported type. "
"Use SearchIndexChunkingV1Request and "
"SearchIndexChunkingV1Response in function signature.",
fg="red",
)
raise click.Abort()

assert use_in_feature is not None
# Map feature names to Connect API names
mapped_feature = USE_IN_FEATURE_MAPPING_FOR_CONNECT_API.get(
use_in_feature, use_in_feature
Expand Down
20 changes: 0 additions & 20 deletions tests/test_sf_cli_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,26 +188,6 @@ def test_accepts_network_flag(
result = runner.invoke(deploy, [*self._BASE_ARGS, "--network", "custom"])
assert result.exit_code != 2, result.output

@patch("datacustomcode.token_provider.SFCLITokenProvider")
@patch("datacustomcode.deploy.deploy_full")
@patch("datacustomcode.cli.find_base_directory")
@patch("datacustomcode.cli.get_package_type")
def test_accepts_use_in_feature_flag(
self, mock_pkg_type, mock_find_base, mock_deploy_full, mock_sf_cli_provider
):
mock_find_base.return_value = "payload"
mock_pkg_type.return_value = "function"
mock_provider_instance = mock_sf_cli_provider.return_value
mock_provider_instance.get_token.return_value = AccessTokenResponse(
access_token="tok", instance_url="https://example.com"
)
runner = CliRunner()
result = runner.invoke(
deploy,
[*self._BASE_ARGS, "--use-in-feature", "SearchIndexChunking"],
)
assert result.exit_code != 2, result.output


class TestRunArgContract:
"""
Expand Down
Loading