nitter/nitters/gitea/config.go
Peter Kurfer 6507d44725
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is passing
feat: run PoC in pipeline
2023-03-08 16:37:00 +01:00

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
}