Skip to content

Commit 880b0a0

Browse files
authored
Send tar instead of gzipped tar file (required for RHDH plugins) (#540)
* mount private unshared label * Send only tar file instead of gzipped tar file
1 parent bbed3cf commit 880b0a0

File tree

6 files changed

+26
-26
lines changed

6 files changed

+26
-26
lines changed

src/ansible_dev_tools/resources/server/creator_v1.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def create_tar_file(init_path: Path, tar_file: Path) -> None:
2525
init_path: The directory path to create the tar file from.
2626
tar_file: The output tar file path.
2727
"""
28-
with tarfile.open(tar_file, "w:gz") as tar:
28+
with tarfile.open(tar_file, "w") as tar:
2929
tar.add(str(init_path), arcname=".")
3030

3131

@@ -44,7 +44,7 @@ def _response_from_tar(self, tar_file: Path) -> FileResponse:
4444
fs = FileSystemStorage(str(tar_file.parent))
4545
response = FileResponse(
4646
fs.open(tar_file.name, "rb"),
47-
content_type="application/tar+gzip",
47+
content_type="application/tar",
4848
status=201,
4949
)
5050
response["Content-Disposition"] = f'attachment; filename="{tar_file.name}"'
@@ -156,7 +156,7 @@ def collection(self, collection: str, project: str) -> Path:
156156
project=project,
157157
)
158158
Init(config).run()
159-
tar_file = self.tmp_dir / f"{collection}.tar.gz"
159+
tar_file = self.tmp_dir / f"{collection}.tar"
160160
create_tar_file(init_path, tar_file)
161161
return tar_file
162162

@@ -187,6 +187,6 @@ def playbook(
187187
subcommand="init",
188188
)
189189
Init(config).run()
190-
tar_file = self.tmp_dir / f"{scm_org}-{scm_project}.tar.gz"
190+
tar_file = self.tmp_dir / f"{scm_org}-{scm_project}.tar"
191191
create_tar_file(init_path, tar_file)
192192
return tar_file

src/ansible_dev_tools/resources/server/creator_v2.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def create_tar_file(init_path: Path, tar_file: Path) -> None:
2525
init_path: The directory path to create the tar file from.
2626
tar_file: The output tar file path.
2727
"""
28-
with tarfile.open(tar_file, "w:gz") as tar:
28+
with tarfile.open(tar_file, "w") as tar:
2929
tar.add(str(init_path), arcname=".")
3030

3131

@@ -44,7 +44,7 @@ def _response_from_tar(self, tar_file: Path) -> FileResponse:
4444
fs = FileSystemStorage(str(tar_file.parent))
4545
response = FileResponse(
4646
fs.open(tar_file.name, "rb"),
47-
content_type="application/tar+gzip",
47+
content_type="application/tar",
4848
status=201,
4949
)
5050
response["Content-Disposition"] = f'attachment; filename="{tar_file.name}"'
@@ -156,7 +156,7 @@ def collection(self, collection: str, project: str) -> Path:
156156
project=project,
157157
)
158158
Init(config).run()
159-
tar_file = self.tmp_dir / f"{collection}.tar.gz"
159+
tar_file = self.tmp_dir / f"{collection}.tar"
160160
create_tar_file(init_path, tar_file)
161161
return tar_file
162162

@@ -187,6 +187,6 @@ def playbook(
187187
subcommand="init",
188188
)
189189
Init(config).run()
190-
tar_file = self.tmp_dir / f"{namespace}-{collection_name}.tar.gz"
190+
tar_file = self.tmp_dir / f"{namespace}-{collection_name}.tar"
191191
create_tar_file(init_path, tar_file)
192192
return tar_file

src/ansible_dev_tools/resources/server/data/openapi.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ paths:
2727
"201":
2828
description: Created
2929
content:
30-
application/tar+gzip:
30+
application/tar:
3131
schema:
3232
AnyValue: {}
3333
"400":
@@ -49,7 +49,7 @@ paths:
4949
"201":
5050
description: Created
5151
content:
52-
application/tar+gzip:
52+
application/tar:
5353
schema:
5454
AnyValue: {}
5555
"400":
@@ -71,7 +71,7 @@ paths:
7171
"201":
7272
description: Created
7373
content:
74-
application/tar+gzip:
74+
application/tar:
7575
schema:
7676
AnyValue: {}
7777
"400":
@@ -93,7 +93,7 @@ paths:
9393
"201":
9494
description: Created
9595
content:
96-
application/tar+gzip:
96+
application/tar:
9797
schema:
9898
AnyValue: {}
9999
"400":

tests/integration/test_server_creator_v1.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ def test_playbook_v1(server_url: str, tmp_path: Path) -> None:
4444
timeout=10,
4545
)
4646
assert response.status_code == requests.codes.get("created")
47-
assert response.headers["Content-Disposition"] == 'attachment; filename="ansible-devops.tar.gz"'
48-
assert response.headers["Content-Type"] == "application/tar+gzip"
49-
dest_file = tmp_path / "ansible-devops.tar.gz"
47+
assert response.headers["Content-Disposition"] == 'attachment; filename="ansible-devops.tar"'
48+
assert response.headers["Content-Type"] == "application/tar"
49+
dest_file = tmp_path / "ansible-devops.tar"
5050
with dest_file.open(mode="wb") as tar_file:
5151
tar_file.write(response.content)
5252
with tarfile.open(dest_file) as file:
@@ -72,9 +72,9 @@ def test_collection_v1(server_url: str, tmp_path: Path) -> None:
7272
timeout=10,
7373
)
7474
assert response.status_code == requests.codes.get("created")
75-
assert response.headers["Content-Disposition"] == 'attachment; filename="namespace.name.tar.gz"'
76-
assert response.headers["Content-Type"] == "application/tar+gzip"
77-
dest_file = tmp_path / "namespace.name.tar.gz"
75+
assert response.headers["Content-Disposition"] == 'attachment; filename="namespace.name.tar"'
76+
assert response.headers["Content-Type"] == "application/tar"
77+
dest_file = tmp_path / "namespace.name.tar"
7878
with dest_file.open(mode="wb") as tar_file:
7979
tar_file.write(response.content)
8080
with tarfile.open(dest_file) as file:

tests/integration/test_server_creator_v2.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ def test_playbook_v2(server_url: str, tmp_path: Path) -> None:
4444
timeout=10,
4545
)
4646
assert response.status_code == requests.codes.get("created")
47-
assert response.headers["Content-Disposition"] == 'attachment; filename="ansible-devops.tar.gz"'
48-
assert response.headers["Content-Type"] == "application/tar+gzip"
49-
dest_file = tmp_path / "ansible-devops.tar.gz"
47+
assert response.headers["Content-Disposition"] == 'attachment; filename="ansible-devops.tar"'
48+
assert response.headers["Content-Type"] == "application/tar"
49+
dest_file = tmp_path / "ansible-devops.tar"
5050
with dest_file.open(mode="wb") as tar_file:
5151
tar_file.write(response.content)
5252
with tarfile.open(dest_file) as file:
@@ -72,9 +72,9 @@ def test_collection_v2(server_url: str, tmp_path: Path) -> None:
7272
timeout=10,
7373
)
7474
assert response.status_code == requests.codes.get("created")
75-
assert response.headers["Content-Disposition"] == 'attachment; filename="namespace.name.tar.gz"'
76-
assert response.headers["Content-Type"] == "application/tar+gzip"
77-
dest_file = tmp_path / "namespace.name.tar.gz"
75+
assert response.headers["Content-Disposition"] == 'attachment; filename="namespace.name.tar"'
76+
assert response.headers["Content-Type"] == "application/tar"
77+
dest_file = tmp_path / "namespace.name.tar"
7878
with dest_file.open(mode="wb") as tar_file:
7979
tar_file.write(response.content)
8080
with tarfile.open(dest_file) as file:

tests/unit/test_server_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def test_validate_response_pass(collection_request: HttpRequest) -> None:
6666
collection_request: A Django request object
6767
"""
6868
response = HttpResponse()
69-
response["Content-Type"] = "application/tar+gzip"
69+
response["Content-Type"] = "application/tar"
7070
response.status_code = HTTPStatus.CREATED.value
7171
response.content = b"Hello, World!"
7272
result = validate_response(collection_request, response)
@@ -82,7 +82,7 @@ def test_validate_response_fail(collection_request: HttpRequest) -> None:
8282
collection_request: A Django request object
8383
"""
8484
response = HttpResponse()
85-
response["Content-Type"] = "application/tar+gzip"
85+
response["Content-Type"] = "application/tar"
8686
response.status_code = HTTPStatus.CREATED.value
8787
result = validate_response(collection_request, response)
8888
assert result.status_code == HTTPStatus.BAD_REQUEST.value

0 commit comments

Comments
 (0)