Denis Bilenko
2e018cfaec
Enable gofumpt and goimports in golangci-lint ( #1999 )
...
## Changes
Enable gofumpt and goimports in golangci-lint and apply autofix.
This makes 'make fmt' redundant, will be cleaned up in follow up diff.
## Tests
Existing tests.
2024-12-12 10:28:42 +01:00
Denis Bilenko
8d5351c1c3
Enable errcheck everywhere and fix or silent remaining issues ( #1987 )
...
## Changes
Enable errcheck linter for the whole codebase.
Fix remaining complaints:
- If we can propagate error to caller, do that
- If we writing to stdout, continue ignoring errors (to avoid crashing
in "cli | head" case)
- Add exception for cobra non-critical API such as
MarkHidden/MarkDeprecated/RegisterFlagCompletionFunc. This keeps current
code and behaviour, to be decided later if we want to change this.
- Continue ignoring errors where that is desired behaviour (e.g.
git.loadConfig).
- Continue ignoring errors where panicking seems riskier than ignoring
the error.
- Annotate cases in libs/dyn with //nolint:errcheck - to be addressed
later.
Note, this PR is not meant to come up with the best strategy for each
case, but to be a relative safe change to enable errcheck linter.
## Tests
Existing tests.
2024-12-11 13:26:00 +01:00
Andrew Nester
60a4a347f9
Fixed typo in error template for auth describe ( #1341 )
...
## Changes
Fixed typo in error template for auth describe
## Tests
Manually + added integration test
2024-04-08 11:19:13 +00:00
Andrew Nester
5a7405e606
Fixed message for successful auth describe run ( #1336 )
...
## Changes
Fixed message for successful auth describe run
2024-04-03 15:47:45 +00:00
Andrew Nester
8c144a2de4
Added `auth describe` command ( #1244 )
...
## Changes
This command provide details on auth configuration user is using as well
as authenticated user and auth mechanism used.
Relies on https://github.com/databricks/databricks-sdk-go/pull/838
(tests will fail until merged)
Examples of output
```
Workspace: https://test.com
User: andrew.nester@databricks.com
Authenticated with: pat
-----
Configuration:
✓ auth_type: pat
✓ host: https://test.com (from bundle)
✓ profile: DEFAULT (from --profile flag)
✓ token: ******** (from /Users/andrew.nester/.databrickscfg config file)
```
```
DATABRICKS_AUTH_TYPE=azure-msi databricks auth describe -p "Azure 2"
Unable to authenticate: inner token: Post "https://foobar.com/oauth2/token ": AADSTS900023: Specified tenant identifier foobar_aaaaaaa' is neither a valid DNS name, nor a valid external domain. See https://login.microsoftonline.com/error?code=900023
-----
Configuration:
✓ auth_type: azure-msi (from DATABRICKS_AUTH_TYPE environment variable)
✓ azure_client_id: 8470f3ba-aaaa-bbbb-cccc-xxxxyyyyzzzz (from /Users/andrew.nester/.databrickscfg config file)
~ azure_client_secret: ******** (from /Users/andrew.nester/.databrickscfg config file, not used for auth type azure-msi)
~ azure_tenant_id: foobar_aaaaaaa (from /Users/andrew.nester/.databrickscfg config file, not used for auth type azure-msi)
✓ azure_use_msi: true (from /Users/andrew.nester/.databrickscfg config file)
✓ host: https://foobar.com (from /Users/andrew.nester/.databrickscfg config file)
✓ profile: Azure 2 (from --profile flag)
```
For account
```
Unable to authenticate: default auth: databricks-cli: cannot get access token: Error: token refresh: Post "https://xxxxxxx.com/v1/token ": http 400: {"error":"invalid_request","error_description":"Refresh token is invalid"}
. Config: host=https://xxxxxxx.com , account_id=ed0ca3c5-fae5-4619-bb38-eebe04a4af4b, profile=ACCOUNT-ed0ca3c5-fae5-4619-bb38-eebe04a4af4b
-----
Configuration:
✓ account_id: ed0ca3c5-fae5-4619-bb38-eebe04a4af4b (from /Users/andrew.nester/.databrickscfg config file)
✓ auth_type: databricks-cli (from /Users/andrew.nester/.databrickscfg config file)
✓ host: https://xxxxxxxxx.com (from /Users/andrew.nester/.databrickscfg config file)
✓ profile: ACCOUNT-ed0ca3c5-fae5-4619-bb38-eebe04a4af4b
```
## Tests
Added unit tests
---------
Co-authored-by: Julia Crawford (Databricks) <julia.crawford@databricks.com>
2024-04-03 08:14:04 +00:00