Skip to content

Commit

Permalink
Merge pull request #137 from mdellweg/chunk_size
Browse files Browse the repository at this point in the history
Add chunk_size option to artifact module
  • Loading branch information
mdellweg authored Nov 8, 2023
2 parents 06f9812 + 076a543 commit 63fe656
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 13 additions & 2 deletions plugins/modules/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
- sha256 digest of the artifact to query or delete.
- When specified together with file, it will be used to verify any transaction.
type: str
chunk_size:
description:
- Size of the chunks to upload a file.
type: int
default: 33554432
extends_documentation_fragment:
- pulp.squeezer.pulp.entity_state
- pulp.squeezer.pulp.glue
Expand Down Expand Up @@ -104,7 +109,9 @@ def process_present(self, entity, natural_key, desired_attributes):
entity = {**desired_attributes, **natural_key}
else:
with open(self.params["file"], "rb") as infile:
self.context.upload(infile, sha256=natural_key["sha256"])
self.context.upload(
infile, sha256=natural_key["sha256"], chunk_size=self.params["chunk_size"]
)
entity = self.context.entity
self.set_changed()
return self.represent(entity)
Expand All @@ -116,7 +123,11 @@ def main():
entity_singular="artifact",
entity_plural="artifacts",
import_errors=[("pulp-glue", PULP_CLI_IMPORT_ERR)],
argument_spec=dict(file=dict(type="path"), sha256=dict()),
argument_spec=dict(
file=dict(type="path"),
sha256=dict(),
chunk_size=dict(type="int", default=33554432),
),
required_if=[("state", "present", ["file"])],
) as module:
sha256 = module.params["sha256"]
Expand Down
2 changes: 2 additions & 0 deletions tests/playbooks/artifact.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
pulp.squeezer.artifact:
file: data/large_artifact.dat
state: present
chunk_size: 1000000
register: result
- name: Verify create artifact with chunked upload
assert:
Expand All @@ -156,6 +157,7 @@
pulp.squeezer.artifact:
file: data/large_artifact.dat
state: present
chunk_size: 1000000
register: result
- name: Verify create artifact with chunked upload (2nd try)
assert:
Expand Down

0 comments on commit 63fe656

Please sign in to comment.