Skip to content

Commit 2126742

Browse files
Precommit
1 parent 4bc352b commit 2126742

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

scripts/release/kubectl-mongodb/python/build_kubectl_plugin.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
# LOCAL_FILE_PATHis the full filename where tests image expects the kuebctl-mongodb binary to be available
2323
LOCAL_FILE_PATH = "docker/mongodb-kubernetes-tests/multi-cluster-kube-config-creator_linux"
2424

25+
2526
def run_goreleaser():
2627
try:
2728
command = ["./goreleaser", "build", "--snapshot", "--clean"]
@@ -74,11 +75,14 @@ def upload_artifacts_to_s3():
7475
permissions = str(oct(stat.st_mode)[-3:])
7576

7677
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},
8084
},
81-
})
85+
)
8286
print(f"Successfully uploaded the artifact {filename}")
8387
uploaded_files += 1
8488
except Exception as e:
@@ -94,7 +98,9 @@ def upload_artifacts_to_s3():
9498
def s3_path(local_path: str):
9599
commit_sha = os.environ.get(COMMIT_SHA_ENV_VAR, "").strip()
96100
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+
)
98104
sys.exit(1)
99105

100106
return f"{S3_BUCKET_KUBECTL_PLUGIN_SUBPATH}/{commit_sha}/{local_path}"
@@ -107,7 +113,6 @@ def download_plugin_for_tests_image():
107113
print(f"An error occurred connecting to S3 to download kubectl plugin for tests image: {e}")
108114
return
109115

110-
111116
commit_sha = os.environ.get(COMMIT_SHA_ENV_VAR, "").strip()
112117
if commit_sha == "":
113118
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():
123128

124129
print(f"Successfully downloaded artifact to {LOCAL_FILE_PATH}")
125130
except ClientError as e:
126-
if e.response['Error']['Code'] == '404':
131+
if e.response["Error"]["Code"] == "404":
127132
print(f"ERROR: Artifact not found at s3://{DEV_S3_BUCKET_NAME}/{plugin_path} ")
128133
else:
129134
print(f"ERROR: Failed to download artifact. S3 Client Error: {e}")
130135
except Exception as e:
131136
print(f"An unexpected error occurred during download: {e}")
132137

138+
133139
def main():
134140
run_goreleaser()
135141
upload_artifacts_to_s3()

0 commit comments

Comments
 (0)