Skip to content

Commit

Permalink
Merge pull request #189 from MikroElektronika/topic/legacy-index
Browse files Browse the repository at this point in the history
Added legacy indexing
  • Loading branch information
StrahinjaJacimovic authored Dec 25, 2024
2 parents 67d8108 + 03fe7ff commit 0d4150b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/checkIndexes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 15 additions & 1 deletion scripts/check_indexes.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

0 comments on commit 0d4150b

Please sign in to comment.