Skip to content

OrasClient.push fails on Windows as empty Manifest Config uses /dev/null which is Linux specific #90

@sunnycarter

Description

@sunnycarter

My code runs fine on Linux. On Windows it fails with an error.

Here's my code:

        client = OrasClient(hostname=acr_url)
        
        client.login(
            username=self._manifest_credentials["username"],
            password=self._manifest_credentials["acr_token"],
        )
        target = (
                f"{client.remote.hostname.replace('https://', '')}/testartifact:1.0.0"
            )
        client.push(`
                files=["testartifact.json"],
                target=target
            )
 File "<>\oras\client.py", line 131, in push
    return self.remote.push(*args, **kwargs)
  File "<>\oras\provider.py", line 718, in push
    response = self.upload_blob(config_file, container, conf)
  File "<>\oras\provider.py", line 217, in upload_blob
    response = self.put_upload(blob, container, layer)
  File "<>\oras\provider.py", line 474, in put_upload
    with open(blob, "rb") as fd:
OSError: [Errno 22] Invalid argument: 'C:\\dev\\null'

I have made a fix for this and will submit a PR. The fix is in oci.py ManifestConfig:

        if platform.system() == "Windows":
            path = "nul"
        else:
            path = "/dev/null"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions