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

Correctly set ExactArgs if generated command has positional arguments #488

Merged
merged 5 commits into from
Jun 16, 2023

Conversation

andrewnester
Copy link
Contributor

@andrewnester andrewnester commented Jun 16, 2023

Changes

Some of the command such as databricks alerts create require positional arguments which are not primitive.

Since these arguments are required, we should correctly set ExactArgs for such commands

Fixes #367

Tests

Running databricks alerts create

Before

andrew.nester@HFW9Y94129 cli % ./cli alerts create                     
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/databricks/bricks/cmd/workspace/alerts.glob..func1(0x22a1280?, {0x2321638, 0x0, 0x0?})
	github.com/databricks/bricks/cmd/workspace/alerts/alerts.go:57 +0x355
github.com/spf13/cobra.(*Command).execute(0x22a1280, {0x2321638, 0x0, 0x0})
	github.com/spf13/cobra@v1.7.0/command.go:940 +0x862
github.com/spf13/cobra.(*Command).ExecuteC(0x22a0700)
	github.com/spf13/cobra@v1.7.0/command.go:1068 +0x3bd
github.com/spf13/cobra.(*Command).ExecuteContextC(...)
	github.com/spf13/cobra@v1.7.0/command.go:1001
github.com/databricks/bricks/cmd/root.Execute()
	github.com/databricks/bricks/cmd/root/root.go:80 +0x6a
main.main()
	github.com/databricks/bricks/main.go:18 +0x17                                           

After

andrew.nester@HFW9Y94129 cli % ./cli alerts create                                                                
Error: provide command input in JSON format by specifying --json option

Acceptance test

=== RUN   TestAccAlertsCreateErrWhenNoArguments
    alerts_test.go:10: gcp
    helpers.go:147: Error running command: provide command input in JSON format by specifying --json option
--- PASS: TestAccAlertsCreateErrWhenNoArguments (1.99s)
PASS

@andrewnester andrewnester enabled auto-merge (squash) June 16, 2023 12:07
.codegen/service.go.tmpl Outdated Show resolved Hide resolved
Co-authored-by: Pieter Noordhuis <pieter.noordhuis@databricks.com>
@andrewnester andrewnester merged commit 9cf0e0d into main Jun 16, 2023
4 checks passed
@andrewnester andrewnester deleted the pos-arguments branch June 16, 2023 12:19
@pietern pietern mentioned this pull request Jun 20, 2023
pietern added a commit that referenced this pull request Jun 20, 2023
## Changes

This version marks the first version available as public preview.

The minor bump to 200 better disambiguates between Databricks CLI "v1" (the Python version)
and this version, Databricks CLI "v2". The minor version of 0.100 may look lower than 0.17
to some, whereas 200 does not. This bump has no other significance.

CLI:
* Add filer.Filer implementation backed by the Files API ([#474](#474)).
* Add fs cp command ([#463](#463)).
* Correctly set ExactArgs if generated command has positional arguments ([#488](#488)).
* Do not use white color as string output ([#489](#489)).
* Update README to reflect public preview status ([#491](#491)).

Bundles:
* Fix force flag not working for bundle destroy ([#434](#434)).
* Fix locker unlock for destroy ([#492](#492)).
* Use better error assertions and clean up locker API ([#490](#490)).

Dependencies:
* Bump golang.org/x/mod from 0.10.0 to 0.11.0 ([#496](#496)).
* Bump golang.org/x/sync from 0.2.0 to 0.3.0 ([#495](#495)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Bricks is crashing when trying to create an Alert without any parameters
2 participants