Documentation
¶
Overview ¶
Package exchange provides import/export functionality for features.
Index ¶
- func ConvertFromExportFeature(ef *ExportFeature) *fogit.Feature
- func ValidateImportData(data *ExportData) error
- func ValidateRelationshipTargets(features []*ExportFeature, allIDs map[string]bool) []string
- func WriteCSV(w io.Writer, features []*ExportFeature) error
- func WriteJSON(w io.Writer, data *ExportData, pretty bool) error
- func WriteYAML(w io.Writer, data *ExportData) error
- type ExportData
- type ExportFeature
- type ExportOptions
- type ExportRelationship
- type ExportVersion
- type ExportVersionConstraint
- type ImportAction
- type ImportOptions
- type ImportResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertFromExportFeature ¶
func ConvertFromExportFeature(ef *ExportFeature) *fogit.Feature
ConvertFromExportFeature converts an export feature to domain format
func ValidateImportData ¶
func ValidateImportData(data *ExportData) error
ValidateImportData validates the structure of import data
func ValidateRelationshipTargets ¶
func ValidateRelationshipTargets(features []*ExportFeature, allIDs map[string]bool) []string
ValidateRelationshipTargets checks if all relationship targets exist Returns warnings but doesn't fail the import
func WriteCSV ¶
func WriteCSV(w io.Writer, features []*ExportFeature) error
WriteCSV writes export data as CSV
Types ¶
type ExportData ¶
type ExportData struct {
FogitVersion string `json:"fogit_version" yaml:"fogit_version"`
ExportedAt string `json:"exported_at" yaml:"exported_at"`
Repository string `json:"repository" yaml:"repository"`
Features []*ExportFeature `json:"features" yaml:"features"`
}
ExportData represents the exported data structure per spec
func Export ¶
func Export(ctx context.Context, repo fogit.Repository, opts ExportOptions) (*ExportData, error)
Export exports features to the specified format
func ExportWithFeatures ¶ added in v1.0.8
func ExportWithFeatures(features []*fogit.Feature, opts ExportOptions) (*ExportData, error)
ExportWithFeatures exports pre-loaded features to the specified format. This is useful for cross-branch export where features come from multiple branches.
func ReadImportFile ¶
func ReadImportFile(filePath string) (*ExportData, error)
ReadImportFile reads and parses an import file (JSON or YAML)
type ExportFeature ¶
type ExportFeature struct {
ID string `json:"id" yaml:"id"`
Name string `json:"name" yaml:"name"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"`
Files []string `json:"files,omitempty" yaml:"files,omitempty"`
Versions map[string]*ExportVersion `json:"versions,omitempty" yaml:"versions,omitempty"`
Relationships []ExportRelationship `json:"relationships,omitempty" yaml:"relationships,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty"`
// Computed fields for convenience
State string `json:"state" yaml:"state"`
CurrentVersion string `json:"current_version" yaml:"current_version"`
}
ExportFeature represents a feature in export format
func ConvertToExportFeature ¶
func ConvertToExportFeature(f *fogit.Feature, featureIDs map[string]bool) *ExportFeature
ConvertToExportFeature converts a domain feature to export format
type ExportOptions ¶
type ExportOptions struct {
Format string // "json", "yaml", or "csv"
Filter *fogit.Filter
FogitDir string
Pretty bool
}
ExportOptions contains options for export operation
type ExportRelationship ¶
type ExportRelationship struct {
ID string `json:"id" yaml:"id"`
Type string `json:"type" yaml:"type"`
TargetID string `json:"target_id" yaml:"target_id"`
TargetName string `json:"target_name" yaml:"target_name"`
TargetExists bool `json:"target_exists" yaml:"target_exists"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
CreatedAt string `json:"created_at" yaml:"created_at"`
VersionConstraint *ExportVersionConstraint `json:"version_constraint,omitempty" yaml:"version_constraint,omitempty"`
}
ExportRelationship represents a relationship in export format
type ExportVersion ¶
type ExportVersion struct {
CreatedAt string `json:"created_at" yaml:"created_at"`
ModifiedAt string `json:"modified_at,omitempty" yaml:"modified_at,omitempty"`
ClosedAt string `json:"closed_at,omitempty" yaml:"closed_at,omitempty"`
Branch string `json:"branch,omitempty" yaml:"branch,omitempty"`
Authors []string `json:"authors,omitempty" yaml:"authors,omitempty"`
Notes string `json:"notes,omitempty" yaml:"notes,omitempty"`
}
ExportVersion represents a feature version in export format
type ExportVersionConstraint ¶
type ExportVersionConstraint struct {
Operator string `json:"operator" yaml:"operator"`
Version interface{} `json:"version" yaml:"version"`
Note string `json:"note,omitempty" yaml:"note,omitempty"`
}
ExportVersionConstraint represents a version constraint in export format
type ImportAction ¶
type ImportAction struct {
Type string // "CREATE", "UPDATE", "SKIP"
FeatureName string
FeatureID string
Reason string
}
ImportAction represents a single import action for reporting
type ImportOptions ¶
type ImportOptions struct {
Merge bool // Skip existing features, import only new ones
Overwrite bool // Replace existing features with imported data
DryRun bool // Preview changes without applying them
}
ImportOptions contains options for import operation
type ImportResult ¶
type ImportResult struct {
Created int
Updated int
Skipped int
Errors []string
Actions []ImportAction // For dry-run reporting
}
ImportResult tracks the results of an import operation
func Import ¶
func Import(ctx context.Context, repo fogit.Repository, data *ExportData, opts ImportOptions) (*ImportResult, error)
Import imports features from export data