-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Install awx collection from branch for operator ci
- Loading branch information
1 parent
6195e8e
commit 6ff000f
Showing
2 changed files
with
40 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import yaml | ||
import sys | ||
|
||
|
||
AWX_ENTRY = 'https://github.com/ansible/awx.git#/awx_collection/' | ||
|
||
|
||
def load_yaml_file(fname): | ||
with open(fname, 'r') as file: | ||
data = yaml.safe_load(file) | ||
return data | ||
|
||
|
||
def write_yaml_file(fname, data): | ||
with open(fname, 'w') as file: | ||
yaml.dump(data, file) | ||
|
||
|
||
def replace_awx(data, path): | ||
for entry in data['collections']: | ||
if entry['name'] == AWX_ENTRY: | ||
entry['name'] = f'file://{path}#/awx_collection/' | ||
del entry['version'] | ||
return data | ||
|
||
raise ValueError(f"Failed to find {AWX_ENTRY} in {data}") | ||
|
||
|
||
def run(fname, awx_path): | ||
write_yaml_file(fname, replace_awx(load_yaml_file(fname), awx_path)) | ||
|
||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) == 3: | ||
run(sys.argv[1], sys.argv[2]) | ||
else: | ||
print(f"Usage: {sys.argv[0]} <awx-operator-molecule-requirements.yml> <awx-git-path>", file=sys.stderr) |