Support plugin-only secrets (#1344)

Closes #1071
This commit is contained in:
qwerty287
2022-10-27 04:21:07 +02:00
committed by GitHub
parent 9ece7a1c49
commit e568c42e84
17 changed files with 154 additions and 50 deletions

View File

@@ -59,10 +59,11 @@ func PostGlobalSecret(c *gin.Context) {
return
}
secret := &model.Secret{
Name: in.Name,
Value: in.Value,
Events: in.Events,
Images: in.Images,
Name: in.Name,
Value: in.Value,
Events: in.Events,
Images: in.Images,
PluginsOnly: in.PluginsOnly,
}
if err := secret.Validate(); err != nil {
c.String(400, "Error inserting global secret. %s", err)
@@ -100,6 +101,7 @@ func PatchGlobalSecret(c *gin.Context) {
if in.Images != nil {
secret.Images = in.Images
}
secret.PluginsOnly = in.PluginsOnly
if err := secret.Validate(); err != nil {
c.String(400, "Error updating global secret. %s", err)

View File

@@ -65,11 +65,12 @@ func PostOrgSecret(c *gin.Context) {
return
}
secret := &model.Secret{
Owner: owner,
Name: in.Name,
Value: in.Value,
Events: in.Events,
Images: in.Images,
Owner: owner,
Name: in.Name,
Value: in.Value,
Events: in.Events,
Images: in.Images,
PluginsOnly: in.PluginsOnly,
}
if err := secret.Validate(); err != nil {
c.String(400, "Error inserting org %q secret. %s", owner, err)
@@ -110,6 +111,7 @@ func PatchOrgSecret(c *gin.Context) {
if in.Images != nil {
secret.Images = in.Images
}
secret.PluginsOnly = in.PluginsOnly
if err := secret.Validate(); err != nil {
c.String(400, "Error updating org %q secret. %s", owner, err)

View File

@@ -50,11 +50,12 @@ func PostSecret(c *gin.Context) {
return
}
secret := &model.Secret{
RepoID: repo.ID,
Name: strings.ToLower(in.Name),
Value: in.Value,
Events: in.Events,
Images: in.Images,
RepoID: repo.ID,
Name: strings.ToLower(in.Name),
Value: in.Value,
Events: in.Events,
Images: in.Images,
PluginsOnly: in.PluginsOnly,
}
if err := secret.Validate(); err != nil {
c.String(400, "Error inserting secret. %s", err)
@@ -95,6 +96,7 @@ func PatchSecret(c *gin.Context) {
if in.Images != nil {
secret.Images = in.Images
}
secret.PluginsOnly = in.PluginsOnly
if err := secret.Validate(); err != nil {
c.String(400, "Error updating secret. %s", err)