config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package config provides public configuration types and utilities for Shipyard projects. This package contains the core configuration structures that can be used by external tools, MCP servers, and other integrations.

Package config provides remote configuration fetching capabilities. This allows teams to extend a shared remote configuration from HTTP, Git, or GitHub.

Index

Constants

This section is empty.

Variables

SupportedEcosystems lists all supported package ecosystems

Functions

func ClearRemoteConfigCache

func ClearRemoteConfigCache() error

ClearRemoteConfigCache clears the remote configuration cache

func IsValidRemoteURL

func IsValidRemoteURL(url string) bool

IsValidRemoteURL checks if a URL is a valid remote config URL

func LoadRemoteTemplate

func LoadRemoteTemplate(templateURL string, forceFresh bool) (string, error)

LoadRemoteTemplate loads a remote template from various sources

func ParseRemoteURL

func ParseRemoteURL(rawURL string) (*url.URL, error)

ParseRemoteURL parses and validates a remote config URL

func ResolveTemplatePath

func ResolveTemplatePath(templatePath, configURL string) string

ResolveTemplatePath resolves a template path relative to a config URL

func SaveToDefaultPath

func SaveToDefaultPath(config *ProjectConfig) error

SaveToDefaultPath saves configuration to the default Shipyard config path

func SaveToFile

func SaveToFile(config *ProjectConfig, configPath string) error

SaveToFile saves a project configuration to a file

Types

type ChangeTypeConfig

type ChangeTypeConfig struct {
	Name        string `mapstructure:"name" json:"name" yaml:"name"`                              // e.g., "feat", "fix", "docs"
	DisplayName string `mapstructure:"display_name" json:"display_name" yaml:"display_name"`      // e.g., "✨ Feature", "🔧 Bug Fix"
	SemverBump  string `mapstructure:"semver_bump" json:"semver_bump" yaml:"semver_bump"`         // "major", "minor", "patch"
	Section     string `mapstructure:"section" json:"section,omitempty" yaml:"section,omitempty"` // changelog section name
}

ChangeTypeConfig represents a custom change type configuration

func DefaultChangeTypes

func DefaultChangeTypes() []ChangeTypeConfig

DefaultChangeTypes returns the default change type configurations

type ChangelogConfig

type ChangelogConfig struct {
	Template    string `mapstructure:"template" json:"template" yaml:"template"`                                 // template name, file path, or URL
	OutputPath  string `mapstructure:"output_path" json:"output_path,omitempty" yaml:"output_path,omitempty"`    // default changelog filename (default: "CHANGELOG.md")
	PackagePath *bool  `mapstructure:"package_path" json:"package_path,omitempty" yaml:"package_path,omitempty"` // place changelog in package path for monorepo (default: true for monorepo)
}

ChangelogConfig represents the changelog configuration

type GitConfig

type GitConfig struct {
	TagTemplate    string `mapstructure:"tag_template" json:"tag_template,omitempty" yaml:"tag_template,omitempty"`
	CommitTemplate string `mapstructure:"commit_template" json:"commit_template,omitempty" yaml:"commit_template,omitempty"`
}

GitConfig represents the git integration configuration

type Package

type Package struct {
	Name          string           `mapstructure:"name" json:"name" yaml:"name"`                                                   // e.g., "api", "frontend"
	Path          string           `mapstructure:"path" json:"path" yaml:"path"`                                                   // e.g., "packages/api", "packages/frontend"
	Manifest      string           `mapstructure:"manifest" json:"manifest" yaml:"manifest"`                                       // e.g., "packages/api/package.json"
	Ecosystem     PackageEcosystem `mapstructure:"ecosystem" json:"ecosystem" yaml:"ecosystem"`                                    // e.g., "npm", "go", "python"
	ChangelogPath string           `mapstructure:"changelog_path" json:"changelog_path,omitempty" yaml:"changelog_path,omitempty"` // e.g., "CHANGELOG.md", "docs/CHANGELOG.md"
}

Package represents a package configuration within a project

func NewPackage

func NewPackage(name, path string, ecosystem PackageEcosystem) *Package

NewPackage creates a new Package instance

func NewPackageFromMap

func NewPackageFromMap(data map[string]interface{}) (*Package, error)

NewPackageFromMap creates a Package from a map

func (*Package) GetChangelogPath

func (p *Package) GetChangelogPath(defaultFilename string) string

GetChangelogPath returns the full path to the changelog file for this package It combines the package path with the changelog filename

func (*Package) IsValid

func (p *Package) IsValid() error

IsValid performs basic validation on the package configuration

func (*Package) ToMap

func (p *Package) ToMap() map[string]interface{}

ToMap converts the Package to a map[string]interface{} suitable for serialization

type PackageEcosystem

type PackageEcosystem string

PackageEcosystem represents the type of package ecosystem

const (
	// EcosystemNPM represents the NPM ecosystem
	EcosystemNPM PackageEcosystem = "npm"
	// EcosystemGo represents the Go ecosystem
	EcosystemGo PackageEcosystem = "go"
	// EcosystemHelm represents the Helm ecosystem
	EcosystemHelm PackageEcosystem = "helm"
)

Constants for supported ecosystems

func GetSupportedEcosystems

func GetSupportedEcosystems() []PackageEcosystem

GetSupportedEcosystems returns all supported ecosystems

type ProjectConfig

type ProjectConfig struct {
	Type RepoType `mapstructure:"type" json:"type" yaml:"type"` // "monorepo" or "single-repo"
	Repo string   `mapstructure:"repo" json:"repo" yaml:"repo"` // e.g., "github.com/NatoNathan/shipyard"

	Changelog   ChangelogConfig    `mapstructure:"changelog" json:"changelog" yaml:"changelog"`
	Git         GitConfig          `mapstructure:"git" json:"git,omitempty" yaml:"git,omitempty"`
	ChangeTypes []ChangeTypeConfig `mapstructure:"change_types" json:"change_types,omitempty" yaml:"change_types,omitempty"`

	// For monorepo projects
	Packages []Package `mapstructure:"packages" json:"packages,omitempty" yaml:"packages,omitempty"`
	// For single-repo projects
	Package Package `mapstructure:"package" json:"package,omitempty" yaml:"package,omitempty"`
}

ProjectConfig represents the complete configuration for a Shipyard project

func DefaultProjectConfig

func DefaultProjectConfig() *ProjectConfig

DefaultProjectConfig returns a default project configuration

func LoadFromDefaultPath

func LoadFromDefaultPath() (*ProjectConfig, error)

LoadFromDefaultPath loads configuration from the default Shipyard config path

func LoadFromFile

func LoadFromFile(configPath string) (*ProjectConfig, error)

LoadFromFile loads a project configuration from a file

func LoadRemoteConfig

func LoadRemoteConfig(remoteURL string, forceFresh bool) (*ProjectConfig, error)

LoadRemoteConfig loads a remote configuration from various sources

func NewMonorepoConfig

func NewMonorepoConfig(repo string, packages []Package) *ProjectConfig

NewMonorepoConfig creates a new monorepo configuration

func NewSingleRepoConfig

func NewSingleRepoConfig(repo string, pkg Package) *ProjectConfig

NewSingleRepoConfig creates a new single-repo configuration

func (*ProjectConfig) GetChangeTypeByName

func (c *ProjectConfig) GetChangeTypeByName(name string) *ChangeTypeConfig

GetChangeTypeByName returns the change type configuration by name

func (*ProjectConfig) GetChangeTypeNames

func (c *ProjectConfig) GetChangeTypeNames() []string

GetChangeTypeNames returns the names of all available change types

func (*ProjectConfig) GetChangeTypes

func (c *ProjectConfig) GetChangeTypes() []ChangeTypeConfig

GetChangeTypes returns the custom change types or default ones if none are configured

func (*ProjectConfig) GetChangelogOutputPath

func (c *ProjectConfig) GetChangelogOutputPath() string

GetChangelogOutputPath returns the changelog output path configuration

func (*ProjectConfig) GetPackageByName

func (c *ProjectConfig) GetPackageByName(name string) *Package

GetPackageByName returns the package with the specified name, or nil if not found

func (*ProjectConfig) GetPackageNames

func (c *ProjectConfig) GetPackageNames() []string

GetPackageNames returns the names of all packages in the project

func (*ProjectConfig) GetPackages

func (c *ProjectConfig) GetPackages() []Package

GetPackages returns all packages in the project configuration. For monorepo projects, it returns the Packages slice. For single-repo projects, it returns a slice containing the single Package.

func (*ProjectConfig) HasPackage

func (c *ProjectConfig) HasPackage(name string) bool

HasPackage returns true if the project has a package with the specified name

func (*ProjectConfig) IsValid

func (c *ProjectConfig) IsValid() error

IsValid performs basic validation on the project configuration

func (*ProjectConfig) ShouldUsePackagePaths

func (c *ProjectConfig) ShouldUsePackagePaths() bool

ShouldUsePackagePaths returns true if changelogs should be placed in package directories for monorepo

func (*ProjectConfig) ToMap

func (c *ProjectConfig) ToMap() map[string]interface{}

ToMap converts the ProjectConfig to a map[string]interface{} suitable for serialization

type RemoteConfigCache

type RemoteConfigCache struct {
	URL         string    `json:"url" yaml:"url"`
	Hash        string    `json:"hash" yaml:"hash"`
	LastFetched time.Time `json:"last_fetched" yaml:"last_fetched"`
	Content     string    `json:"content" yaml:"content"`
	CachePath   string    `json:"cache_path" yaml:"cache_path"`
	TTL         int       `json:"ttl" yaml:"ttl"` // Time to live in minutes
}

RemoteConfigCache represents a cached remote config entry

func ListCachedRemoteConfigs

func ListCachedRemoteConfigs() ([]RemoteConfigCache, error)

ListCachedRemoteConfigs returns a list of cached remote configurations

type RemoteConfigFetcher

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

RemoteConfigFetcher provides functionality to fetch remote configurations

func NewRemoteConfigFetcher

func NewRemoteConfigFetcher(cacheDir string) *RemoteConfigFetcher

NewRemoteConfigFetcher creates a new remote config fetcher

func (*RemoteConfigFetcher) ClearCache

func (f *RemoteConfigFetcher) ClearCache() error

ClearCache clears the remote config cache

func (*RemoteConfigFetcher) FetchRemoteConfig

func (f *RemoteConfigFetcher) FetchRemoteConfig(extendsURL string, forceFresh bool) (*viper.Viper, error)

FetchRemoteConfig fetches a remote configuration and returns a viper instance

func (*RemoteConfigFetcher) FetchRemoteTemplate

func (f *RemoteConfigFetcher) FetchRemoteTemplate(templateURL string, forceFresh bool) (string, error)

FetchRemoteTemplate fetches a remote template file and returns its content

func (*RemoteConfigFetcher) ListCachedConfigs

func (f *RemoteConfigFetcher) ListCachedConfigs() ([]RemoteConfigCache, error)

ListCachedConfigs returns a list of cached remote configurations

type RepoType

type RepoType string

RepoType represents the type of repository structure

const (
	// RepositoryTypeMonorepo represents a monorepo with multiple packages
	RepositoryTypeMonorepo RepoType = "monorepo"
	// RepositoryTypeSingleRepo represents a single-package repository
	RepositoryTypeSingleRepo RepoType = "single-repo"
)

Repository types supported by Shipyard

type ValidationError

type ValidationError struct {
	Field   string
	Message string
}

ValidationError represents a configuration validation error

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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