diff options
author | Krzysztof Kuzmicki <krzysztof.kuzmicki@nokia.com> | 2021-09-02 09:39:44 +0200 |
---|---|---|
committer | Krzysztof Kuzmicki <krzysztof.kuzmicki@nokia.com> | 2021-10-01 14:23:46 +0000 |
commit | 5522f4473bc6f0256744b10f76a3ac3e06b8e654 (patch) | |
tree | bc1d029718672c0b60c2d8ab1bb0b6ff012f3181 /external-schema-repo-generator/generator/utils.sh | |
parent | 1898455d2fdd4c4f1f4914119e123babed60ce61 (diff) |
[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 <krzysztof.kuzmicki@nokia.com>
Issue-ID: DCAEGEN2-2893 DCAEGEN2-2894 DCAEGEN2-2895
Change-Id: Ia55e2fb29eb2fa6575821f12af5e22f0f1d8ff5a
Diffstat (limited to 'external-schema-repo-generator/generator/utils.sh')
-rw-r--r-- | external-schema-repo-generator/generator/utils.sh | 23 |
1 files changed, 23 insertions, 0 deletions
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) +} |