Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support yaml output #241

Merged
merged 13 commits into from
Nov 26, 2024
Merged

Support yaml output #241

merged 13 commits into from
Nov 26, 2024

Conversation

Standing-Man
Copy link
Contributor

Fixed #240

Support yaml output for the command registry list

@bupd
Copy link
Contributor

bupd commented Nov 5, 2024

Every command need to have support for yaml output.

if FormatFlag == "yaml" {
utils.PrintPayloadInYAMLFormat(registry)
return
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Produce an error message to user when using flags other than json or yaml.

bugInlisting

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have finalized the subcommand list for project, registry, and user. I would like to confirm that this is accurate before moving on to support the remaining commands.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I use a generic function to unify the output in both YAML and JSON formats?

@Standing-Man Standing-Man requested a review from bupd November 8, 2024 04:47
Copy link
Contributor

@bupd bupd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JianMinTang thanks for the contribution. I found some commands still need additional formats. adding formats for those commands would be better.

commands need to be covered are

  • artifact
    • info
    • tags (these have issue with output)
❯ ./harbor-dev artifact tags list
INFO[0003] [0xc000695e60]

❯ ./harbor-dev artifact tags list -o yaml
INFO[0002] [0xc000034ba0]
  • project

    • view (also lacks table format)
  • registry

    • info (lacks table format)
  • repo

    • info (also lacks table format)

@Standing-Man
Copy link
Contributor Author

Standing-Man commented Nov 13, 2024

Hi @bupd and @Vad1mo, I am a bit confused about the difference between list and info under the same command. If there is any difference in the information they display, could you clearly explain the distinction between them?

I created a sample, but I think the info subcommand is redundant, or it could display only the name and description fields within the subcommand info.
image

Maybe the list command is displaying incorrectly, if the user want to list ther repos by the command harbor repo list, we should show every repositories, not just those within a single project. If the user wants to view detailed information about a specific repository, they should use the command harbor repo info to see information about that particular repository.

My suggestion might not be correct, So I am open to receiving your suggestions and guidance on this issue.

@bupd
Copy link
Contributor

bupd commented Nov 18, 2024

if the user want to list ther repos by the command harbor repo list, we should show every repositories, not just those within a single project.

./harbor-dev catalog

catalog command can be used if the user needs to list all the repos. instead of repos under a single project.
catalog seems more oci than list.

we still not have catalog command. we sure need one in the future.

@bupd
Copy link
Contributor

bupd commented Nov 18, 2024

If the user wants to view detailed information about a specific repository, they should use the command harbor repo info to see information about that particular repository.

harbor repo view <project_name>/<repo_name>

we can rename the repo info to repo view this might be clear than info.

@bupd
Copy link
Contributor

bupd commented Nov 18, 2024

SO, @JianMinTang

repo list - will list repos under a single project
catalog - will list all repos
repo view - will show details about a single repo

@Standing-Man Standing-Man force-pushed the bug/JianMinTang/240 branch 3 times, most recently from 948eeba to 8262575 Compare November 20, 2024 01:46
Standing-Man and others added 12 commits November 20, 2024 10:13
Signed-off-by: JianMinTang <jmtangcs@gmail.com>
Signed-off-by: JianMinTang <jmtangcs@gmail.com>
Signed-off-by: JianMinTang <jmtangcs@gmail.com>
Signed-off-by: JianMinTang <jmtangcs@gmail.com>
Signed-off-by: JianMinTang <jmtangcs@gmail.com>
Signed-off-by: JianMinTang <jmtangcs@gmail.com>
* generate credential name

Signed-off-by: bupd <bupdprasanth@gmail.com>

* feat: add support for the password-stdin flag in login flow

Signed-off-by: karanngi <karann.git@gmail.com>

* fix deps

- fixes dependencies

Signed-off-by: bupd <bupdprasanth@gmail.com>

* return stdout for tests

Signed-off-by: bupd <bupdprasanth@gmail.com>

* update workflow

Signed-off-by: bupd <bupdprasanth@gmail.com>

---------

Signed-off-by: bupd <bupdprasanth@gmail.com>
Signed-off-by: karanngi <karann.git@gmail.com>
Co-authored-by: karanngi <karann.git@gmail.com>
Signed-off-by: JianMinTang <jmtangcs@gmail.com>
print test output to screen

Signed-off-by: JianMinTang <jmtangcs@gmail.com>
Signed-off-by: JianMinTang <jmtangcs@gmail.com>

Add more detail on repo view

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

Support table format on registry view

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

Support table format on project view

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

Fixed tags list

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

Support table format and YAML/JSON output on artifact view

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

Fixed alignment problem

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

Fixed the code format

Signed-off-by: JianMinTang <jmtangcs@gmail.com>
* generate credential name

Signed-off-by: bupd <bupdprasanth@gmail.com>

* feat: add support for the password-stdin flag in login flow

Signed-off-by: karanngi <karann.git@gmail.com>

* fix deps

- fixes dependencies

Signed-off-by: bupd <bupdprasanth@gmail.com>

* return stdout for tests

Signed-off-by: bupd <bupdprasanth@gmail.com>

* update workflow

Signed-off-by: bupd <bupdprasanth@gmail.com>

---------

Signed-off-by: bupd <bupdprasanth@gmail.com>
Signed-off-by: karanngi <karann.git@gmail.com>
Co-authored-by: karanngi <karann.git@gmail.com>
Signed-off-by: JianMinTang <jmtangcs@gmail.com>
print test output to screen

Signed-off-by: JianMinTang <jmtangcs@gmail.com>
Signed-off-by: JianMinTang <jmtangcs@gmail.com>

Use gofmt to format all code

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

fix: Support YAML output for additional commands

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

fix: Implement a generic function to format output

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

chore: fix the problem about golangci-lint

Signed-off-by: JianMinTang <jmtangcs@gmail.com>
@Standing-Man
Copy link
Contributor Author

Hi @bupd, I’ve added the table format and YAML/JSON output to some commands, following your suggestions. Thank you so much for your valuable input!

@Standing-Man Standing-Man requested a review from bupd November 20, 2024 02:31
@Vad1mo Vad1mo merged commit c464871 into goharbor:main Nov 26, 2024
5 checks passed
@Standing-Man Standing-Man deleted the bug/JianMinTang/240 branch November 27, 2024 01:29
Copy link
Contributor

@bupd bupd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

qcserestipy pushed a commit to qcserestipy/harbor-cli that referenced this pull request Dec 22, 2024
* Support yaml output for 'registry list'

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

* Use gofmt to format all code

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

* fix: Support YAML output for additional commands

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

* fix: Support YAML format on artiface and repo command

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

* fix: Implement a generic function to format output

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

* chore: fix the problem about golangci-lint

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

* AutoGenerate credential name in login (goharbor#250)

* generate credential name

Signed-off-by: bupd <bupdprasanth@gmail.com>

* feat: add support for the password-stdin flag in login flow

Signed-off-by: karanngi <karann.git@gmail.com>

* fix deps

- fixes dependencies

Signed-off-by: bupd <bupdprasanth@gmail.com>

* return stdout for tests

Signed-off-by: bupd <bupdprasanth@gmail.com>

* update workflow

Signed-off-by: bupd <bupdprasanth@gmail.com>

---------

Signed-off-by: bupd <bupdprasanth@gmail.com>
Signed-off-by: karanngi <karann.git@gmail.com>
Co-authored-by: karanngi <karann.git@gmail.com>
Signed-off-by: JianMinTang <jmtangcs@gmail.com>

* print test output to screen (goharbor#254)

print test output to screen

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

* Support table format for repo view and add some comments on repo list

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

Add more detail on repo view

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

Support table format on registry view

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

Support table format on project view

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

Fixed tags list

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

Support table format and YAML/JSON output on artifact view

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

Fixed alignment problem

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

Fixed the code format

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

* AutoGenerate credential name in login (goharbor#250)

* generate credential name

Signed-off-by: bupd <bupdprasanth@gmail.com>

* feat: add support for the password-stdin flag in login flow

Signed-off-by: karanngi <karann.git@gmail.com>

* fix deps

- fixes dependencies

Signed-off-by: bupd <bupdprasanth@gmail.com>

* return stdout for tests

Signed-off-by: bupd <bupdprasanth@gmail.com>

* update workflow

Signed-off-by: bupd <bupdprasanth@gmail.com>

---------

Signed-off-by: bupd <bupdprasanth@gmail.com>
Signed-off-by: karanngi <karann.git@gmail.com>
Co-authored-by: karanngi <karann.git@gmail.com>
Signed-off-by: JianMinTang <jmtangcs@gmail.com>

* print test output to screen (goharbor#254)

print test output to screen

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

* Support yaml output for 'registry list'

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

Use gofmt to format all code

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

fix: Support YAML output for additional commands

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

fix: Implement a generic function to format output

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

chore: fix the problem about golangci-lint

Signed-off-by: JianMinTang <jmtangcs@gmail.com>

---------

Signed-off-by: JianMinTang <jmtangcs@gmail.com>
Signed-off-by: bupd <bupdprasanth@gmail.com>
Signed-off-by: karanngi <karann.git@gmail.com>
Co-authored-by: Prasanth B <89722848+bupd@users.noreply.github.com>
Co-authored-by: karanngi <karann.git@gmail.com>
Co-authored-by: Vadim Bauer <vb@container-registry.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Harbor CLI does not support yaml output
3 participants