22
22
# LOCAL_FILE_PATHis the full filename where tests image expects the kuebctl-mongodb binary to be available
23
23
LOCAL_FILE_PATH = "docker/mongodb-kubernetes-tests/multi-cluster-kube-config-creator_linux"
24
24
25
+
25
26
def run_goreleaser ():
26
27
try :
27
28
command = ["./goreleaser" , "build" , "--snapshot" , "--clean" ]
@@ -74,11 +75,14 @@ def upload_artifacts_to_s3():
74
75
permissions = str (oct (stat .st_mode )[- 3 :])
75
76
76
77
try :
77
- s3_client .upload_file (local_path , DEV_S3_BUCKET_NAME , s3_key , ExtraArgs = {
78
- "Metadata" :{
79
- "posix-permissions" : permissions
78
+ s3_client .upload_file (
79
+ local_path ,
80
+ DEV_S3_BUCKET_NAME ,
81
+ s3_key ,
82
+ ExtraArgs = {
83
+ "Metadata" : {"posix-permissions" : permissions },
80
84
},
81
- } )
85
+ )
82
86
print (f"Successfully uploaded the artifact { filename } " )
83
87
uploaded_files += 1
84
88
except Exception as e :
@@ -94,7 +98,9 @@ def upload_artifacts_to_s3():
94
98
def s3_path (local_path : str ):
95
99
commit_sha = os .environ .get (COMMIT_SHA_ENV_VAR , "" ).strip ()
96
100
if commit_sha == "" :
97
- print (f"Error: The commit sha environment variable { COMMIT_SHA_ENV_VAR } is not set. It's required to form the S3 Path." )
101
+ print (
102
+ f"Error: The commit sha environment variable { COMMIT_SHA_ENV_VAR } is not set. It's required to form the S3 Path."
103
+ )
98
104
sys .exit (1 )
99
105
100
106
return f"{ S3_BUCKET_KUBECTL_PLUGIN_SUBPATH } /{ commit_sha } /{ local_path } "
@@ -107,7 +113,6 @@ def download_plugin_for_tests_image():
107
113
print (f"An error occurred connecting to S3 to download kubectl plugin for tests image: { e } " )
108
114
return
109
115
110
-
111
116
commit_sha = os .environ .get (COMMIT_SHA_ENV_VAR , "" ).strip ()
112
117
if commit_sha == "" :
113
118
print ("Error: The commit sha environment variable is not set. It's required to form the S3 Path." )
@@ -123,13 +128,14 @@ def download_plugin_for_tests_image():
123
128
124
129
print (f"Successfully downloaded artifact to { LOCAL_FILE_PATH } " )
125
130
except ClientError as e :
126
- if e .response [' Error' ][ ' Code' ] == ' 404' :
131
+ if e .response [" Error" ][ " Code" ] == " 404" :
127
132
print (f"ERROR: Artifact not found at s3://{ DEV_S3_BUCKET_NAME } /{ plugin_path } " )
128
133
else :
129
134
print (f"ERROR: Failed to download artifact. S3 Client Error: { e } " )
130
135
except Exception as e :
131
136
print (f"An unexpected error occurred during download: { e } " )
132
137
138
+
133
139
def main ():
134
140
run_goreleaser ()
135
141
upload_artifacts_to_s3 ()
0 commit comments