Skip to content

improve error message of oras attach when subject artifact is not specified #1424

@qweeah

Description

@qweeah

When using oras attach, if a user forgot to provide the subject artifact reference and only specifies one to-be-uploaded file, ORAS CLI will output (tested in bash, different shell might have different output):

> ARTIFACT=
> oras attach --artifact-type test/example $ARTIFACT./test.json
Error: neither file nor annotation provided in the command
Usage: oras attach [flags] --artifact-type=<type> <name>{:<tag>|@<digest>} <file>[:<layer_media_type>] [...]
To attach to an existing artifact, please provide files via argument or annotations via flag "--annotation". Run "oras attach -h" for more options and examplesdigest]

Input was parsed under a wrong consumption: user does specify subject artifact reference ./layers, which actually is a file reference to be attached. This error can be avoided by parsing the only input argument. If the reference is valid, continue with current output. If it's not, give corresponding hint like:

Error: "./test.json" is an invalid artifact reference
Did you forget to specify a subject artifact?

Metadata

Metadata

Assignees

No one assigned

    Labels

    uxUser experience related

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions