From 03fe7ffa045244ce45c511cc49ea5751afb54fcd Mon Sep 17 00:00:00 2001 From: strahi-linux Date: Wed, 25 Dec 2024 11:39:02 +0100 Subject: [PATCH] Added legacy indexing --- .github/workflows/checkIndexes.yaml | 3 +++ scripts/check_indexes.py | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/checkIndexes.yaml b/.github/workflows/checkIndexes.yaml index 84ada7953..ae725ce22 100644 --- a/.github/workflows/checkIndexes.yaml +++ b/.github/workflows/checkIndexes.yaml @@ -28,6 +28,9 @@ on: env: GLOBAL_REGEX: "images_sdk|templates|mikrosdk|easy|flip|mcucard|mcu_card|click|mikromedia|pim|queries|sibrain|kit|board" + ES_HOST_LEGACY: ${{ secrets.ES_HOST_LEGACY }} + ES_USER_LEGACY: ${{ secrets.ES_USER_LEGACY }} + ES_PASSWORD_LEGACY: ${{ secrets.ES_PASSWORD_LEGACY }} jobs: manual_run: diff --git a/scripts/check_indexes.py b/scripts/check_indexes.py index 034a6e409..a5c9a8259 100644 --- a/scripts/check_indexes.py +++ b/scripts/check_indexes.py @@ -1,9 +1,12 @@ -import sys, json, argparse, requests +import os, sys, json, argparse, requests import classes.class_gh as gh import classes.class_es as es import add_extra_index_info as extra_info +# Legacy packages for NECTO version 7.0.4 and lower +legacy_packages = ["clocks", "schemas", "database", "images", "images_sdk"] + if __name__ == "__main__": # First, check for arguments passed def str2bool(v): @@ -34,6 +37,12 @@ def str2bool(v): index=args.es_index, token=args.gh_token ) + if 'ES_HOST_LEGACY' in os.environ and 'ES_USER_LEGACY' in os.environ and 'ES_PASSWORD_LEGACY': + es_instance_legacy = es.index( + es_host=os.environ['ES_HOST_LEGACY'], es_user=os.environ['ES_USER_LEGACY'], es_password=os.environ['ES_PASSWORD_LEGACY'], + index=args.es_index, token=args.gh_token + ) + gh_instance = gh.repo(args.gh_repo, args.gh_token) es_instance.fetch(regex=args.es_regex) @@ -80,5 +89,10 @@ def str2bool(v): es_instance.update(None, indexed_item['doc']['id'], indexed_item['source']) print("%sOK: Asset \"%s\" download link is correct. - %s" % (es_instance.Colors.OKBLUE, indexed_item['source']['name'], indexed_item['source']['download_link'])) + if 'ES_HOST_LEGACY' in os.environ and 'ES_USER_LEGACY' in os.environ and 'ES_PASSWORD_LEGACY': + if indexed_item['source']['name'] in legacy_packages: + es_instance_legacy.update('necto_package', indexed_item['doc']['id'], indexed_item['source']) + print("%sOK: \"%s\" indexed for legacy NECTO." % (es_instance_legacy.Colors.OKGREEN, indexed_item['source']['name'])) + if err and args.log_only: sys.exit(-1)