|
1 | 1 | import os
|
2 |
| -import subprocess |
3 | 2 | import sys
|
4 | 3 |
|
5 | 4 | import boto3
|
| 5 | +import utils |
6 | 6 | from botocore.exceptions import ClientError, NoCredentialsError, PartialCredentialsError
|
7 | 7 |
|
8 | 8 | from lib.base_logger import logger
|
|
14 | 14 | )
|
15 | 15 |
|
16 | 16 | AWS_REGION = "eu-north-1"
|
17 |
| -KUBECTL_PLUGIN_BINARY_NAME = "kubectl-mongodb" |
18 |
| -S3_BUCKET_KUBECTL_PLUGIN_SUBPATH = KUBECTL_PLUGIN_BINARY_NAME |
| 17 | +S3_BUCKET_KUBECTL_PLUGIN_SUBPATH = utils.KUBECTL_PLUGIN_BINARY_NAME |
19 | 18 |
|
20 | 19 | GORELEASER_DIST_DIR = "dist"
|
21 | 20 |
|
22 |
| -# LOCAL_KUBECTL_PLUGIN_PATH the full filename where tests image expects the kuebctl-mongodb binary to be available |
| 21 | +# LOCAL_KUBECTL_PLUGIN_PATH is the full filename where tests image expects the kuebctl-mongodb binary to be available |
23 | 22 | LOCAL_KUBECTL_PLUGIN_PATH = "docker/mongodb-kubernetes-tests/multi-cluster-kube-config-creator_linux"
|
24 | 23 |
|
25 | 24 |
|
26 |
| -def run_goreleaser(): |
27 |
| - try: |
28 |
| - command = ["./goreleaser", "build", "--snapshot", "--clean", "--skip", "post-hooks"] |
29 |
| - |
30 |
| - process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, bufsize=1) |
31 |
| - |
32 |
| - for log in iter(process.stdout.readline, ""): |
33 |
| - print(log, end="") |
34 |
| - |
35 |
| - process.stdout.close() |
36 |
| - exit_code = process.wait() |
37 |
| - |
38 |
| - if exit_code != 0: |
39 |
| - logger.debug(f"GoReleaser command failed with exit code {exit_code}.") |
40 |
| - sys.exit(1) |
| 25 | +def run_goreleaser_build(): |
41 | 26 |
|
42 |
| - logger.info("GoReleaser build completed successfully!") |
43 |
| - |
44 |
| - except FileNotFoundError: |
45 |
| - logger.debug( |
46 |
| - "ERROR: 'goreleaser' command not found. Please ensure goreleaser is installed and in your system's PATH." |
47 |
| - ) |
48 |
| - sys.exit(1) |
49 |
| - except Exception as e: |
50 |
| - logger.debug(f"An unexpected error occurred while running `goreleaser build`: {e}") |
51 |
| - sys.exit(1) |
| 27 | + command = ["./goreleaser", "build", "--snapshot", "--clean", "--skip", "post-hooks"] |
| 28 | + utils.run_goreleaser_command(command) |
52 | 29 |
|
53 | 30 |
|
54 | 31 | # upload_artifacts_to_s3 uploads the artifacts that are generated by goreleaser to S3 bucket at a specific path.
|
@@ -123,9 +100,9 @@ def download_plugin_for_tests_image(build_scenario: BuildScenario, s3_bucket: st
|
123 | 100 |
|
124 | 101 | def main():
|
125 | 102 | build_scenario = BuildScenario.infer_scenario_from_environment()
|
126 |
| - kubectl_plugin_build_info = load_build_info(build_scenario).binaries[KUBECTL_PLUGIN_BINARY_NAME] |
| 103 | + kubectl_plugin_build_info = load_build_info(build_scenario).binaries[utils.KUBECTL_PLUGIN_BINARY_NAME] |
127 | 104 |
|
128 |
| - run_goreleaser() |
| 105 | + run_goreleaser_build() |
129 | 106 |
|
130 | 107 | upload_artifacts_to_s3(kubectl_plugin_build_info.s3_store, kubectl_plugin_build_info.version)
|
131 | 108 |
|
|
0 commit comments