-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
inputs: allow to override repo ref with sha1 form store
- Loading branch information
1 parent
3affab4
commit bc0e535
Showing
5 changed files
with
100 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import requests | ||
import json | ||
|
||
STORE_API = "https://appstore.aws.prd.ldg-tech.com" | ||
|
||
|
||
def fetch_data_from_api(): | ||
request_headers = {'Content-Type': 'application/json'} | ||
r = requests.get(STORE_API + '/api/applications', headers=request_headers) | ||
|
||
store_app_list = json.loads(r.text) | ||
return store_app_list | ||
|
||
|
||
def get_sha1(live_json: dict, provider: str, device: str, version: str): | ||
for version_json in live_json["application_versions"]: | ||
pattern = f"{device}/{version}/" | ||
|
||
if version_json["firmware"].startswith(pattern): | ||
if int(provider) in version_json["providers"]: | ||
return version_json["sha1"] | ||
return | ||
|
||
|
||
def override_sha1(input_json: dict, provider: str, device: str, version: str): | ||
live_json = fetch_data_from_api() | ||
|
||
for app_json in input_json: | ||
for live_app_json in live_json: | ||
if app_json["url"] == live_app_json["sourceURL"]: | ||
sha1 = get_sha1(live_app_json, provider, device, version) | ||
if sha1: | ||
app_json["ref"] = sha1 | ||
break | ||
|
||
return input_json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import subprocess | ||
import shutil | ||
from pathlib import Path | ||
|
||
|
||
|
@@ -37,12 +38,22 @@ def git_setup(repo_name: str, repo_ref: str, repo_url: str, workdir: Path): | |
GIT_CONFIG = ' -c url."https://github.com/".insteadOf="[email protected]:" -c url."https://".insteadOf="git://"' | ||
|
||
if not Path.exists(workdir/Path(repo_name)): | ||
run_cmd(f"git {GIT_CONFIG} clone {repo_url} --recurse-submodules {repo_name}", cwd=workdir) | ||
run_cmd(f"git {GIT_CONFIG} clone {repo_url} {repo_name}", cwd=workdir) | ||
else: | ||
run_cmd(f"git fetch", cwd=workdir/Path(repo_name)) | ||
|
||
run_cmd(f"git checkout {repo_ref}", cwd=workdir/Path(repo_name)) | ||
run_cmd("git submodule update --recursive", cwd=workdir/Path(repo_name)) | ||
error, _ = run_cmd(f"git checkout {repo_ref}", cwd=workdir/Path(repo_name), no_throw=True) | ||
if error: | ||
print("Error: removing folder") | ||
shutil.rmtree(workdir/Path(repo_name)) | ||
return | ||
|
||
error, _ = run_cmd(f"git {GIT_CONFIG} submodule update --init --recursive", cwd=workdir/Path(repo_name), no_throw=True) | ||
if error: | ||
print("Error: removing folder") | ||
shutil.rmtree(workdir/Path(repo_name)) | ||
return | ||
|
||
|
||
def merge_json(json1: dict, json2: dict, key: str): | ||
merged_data = [] | ||
|