-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Add API route to list org secrets #26485
Conversation
- Add a new function `CountOrgSecrets` in the file `models/secret/secret.go` - Add a new file `modules/structs/secret.go` - Add a new function `ListActionsSecrets` in the file `routers/api/v1/api.go` - Add a new file `routers/api/v1/org/action.go` - Add a new function `listActionsSecrets` in the file `routers/api/v1/org/action.go` Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
- Add a new API endpoint for listing an organization's actions secrets Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: techknowlogick <matti@mdranta.net>
- Add a new file `routers/api/v1/swagger/action.go` - Add a new struct `swaggerResponseSecretList` in the `action.go` file - Add a new file `templates/swagger/v1_json.tmpl` - Modify the `v1_json.tmpl` file to include a new property `Secret` in the `properties` section of the `User` object - Modify the `v1_json.tmpl` file to include a new definition `SecretList` in the `definitions` section Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
- Change the function name from `FindSecrets` to `CountSecrets` in `models/secret/secret.go` - Change the function name from `CountOrgSecrets` to `CountSecrets` in `routers/api/v1/org/action.go` Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
|
||
// ListActionsSecrets list an organization's actions secrets | ||
func ListActionsSecrets(ctx *context.APIContext) { | ||
// swagger:operation GET /orgs/{org}/actions/secrets organization orgListActionsSecrets |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Erm… User secrets exist too already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That and we were not sure if we keep them action-only.
I think it is better to omit the actions/
part from the URL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or do you explicitly only want to return the action secrets here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just following the spec: https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28#list-organization-secrets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, what do we do in this case?
Deviate from the GitHub standard?
Add extra routes, and mark this one as deprecated with a comment only for compatibility with the GitHub API
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry if my previous response was unclear. Please provide more details or elaborate on what you want me to explain. Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- We try to be compatible with GitHub API where possible, so far so good
- I think this is the wrong URL for that route, I suggest
/orgs/{org}/secrets
//users/{user}/secrets
instead
That leaves the question what to do with the missing URL.
I suggest adding three routes in this PR: The two mentioned above, and the one you already implemented.
However, as the third should only be used by existing scripts and nothing else, I recommend marking this route as // deprecated: true
with a comment that it is only intended for GitHub API compatibility and that our routes are the other two above instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I said in #24200 (comment) , we can provide other API routes for more purposes but share the data table.
So LGTM.
- Rename the `Created` field to `created_at` in the `Secret` struct Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
- Change the property name from "created" to "created_at" in the User object Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
If I read the code correctly, there is no route to list user secrets, only org secrets. I'm OK with that if we don't want to do that in this PR, but please update the title. |
@wolfogre done for changed the PR title. |
…n status - Remove unnecessary code for checking organization membership and admin status in `ListActionsSecrets` function Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
@delvh any feedback? or we can merge the PR. |
No block from my side, if we want to be compatible with the GitHub API. |
* upstream/main: Sync repo's IsEmpty status correctly (go-gitea#26517) [skip ci] Updated translations via Crowdin Remove fomantic transition module (go-gitea#26469) Explain SearchOptions and fix ToSearchOptions (go-gitea#26542) Update go dependencies (go-gitea#26534) Differentiate better between user settings and admin settings (go-gitea#26538) Add missing triggers to update issue indexer (go-gitea#26539) Improve deadline icon location in milestone list page (go-gitea#26532) Use unique class for breadcrumb divider (go-gitea#26524) Fix typo of RunerOwnerID (go-gitea#26508) Improve clickable area in repo action view page (go-gitea#26115) Fix dark theme highlight for "NameNamespace" (go-gitea#26519) Remove duplicate CSS import for chroma/base.css (go-gitea#26523) Fix project filter bugs (go-gitea#26490) Fix display problems of members and teams unit (go-gitea#26363) Use `hidden` over `clip` for text truncation (go-gitea#26520) Add API route to list org secrets (go-gitea#26485) Set "type=button" for editor's toolbar buttons (go-gitea#26510) Apply to become a maintainer (go-gitea#26514) Detect ogg mime-type as audio or video (go-gitea#26494)
CountOrgSecrets
in the filemodels/secret/secret.go
modules/structs/secret.go
ListActionsSecrets
in the filerouters/api/v1/api.go
routers/api/v1/org/action.go
listActionsSecrets
in the filerouters/api/v1/org/action.go
go-sdk: https://gitea.com/gitea/go-sdk/pulls/629