mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-25 09:50:31 +00:00
cc30db44ac
* use async key pair for webhooks * fix tests * fix linter * improve code * add key pair to database * undo some changes * more undo * improve docs * add api-endpoint * add signaturne api endpoint * fix error * fix linting and test * fix lint * add test * migration 006 * no need for migration * replace httsign lib * fix lint Co-authored-by: 6543 <6543@obermui.de>
36 lines
649 B
Go
36 lines
649 B
Go
package datastore
|
|
|
|
import "github.com/woodpecker-ci/woodpecker/server/model"
|
|
|
|
func (s storage) ServerConfigGet(key string) (string, error) {
|
|
config := &model.ServerConfig{
|
|
Key: key,
|
|
}
|
|
|
|
err := wrapGet(s.engine.Get(config))
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return config.Value, nil
|
|
}
|
|
|
|
func (s storage) ServerConfigSet(key, value string) error {
|
|
config := &model.ServerConfig{
|
|
Key: key,
|
|
Value: value,
|
|
}
|
|
|
|
count, err := s.engine.Count(config)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if count == 0 {
|
|
_, err := s.engine.Insert(config)
|
|
return err
|
|
}
|
|
|
|
_, err = s.engine.Where("key = ?", config.Key).AllCols().Update(config)
|
|
return err
|
|
}
|