Skip to content

Commit b4fd894

Browse files
rename drop-version to drop-deployment. SQL unchanged (#2520)
1 parent 0f21d19 commit b4fd894

File tree

6 files changed

+153
-16
lines changed

6 files changed

+153
-16
lines changed

src/snowflake/cli/_plugins/dcm/commands.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def list_deployments(
207207

208208

209209
@app.command(requires_connection=True)
210-
def drop_version(
210+
def drop_deployment(
211211
identifier: FQN = dcm_identifier,
212212
version_name: str = typer.Argument(
213213
help="Name or alias of the version to drop. For names containing '$', use single quotes to prevent shell expansion (e.g., 'VERSION$1').",
@@ -227,7 +227,7 @@ def drop_version(
227227
)
228228

229229
dpm = DCMProjectManager()
230-
dpm.drop_version(
230+
dpm.drop_deployment(
231231
project_name=identifier,
232232
version_name=version_name,
233233
if_exists=if_exists,

src/snowflake/cli/_plugins/dcm/manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def list_versions(self, project_name: FQN):
8080
query = f"SHOW VERSIONS IN DCM PROJECT {project_name.identifier}"
8181
return self.execute_query(query=query)
8282

83-
def drop_version(
83+
def drop_deployment(
8484
self,
8585
project_name: FQN,
8686
version_name: str,

tests/__snapshots__/test_help_messages.ambr

Lines changed: 137 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7485,6 +7485,141 @@
74857485
+------------------------------------------------------------------------------+
74867486

74877487

7488+
'''
7489+
# ---
7490+
# name: test_help_messages[dcm.drop-deployment]
7491+
'''
7492+
7493+
Usage: root dcm drop-deployment [OPTIONS] IDENTIFIER VERSION_NAME
7494+
7495+
Drops a version from the DCM Project.
7496+
7497+
7498+
+- Arguments ------------------------------------------------------------------+
7499+
| * identifier TEXT Identifier of the DCM Project; for example: |
7500+
| MY_PROJECT |
7501+
| [required] |
7502+
| * version_name TEXT Name or alias of the version to drop. For names |
7503+
| containing '$', use single quotes to prevent |
7504+
| shell expansion (e.g., 'VERSION$1'). |
7505+
| [required] |
7506+
+------------------------------------------------------------------------------+
7507+
+- Options --------------------------------------------------------------------+
7508+
| --if-exists Do nothing if the version does not exist. |
7509+
| --help -h Show this message and exit. |
7510+
+------------------------------------------------------------------------------+
7511+
+- Connection configuration ---------------------------------------------------+
7512+
| --connection,--environment -c TEXT Name of the connection, as |
7513+
| defined in your config.toml |
7514+
| file. Default: default. |
7515+
| --host TEXT Host address for the |
7516+
| connection. Overrides the |
7517+
| value specified for the |
7518+
| connection. |
7519+
| --port INTEGER Port for the connection. |
7520+
| Overrides the value specified |
7521+
| for the connection. |
7522+
| --account,--accountname TEXT Name assigned to your |
7523+
| Snowflake account. Overrides |
7524+
| the value specified for the |
7525+
| connection. |
7526+
| --user,--username TEXT Username to connect to |
7527+
| Snowflake. Overrides the |
7528+
| value specified for the |
7529+
| connection. |
7530+
| --password TEXT Snowflake password. Overrides |
7531+
| the value specified for the |
7532+
| connection. |
7533+
| --authenticator TEXT Snowflake authenticator. |
7534+
| Overrides the value specified |
7535+
| for the connection. |
7536+
| --private-key-file,--privat… TEXT Snowflake private key file |
7537+
| path. Overrides the value |
7538+
| specified for the connection. |
7539+
| --token TEXT OAuth token to use when |
7540+
| connecting to Snowflake. |
7541+
| --token-file-path TEXT Path to file with an OAuth |
7542+
| token to use when connecting |
7543+
| to Snowflake. |
7544+
| --database,--dbname TEXT Database to use. Overrides |
7545+
| the value specified for the |
7546+
| connection. |
7547+
| --schema,--schemaname TEXT Database schema to use. |
7548+
| Overrides the value specified |
7549+
| for the connection. |
7550+
| --role,--rolename TEXT Role to use. Overrides the |
7551+
| value specified for the |
7552+
| connection. |
7553+
| --warehouse TEXT Warehouse to use. Overrides |
7554+
| the value specified for the |
7555+
| connection. |
7556+
| --temporary-connection -x Uses a connection defined |
7557+
| with command line parameters, |
7558+
| instead of one defined in |
7559+
| config |
7560+
| --mfa-passcode TEXT Token to use for multi-factor |
7561+
| authentication (MFA) |
7562+
| --enable-diag Whether to generate a |
7563+
| connection diagnostic report. |
7564+
| --diag-log-path TEXT Path for the generated |
7565+
| report. Defaults to system |
7566+
| temporary directory. |
7567+
| --diag-allowlist-path TEXT Path to a JSON file that |
7568+
| contains allowlist |
7569+
| parameters. |
7570+
| --oauth-client-id TEXT Value of client id provided |
7571+
| by the Identity Provider for |
7572+
| Snowflake integration. |
7573+
| --oauth-client-secret TEXT Value of the client secret |
7574+
| provided by the Identity |
7575+
| Provider for Snowflake |
7576+
| integration. |
7577+
| --oauth-authorization-url TEXT Identity Provider endpoint |
7578+
| supplying the authorization |
7579+
| code to the driver. |
7580+
| --oauth-token-request-url TEXT Identity Provider endpoint |
7581+
| supplying the access tokens |
7582+
| to the driver. |
7583+
| --oauth-redirect-uri TEXT URI to use for authorization |
7584+
| code redirection. |
7585+
| --oauth-scope TEXT Scope requested in the |
7586+
| Identity Provider |
7587+
| authorization request. |
7588+
| --oauth-disable-pkce Disables Proof Key for Code |
7589+
| Exchange (PKCE). Default: |
7590+
| False. |
7591+
| --oauth-enable-refresh-toke… Enables a silent |
7592+
| re-authentication when the |
7593+
| actual access token becomes |
7594+
| outdated. Default: False. |
7595+
| --oauth-enable-single-use-r… Whether to opt-in to |
7596+
| single-use refresh token |
7597+
| semantics. Default: False. |
7598+
| --client-store-temporary-cr… Store the temporary |
7599+
| credential. |
7600+
+------------------------------------------------------------------------------+
7601+
+- Global configuration -------------------------------------------------------+
7602+
| --format [TABLE|JSON|JSON_EXT| Specifies the output |
7603+
| CSV] format. |
7604+
| [default: TABLE] |
7605+
| --verbose -v Displays log entries |
7606+
| for log levels info |
7607+
| and higher. |
7608+
| --debug Displays log entries |
7609+
| for log levels debug |
7610+
| and higher; debug logs |
7611+
| contain additional |
7612+
| information. |
7613+
| --silent Turns off intermediate |
7614+
| output to console. |
7615+
| --enhanced-exit-codes Differentiate exit |
7616+
| error codes based on |
7617+
| failure type. |
7618+
| [env var: |
7619+
| SNOWFLAKE_ENHANCED_EX… |
7620+
+------------------------------------------------------------------------------+
7621+
7622+
74887623
'''
74897624
# ---
74907625
# name: test_help_messages[dcm.drop-version]
@@ -8172,7 +8307,7 @@
81728307
| deploy Applies changes defined in DCM Project to Snowflake. |
81738308
| describe Provides description of DCM Project. |
81748309
| drop Drops DCM Project with given name. |
8175-
| drop-version Drops a version from the DCM Project. |
8310+
| drop-deployment Drops a version from the DCM Project. |
81768311
| list Lists all available DCM Projects. |
81778312
| list-deployments Lists deployments of given DCM Project. |
81788313
| plan Plans a DCM Project deployment (validates without |
@@ -20820,7 +20955,7 @@
2082020955
| deploy Applies changes defined in DCM Project to Snowflake. |
2082120956
| describe Provides description of DCM Project. |
2082220957
| drop Drops DCM Project with given name. |
20823-
| drop-version Drops a version from the DCM Project. |
20958+
| drop-deployment Drops a version from the DCM Project. |
2082420959
| list Lists all available DCM Projects. |
2082520960
| list-deployments Lists deployments of given DCM Project. |
2082620961
| plan Plans a DCM Project deployment (validates without |

tests/dcm/test_commands.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def test_list_deployments(mock_pm, runner):
259259
@mock.patch(DCMProjectManager)
260260
@pytest.mark.parametrize("if_exists", [True, False])
261261
def test_drop_version(mock_pm, runner, if_exists):
262-
command = ["dcm", "drop-version", "fooBar", "v1"]
262+
command = ["dcm", "drop-deployment", "fooBar", "v1"]
263263
if if_exists:
264264
command.append("--if-exists")
265265

@@ -268,7 +268,7 @@ def test_drop_version(mock_pm, runner, if_exists):
268268
assert result.exit_code == 0, result.output
269269
assert "Version 'v1' dropped from DCM Project 'fooBar'" in result.output
270270

271-
mock_pm().drop_version.assert_called_once_with(
271+
mock_pm().drop_deployment.assert_called_once_with(
272272
project_name=FQN.from_string("fooBar"),
273273
version_name="v1",
274274
if_exists=if_exists,
@@ -293,7 +293,7 @@ def test_drop_version_shell_expansion_warning(
293293
mock_pm, runner, version_name, should_warn
294294
):
295295
"""Test that warning is displayed for version names that look like shell expansion results."""
296-
result = runner.invoke(["dcm", "drop-version", "fooBar", version_name])
296+
result = runner.invoke(["dcm", "drop-deployment", "fooBar", version_name])
297297

298298
assert result.exit_code == 0, result.output
299299

@@ -303,7 +303,7 @@ def test_drop_version_shell_expansion_warning(
303303
else:
304304
assert "might be truncated due to shell expansion" not in result.output
305305

306-
mock_pm().drop_version.assert_called_once_with(
306+
mock_pm().drop_deployment.assert_called_once_with(
307307
project_name=FQN.from_string("fooBar"),
308308
version_name=version_name,
309309
if_exists=False,

tests/dcm/test_manager.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ def test_list_versions(mock_execute_query):
149149
@pytest.mark.parametrize("if_exists", [True, False])
150150
def test_drop_version(mock_execute_query, if_exists):
151151
mgr = DCMProjectManager()
152-
mgr.drop_version(project_name=TEST_PROJECT, version_name="v1", if_exists=if_exists)
152+
mgr.drop_deployment(
153+
project_name=TEST_PROJECT, version_name="v1", if_exists=if_exists
154+
)
153155

154156
expected_query = "ALTER DCM PROJECT my_project DROP VERSION"
155157
if if_exists:

tests_integration/test_dcm_project.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def test_project_drop_version(
157157

158158
# Drop the non-existent version (should fail without --if-exists)
159159
result = runner.invoke_with_connection(
160-
["dcm", "drop-version", project_name, "VERSION$1"]
160+
["dcm", "drop-deployment", project_name, "VERSION$1"]
161161
)
162162
assert result.exit_code == 1, result.output
163163
assert "Version does not exist" in result.output
@@ -212,7 +212,7 @@ def test_project_drop_version(
212212

213213
# Drop the version by name
214214
result = runner.invoke_with_connection(
215-
["dcm", "drop-version", project_name, "VERSION$1"]
215+
["dcm", "drop-deployment", project_name, "VERSION$1"]
216216
)
217217
assert result.exit_code == 0, result.output
218218
assert (
@@ -222,7 +222,7 @@ def test_project_drop_version(
222222

223223
# Drop the version by alias
224224
result = runner.invoke_with_connection(
225-
["dcm", "drop-version", project_name, "v2"]
225+
["dcm", "drop-deployment", project_name, "v2"]
226226
)
227227
assert result.exit_code == 0, result.output
228228
assert (
@@ -235,7 +235,7 @@ def test_project_drop_version(
235235

236236
# Try to drop the default version
237237
result = runner.invoke_with_connection(
238-
["dcm", "drop-version", project_name, "VERSION$3"]
238+
["dcm", "drop-deployment", project_name, "VERSION$3"]
239239
)
240240
assert result.exit_code == 0, result.output
241241
assert (
@@ -245,14 +245,14 @@ def test_project_drop_version(
245245

246246
# Try to drop non-existent version without --if-exists (should fail)
247247
result = runner.invoke_with_connection(
248-
["dcm", "drop-version", project_name, "non_existent"]
248+
["dcm", "drop-deployment", project_name, "non_existent"]
249249
)
250250
assert result.exit_code == 1, result.output
251251
assert "Version does not exist" in result.output
252252

253253
# Try to drop non-existent version with --if-exists (should succeed)
254254
result = runner.invoke_with_connection(
255-
["dcm", "drop-version", project_name, "non_existent", "--if-exists"]
255+
["dcm", "drop-deployment", project_name, "non_existent", "--if-exists"]
256256
)
257257
assert result.exit_code == 0, result.output
258258
assert (

0 commit comments

Comments
 (0)