52 lines
972 B
Go
52 lines
972 B
Go
package gitea
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"code.icb4dc0.de/prskr/nitter/nitters"
|
|
)
|
|
|
|
var (
|
|
ErrMissingBaseAddress = errors.New("API base address is required")
|
|
ErrMissingToken = errors.New("API token is required")
|
|
ErrMissingPRIndex = errors.New("PR index is required")
|
|
)
|
|
|
|
type GiteaConfig struct {
|
|
nitters.Config `mapstructure:",squash"`
|
|
BaseAddress string `mapstructure:"base-address"`
|
|
Token string `mapstructure:"token"`
|
|
}
|
|
|
|
func (gc GiteaConfig) Validate() error {
|
|
if err := gc.Config.Validate(); err != nil {
|
|
return err
|
|
}
|
|
|
|
if gc.BaseAddress == "" {
|
|
return ErrMissingBaseAddress
|
|
}
|
|
|
|
if gc.Token == "" {
|
|
return ErrMissingToken
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
type GiteaPRConfig struct {
|
|
GiteaConfig `mapstructure:",squash"`
|
|
PRIndex int64 `mapstructure:"pull-index"`
|
|
}
|
|
|
|
func (gpc GiteaPRConfig) Validate() error {
|
|
if err := gpc.GiteaConfig.Validate(); err != nil {
|
|
return err
|
|
}
|
|
|
|
if gpc.PRIndex < 0 {
|
|
return ErrMissingPRIndex
|
|
}
|
|
|
|
return nil
|
|
}
|