diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b0911000..5749e760 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -108,7 +108,7 @@ jobs: path: | ~/python ~/ssl - key: ${{ matrix.os }}-${{ matrix.jid }}-20210325 + key: ${{ matrix.os }}-${{ matrix.jid }}-20210407 - name: Set env variables env: diff --git a/src/gam/gapi/chromehistory.py b/src/gam/gapi/chromehistory.py index 9fe5a06f..cf1a9a9e 100644 --- a/src/gam/gapi/chromehistory.py +++ b/src/gam/gapi/chromehistory.py @@ -30,7 +30,7 @@ CHROME_PLATFORM_CHOICE_MAP = { 'linux': 'linux', 'mac': 'mac', 'macarm64': 'mac_arm64', - 'sebview': 'webview', + 'webview': 'webview', 'win': 'win', 'win64': 'win64', } diff --git a/src/gam/gapi/chromepolicy.py b/src/gam/gapi/chromepolicy.py index 6b9e644d..f8ffeb1e 100644 --- a/src/gam/gapi/chromepolicy.py +++ b/src/gam/gapi/chromepolicy.py @@ -1,5 +1,6 @@ """Chrome Browser Cloud Management API calls""" +import re import sys import googleapiclient.errors @@ -300,11 +301,22 @@ def update_policy(): elif vtype in ['TYPE_LIST']: value = value.split(',') if myarg == 'chrome.users.chromebrowserupdates' and \ - cased_field == 'targetVersionPrefixSetting': - if value.find('-') != -1: - channel, minus = value.split('-') - milestone = gapi_chromehistory.get_relative_milestone(channel, int(minus)) - value = f'{milestone}.' + cased_field == 'targetVersionPrefixSetting': + mg = re.compile(r'^([a-z]+)-(\d+)$').match(value) + if mg: + channel = mg.group(1).lower().replace('_', '') + minus = mg.group(2) + if channel not in gapi_chromehistory.CHROME_CHANNEL_CHOICE_MAP: + expected_channels = ', '.join(gapi_chromehistory.CHROME_CHANNEL_CHOICE_MAP) + msg = f'Expected {myarg} {cased_field} channel to be one of ' \ + f'{expected_channels}, got {channel}' + controlflow.system_error_exit(8, msg) + milestone = gapi_chromehistory.get_relative_milestone( + gapi_chromehistory.CHROME_CHANNEL_CHOICE_MAP[channel], int(minus)) + if not milestone: + msg = f'{myarg} {cased_field} channel {channel} offset {minus} does not exist' + controlflow.system_error_exit(8, msg) + value = f'{milestone}.' body['requests'][-1]['policyValue']['value'][cased_field] = value body['requests'][-1]['updateMask'] += f'{cased_field},' i += 2