package gitea import ( "errors" "code.gitea.io/sdk/gitea" "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"` ReviewState gitea.ReviewStateType `mapstructure:"review-state"` } func (gpc GiteaPRConfig) Validate() error { if err := gpc.GiteaConfig.Validate(); err != nil { return err } if gpc.PRIndex < 0 { return ErrMissingPRIndex } return nil } type GiteaPRLintConfig struct { GiteaPRConfig `mapstructure:",squash"` FromPRBase bool `mapstructure:"from-pr-base"` ExtraArgs []string `mapstructure:"golangci-lint-extra-args"` } func (gpc GiteaPRLintConfig) Validate() error { return gpc.GiteaPRConfig.Validate() }