diff --git a/eng/mgmt/automation/generate.py b/eng/mgmt/automation/generate.py index 1496dfbe99ee3..47437d8adc470 100755 --- a/eng/mgmt/automation/generate.py +++ b/eng/mgmt/automation/generate.py @@ -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', @@ -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()) @@ -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]) diff --git a/eng/mgmt/automation/parameters.py b/eng/mgmt/automation/parameters.py index 346ef41ceb128..004b7feb25061 100644 --- a/eng/mgmt/automation/parameters.py +++ b/eng/mgmt/automation/parameters.py @@ -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/java@4.0.5' 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'