Skip to content

Commit d39bce7

Browse files
appleboyGiteaBot
andauthored
fix(api): owner ID should be zero when created repo secret (#31715)
- Change condition to include `RepoID` equal to 0 for organization secrets --------- Signed-off-by: Bo-Yi Wu <[email protected]> Co-authored-by: Giteabot <[email protected]>
1 parent bf5ae79 commit d39bce7

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

Diff for: routers/api/v1/repo/action.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,11 @@ func (Action) CreateOrUpdateSecret(ctx *context.APIContext) {
117117
// "404":
118118
// "$ref": "#/responses/notFound"
119119

120-
owner := ctx.Repo.Owner
121120
repo := ctx.Repo.Repository
122121

123122
opt := web.GetForm(ctx).(*api.CreateOrUpdateSecretOption)
124123

125-
_, created, err := secret_service.CreateOrUpdateSecret(ctx, owner.ID, repo.ID, ctx.PathParam("secretname"), opt.Data)
124+
_, created, err := secret_service.CreateOrUpdateSecret(ctx, 0, repo.ID, ctx.PathParam("secretname"), opt.Data)
126125
if err != nil {
127126
if errors.Is(err, util.ErrInvalidArgument) {
128127
ctx.Error(http.StatusBadRequest, "CreateOrUpdateSecret", err)
@@ -174,10 +173,9 @@ func (Action) DeleteSecret(ctx *context.APIContext) {
174173
// "404":
175174
// "$ref": "#/responses/notFound"
176175

177-
owner := ctx.Repo.Owner
178176
repo := ctx.Repo.Repository
179177

180-
err := secret_service.DeleteSecretByName(ctx, owner.ID, repo.ID, ctx.PathParam("secretname"))
178+
err := secret_service.DeleteSecretByName(ctx, 0, repo.ID, ctx.PathParam("secretname"))
181179
if err != nil {
182180
if errors.Is(err, util.ErrInvalidArgument) {
183181
ctx.Error(http.StatusBadRequest, "DeleteSecret", err)

0 commit comments

Comments
 (0)