oras-project / oras

OCI registry client - managing content like artifacts, images, packages
https://oras.land
Apache License 2.0
1.44k stars 174 forks source link

`--format` and `--pretty` should not be used at the same time for `oras manifest fetch` #1356

Closed qweeah closed 5 months ago

qweeah commented 5 months ago

What happened in your environment?

I can use --format and --pretty at the same time for oras manifest fetch

> oras manifest fetch localhost:5000/demo:eol --pretty --format json
{
  "ref": "localhost:5000/demo@sha256:8536ab80a4bfef21647eb36f0f17bac607c995149cc818c3a5b4dd8153cb7006",
  "mediaType": "application/vnd.oci.image.manifest.v1+json",
  "digest": "sha256:8536ab80a4bfef21647eb36f0f17bac607c995149cc818c3a5b4dd8153cb7006",
  "size": 535,
  "content": {
    "annotations": {
      "org.opencontainers.image.created": "2024-04-15T12:31:43Z"
    },
    "artifactType": "application/vnd.unknown.artifact.v1",
    "config": {
      "data": "e30=",
      "digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
      "mediaType": "application/vnd.oci.empty.v1+json",
      "size": 2
    },
    "layers": [
      {
        "data": "e30=",
        "digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
        "mediaType": "application/vnd.oci.empty.v1+json",
        "size": 2
      }
    ],
    "mediaType": "application/vnd.oci.image.manifest.v1+json",
    "schemaVersion": 2
  }
}

The --pretty is actually ignore since it only effects raw content output. The output of --format json is already designed to be prettified

What did you expect to happen?

Return error when --format and --pretty are used at the same time for command oras manifest fetch

How can we reproduce it?

Fetch a manifest with --format and --pretty.

What is the version of your ORAS CLI?

Version: 1.2.0-beta.1+unreleased Go version: go1.22.1 Git commit: 2edebad6a91eed27fac639d0b51f3e8c5f1aba3c

What is your OS environment?

Ubuntu 20.05

Are you willing to submit PRs to fix it?

qweeah commented 5 months ago

@wangxiaoxuan273 Can you help take a look at this issue since you are already working on refactoring the utilities function of flag conflict detection?