forked from linode/terraform-provider-linode
-
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.
add/edit scripts and workflow to upload test data to obj storage (lin…
- Loading branch information
1 parent
5fb5469
commit fa9603c
Showing
3 changed files
with
137 additions
and
1 deletion.
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,37 @@ | ||
import argparse | ||
import xml.etree.ElementTree as ET | ||
|
||
# Parse command-line arguments | ||
parser = argparse.ArgumentParser(description='Modify XML with workflow information') | ||
parser.add_argument('--branch_name', required=True) | ||
parser.add_argument('--gha_run_id', required=True) | ||
parser.add_argument('--gha_run_number', required=True) | ||
parser.add_argument('--xmlfile', required=True) # Added argument for XML file path | ||
|
||
args = parser.parse_args() | ||
|
||
# Open and parse the XML file | ||
xml_file_path = args.xmlfile | ||
tree = ET.parse(xml_file_path) | ||
root = tree.getroot() | ||
|
||
# Create new elements for the information | ||
branch_name_element = ET.Element('branch_name') | ||
branch_name_element.text = args.branch_name | ||
|
||
gha_run_id_element = ET.Element('gha_run_id') | ||
gha_run_id_element.text = args.gha_run_id | ||
|
||
gha_run_number_element = ET.Element('gha_run_number') | ||
gha_run_number_element.text = args.gha_run_number | ||
|
||
# Add the new elements to the root of the XML | ||
root.append(branch_name_element) | ||
root.append(gha_run_id_element) | ||
root.append(gha_run_number_element) | ||
|
||
# Save the modified XML | ||
modified_xml_file_path = xml_file_path # Overwrite it | ||
tree.write(modified_xml_file_path) | ||
|
||
print(f'Modified XML saved to {modified_xml_file_path}') |
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,41 @@ | ||
import boto3 | ||
import sys | ||
import os | ||
from botocore.exceptions import NoCredentialsError | ||
|
||
ACCESS_KEY = os.environ.get('LINODE_CLI_OBJ_ACCESS_KEY') | ||
SECRET_KEY = os.environ.get('LINODE_CLI_OBJ_SECRET_KEY') | ||
BUCKET_NAME = 'dx-test-results' | ||
|
||
linode_obj_config = { | ||
"aws_access_key_id": ACCESS_KEY, | ||
"aws_secret_access_key": SECRET_KEY, | ||
"endpoint_url": "https://us-southeast-1.linodeobjects.com", | ||
"region_name": "us-southeast-1", | ||
} | ||
|
||
|
||
def upload_to_linode_object_storage(file_name): | ||
try: | ||
s3 = boto3.client('s3', **linode_obj_config) | ||
|
||
s3.upload_file(Filename=file_name, Bucket=BUCKET_NAME, Key=file_name) | ||
|
||
print(f'Successfully uploaded {file_name} to Linode Object Storage.') | ||
|
||
except NoCredentialsError: | ||
print('Credentials not available. Ensure you have set your AWS credentials.') | ||
|
||
|
||
if __name__ == '__main__': | ||
if len(sys.argv) != 2: | ||
print('Usage: python upload_to_linode.py <file_name>') | ||
sys.exit(1) | ||
|
||
file_name = sys.argv[1] | ||
|
||
if not file_name: | ||
print('Error: The provided file name is empty or invalid.') | ||
sys.exit(1) | ||
|
||
upload_to_linode_object_storage(file_name) |