circleci-cli icon indicating copy to clipboard operation
circleci-cli copied to clipboard

Add `list project environment variable` subcommand (one of commands to manage projects)

Open threepipes opened this issue 2 years ago • 3 comments

Checklist

=========

  • [x] I have performed a self-review of my own code
  • [x] I have commented my code, particularly in hard-to-understand areas
  • [x] I have checked for similar issues and haven't found anything relevant.
    • https://github.com/CircleCI-Public/circleci-cli/issues/652 is the issue that this PR is targeting
  • [x] This is not a security issue (which should be reported here: https://circleci.com/security/)
  • [x] I have read Contribution Guidelines.

Changes

=======

  • Add a project command
    • Add a subcommand to list project environment variables
      • circleci project secret list <vcs> <org> <project>
  • Replace a request header Accept-Type with Accept in api/rest/client.go

Rationale

=========

This PR partially solves https://github.com/CircleCI-Public/circleci-cli/issues/652. Currently, CircleCI CLI does not have the ability to manage Projects. This change enables one of these abilities and makes it easier to write the rest subcommands.

Considerations

==============

  • Replace a request header Accept-Type with Accept in api/rest/client.go
    • Accept header, rather than Accept-Type, is generally used to controll content-type response header
    • The API projects/envvar requires Accept header to return responses of content-type:application/json
      • If not the case, the response header is content-type:text/plain
      • This can't be accepted by the Client of api/rest/client.go
    • With my checking, the runner API doesn't care Accept-Type header
      • I checked that runner resource-class and runner token commands succeeded without Accept-Type or Accept
      • ref. https://github.com/CircleCI-Public/circleci-cli/pull/474 is the PR that the Accept-Type is added

I will add other subcommands to manage project environment variables like create and delete.

Here are some helpful tips you can follow when submitting a pull request:

  1. Fork the repository and create your branch from master.
  2. Run make build in the repository root.
  3. If you've fixed a bug or added code that should be tested, add tests!
  4. Ensure the test suite passes (make test).
  5. The --debug flag is often helpful for debugging HTTP client requests and responses.
  6. Format your code with gofmt.
  7. Make sure your code lints (make lint). Note: This requires Docker to run inside a local job.

threepipes avatar Aug 20 '22 11:08 threepipes

Codecov Report

:exclamation: No coverage uploaded for pull request base (main@c849191). Click here to learn what that means. Patch has no changes to coverable lines.

:exclamation: Current head d9b35dd differs from pull request most recent head a3f7e7d. Consider uploading reports for the commit a3f7e7d to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #770   +/-   ##
=======================================
  Coverage        ?   33.64%           
=======================================
  Files           ?       49           
  Lines           ?     5495           
  Branches        ?        0           
=======================================
  Hits            ?     1849           
  Misses          ?     3390           
  Partials        ?      256           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov[bot] avatar Aug 20 '22 11:08 codecov[bot]

@CircleCI-Public/Extensibility Could you review this PR? As I am new to this project as a contributor, please let me know if there is anything I have to do for your review.

threepipes avatar Aug 29 '22 11:08 threepipes

Hello @threepipes This PR is large, could it possibly be broken down into smaller PRs. ie: Accept-Type in one PR and project command in a separate one? Thank you

corinnesollows avatar Sep 21 '22 14:09 corinnesollows

@corinnesollows Thank you for your comment and advice. Sure, I will make a PR for the Accept-Type header. I will let this PR be as of now because the Accept-Type change is required for the current implementation. So I hope you will check this one after checking the Accept-Type one.

threepipes avatar Sep 22 '22 13:09 threepipes

The header changes are extracted: https://github.com/CircleCI-Public/circleci-cli/pull/784

threepipes avatar Sep 22 '22 14:09 threepipes

@corinnesollows Thank you for your approval of https://github.com/CircleCI-Public/circleci-cli/pull/784. This PR no longer contains the Accept-Type header changes. If there are any more requirements, feel free to let me know.

threepipes avatar Sep 24 '22 04:09 threepipes

It would be extremely tight if this could get some attention @CircleCI-Public/Extensibility @corinnesollows

flanger001 avatar Jan 05 '23 14:01 flanger001