2017-04-11 17:06:45 +00:00
|
|
|
package secrets
|
|
|
|
|
|
|
|
import (
|
2021-12-11 12:15:04 +00:00
|
|
|
"context"
|
|
|
|
|
2021-09-27 17:51:55 +00:00
|
|
|
"github.com/woodpecker-ci/woodpecker/server/model"
|
2017-04-11 17:06:45 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type builtin struct {
|
2021-12-11 12:15:04 +00:00
|
|
|
context.Context
|
2017-04-11 17:06:45 +00:00
|
|
|
store model.SecretStore
|
|
|
|
}
|
|
|
|
|
|
|
|
// New returns a new local secret service.
|
2021-12-11 12:15:04 +00:00
|
|
|
func New(ctx context.Context, store model.SecretStore) model.SecretService {
|
|
|
|
return &builtin{store: store, Context: ctx}
|
2017-04-11 17:06:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (b *builtin) SecretFind(repo *model.Repo, name string) (*model.Secret, error) {
|
|
|
|
return b.store.SecretFind(repo, name)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *builtin) SecretList(repo *model.Repo) ([]*model.Secret, error) {
|
|
|
|
return b.store.SecretList(repo)
|
|
|
|
}
|
|
|
|
|
2017-05-12 10:30:19 +00:00
|
|
|
func (b *builtin) SecretListBuild(repo *model.Repo, build *model.Build) ([]*model.Secret, error) {
|
|
|
|
return b.store.SecretList(repo)
|
|
|
|
}
|
|
|
|
|
2017-04-11 17:06:45 +00:00
|
|
|
func (b *builtin) SecretCreate(repo *model.Repo, in *model.Secret) error {
|
|
|
|
return b.store.SecretCreate(in)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *builtin) SecretUpdate(repo *model.Repo, in *model.Secret) error {
|
|
|
|
return b.store.SecretUpdate(in)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *builtin) SecretDelete(repo *model.Repo, name string) error {
|
|
|
|
secret, err := b.store.SecretFind(repo, name)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return b.store.SecretDelete(secret)
|
|
|
|
}
|