From 5522f4473bc6f0256744b10f76a3ac3e06b8e654 Mon Sep 17 00:00:00 2001 From: Krzysztof Kuzmicki Date: Thu, 2 Sep 2021 09:39:44 +0200 Subject: [UTILS] Fix and resolve remote references in standard defined domain Add functionality to scripts that: - Looks in cloned schema file for remote refs. - Downloads remote refs to schema directory - Splits schema directory directories less than 1mb - Replace remote and local refs locations with local locations and current directory structure - Creates for each directory separate configmap less than 1mb Signed-off-by: Krzysztof Kuzmicki Issue-ID: DCAEGEN2-2893 DCAEGEN2-2894 DCAEGEN2-2895 Change-Id: Ia55e2fb29eb2fa6575821f12af5e22f0f1d8ff5a --- external-schema-repo-generator/generator/utils.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'external-schema-repo-generator/generator/utils.sh') diff --git a/external-schema-repo-generator/generator/utils.sh b/external-schema-repo-generator/generator/utils.sh index de32515..fad8616 100644 --- a/external-schema-repo-generator/generator/utils.sh +++ b/external-schema-repo-generator/generator/utils.sh @@ -24,6 +24,7 @@ EXPECTED_1_ARG=1 EXPECTED_2_ARGS=2 EXPECTED_4_ARGS=4 EXPECTED_9_ARGS=9 +EXPECTED_10_ARGS=10 # Checks whether number of arguments is valid @@ -41,3 +42,25 @@ move_to_starting_directory() { echo "Moving back to: $starting_directory" cd $starting_directory } + +fix_schema_references(){ + schemas=$(grep -Eo "http.*[^\/]+(.yaml)" $1/$2-*/$3/* | sort -u) + for schema in $schemas; do + schemaFilePath=$(echo "$schema" | awk -F ":https:" '{print $1}') + remotePath=$(echo "$schema" | awk -F ".yaml:" '{print $2}') + fileName=$(echo "$remotePath" | grep -Eo "([^/]\w*.yaml)") + sed -i "s%${remotePath}%${fileName}%g" $schemaFilePath + done + schemas=$(grep -Eo "(\w*.yaml)" $1/$2-*/$3/* | sort -u) + for schema in $schemas; do + schemaFilePath=$(echo "$schema" | awk -F ":" '{print $1}') + wrongPath=$(echo "$schema" | awk -F ".yaml:" '{print $2}') + fileName="../..$(ls -d $1/$2-*/$3/* | grep $wrongPath | awk -F "$1" '{print $2}')" + sed -i "s%${wrongPath}%${fileName}%g" $schemaFilePath + done +} + + +check5GApiBranchExistenceInRefs () { + echo $(sed -n '/5G_APIs/p' $1/*.yaml | awk -F "raw/|blob/" '{print $2}' | awk -F "/" '{print $1}' | uniq) +} -- cgit 1.2.3-korg