Skip to content

Commit

Permalink
Merge pull request #9 from MarkWarneke/dev
Browse files Browse the repository at this point in the history
Move cli creation into function
  • Loading branch information
MarkWarneke authored Mar 14, 2021
2 parents 80c3802 + 01fcbf3 commit 7e89ca8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Install the package
pip install az.cli
```

Login using `az login`, see [sign in using a service principal](https://docs.microsoft.com/en-us/cli/azure/create-an-azure-service-principal-azure-cli?view=azure-cli-latest#sign-in-using-a-service-principalt).
Login using `az login` or [sign in using a service principal](https://docs.microsoft.com/en-us/cli/azure/create-an-azure-service-principal-azure-cli?view=azure-cli-latest#sign-in-using-a-service-principalt).

Under the hood the package uses the [~/.azure](https://github.com/Azure/azure-cli/blob/dev/src/azure-cli-core/azure/cli/core/_environment.py) folder to persist and retrieve config.

Expand Down
6 changes: 3 additions & 3 deletions src/az/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# Based on https://github.com/Azure/azure-cli/blob/dev/src/azure-cli-core/azure/cli/core/__init__.py
# commit 8e369b9d2d63ddf5c6678ee710905bf9e5028f99
# --------------------------------------------------------------------------------------------

import sys
from io import StringIO
import json
Expand All @@ -16,8 +15,6 @@
from azure.cli.core import get_default_cli
from knack.log import CLI_LOGGER_NAME

# Create default shell to run commands
_cli = get_default_cli()

AzResult = namedtuple('AzResult', ['exit_code', 'result_dict', 'log'])

Expand Down Expand Up @@ -59,6 +56,9 @@ def az(command):
:return: a named tuple consisting of exit_code, out and log
"""

# Create default shell to run commands
_cli = get_default_cli()

# Create string buffer to get the result and logs
stdout_buf = StringIO()
log_buf = StringIO()
Expand Down
3 changes: 2 additions & 1 deletion tests/az_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@

def test_az(az_login):
error_code, result_dict, log = az(AZ_SUCCESSFUL_COMMAND)
assert error_code == 0
assert log == ""
assert error_code == 0



def test_az_failure(az_login):
Expand Down

0 comments on commit 7e89ca8

Please sign in to comment.