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

[SNOW-1759502] New CLI options for git setup #1822

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
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
Prev Previous commit
Next Next commit
Fixes + integration test
sfc-gh-pjob committed Oct 29, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 328660551a5d2e190defc9221086d98c8d94dfe8
26 changes: 14 additions & 12 deletions src/snowflake/cli/_plugins/git/commands.py
Original file line number Diff line number Diff line change
@@ -127,7 +127,6 @@ def setup(
"--url",
help="Origin URL.",
show_default=False,
click_type=IdentifierType(),
),
no_secret: Optional[bool] = typer.Option(
False,
@@ -230,18 +229,21 @@ def setup(
)

# API integration is an account-level object
api_integration = FQN.from_string(f"{repository_name.name}_api_integration")
api_integration.set_name(
provided_api_integration_identifier
or typer.prompt(
"API integration identifier (will be created if not exists)",
default=_unique_new_object_name(
om,
object_type=ObjectType.INTEGRATION,
proposed_fqn=api_integration,
),
if provided_api_integration_identifier:
api_integration = provided_api_integration_identifier
else:
api_integration = FQN.from_string(f"{repository_name.name}_api_integration")
api_integration.set_name(
provided_api_integration_identifier
or typer.prompt(
"API integration identifier (will be created if not exists)",
default=_unique_new_object_name(
om,
object_type=ObjectType.INTEGRATION,
proposed_fqn=api_integration,
),
)
)
)

if should_create_secret:
manager.create_password_secret(
21 changes: 21 additions & 0 deletions tests_integration/test_git.py
Original file line number Diff line number Diff line change
@@ -39,6 +39,27 @@ def sf_git_repository(runner, test_database):
return repo_name


@pytest.mark.integration
def test_setup_repository_with_options(runner, test_database):
repo_name = "SNOWCLI_TESTING_REPO"
integration_name = "SNOWCLI_TESTING_REPO_API_INTEGRATION"
result = runner.invoke_with_connection(
[
"git",
"setup",
repo_name,
"--url",
"https://github.com/snowflakedb/snowflake-cli.git",
"--no-secret",
"--api-integration",
integration_name,
]
)
assert result.exit_code == 0
assert f"Git Repository {repo_name} was successfully created." in result.output
return repo_name


@pytest.mark.integration
def test_object_commands(runner, sf_git_repository):
# object list