sync

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2025 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package sync provides options and utilities for synchronizing the catalog with provider APIs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Options)

Option is a function that configures sync Options.

func WithAutoApprove

func WithAutoApprove(autoApprove bool) Option

WithAutoApprove configures auto approval.

func WithAutoInstallDeps added in v0.0.17

func WithAutoInstallDeps(autoInstall bool) Option

WithAutoInstallDeps configures whether to automatically install missing dependencies.

func WithCleanModelsDevRepo

func WithCleanModelsDevRepo(cleanup bool) Option

WithCleanModelsDevRepo configures whether to remove temporary models.dev repository after update.

func WithDryRun

func WithDryRun(dryRun bool) Option

WithDryRun configures dry run mode.

func WithFailFast

func WithFailFast(failFast bool) Option

WithFailFast configures fail-fast behavior.

func WithFresh

func WithFresh(fresh bool) Option

WithFresh configures whether to delete existing models and fetch fresh from APIs.

func WithOutputPath

func WithOutputPath(path string) Option

WithOutputPath configures the output path for saving.

func WithProvider

func WithProvider(providerID catalogs.ProviderID) Option

WithProvider configures syncing for a specific provider only.

func WithReformat

func WithReformat(reformat bool) Option

WithReformat configures whether to reformat providers.yaml file even without changes.

func WithRequireAllSources added in v0.0.17

func WithRequireAllSources(require bool) Option

WithRequireAllSources configures whether all sources are required to succeed.

func WithSkipDepPrompts added in v0.0.17

func WithSkipDepPrompts(skip bool) Option

WithSkipDepPrompts configures whether to skip dependency prompts.

func WithSources

func WithSources(types ...sources.ID) Option

WithSources configures which sources to use.

func WithSourcesDir

func WithSourcesDir(dir string) Option

WithSourcesDir configures the directory for external source data (models.dev cache/git).

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout configures the sync timeout.

type Options

type Options struct {
	// Orchestration control
	DryRun      bool          // Show changes without applying them
	AutoApprove bool          // Skip confirmation prompts
	FailFast    bool          // Stop on first source error instead of continuing
	Timeout     time.Duration // Timeout for the entire sync operation

	// Source selection
	Sources    []sources.ID         // Which sources to use (empty means all)
	ProviderID *catalogs.ProviderID // Filter for specific provider

	// Output control (used AFTER merging)
	OutputPath string // Where to save final catalog (empty means default location)

	// Source behavior control
	Fresh              bool   // Delete existing models and fetch fresh from APIs (destructive)
	CleanModelsDevRepo bool   // Remove temporary models.dev repository after update
	Reformat           bool   // Reformat providers.yaml file even without changes
	SourcesDir         string // Directory for external source data (models.dev cache/git)

	// Dependency control
	AutoInstallDeps   bool // Automatically install missing dependencies without prompting
	SkipDepPrompts    bool // Skip dependency prompts and continue without optional dependencies
	RequireAllSources bool // Require all sources to succeed (fail if any dependencies are missing)
}

Options controls the overall sync orchestration in Starmap.Sync().

func Defaults

func Defaults() *Options

Defaults returns the default sync options.

func (*Options) Apply

func (s *Options) Apply(opts ...Option) *Options

Apply applies the given options to the sync options.

func (*Options) SourceOptions

func (s *Options) SourceOptions() []sources.Option

SourceOptions converts sync options to properly typed source options.

func (*Options) Validate

func (s *Options) Validate(providers *catalogs.Providers) error

Validate checks if the sync options are valid.

type ProviderResult

type ProviderResult struct {
	ProviderID catalogs.ProviderID  // The provider that was synced
	Added      []catalogs.Model     // New models not in catalog
	Updated    []differ.ModelUpdate // Existing models with changes
	Removed    []catalogs.Model     // Models in catalog but not in API (informational only)

	// Summary counts
	AddedCount   int // Number of models added
	UpdatedCount int // Number of models updated
	RemovedCount int // Number of models removed from API (not deleted from catalog)

	// Metadata
	APIModelsCount      int // Total models fetched from API
	ExistingModelsCount int // Total models that existed in catalog
	EnhancedCount       int // Number of models enhanced with models.dev data
}

ProviderResult represents sync results for a single provider.

func (*ProviderResult) HasChanges

func (spr *ProviderResult) HasChanges() bool

HasChanges returns true if the provider result contains any changes.

func (*ProviderResult) Summary

func (spr *ProviderResult) Summary() string

Summary returns a human-readable summary of the provider result.

type Result

type Result struct {
	// Overall statistics
	TotalChanges     int                                     // Total number of changes across all providers
	ProvidersChanged int                                     // Number of providers with changes
	ProviderResults  map[catalogs.ProviderID]*ProviderResult // Results per provider

	// Operation metadata
	DryRun    bool   // Whether this was a dry run
	Fresh     bool   // Whether this was a fresh sync
	OutputDir string // Where files were written (empty means default)
}

Result represents the complete result of a sync operation.

func ChangesetToResult

func ChangesetToResult(changeset *differ.Changeset, dryRun bool, outputDir string, providerAPICounts map[catalogs.ProviderID]int, modelProviderMap map[string]catalogs.ProviderID) *Result

ChangesetToResult converts a reconcile.Changeset to a SyncResult.

func (*Result) HasChanges

func (sr *Result) HasChanges() bool

HasChanges returns true if the sync result contains any changes.

func (*Result) Summary

func (sr *Result) Summary() string

Summary returns a human-readable summary of the sync result.

Jump to

Keyboard shortcuts

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