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

Mgmt-Lite: update suffix parameters during runtime #17861

Merged
merged 3 commits into from
Nov 27, 2020
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
16 changes: 16 additions & 0 deletions eng/mgmt/automation/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ def parse_args() -> argparse.Namespace:
action = 'store_true',
help = 'Do compile after generation or not',
)
parser.add_argument('--suffix', help = 'Suffix for namespace and artifact')
parser.add_argument(
'--auto-commit-external-change',
action = 'store_true',
Expand All @@ -340,6 +341,20 @@ def parse_args() -> argparse.Namespace:
return parser.parse_args()


def update_parameters(suffix):
# update changeable parameters in parameters.py
global SUFFIX, NAMESPACE_SUFFIX, ARTIFACT_SUFFIX, NAMESPACE_FORMAT, ARTIFACT_FORMAT, OUTPUT_FOLDER_FORMAT

SUFFIX = suffix

NAMESPACE_SUFFIX = '.{0}'.format(SUFFIX) if SUFFIX else ''
ARTIFACT_SUFFIX = '-{0}'.format(SUFFIX) if SUFFIX else ''
NAMESPACE_FORMAT = 'com.azure.resourcemanager.{{0}}{0}'.format(
NAMESPACE_SUFFIX)
ARTIFACT_FORMAT = 'azure-resourcemanager-{{0}}{0}'.format(ARTIFACT_SUFFIX)
OUTPUT_FOLDER_FORMAT = 'sdk/{{0}}/{0}'.format(ARTIFACT_FORMAT)


def valid_service(service: str):
return re.sub('[^a-z0-9_]', '', service.lower())

Expand Down Expand Up @@ -458,6 +473,7 @@ def sdk_automation(input_file: str, output_file: str):

def main():
args = vars(parse_args())
update_parameters(args.get('suffix'))

if args.get('config'):
return sdk_automation(args['config'][0], args['config'][1])
Expand Down
18 changes: 12 additions & 6 deletions eng/mgmt/automation/parameters.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
#!/usr/bin/env python3

# changeable parameters
# use update logic in generate.py#update_parameters
# set to None first to guarantee it would be updated
SUFFIX = None

NAMESPACE_SUFFIX = None
ARTIFACT_SUFFIX = None
NAMESPACE_FORMAT = None
ARTIFACT_FORMAT = None
OUTPUT_FOLDER_FORMAT = None

# Constant parameters
SDK_ROOT = '../../../' # related to file dir
AUTOREST_CORE_VERSION = '3.0.6327'
AUTOREST_JAVA = '@autorest/[email protected]'
DEFAULT_VERSION = '1.0.0-beta.1'
SUFFIX = None # 'generated'
GROUP_ID = 'com.azure.resourcemanager'
API_SPECS_FILE = 'api-specs.yaml'

NAMESPACE_SUFFIX = '.{0}'.format(SUFFIX) if SUFFIX else ''
ARTIFACT_SUFFIX = '-{0}'.format(SUFFIX) if SUFFIX else ''
NAMESPACE_FORMAT = 'com.azure.resourcemanager.{{0}}{0}'.format(NAMESPACE_SUFFIX)
ARTIFACT_FORMAT = 'azure-resourcemanager-{{0}}{0}'.format(ARTIFACT_SUFFIX)
OUTPUT_FOLDER_FORMAT = 'sdk/{{0}}/{0}'.format(ARTIFACT_FORMAT)
CI_FILE_FORMAT = 'sdk/{0}/ci.yml'
POM_FILE_FORMAT = 'sdk/{0}/pom.xml'
README_FORMAT = 'specification/{0}/resource-manager/readme.md'
Expand Down