Skip to content

Commit ba0e2fc

Browse files
authored
Merge branch 'main' into fix/actions_apispec
2 parents 9443bc7 + b6074fb commit ba0e2fc

File tree

3 files changed

+28
-12
lines changed

3 files changed

+28
-12
lines changed

api/repo.go

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,19 @@ func CreateRepo(c *gin.Context) {
149149
r.SetVisibility(input.GetVisibility())
150150
}
151151

152+
// fields restricted to platform admins
153+
if u.GetAdmin() {
154+
// trusted default is false
155+
if input.GetTrusted() != r.GetTrusted() {
156+
r.SetTrusted(input.GetTrusted())
157+
}
158+
}
159+
152160
// set default events if no events are passed in
153161
if !input.GetAllowPull() && !input.GetAllowPush() &&
154162
!input.GetAllowDeploy() && !input.GetAllowTag() &&
155163
!input.GetAllowComment() {
156-
// default events to push and pull_request
157-
r.SetAllowPull(true)
164+
// default event to push
158165
r.SetAllowPush(true)
159166
} else {
160167
r.SetAllowComment(input.GetAllowComment())
@@ -789,6 +796,14 @@ func UpdateRepo(c *gin.Context) {
789796
)
790797
}
791798

799+
// fields restricted to platform admins
800+
if u.GetAdmin() {
801+
// trusted
802+
if input.GetTrusted() != r.GetTrusted() {
803+
r.SetTrusted(input.GetTrusted())
804+
}
805+
}
806+
792807
// send API call to update the repo
793808
err = database.FromContext(c).UpdateRepo(r)
794809
if err != nil {
@@ -1044,11 +1059,12 @@ func ChownRepo(c *gin.Context) {
10441059
}
10451060

10461061
// checkAllowlist is a helper function to ensure only repos in the
1047-
// allowlist are allowed to enable repos. If the allowlist is
1048-
// empty then any repo can be enabled.
1062+
// allowlist are allowed to enable repos.
1063+
//
1064+
// a single entry of '*' allows any repo to be enabled.
10491065
func checkAllowlist(r *library.Repo, allowlist []string) bool {
1050-
// if the allowlist is not set or empty allow any repo to be enabled
1051-
if len(allowlist) == 0 {
1066+
// check if all repos are allowed to be enabled
1067+
if len(allowlist) == 1 && allowlist[0] == "*" {
10521068
return true
10531069
}
10541070

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ require (
1414
github.com/gin-gonic/gin v1.8.1
1515
github.com/go-playground/assert/v2 v2.2.0
1616
github.com/go-redis/redis/v8 v8.11.5
17-
github.com/go-vela/types v0.15.1
17+
github.com/go-vela/types v0.16.0
1818
github.com/golang-jwt/jwt/v4 v4.4.2
1919
github.com/google/go-cmp v0.5.9
2020
github.com/google/go-github/v44 v44.1.0
@@ -30,7 +30,7 @@ require (
3030
github.com/sirupsen/logrus v1.9.0
3131
github.com/spf13/afero v1.9.2
3232
github.com/urfave/cli/v2 v2.17.1
33-
go.starlark.net v0.0.0-20220928063852-5fccb4daaf6d
33+
go.starlark.net v0.0.0-20221028183056-acb66ad56dd2
3434
golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1
3535
gopkg.in/square/go-jose.v2 v2.6.0
3636
gopkg.in/tomb.v2 v2.0.0-20161208151619-d5d1b5820637

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC
160160
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
161161
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
162162
github.com/go-test/deep v1.0.2 h1:onZX1rnHT3Wv6cqNgYyFOOlgVKJrksuCMCRvJStbMYw=
163-
github.com/go-vela/types v0.15.1 h1:nQxfxoqxavuTYtvFJW4wK9UkkADN2VG6Z4ubvJ8PT1s=
164-
github.com/go-vela/types v0.15.1/go.mod h1:6KoRkvXMw9DkAcLdtI7PxPqMlT2Bl0DiigQamLGGjwo=
163+
github.com/go-vela/types v0.16.0 h1:YsgbnnOS7FPFA0dPRZCLH2ryCdya14qSi3MgJab6ixo=
164+
github.com/go-vela/types v0.16.0/go.mod h1:6KoRkvXMw9DkAcLdtI7PxPqMlT2Bl0DiigQamLGGjwo=
165165
github.com/goccy/go-json v0.9.7 h1:IcB+Aqpx/iMHu5Yooh7jEzJk1JZ7Pjtmys2ukPr7EeM=
166166
github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
167167
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
@@ -563,8 +563,8 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
563563
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
564564
go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
565565
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
566-
go.starlark.net v0.0.0-20220928063852-5fccb4daaf6d h1:aF+anaRVZu22kdETjLavnIn/cvD+arhmik6vMU3joW4=
567-
go.starlark.net v0.0.0-20220928063852-5fccb4daaf6d/go.mod h1:kIVgS18CjmEC3PqMd5kaJSGEifyV/CeB9x506ZJ1Vbk=
566+
go.starlark.net v0.0.0-20221028183056-acb66ad56dd2 h1:5/KzhcSqd4UgY51l17r7C5g/JiE6DRw1Vq7VJfQHuMc=
567+
go.starlark.net v0.0.0-20221028183056-acb66ad56dd2/go.mod h1:kIVgS18CjmEC3PqMd5kaJSGEifyV/CeB9x506ZJ1Vbk=
568568
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
569569
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
570570
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=

0 commit comments

Comments
 (0)