plugins

package
v5.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PALIGO_RATE_LIMIT_CHECK_INTERVAL = 5 * time.Second
	PALIGO_DOCUMENT_SHOW_LIMIT       = 50
	PALIGO_FOLDER_SHOW_LIMIT         = 50
)

https://paligo.net/docs/apidocs/en/index-en.html#UUID-a5b548af-9a37-d305-f5a8-11142d86fe20

Variables

View Source
var (
	// ErrBaseURLInvalidOrUnreachable is returned when the base URL/host/service is invalid or unreachable.
	ErrBaseURLInvalidOrUnreachable = errors.New("base url invalid or service unreachable")

	// ErrBadCredentials indicates token is invalid/expired or username does not match the token.
	ErrBadCredentials = errors.New("bad credentials")

	// ErrMissingScopes indicates the token is valid but missing required scopes.
	ErrMissingScopes = errors.New("token missing required scopes")

	// ErrUnexpectedHTTPStatus is used for other non-2xx statuses not classified above.
	ErrUnexpectedHTTPStatus = errors.New("unexpected http status")

	// ErrAPIResponseTooLarge is returned internally when a single API response exceeds
	// the configured per-request size limit. Callers treat this as a soft failure:
	// skip the current batch and move on when possible.
	ErrAPIResponseTooLarge = errors.New("confluence api response exceeded configured size limit")

	// ErrTotalScanVolumeExceeded is returned when the total downloaded bytes across
	// the scan exceed the configured global limit. Callers should stop scanning
	// gracefully and not treat this as a hard failure.
	ErrTotalScanVolumeExceeded = errors.New("confluence total scan volume exceeded configured limit")
)
View Source
var ErrFileDiffSizeExceeded = errors.New("file diff size exceeded")
View Source
var (
	ErrHTTPSRequired = errors.New("must use https")
)

Functions

func GetGitStartAndEndLine

func GetGitStartAndEndLine(gitInfo *GitInfo, localStartLine, localEndLine int) (int, int, error)

GetGitStartAndEndLine walks the diff hunks and discover the actual start and end lines of the file

func ParseConfluenceItemID

func ParseConfluenceItemID(id string) (string, bool)

ParseConfluenceItemID extracts the Confluence page ID from an item ID produced by NewConfluenceItemID. It returns ("", false) if the ID does not conform to the expected pattern.

Types

type Channels

type Channels struct {
	Items  chan ISourceItem
	Errors chan error
	// contains filtered or unexported fields
}

func (*Channels) GetErrorsCh

func (c *Channels) GetErrorsCh() chan error

func (*Channels) GetItemsCh

func (c *Channels) GetItemsCh() chan ISourceItem

type Component

type Component struct {
	PaligoItem
	Subtype          string        `json:"subtype"`
	Creator          int           `json:"creator"`
	Owner            int           `json:"owner"`
	Author           int           `json:"author"`
	CreatedAt        int           `json:"created_at"`
	ModifiedAt       int           `json:"modified_at"`
	Checkout         bool          `json:"checkout"`
	CheckoutUser     string        `json:"checkout_user"`
	ParentResource   int           `json:"parent_resource"`
	Taxonomies       []interface{} `json:"taxonomies"`
	ReleaseStatus    string        `json:"release_status"`
	Content          string        `json:"content"`
	Languages        []string      `json:"languages"`
	External         []interface{} `json:"external"`
	CustomAttributes []interface{} `json:"custom_attributes"`
}

type ConfluenceClient

type ConfluenceClient interface {
	WalkAllPages(ctx context.Context, limit int, visit func(*Page) error) error
	WalkPagesByIDs(ctx context.Context, pageIDs []string, limit int, visit func(*Page) error) error
	WalkPagesBySpaceIDs(ctx context.Context, spaceIDs []string, limit int, visit func(*Page) error) error
	WalkPageVersions(ctx context.Context, pageID string, limit int, visit func(int) error) error
	FetchPageAtVersion(ctx context.Context, pageID string, version int) (*Page, error)
	WalkSpacesByKeys(ctx context.Context, spaceKeys []string, limit int, visit func(*Space) error) error
	WikiBaseURL() string
	APIResponseLimitHit() bool
}

ConfluenceClient defines the operations required by the Confluence plugin. Methods stream results via visitor callbacks and handle pagination internally.

func NewConfluenceClient

func NewConfluenceClient(inputBaseURL, username, token string, opts ...ConfluenceClientOption) (ConfluenceClient, error)

NewConfluenceClient constructs a ConfluenceClient for the given base input URL. Behavior:

type ConfluenceClientOption

type ConfluenceClientOption func(*httpConfluenceClient)

func WithMaxAPIResponseBytes

func WithMaxAPIResponseBytes(n int64) ConfluenceClientOption

WithMaxAPIResponseBytes sets an optional per-request API response size limit in bytes. A value of 0 disables the limit. Negative values are treated as 0.

func WithMaxTotalScanBytes

func WithMaxTotalScanBytes(n int64) ConfluenceClientOption

WithMaxTotalScanBytes sets an optional total downloaded-bytes limit in bytes for the entire Confluence scan. A value of 0 disables the limit. Negative values are treated as 0.

type ConfluencePlugin

type ConfluencePlugin struct {
	Plugin

	SpaceIDs  []string
	SpaceKeys []string
	PageIDs   []string
	History   bool
	// contains filtered or unexported fields
}

func (*ConfluencePlugin) DefineCommand

func (p *ConfluencePlugin) DefineCommand(items chan ISourceItem, errs chan error) (*cobra.Command, error)

DefineCommand wires the Cobra command, flags, and pre-run initialization.

func (*ConfluencePlugin) GetName

func (p *ConfluencePlugin) GetName() string

GetName returns the CLI subcommand name for this plugin.

func (*ConfluencePlugin) NewConfluenceItemID

func (p *ConfluencePlugin) NewConfluenceItemID(pageID string, version int) string

NewConfluenceItemID builds the item ID for a Confluence page.

type DiffType

type DiffType int
const (
	AddedContent DiffType = iota
	RemovedContent
)

type DiscordPlugin

type DiscordPlugin struct {
	Token            string
	Guilds           []string
	Channels         []string
	Count            int
	BackwardDuration time.Duration
	Session          *discordgo.Session
	// contains filtered or unexported fields
}

func (*DiscordPlugin) DefineCommand

func (p *DiscordPlugin) DefineCommand(items chan ISourceItem, errors chan error) (*cobra.Command, error)

func (*DiscordPlugin) GetName

func (p *DiscordPlugin) GetName() string

type Document

type Document struct {
	PaligoItem
	Content   string   `json:"content"`
	Languages []string `json:"languages"`
}

type EmptyFolder

type EmptyFolder struct {
	PaligoItem
	Children string `json:"children"`
}

type FileSystemPlugin

type FileSystemPlugin struct {
	Plugin
	Path        string
	ProjectName string
	Ignored     []string
}

func (*FileSystemPlugin) DefineCommand

func (p *FileSystemPlugin) DefineCommand(items chan ISourceItem, errors chan error) (*cobra.Command, error)

func (*FileSystemPlugin) GetName

func (p *FileSystemPlugin) GetName() string

type Folder

type Folder struct {
	PaligoItem
	Children []PaligoItem `json:"children"`
}

type GitInfo

type GitInfo struct {
	Hunks       []*gitdiff.TextFragment
	ContentType DiffType
}

type GitPlugin

type GitPlugin struct {
	Plugin
	Channels
	// contains filtered or unexported fields
}

func (*GitPlugin) DefineCommand

func (p *GitPlugin) DefineCommand(items chan ISourceItem, errors chan error) (*cobra.Command, error)

func (*GitPlugin) GetName

func (p *GitPlugin) GetName() string

type IPlugin

type IPlugin interface {
	GetName() string
	DefineCommand(items chan ISourceItem, errors chan error) (*cobra.Command, error)
}

func NewConfluencePlugin

func NewConfluencePlugin() IPlugin

NewConfluencePlugin constructs a new Confluence plugin with a default chunker.

func NewGitPlugin

func NewGitPlugin() IPlugin

type ISlackClient

type ISlackClient interface {
	GetConversations(*slack.GetConversationsParameters) ([]slack.Channel, string, error)
	ListTeams(slack.ListTeamsParameters) ([]slack.Team, string, error)
}

type ISourceItem

type ISourceItem interface {
	GetContent() *string
	GetID() string
	GetSource() string
	GetGitInfo() *GitInfo
}

type ListFoldersResponse

type ListFoldersResponse struct {
	Page       int           `json:"page"`
	NextPage   string        `json:"next_page"`
	TotalPages int           `json:"total_pages"`
	Folders    []EmptyFolder `json:"folders"`
}

type Option

type Option func(*Channels)

type Page

type Page struct {
	ID      string            `json:"id"`
	Status  string            `json:"status"`
	Title   string            `json:"title"`
	SpaceID string            `json:"spaceId"`
	Type    string            `json:"type"`
	Body    PageBody          `json:"body"`
	Links   map[string]string `json:"_links"`
	Version PageVersion       `json:"version"`
}

Page represents a Confluence page.

type PageBody

type PageBody struct {
	Storage *struct {
		Value string `json:"value"`
	} `json:"storage,omitempty"`
}

PageBody contains the Storage-Format body of a page.

type PageVersion

type PageVersion struct {
	Number int `json:"number"`
}

PageVersion models the "version" object returned by Confluence.

type PaligoClient

type PaligoClient struct {
	Instance string
	// contains filtered or unexported fields
}

type PaligoItem

type PaligoItem struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
	UUID string `json:"uuid"`
	Type string `json:"type"`
}

type PaligoPlugin

type PaligoPlugin struct {
	Plugin
	Channels
	// contains filtered or unexported fields
}

func (*PaligoPlugin) DefineCommand

func (p *PaligoPlugin) DefineCommand(items chan ISourceItem, errors chan error) (*cobra.Command, error)

func (*PaligoPlugin) GetAuthorizationHeader

func (p *PaligoPlugin) GetAuthorizationHeader() string

func (*PaligoPlugin) GetCredentials

func (p *PaligoPlugin) GetCredentials() (string, string)

func (*PaligoPlugin) GetName

func (p *PaligoPlugin) GetName() string

type Plugin

type Plugin struct {
	ID    string
	Limit chan struct{}
}

type PluginChannels

type PluginChannels interface {
	GetItemsCh() chan ISourceItem
	GetErrorsCh() chan error
}

func NewChannels

func NewChannels(opts ...Option) PluginChannels

type SlackPlugin

type SlackPlugin struct {
	Plugin
	Channels
	Token string
}

func (*SlackPlugin) DefineCommand

func (p *SlackPlugin) DefineCommand(items chan ISourceItem, errors chan error) (*cobra.Command, error)

func (*SlackPlugin) GetName

func (p *SlackPlugin) GetName() string

type Space

type Space struct {
	ID    string            `json:"id"`
	Key   string            `json:"key"`
	Name  string            `json:"name"`
	Links map[string]string `json:"_links"`
}

Space represents a Confluence space.

type StringBuilderPool

type StringBuilderPool struct {
	// contains filtered or unexported fields
}

StringBuilderPool provides thread-safe object pooling for string builders

func (*StringBuilderPool) Get

func (p *StringBuilderPool) Get() *strings.Builder

Get retrieves a string builder from the pool

func (*StringBuilderPool) Put

func (p *StringBuilderPool) Put(sb *strings.Builder)

Put returns a string builder to the pool with size limits

func (*StringBuilderPool) Stats

func (p *StringBuilderPool) Stats() (gets, puts, discards, news int64, efficiency float64)

Stats returns pool efficiency statistics

Jump to

Keyboard shortcuts

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