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

Regression fix for knack config file chaining functionality #577

Merged
merged 5 commits into from
May 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 2 additions & 6 deletions .azure-pipelines/templates/install-azure-cli-edge.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
steps:
# commented out for now because DevOps CLI is broken with latest Azure CLI build
# - script: 'pip install --pre azure-cli --extra-index-url https://azurecliprod.blob.core.windows.net/edge'
# displayName: 'Install Azure CLI Edge'

- script: pip install azure-cli
displayName: 'Install Azure CLI released version (in place of edge due to active bug)'
- script: 'pip install --pre azure-cli --extra-index-url https://azurecliprod.blob.core.windows.net/edge'
displayName: 'Install Azure CLI Edge'
21 changes: 2 additions & 19 deletions azure-devops/azext_devops/dev/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
# --------------------------------------------------------------------------------------------

import os
import stat
from six.moves import configparser

from knack.config import CLIConfig, get_config_parser
from knack.util import ensure_dir
Expand Down Expand Up @@ -39,24 +37,9 @@ def __init__(self, config_dir=AZ_DEVOPS_GLOBAL_CONFIG_DIR, config_env_var_prefix
azdevops_config.config_parser.read(AZ_DEVOPS_GLOBAL_CONFIG_PATH)


def set_global_config(config):
ensure_dir(AZ_DEVOPS_GLOBAL_CONFIG_DIR)
with open(AZ_DEVOPS_GLOBAL_CONFIG_PATH, 'w') as configfile:
config.write(configfile)
os.chmod(AZ_DEVOPS_GLOBAL_CONFIG_PATH, stat.S_IRUSR | stat.S_IWUSR)
# reload config
azdevops_config.config_parser.read(AZ_DEVOPS_GLOBAL_CONFIG_PATH)


def set_global_config_value(section, option, value):
config = get_config_parser()
config.read(AZ_DEVOPS_GLOBAL_CONFIG_PATH)
try:
config.add_section(section)
except configparser.DuplicateSectionError:
pass
config.set(section, option, _normalize_config_value(value))
set_global_config(config)
azdevops_config.set_value(section, option, _normalize_config_value(value))
azdevops_config.config_parser.read(AZ_DEVOPS_GLOBAL_CONFIG_PATH)


def _normalize_config_value(value):
Expand Down
2 changes: 1 addition & 1 deletion azure-devops/azext_devops/dev/team/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def print_current_configuration(file_config=None):
env_vars = [ev for ev in os.environ if ev.startswith(CLI_ENV_VARIABLE_PREFIX)]
if env_vars:
print(MSG_HEADING_ENV_VARS)
print('\n'.join(['{} = {}'.format(ev, os.environ[ev]) for ev in env_vars]))
print('\n'.join(['{}'.format(ev) for ev in env_vars]))


MSG_INTRO = '\nWelcome to the Azure DevOps CLI! This command will guide you through setting some default values.\n'
Expand Down