config

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigDir

func ConfigDir() (string, error)

ConfigDir returns the config directory path

func ConfigPath

func ConfigPath() (string, error)

ConfigPath returns the path to the config file

func Save

func Save(cfg *Config) error

Save writes the config to file

Types

type Config

type Config struct {
	// Global settings (non-integration specific)
	ActivityDays int `json:"activity_days,omitempty" envconfig:"ACTIVITY_DAYS" default:"14"`

	// Integration configs (embedded)
	GitLab GitLabConfig `json:"gitlab,omitempty"`
	Jira   JiraConfig   `json:"jira,omitempty"`
	Slack  SlackConfig  `json:"slack,omitempty"`
}

Config is the root configuration struct

func Load

func Load() (*Config, error)

Load reads config from file and applies environment variable overrides

func LoadFromFile

func LoadFromFile() (*Config, error)

LoadFromFile reads config from file only (no env overrides) Used when we want to modify and write back without losing env-only values

func (*Config) RequireGitLab

func (c *Config) RequireGitLab() error

RequireGitLab validates that GitLab config is present

func (*Config) RequireJira

func (c *Config) RequireJira() error

RequireJira validates that Jira OAuth config is present

func (*Config) RequireSlack

func (c *Config) RequireSlack() error

RequireSlack validates that Slack bot token is present

type GitLabConfig

type GitLabConfig struct {
	URL   string `json:"url,omitempty" envconfig:"GITLAB_URL"`
	Token string `json:"token,omitempty" envconfig:"GITLAB_PERSONAL_TOKEN"`
}

GitLabConfig holds GitLab-specific configuration

type JiraConfig

type JiraConfig struct {
	ClientID     string     `json:"client_id,omitempty" envconfig:"JIRA_CLIENT_ID"`
	ClientSecret string     `json:"client_secret,omitempty" envconfig:"JIRA_CLIENT_SECRET"`
	BaseURL      string     `json:"base_url,omitempty" envconfig:"JIRA_BASE_URL"`
	CloudID      string     `json:"cloud_id,omitempty"`
	Token        *JiraToken `json:"token,omitempty"`
}

JiraConfig holds Jira-specific configuration

type JiraToken

type JiraToken struct {
	AccessToken  string    `json:"access_token"`
	RefreshToken string    `json:"refresh_token"`
	ExpiresAt    time.Time `json:"expires_at"`
	CloudID      string    `json:"cloud_id,omitempty"`
	SiteURL      string    `json:"site_url,omitempty"` // Browsable URL like https://company.atlassian.net
}

JiraToken holds Jira OAuth tokens

func (*JiraToken) IsExpired

func (t *JiraToken) IsExpired() bool

IsExpired checks if the token is expired (with 1 min buffer)

type SlackConfig

type SlackConfig struct {
	// OAuth credentials (for `dex slack auth`)
	ClientID     string      `json:"client_id,omitempty" envconfig:"SLACK_CLIENT_ID"`
	ClientSecret string      `json:"client_secret,omitempty" envconfig:"SLACK_CLIENT_SECRET"`
	Token        *SlackToken `json:"token,omitempty"`

	// Manual tokens (legacy, can be set directly or via OAuth)
	BotToken  string `json:"bot_token,omitempty" envconfig:"SLACK_BOT_TOKEN"`
	AppToken  string `json:"app_token,omitempty" envconfig:"SLACK_APP_TOKEN"`   // For Socket Mode
	UserToken string `json:"user_token,omitempty" envconfig:"SLACK_USER_TOKEN"` // For search API
}

SlackConfig holds Slack-specific configuration

type SlackToken

type SlackToken struct {
	AccessToken  string `json:"access_token"`            // Bot token (xoxb-...)
	UserToken    string `json:"user_token,omitempty"`    // User token (xoxp-...) if user scopes requested
	RefreshToken string `json:"refresh_token,omitempty"` // For token rotation
	TeamID       string `json:"team_id"`
	TeamName     string `json:"team_name"`
	BotUserID    string `json:"bot_user_id"`
}

SlackToken holds Slack OAuth tokens

Jump to

Keyboard shortcuts

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