19
19
20
20
GORELEASER_DIST_DIR = "dist"
21
21
22
- # LOCAL_KUBECTL_PLUGIN_PATH is the full filename where tests image expects the kuebctl-mongodb binary to be available
23
- LOCAL_KUBECTL_PLUGIN_PATH = "docker/mongodb-kubernetes-tests/multi-cluster-kube-config-creator_linux"
24
-
25
-
26
22
def run_goreleaser ():
27
23
try :
28
24
command = ["./goreleaser" , "build" , "--snapshot" , "--clean" , "--skip" , "post-hooks" ]
@@ -101,8 +97,19 @@ def s3_path(local_path: str, version: str):
101
97
return f"{ S3_BUCKET_KUBECTL_PLUGIN_SUBPATH } /{ version } /{ local_path } "
102
98
103
99
104
- # download_plugin_for_tests_image downloads just the linux amd64 version of the binary and places it
105
- # at the location LOCAL_KUBECTL_PLUGIN_PATH.
100
+ def s3_and_local_plugin_path (version : str ) -> dict [str , str ]:
101
+ s3_common_path = f"{ S3_BUCKET_KUBECTL_PLUGIN_SUBPATH } /{ version } /dist"
102
+ local_common_path = "docker/mongodb-kubernetes-tests"
103
+ # path in s3 : local path
104
+ return {
105
+ f"{ s3_common_path } /kubectl-mongodb_linux_amd64_v1/kubectl-mongodb" : f"{ local_common_path } /multi-cluster-kube-config-creator_amd64" ,
106
+ f"{ s3_common_path } /kubectl-mongodb_linux_arm64/kubectl-mongodb" : f"{ local_common_path } /multi-cluster-kube-config-creator_arm64" ,
107
+ f"{ s3_common_path } /kubectl-mongodb_linux_ppc64le/kubectl-mongodb" : f"{ local_common_path } /multi-cluster-kube-config-creator_ppc64le" ,
108
+ f"{ s3_common_path } /kubectl-mongodb_linux_s390x/kubectl-mongodb" : f"{ local_common_path } /multi-cluster-kube-config-creator_s390x" ,
109
+ }
110
+
111
+ # download_plugin_for_tests_image downloads the plugin for all the architectures and places them to the paths configured in
112
+ # s3_and_local_plugin_path
106
113
def download_plugin_for_tests_image (build_scenario : BuildScenario , s3_bucket : str , version : str ):
107
114
try :
108
115
s3_client = boto3 .client ("s3" , region_name = AWS_REGION )
@@ -111,23 +118,23 @@ def download_plugin_for_tests_image(build_scenario: BuildScenario, s3_bucket: st
111
118
sys .exit (1 )
112
119
113
120
plugin_path = f"{ S3_BUCKET_KUBECTL_PLUGIN_SUBPATH } /{ version } /dist/kubectl-mongodb_linux_amd64_v1/kubectl-mongodb"
114
-
115
- logger .info (f"Downloading s3://{ s3_bucket } /{ plugin_path } to { LOCAL_KUBECTL_PLUGIN_PATH } " )
116
- try :
117
- s3_client .download_file (s3_bucket , plugin_path , LOCAL_KUBECTL_PLUGIN_PATH )
118
- # change the file's permissions to make file executable
119
- os .chmod (LOCAL_KUBECTL_PLUGIN_PATH , 0o755 )
120
-
121
- logger .info (f"Successfully downloaded artifact to { LOCAL_KUBECTL_PLUGIN_PATH } " )
122
- except ClientError as e :
123
- if e .response ["Error" ]["Code" ] == "404" :
124
- logger .debug (f"ERROR: Artifact not found at s3://{ s3_bucket } /{ plugin_path } " )
125
- else :
126
- logger .debug (f"ERROR: Failed to download artifact. S3 Client Error: { e } " )
127
- sys .exit (1 )
128
- except Exception as e :
129
- logger .debug (f"An unexpected error occurred during download: { e } " )
130
- sys .exit (1 )
121
+ for plugin_path , local_path in s3_and_local_plugin_path ( version ). items :
122
+ logger .info (f"Downloading s3://{ s3_bucket } /{ plugin_path } to { local_path } " )
123
+ try :
124
+ s3_client .download_file (s3_bucket , plugin_path , local_path )
125
+ # change the file's permissions to make file executable
126
+ os .chmod (local_path , 0o755 )
127
+
128
+ logger .info (f"Successfully downloaded artifact to { local_path } " )
129
+ except ClientError as e :
130
+ if e .response ["Error" ]["Code" ] == "404" :
131
+ logger .debug (f"ERROR: Artifact not found at s3://{ s3_bucket } /{ plugin_path } " )
132
+ else :
133
+ logger .debug (f"ERROR: Failed to download artifact. S3 Client Error: { e } " )
134
+ sys .exit (1 )
135
+ except Exception as e :
136
+ logger .debug (f"An unexpected error occurred during download: { e } " )
137
+ sys .exit (1 )
131
138
132
139
133
140
def main ():
@@ -138,9 +145,9 @@ def main():
138
145
139
146
upload_artifacts_to_s3 (kubectl_plugin_build_info .s3_store , kubectl_plugin_build_info .version )
140
147
141
- # download_plugin_for_tests_image(
142
- # build_scenario, kubectl_plugin_build_info.s3_store, kubectl_plugin_build_info.version
143
- # )
148
+ download_plugin_for_tests_image (
149
+ build_scenario , kubectl_plugin_build_info .s3_store , kubectl_plugin_build_info .version
150
+ )
144
151
145
152
146
153
if __name__ == "__main__" :
0 commit comments