Documentation
¶
Index ¶
- type BlobFragment
- type BlobObject
- type ChangedFile
- type CommitStrategy
- type CommitStrategyConfig
- type CommitStrategyOrRef
- type ConfigFileType
- type Configs
- type CopierFileMeta
- type CopyTransform
- type CreateFileRequest
- type Defaults
- type DeprecatedFileEntry
- type DeprecationConfig
- type DeprecationFile
- type Destination
- type Entry
- type ExcludeOrRef
- type GitObject
- type GlobTransform
- type MainConfig
- type MatchResult
- type MessageContext
- type MoveTransform
- type PatternType
- type PullRequestQuery
- type Ref
- type RefOrValue
- type RegexTransform
- type RepoFilesResponse
- type Repository
- type Source
- type SourcePattern
- type TransformContext
- type Transformation
- type TransformationType
- type TransformationsOrRef
- type TreeFragment
- type UploadFileContent
- type UploadKey
- type Workflow
- type WorkflowConfig
- type WorkflowConfigRef
- type YAMLConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlobFragment ¶
type BlobFragment struct {
Blob BlobObject `graphql:"... on Blob"`
}
type BlobObject ¶
type BlobObject struct {
Text string `json:"text"`
}
type ChangedFile ¶
type CommitStrategy ¶
type CommitStrategy string
CommitStrategy represents the strategy for committing changes
const ( CommitStrategyDirect CommitStrategy = "direct" CommitStrategyPR CommitStrategy = "pull_request" )
type CommitStrategyConfig ¶
type CommitStrategyConfig struct {
Type string `yaml:"type" json:"type"` // "direct" or "pull_request"
CommitMessage string `yaml:"commit_message,omitempty" json:"commit_message,omitempty"`
PRTitle string `yaml:"pr_title,omitempty" json:"pr_title,omitempty"`
PRBody string `yaml:"pr_body,omitempty" json:"pr_body,omitempty"`
UsePRTemplate bool `yaml:"use_pr_template,omitempty" json:"use_pr_template,omitempty"` // If true, fetch and use PR template from target repo
AutoMerge bool `yaml:"auto_merge,omitempty" json:"auto_merge,omitempty"`
}
CommitStrategyConfig defines commit strategy settings
func (*CommitStrategyConfig) Validate ¶
func (c *CommitStrategyConfig) Validate() error
Validate validates the commit strategy configuration
type CommitStrategyOrRef ¶
type CommitStrategyOrRef struct {
Ref string `yaml:"-" json:"-"`
CommitStrategy *CommitStrategyConfig `yaml:"-" json:"-"`
// contains filtered or unexported fields
}
CommitStrategyOrRef can be either inline commit strategy or a $ref
func (*CommitStrategyOrRef) IsRef ¶
func (c *CommitStrategyOrRef) IsRef() bool
IsRef returns true if this is a reference
func (CommitStrategyOrRef) MarshalYAML ¶
func (c CommitStrategyOrRef) MarshalYAML() (interface{}, error)
MarshalYAML implements custom YAML marshaling for commit strategy
func (*CommitStrategyOrRef) UnmarshalYAML ¶
func (c *CommitStrategyOrRef) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements custom YAML unmarshaling for commit strategy
type ConfigFileType ¶
type ConfigFileType []Configs
type Configs ¶
type Configs struct {
SourceDirectory string `json:"source_directory"`
TargetRepo string `json:"target_repo"`
TargetBranch string `json:"target_branch"`
TargetDirectory string `json:"target_directory"`
RecursiveCopy bool `json:"recursive_copy"`
CopierCommitStrategy string `json:"copier_commit_strategy"`
PRTitle string `json:"pr_title"`
CommitMessage string `json:"commit_message"`
MergeWithoutReview bool `json:"merge_without_review"`
}
Configs represents the configuration for file copying operations between repositories.
Example usage:
config := Configs{
SourceDirectory: "docs/api",
TargetRepo: "company/public-docs",
TargetBranch: "main",
TargetDirectory: "reference",
RecursiveCopy: true,
CopierCommitStrategy: "pr",
PRTitle: "Update API documentation",
CommitMessage: "Sync API docs from internal repo",
MergeWithoutReview: false,
}
type CopierFileMeta ¶ added in v0.4.0
type CopierFileMeta struct {
RuleName string `json:"rule_name,omitempty"`
SourceRepo string `json:"source_repo,omitempty"`
SourcePath string `json:"source_path,omitempty"`
CommitSHA string `json:"commit_sha,omitempty"`
PRNumber int `json:"pr_number,omitempty"`
}
CopierFileMeta carries per-file provenance for uploads (order matches UploadFileContent.Content).
type CopyTransform ¶
type CopyTransform struct {
From string `yaml:"from" json:"from"` // Source file path
To string `yaml:"to" json:"to"` // Destination file path
}
CopyTransform copies a single file to a new location
func (*CopyTransform) Validate ¶
func (c *CopyTransform) Validate() error
Validate validates a copy transformation
type CreateFileRequest ¶
type Defaults ¶
type Defaults struct {
CommitStrategy *CommitStrategyConfig `yaml:"commit_strategy,omitempty" json:"commit_strategy,omitempty"`
DeprecationCheck *DeprecationConfig `yaml:"deprecation_check,omitempty" json:"deprecation_check,omitempty"`
Exclude []string `yaml:"exclude,omitempty" json:"exclude,omitempty"`
}
Defaults defines default settings for all workflows
type DeprecatedFileEntry ¶
type DeprecatedFileEntry struct {
FileName string `json:"filename"`
Repo string `json:"repo"`
Branch string `json:"branch"`
DeletedOn string `json:"deleted_on"`
SourcePath string `json:"source_path,omitempty"` // Original source file path
PRNumber int `json:"pr_number,omitempty"` // PR that caused the deletion
}
type DeprecationConfig ¶
type DeprecationConfig struct {
Enabled bool `yaml:"enabled" json:"enabled"`
File string `yaml:"file,omitempty" json:"file,omitempty"` // defaults to deprecated_examples.json
}
DeprecationConfig defines deprecation tracking settings
type DeprecationFile ¶
type DeprecationFile []DeprecatedFileEntry
type Destination ¶
type Destination struct {
Repo string `yaml:"repo" json:"repo"`
Branch string `yaml:"branch,omitempty" json:"branch,omitempty"` // defaults to "main"
InstallationID string `yaml:"installation_id,omitempty" json:"installation_id,omitempty"` // optional override
}
Destination defines the destination repository and branch
func (*Destination) Validate ¶
func (d *Destination) Validate() error
Validate validates a destination
type Entry ¶
type Entry struct {
Name string `json:"name"`
Type string `json:"type"`
Mode int `json:"mode"`
Object *BlobFragment `json:"object"`
}
type ExcludeOrRef ¶
type ExcludeOrRef struct {
Ref string `yaml:"-" json:"-"`
Exclude []string `yaml:"-" json:"-"`
// contains filtered or unexported fields
}
ExcludeOrRef can be either inline exclude patterns or a $ref
func (*ExcludeOrRef) IsRef ¶
func (e *ExcludeOrRef) IsRef() bool
IsRef returns true if this is a reference
func (ExcludeOrRef) MarshalYAML ¶
func (e ExcludeOrRef) MarshalYAML() (interface{}, error)
MarshalYAML implements custom YAML marshaling for exclude patterns
func (*ExcludeOrRef) UnmarshalYAML ¶
func (e *ExcludeOrRef) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements custom YAML unmarshaling for exclude patterns
type GitObject ¶
type GitObject struct {
TreeFragment `graphql:"... on Tree"`
}
type GlobTransform ¶
type GlobTransform struct {
Pattern string `yaml:"pattern" json:"pattern"` // Glob pattern (e.g., "mflix/server/**/*.js")
Transform string `yaml:"transform" json:"transform"` // Path transform template (e.g., "server/${relative_path}")
}
GlobTransform uses glob patterns with path transformation
func (*GlobTransform) Validate ¶
func (g *GlobTransform) Validate() error
Validate validates a glob transformation
type MainConfig ¶
type MainConfig struct {
Defaults *Defaults `yaml:"defaults,omitempty" json:"defaults,omitempty"`
WorkflowConfigs []WorkflowConfigRef `yaml:"workflow_configs" json:"workflow_configs"`
}
MainConfig represents the central configuration file that references workflow configs
func (*MainConfig) SetDefaults ¶
func (m *MainConfig) SetDefaults()
SetDefaults sets default values for the main configuration
func (*MainConfig) Validate ¶
func (m *MainConfig) Validate() error
Validate validates the main configuration
type MatchResult ¶
type MatchResult struct {
Matched bool // Whether the pattern matched
Variables map[string]string // Extracted variables from the match
}
MatchResult represents the result of a pattern match
func NewMatchResult ¶
func NewMatchResult(matched bool, variables map[string]string) MatchResult
NewMatchResult creates a new match result
type MessageContext ¶
type MessageContext struct {
RuleName string // Name of the copy rule
SourceRepo string // Source repository
TargetRepo string // Target repository
SourceBranch string // Source branch
TargetBranch string // Target branch
FileCount int // Number of files being copied
PRNumber int // PR number that triggered the copy
CommitSHA string // Commit SHA
Variables map[string]string // Variables from pattern matching
}
MessageContext holds context for message template rendering
func NewMessageContext ¶
func NewMessageContext() *MessageContext
NewMessageContext creates a new message context
type MoveTransform ¶
type MoveTransform struct {
From string `yaml:"from" json:"from"` // Source path (can be directory or file)
To string `yaml:"to" json:"to"` // Destination path
}
MoveTransform moves files from one directory to another
func (*MoveTransform) Validate ¶
func (m *MoveTransform) Validate() error
Validate validates a move transformation
type PatternType ¶
type PatternType string
PatternType defines the type of pattern matching to use
const ( PatternTypePrefix PatternType = "prefix" PatternTypeGlob PatternType = "glob" PatternTypeRegex PatternType = "regex" )
func (PatternType) IsValid ¶
func (p PatternType) IsValid() bool
IsValid returns true if the pattern type is valid
func (PatternType) String ¶
func (p PatternType) String() string
String returns the string representation
type PullRequestQuery ¶
type PullRequestQuery struct {
Repository struct {
PullRequest struct {
Files struct {
PageInfo struct {
EndCursor githubv4.String
HasNextPage bool
}
Edges []struct {
Node struct {
Path githubv4.String
Additions githubv4.Int
Deletions githubv4.Int
ChangeType githubv4.String
}
}
} `graphql:"files(first: 100, after: $cursor)"`
} `graphql:"pullRequest(number: $number)"`
} `graphql:"repository(owner: $owner, name: $name)"`
}
type Ref ¶
type Ref struct {
Ref string `yaml:"$ref,omitempty" json:"$ref,omitempty"`
}
Ref represents a reference to another file
type RefOrValue ¶
type RefOrValue[T any] struct { Ref string `yaml:"$ref,omitempty" json:"$ref,omitempty"` Value *T `yaml:",inline" json:",inline"` }
RefOrValue is a generic type that can be either a reference or an inline value This is used for fields that support $ref
func (*RefOrValue[T]) GetValue ¶
func (r *RefOrValue[T]) GetValue() *T
GetValue returns the inline value (nil if this is a reference)
func (*RefOrValue[T]) IsRef ¶
func (r *RefOrValue[T]) IsRef() bool
IsRef returns true if this is a reference
type RegexTransform ¶
type RegexTransform struct {
Pattern string `yaml:"pattern" json:"pattern"` // Regex pattern with named groups
Transform string `yaml:"transform" json:"transform"` // Path transform template using captured groups
}
RegexTransform uses regex patterns with named capture groups
func (*RegexTransform) Validate ¶
func (r *RegexTransform) Validate() error
Validate validates a regex transformation
type RepoFilesResponse ¶
type RepoFilesResponse struct {
Repository Repository `graphql:"repository(owner: $owner, name: $name)"`
}
type Repository ¶
type Repository struct {
Object *GitObject `graphql:"object(expression: \"HEAD:\")"`
}
type Source ¶
type Source struct {
Repo string `yaml:"repo" json:"repo"`
Branch string `yaml:"branch,omitempty" json:"branch,omitempty"` // defaults to "main"
InstallationID string `yaml:"installation_id,omitempty" json:"installation_id,omitempty"` // optional override
}
Source defines the source repository and branch
type SourcePattern ¶
type SourcePattern struct {
Type PatternType `yaml:"type" json:"type"`
Pattern string `yaml:"pattern" json:"pattern"`
ExcludePatterns []string `yaml:"exclude_patterns,omitempty" json:"exclude_patterns,omitempty"` // Optional: regex patterns to exclude from matches
}
SourcePattern defines how to match source files (used by pattern matcher)
func (*SourcePattern) Validate ¶
func (sp *SourcePattern) Validate() error
Validate validates a source pattern
type TransformContext ¶
type TransformContext struct {
SourcePath string // Original source file path
Variables map[string]string // Variables extracted from pattern matching
}
TransformContext holds context for path transformations
func NewTransformContext ¶
func NewTransformContext(sourcePath string, variables map[string]string) *TransformContext
NewTransformContext creates a new transformation context
func (*TransformContext) AddBuiltInVariables ¶
func (tc *TransformContext) AddBuiltInVariables()
AddBuiltInVariables adds built-in variables like ${path}, ${filename}, ${dir}, ${ext}
type Transformation ¶
type Transformation struct {
// Type is inferred from which field is set (move, copy, glob, regex)
Move *MoveTransform `yaml:"move,omitempty" json:"move,omitempty"`
Copy *CopyTransform `yaml:"copy,omitempty" json:"copy,omitempty"`
Glob *GlobTransform `yaml:"glob,omitempty" json:"glob,omitempty"`
Regex *RegexTransform `yaml:"regex,omitempty" json:"regex,omitempty"`
}
Transformation defines how to transform file paths from source to destination
func (*Transformation) GetType ¶
func (t *Transformation) GetType() TransformationType
GetType returns the type of transformation
func (*Transformation) Validate ¶
func (t *Transformation) Validate() error
Validate validates a transformation
type TransformationType ¶
type TransformationType string
TransformationType defines the type of transformation
const ( TransformationTypeMove TransformationType = "move" TransformationTypeCopy TransformationType = "copy" TransformationTypeGlob TransformationType = "glob" TransformationTypeRegex TransformationType = "regex" )
type TransformationsOrRef ¶
type TransformationsOrRef struct {
Ref string `yaml:"-" json:"-"`
Transformations []Transformation `yaml:"-" json:"-"`
// contains filtered or unexported fields
}
TransformationsOrRef can be either inline transformations or a $ref
func (*TransformationsOrRef) IsRef ¶
func (t *TransformationsOrRef) IsRef() bool
IsRef returns true if this is a reference
func (TransformationsOrRef) MarshalYAML ¶
func (t TransformationsOrRef) MarshalYAML() (interface{}, error)
MarshalYAML implements custom YAML marshaling for transformations
func (*TransformationsOrRef) UnmarshalYAML ¶
func (t *TransformationsOrRef) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements custom YAML unmarshaling for transformations
type TreeFragment ¶
type TreeFragment struct {
Entries []*Entry `json:"entries,omitempty"`
}
type UploadFileContent ¶
type UploadFileContent struct {
TargetBranch string `json:"target_branch"`
Content []github.RepositoryContent `json:"content"`
// FileMeta aligns 1:1 with Content — provenance for each file (audit, Slack, diagnostics).
FileMeta []CopierFileMeta `json:"file_meta,omitempty"`
CommitStrategy CommitStrategy `json:"commit_strategy,omitempty"`
CommitMessage string `json:"commit_message,omitempty"`
PRTitle string `json:"pr_title,omitempty"`
PRBody string `json:"pr_body,omitempty"`
UsePRTemplate bool `json:"use_pr_template,omitempty"` // If true, fetch and merge PR template from target repo
AutoMergePR bool `json:"auto_merge_pr,omitempty"`
}
type UploadKey ¶
type UploadKey struct {
RepoName string `json:"repo_name"`
BranchPath string `json:"branch_path"`
RuleName string `json:"rule_name"` // Include rule name to allow multiple rules targeting same repo/branch
CommitStrategy string `json:"commit_strategy"` // Include strategy to differentiate direct vs PR
}
type Workflow ¶
type Workflow struct {
Name string `yaml:"name" json:"name"`
Source Source `yaml:"source" json:"source"`
Destination Destination `yaml:"destination" json:"destination"`
Transformations []Transformation `yaml:"transformations" json:"transformations"`
Exclude []string `yaml:"exclude,omitempty" json:"exclude,omitempty"`
CommitStrategy *CommitStrategyConfig `yaml:"commit_strategy,omitempty" json:"commit_strategy,omitempty"`
DeprecationCheck *DeprecationConfig `yaml:"deprecation_check,omitempty" json:"deprecation_check,omitempty"`
// Internal fields for $ref support (not serialized)
TransformationsRef string `yaml:"-" json:"-"`
ExcludeRef string `yaml:"-" json:"-"`
CommitStrategyRef string `yaml:"-" json:"-"`
}
Workflow defines a complete source → destination mapping with transformations
func (*Workflow) UnmarshalYAML ¶
UnmarshalYAML implements custom YAML unmarshaling for Workflow to support $ref
type WorkflowConfig ¶
type WorkflowConfig struct {
Defaults *Defaults `yaml:"defaults,omitempty" json:"defaults,omitempty"`
Workflows []Workflow `yaml:"workflows" json:"workflows"`
// Context information (not from YAML, set by loader)
SourceRepo string `yaml:"-" json:"-"` // Source repo this config came from (for context inference)
SourceBranch string `yaml:"-" json:"-"` // Source branch this config came from (for context inference)
}
WorkflowConfig represents a workflow configuration file (can be in source repos)
func (*WorkflowConfig) ApplyGlobalDefaults ¶
func (w *WorkflowConfig) ApplyGlobalDefaults(globalDefaults *Defaults)
ApplyGlobalDefaults applies global defaults from main config to workflow config
func (*WorkflowConfig) ApplySourceContext ¶
func (w *WorkflowConfig) ApplySourceContext()
ApplySourceContext applies source repo/branch context to workflows that don't specify them This allows workflows in source repos to omit the source.repo and source.branch fields
func (*WorkflowConfig) SetDefaults ¶
func (w *WorkflowConfig) SetDefaults()
SetDefaults sets default values for a workflow config
func (*WorkflowConfig) Validate ¶
func (w *WorkflowConfig) Validate() error
Validate validates a workflow config
type WorkflowConfigRef ¶
type WorkflowConfigRef struct {
Source string `yaml:"source" json:"source"` // "local", "repo", or "inline"
Path string `yaml:"path,omitempty" json:"path,omitempty"` // Path to config file
Repo string `yaml:"repo,omitempty" json:"repo,omitempty"` // Repository (for source="repo")
Branch string `yaml:"branch,omitempty" json:"branch,omitempty"` // Branch (for source="repo")
Enabled *bool `yaml:"enabled,omitempty" json:"enabled,omitempty"` // Whether this workflow config is enabled (default: true)
Workflows []Workflow `yaml:"workflows,omitempty" json:"workflows,omitempty"` // Inline workflows (for source="inline")
}
WorkflowConfigRef references a workflow configuration file
func (*WorkflowConfigRef) Validate ¶
func (w *WorkflowConfigRef) Validate() error
Validate validates a workflow config reference
type YAMLConfig ¶
type YAMLConfig struct {
Workflows []Workflow `yaml:"workflows" json:"workflows"`
Defaults *Defaults `yaml:"defaults,omitempty" json:"defaults,omitempty"`
}
YAMLConfig represents the YAML-based configuration structure
func (*YAMLConfig) SetDefaults ¶
func (c *YAMLConfig) SetDefaults()
SetDefaults sets default values for the configuration
func (*YAMLConfig) Validate ¶
func (c *YAMLConfig) Validate() error
Validate validates the YAML configuration