config

package
v0.0.0-...-38d5e0a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config provides configuration management for the PR CLI application

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingPlatform       = errors.New("platform is required")
	ErrMissingToken          = errors.New("token is required")
	ErrMissingOwner          = errors.New("repository owner is required")
	ErrMissingRepo           = errors.New("repository name is required")
	ErrInvalidPRNum          = errors.New("PR number must be greater than 0")
	ErrMissingCommentSender  = errors.New("comment sender is required")
	ErrMissingTriggerComment = errors.New("trigger comment is required")
)

Configuration validation errors

Functions

This section is empty.

Types

type Config

type Config struct {
	// Platform configuration
	Platform     string `json:"platform" yaml:"platform" mapstructure:"platform"`
	Token        string `json:"token" yaml:"token" mapstructure:"token"`
	CommentToken string `json:"comment_token,omitempty" yaml:"comment_token,omitempty" mapstructure:"comment-token"`
	BaseURL      string `json:"base_url,omitempty" yaml:"base_url,omitempty" mapstructure:"base-url"`

	// Repository configuration
	Owner string `json:"owner" yaml:"owner" mapstructure:"repo-owner"`
	Repo  string `json:"repo" yaml:"repo" mapstructure:"repo-name"`

	// PR configuration
	PRNum         int    `json:"pr_num" yaml:"pr_num" mapstructure:"pr-num"`
	CommentSender string `json:"comment_sender" yaml:"comment_sender" mapstructure:"comment-sender"`

	// CLI-specific configuration
	TriggerComment string `json:"trigger_comment,omitempty" yaml:"trigger_comment,omitempty" mapstructure:"trigger-comment"`
	Debug          bool   `json:"debug,omitempty" yaml:"debug,omitempty" mapstructure:"debug"`
	Verbose        bool   `json:"verbose,omitempty" yaml:"verbose,omitempty" mapstructure:"verbose"`
	LogFormat      string `json:"log_format,omitempty" yaml:"log_format,omitempty" mapstructure:"log-format"`
	ResultsDir     string `json:"results_dir,omitempty" yaml:"results_dir,omitempty" mapstructure:"results-dir"`

	// LGTM configuration
	LGTMThreshold   int      `json:"lgtm_threshold" yaml:"lgtm_threshold" mapstructure:"lgtm-threshold"`
	LGTMPermissions []string `json:"lgtm_permissions" yaml:"lgtm_permissions" mapstructure:"lgtm-permissions"`
	LGTMReviewEvent string   `json:"lgtm_review_event,omitempty" yaml:"lgtm_review_event,omitempty" mapstructure:"lgtm-review-event"`
	RobotAccounts   []string `json:"robot_accounts,omitempty" yaml:"robot_accounts,omitempty" mapstructure:"robot-accounts"`

	// Merge configuration
	MergeMethod string `json:"merge_method" yaml:"merge_method" mapstructure:"merge-method"`

	// Check configuration
	SelfCheckName string `json:"self_check_name,omitempty" yaml:"self_check_name,omitempty" mapstructure:"self-check-name"`

	// Cherry-pick configuration
	UseGitCLIForCherryPick bool `` /* 129-byte string literal not displayed */

	// Logging configuration
	LogLevel string `json:"log_level" yaml:"log_level" mapstructure:"log-level"`
}

Config holds the configuration for PR CLI operations

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig returns a new Config with default values

func (*Config) DebugString

func (c *Config) DebugString() string

DebugString returns a JSON representation of the config with sensitive information redacted

func (*Config) HasLGTMPermission

func (c *Config) HasLGTMPermission(userPerm string) bool

HasLGTMPermission checks if the given permission is in the LGTM permissions list

func (*Config) IsRobotUser

func (c *Config) IsRobotUser(user string) bool

IsRobotUser checks if the user is a robot user that should be excluded from LGTM status

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the configuration is valid

type WebhookConfig

type WebhookConfig struct {
	// Server settings
	ListenAddr  string `json:"listen_addr" yaml:"listen_addr" mapstructure:"listen-addr"`
	WebhookPath string `json:"webhook_path" yaml:"webhook_path" mapstructure:"webhook-path"`
	HealthPath  string `json:"health_path" yaml:"health_path" mapstructure:"health-path"`
	MetricsPath string `json:"metrics_path" yaml:"metrics_path" mapstructure:"metrics-path"`

	// Security
	WebhookSecret    string   `json:"-" yaml:"-" mapstructure:"webhook-secret"`
	AllowedRepos     []string `json:"allowed_repos" yaml:"allowed_repos" mapstructure:"allowed-repos"`
	RequireSignature bool     `json:"require_signature" yaml:"require_signature" mapstructure:"require-signature"`

	// TLS
	TLSEnabled  bool   `json:"tls_enabled" yaml:"tls_enabled" mapstructure:"tls-enabled"`
	TLSCertFile string `json:"tls_cert_file" yaml:"tls_cert_file" mapstructure:"tls-cert-file"`
	TLSKeyFile  string `json:"tls_key_file" yaml:"tls_key_file" mapstructure:"tls-key-file"`

	// Processing
	AsyncProcessing bool `json:"async_processing" yaml:"async_processing" mapstructure:"async-processing"`
	WorkerCount     int  `json:"worker_count" yaml:"worker_count" mapstructure:"worker-count"`
	QueueSize       int  `json:"queue_size" yaml:"queue_size" mapstructure:"queue-size"`

	// Rate limiting
	RateLimitEnabled  bool `json:"rate_limit_enabled" yaml:"rate_limit_enabled" mapstructure:"rate-limit-enabled"`
	RateLimitRequests int  `json:"rate_limit_requests" yaml:"rate_limit_requests" mapstructure:"rate-limit-requests"`

	// Pull Request event configuration
	PREventEnabled bool     `json:"pr_event_enabled" yaml:"pr_event_enabled" mapstructure:"pr-event-enabled"`
	PREventActions []string `json:"pr_event_actions" yaml:"pr_event_actions" mapstructure:"pr-event-actions"`

	// Workflow dispatch configuration
	WorkflowFile   string            `json:"workflow_file" yaml:"workflow_file" mapstructure:"workflow-file"`
	WorkflowRepo   string            `json:"workflow_repo" yaml:"workflow_repo" mapstructure:"workflow-repo"`
	WorkflowRef    string            `json:"workflow_ref" yaml:"workflow_ref" mapstructure:"workflow-ref"`
	WorkflowInputs map[string]string `json:"workflow_inputs" yaml:"workflow_inputs" mapstructure:"workflow-inputs"`

	// Base PR CLI configuration
	BaseConfig *Config `json:"-" yaml:"-"`
}

WebhookConfig holds webhook server configuration

func NewDefaultWebhookConfig

func NewDefaultWebhookConfig() *WebhookConfig

NewDefaultWebhookConfig returns default webhook configuration

func (*WebhookConfig) DebugString

func (wc *WebhookConfig) DebugString() string

DebugString returns a string representation with sensitive data redacted

func (*WebhookConfig) LoadFromEnv

func (wc *WebhookConfig) LoadFromEnv() error

LoadFromEnv loads webhook configuration from environment variables

func (*WebhookConfig) Validate

func (wc *WebhookConfig) Validate() error

Validate checks if the webhook configuration is valid

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL