domain

package
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Defines the file extensions for the artifacts
	TOMLExt = "toml"
	JSONExt = "json"
	MDExt   = "md"
	TxtExt  = "txt"

	// Defines the artifact types. These are also used as suffixes for the artifact file names.
	ArtifactAddress                      = "addresses"
	ArtifactDataStore                    = "datastore"
	ArtifactJobSpec                      = "jobspecs"
	ArtifactJobs                         = "jobs"
	ArtifactsDurablePipelineDirName      = "durable_pipelines"
	ArtifactMCMSProposal                 = "mcms_proposal"
	ArtifactMCMSProposalDecoded          = "mcms_proposal_decoded"
	ArtifactsMCMSTimelockProposal        = "mcms_timelock_proposal"
	ArtifactsMCMSTimelockProposalDecoded = "mcms_timelock_proposal_decoded"
)
View Source
const (
	// LibDirName is the name of the directory containing the domain's lib directory.
	LibDirName = "lib"

	// InternalDirName is the name of the directory containing the domain's internal directory.
	InternalDirName = "internal"

	// CmdDirName is the name of the directory containing the domain's cmd directory.
	CmdDirName = "cmd"

	// AddressBookFileName is the name of the file containing the address book.
	AddressBookFileName = "addresses.json"

	// ArchivedProposalsDirName is the name of the directory containing archived proposals.
	ArchivedProposalsDirName = "archived_proposals"

	// ArtifactsDirName is the name of the directory containing migration artifacts.
	ArtifactsDirName = "artifacts"

	// DarastoreDirName is the name of the directory containing the datastore files.
	DatastoreDirName = "datastore"

	// DataStoreFileName is the name of the file containing the fdatastore.
	DataStoreFileName = "datastore.json"

	// AddressRefsFileName is the name of the file containing the address refs.
	AddressRefsFileName = "address_refs.json"

	// ChainMetadataFileName is the name of the file containing the chain metadata.
	ChainMetadataFileName = "chain_metadata.json"

	// ContractMetadataFileName is the name of the file containing the contract metadata.
	ContractMetadataFileName = "contract_metadata.json"

	// DomainConfigDirName is the name of the directory containing the domain's config directory.
	DomainConfigDirName = ".config"

	// DomainConfigLocalDirName is the name of the directory containing the local domain config.
	DomainConfigLocalDirName = "local"

	// DomainConfigLocalFileName is the name of the file containing the local domain config.
	DomainConfigLocalFileName = "config.yml"

	// DomainConfigNetworksDirName is the name of the directory containing the domain networks config.
	DomainConfigNetworksDirName = "networks"

	// DomainConfigCIDirName is the name of the directory containing the domain CI config.
	DomainConfigCIDirName = "ci"

	// EnvMetadataFileName is the name of the file containing the environment metadata.
	EnvMetadataFileName = "env_metadata.json"

	// NodesFileName is the name of the file containing node information in the
	// environment directory.
	NodesFileName = "nodes.json"

	// ProposalsDirName is the name of the directory containing proposals.
	ProposalsDirName = "proposals"

	// DecodedProposalsDirName is the name of the directory containing decoded proposals.
	DecodedProposalsDirName = "decoded_proposals"

	// PipelinesFileName is the name of the file containing the pipelines initialization for
	// the environment.
	PipelinesFileName = "pipelines.go"

	// OperationsReportsDirName is the name of the directory containing operations reports.[
	OperationsReportsDirName = "operations_reports"

	// ViewStateFileName is the name of the file containing the view state of the
	// environment.
	ViewStateFileName = "state.json"

	// MigrationsFileName is the name of the file containing the migrations for the
	// environment.
	MigrationsFileName = "migrations.go"

	// MigrationsArchiveFileName is the name of the file containing the archived
	// migrations for the environment.
	MigrationsArchiveFileName = "migrations_archive.go"

	// DurablePipelineDirName is the name of the directory containing durable pipelines.
	DurablePipelineDirName = "durable_pipelines"

	// DurablePipelineInputsDirName is the name of the directory containing the inputs
	// for the durable pipelines.
	DurablePipelineInputsDirName = "inputs"
)

Variables

View Source
var (
	ProjectRoot = getProjectRoot()
	DomainsRoot = filepath.Join(ProjectRoot, "domains")
)

Defines root paths for the project and domains.

View Source
var (
	// ErrArtifactNotFound is returned when an artifact is not in the filesystem.
	ErrArtifactNotFound = errors.New("artifact not found")
)

Functions

func LoadJobSpecs deprecated

func LoadJobSpecs(jobSpecsFilePath string) (map[string][]string, error)

Deprecated: The map used to represent the job specs that was provided by `chainlink/deployments` is no longer used, and has been replaced by a slice of `fdeployment.ProposedJob` structs. This has been kept around for backwards compatibility with existing migrations, but should not be used in new code. Prefer using `LoadJobs` instead.

func LoadJobs

func LoadJobs(jobsFilePath string) ([]fdeployment.ProposedJob, error)

LoadJobs unmarshals a slice of `fdeployment.ProposedJob` structs from a file.

func SaveViewState added in v0.26.0

func SaveViewState(filePath string, v json.Marshaler) error

SaveViewState saves the view state as JSON to a file at the filePath.

Types

type ArtifactsDir

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

ArtifactsDir represents a directory containing all migration artifacts grouped by the migration key. It provides methods to interact with the artifacts in the directory.

func NewArtifactsDir

func NewArtifactsDir(rootPath, domainKey, envKey string) *ArtifactsDir

NewArtifactsDir creates a new Artifacts.

func (*ArtifactsDir) ArchiveProposalsDirExists

func (a *ArtifactsDir) ArchiveProposalsDirExists() (bool, error)

ArchiveProposalsDirExists checks if the proposals directory exists

func (*ArtifactsDir) ArchivedProposalsDirPath

func (a *ArtifactsDir) ArchivedProposalsDirPath() string

ArchivedProposalsDirPath returns the path to the directory containing archived proposals.

func (*ArtifactsDir) ArtifactsDirPath

func (a *ArtifactsDir) ArtifactsDirPath() string

ArtifactsDirPath returns the path to the directory containing the artifacts but not proposals.

func (*ArtifactsDir) CreateArchivedProposalsDir

func (a *ArtifactsDir) CreateArchivedProposalsDir() error

CreateArchivedProposalsDir creates the proposals directory within the artifacts directory if it does not exist. It also creates a .gitkeep file within the proposals directory to ensure the directory is tracked by git.

func (*ArtifactsDir) CreateDecodedProposalsDir

func (a *ArtifactsDir) CreateDecodedProposalsDir() error

CreateDecodedProposalsDir creates the decoded_proposals directory within the artifacts directory if it does not exist. It also creates a .gitkeep file within the proposals directory to ensure the directory is tracked by git.

func (*ArtifactsDir) CreateMigrationDir

func (a *ArtifactsDir) CreateMigrationDir(migKey string) error

CreateMigrationDir creates a new directory within the artifacts directory with the specified migration key. If the directory already exists, it will return nil.

func (*ArtifactsDir) CreateOperationsReportsDir

func (a *ArtifactsDir) CreateOperationsReportsDir() error

CreateOperationsReportsDir creates the operations reports directory if it does not exist. It also creates a .gitkeep file within the operations reports directory to ensure the directory is tracked by git.

func (*ArtifactsDir) CreateProposalsDir

func (a *ArtifactsDir) CreateProposalsDir() error

CreateProposalsDir creates the proposals directory within the artifacts directory if it does not exist. It also creates a .gitkeep file within the proposals directory to ensure the directory is tracked by git.

func (*ArtifactsDir) DecodedProposalsDirPath

func (a *ArtifactsDir) DecodedProposalsDirPath() string

DecodedProposalsDirPath returns the path to the directory containing the decoded proposals.

func (*ArtifactsDir) DomainKey

func (a *ArtifactsDir) DomainKey() string

DomainKey returns the domain key that the artifacts belong to.

func (*ArtifactsDir) EnvKey

func (a *ArtifactsDir) EnvKey() string

EnvKey returns the environment key that the artifacts belong to.

func (*ArtifactsDir) LoadAddressBookByMigrationKey

func (a *ArtifactsDir) LoadAddressBookByMigrationKey(migKey string) (*fdeployment.AddressBookMap, error)

LoadAddressBookByMigrationKey searches for an address book file in the migration directory and returns the address book as an AddressBookMap.

The search will look for a address book file with a matching name as the domain, env and migration key, returning the first matching file. An error is returned if no matches are found or if an error occurs during the search.

Pattern format: "*-<domain>-<env>-<migKey>_addresses.json".

func (*ArtifactsDir) LoadChangesetOutput

func (a *ArtifactsDir) LoadChangesetOutput(migKey string) (fdeployment.ChangesetOutput, error)

LoadChangesetOutput reads the artifacts from the specified migration directory and returns the ChangesetOutput.

func (*ArtifactsDir) LoadDataStoreByMigrationKey

func (a *ArtifactsDir) LoadDataStoreByMigrationKey(migKey string) (fdatastore.DataStore, error)

LoadDataStoreByMigrationKey searches for a datastore file in the migration directory and returns the datastore as read-only.

The search will look for a datastore file with a matching name as the domain, env and migration key, returning the first matching file. An error is returned if no matches are found or if an error occurs during the search.

Pattern format: "*-<domain>-<env>-<migKey>_datastore.json".

func (*ArtifactsDir) LoadOperationsReports

func (a *ArtifactsDir) LoadOperationsReports(migKey string) ([]foperations.Report[any, any], error)

LoadOperationsReports reads the reports from the operations reports directory for the specified migration key.

func (*ArtifactsDir) MigrationDirExists

func (a *ArtifactsDir) MigrationDirExists(migKey string) (bool, error)

MigrationDirExists checks if the migration directory containing the artifacts for the specified migration key exists.

func (*ArtifactsDir) MigrationDirPath

func (a *ArtifactsDir) MigrationDirPath(migKey string) string

MigrationDirPath returns the path to the directory containing the artifacts for the specified migration key.

func (*ArtifactsDir) MigrationOperationsReportsFileExists

func (a *ArtifactsDir) MigrationOperationsReportsFileExists(migKey string) (bool, error)

MigrationOperationsReportsFileExists checks if the operations reports file exists for the specified migration key.

func (*ArtifactsDir) OperationsReportsDirExists

func (a *ArtifactsDir) OperationsReportsDirExists() (bool, error)

OperationsReportsDirExists checks if the operations_reports directory exists.

func (*ArtifactsDir) OperationsReportsDirPath

func (a *ArtifactsDir) OperationsReportsDirPath() string

OperationsReportsDirPath returns the path to the directory containing the operations reports.

func (*ArtifactsDir) ProposalsDirExists

func (a *ArtifactsDir) ProposalsDirExists() (bool, error)

ProposalsDirExists checks if the proposals directory exists

func (*ArtifactsDir) ProposalsDirPath

func (a *ArtifactsDir) ProposalsDirPath() string

ProposalsDirPath returns the path to the directory containing the proposals.

func (*ArtifactsDir) RemoveMigrationDir

func (a *ArtifactsDir) RemoveMigrationDir(migKey string) error

RemoveMigrationDir removes the directory containing the artifacts for the specified migration key.

func (*ArtifactsDir) SaveChangesetOutput

func (a *ArtifactsDir) SaveChangesetOutput(migKey string, output fdeployment.ChangesetOutput) error

SaveChangesetOutput writes the ChangesetOutput as artifacts to the specified migration directory.

func (*ArtifactsDir) SaveOperationsReports

func (a *ArtifactsDir) SaveOperationsReports(migKey string, reports []foperations.Report[any, any]) error

SaveOperationsReports writes an operations report as JSON to the operations reports directory for the specified migration key. if the directory does not exist, it will be created. if the file already exists, it will be overwritten.

func (*ArtifactsDir) SetDurablePipelines

func (a *ArtifactsDir) SetDurablePipelines(timestamp string) error

SetDurablePipelines sets the directory containing the durable pipeline artifacts and the timestamp for the durable pipelines.

type Domain

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

Domain represents a specific domain that is operated by a team. Each domain corresponds to a team's ownership of a set of migrations that span multiple environments.

func GetDomain

func GetDomain(key string) (Domain, error)

GetDomain returns a Domain for the specified key based on the available dirs in the domains root. If the key is not recognized, it will return an error

func MustGetDomain

func MustGetDomain(key string) Domain

MustGetDomain returns a Domain for the specified key. If the key is not recognized, it will panic.

func NewDomain

func NewDomain(rootPath, key string) Domain

NewDomain creates a new Domain.

func (Domain) AddressBookByEnv

func (d Domain) AddressBookByEnv(env string) (fdeployment.AddressBook, error)

AddressBookByEnv returns the address book for the specified environment.

func (Domain) ArtifactsDirByEnv

func (d Domain) ArtifactsDirByEnv(env string) *ArtifactsDir

ArtifactsDirByEnv returns the artifacts directory for the specified environment.

func (Domain) CmdDirPath

func (d Domain) CmdDirPath() string

CmdDirPath returns the path to the cmd directory within the domain. This is where the domain's command line tools should be placed.

func (Domain) ConfigCICommonFilePath added in v0.34.0

func (d Domain) ConfigCICommonFilePath() string

ConfigCICommonFilePath returns the path to the domain's CI common .env file.

func (Domain) ConfigCIDirPath added in v0.33.0

func (d Domain) ConfigCIDirPath() string

ConfigCIDirPath returns the path where the domain's CI .env files are stored.

func (Domain) ConfigCIEnvFilePath added in v0.34.0

func (d Domain) ConfigCIEnvFilePath(env string) string

ConfigCIEnvFilePath returns the path to the domain's CI .env file for the specified environment.

func (Domain) ConfigDirPath added in v0.33.0

func (d Domain) ConfigDirPath() string

ConfigDirPath returns the path to the domain config directory within the domain.

func (Domain) ConfigDomainFilePath added in v0.37.1

func (d Domain) ConfigDomainFilePath() string

ConfigDomainFilePath returns the path to the domain's domain config file.

func (Domain) ConfigLocalDirPath added in v0.33.0

func (d Domain) ConfigLocalDirPath() string

ConfigLocalDirPath returns the path where local execution config files are stored.

func (Domain) ConfigLocalFilePath added in v0.33.0

func (d Domain) ConfigLocalFilePath(env string) string

ConfigLocalFilePath returns the path to a domain environment's local execution config file.

func (Domain) ConfigNetworksDirPath added in v0.33.0

func (d Domain) ConfigNetworksDirPath() string

ConfigNetworksDirPath returns the path where the domain's networks config files are stored.

func (Domain) ConfigNetworksFilePath added in v0.38.0

func (d Domain) ConfigNetworksFilePath(filename string) string

ConfigNetworksFilePath returns the path to a domain environment's networks config file.

func (Domain) DataStoreByEnv

func (d Domain) DataStoreByEnv(env string) (fdatastore.DataStore, error)

DataStoreByEnv returns the datastore for the specified environment.

func (Domain) DirPath

func (d Domain) DirPath() string

DirPath returns the path to the domain directory.

func (Domain) EnvDir

func (d Domain) EnvDir(env string) EnvDir

EnvDir returns a DomainEnv for the specified environment.

func (Domain) InternalDirPath

func (d Domain) InternalDirPath() string

InternalDirPath returns the path to the internal directory within the domain. This is where internal packages should be placed.

func (Domain) Key

func (d Domain) Key() string

Key returns the key of the domain.

func (Domain) LibDirPath

func (d Domain) LibDirPath() string

LibDirPath returns the path to the lib directory within the domain. This is where shared libraries and packages should be placed.

func (Domain) RootPath added in v0.27.0

func (d Domain) RootPath() string

RootPath returns the root path of domains filesystem.

func (Domain) String

func (d Domain) String() string

String returns the key of the domain.

type EnvDir

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

EnvDir represents a specific environment directory within a domain.

func NewEnvDir

func NewEnvDir(rootPath, domainKey, key string) EnvDir

NewEnvDir creates a new DomainEnv.

func (EnvDir) AddressBook

func (d EnvDir) AddressBook() (fdeployment.AddressBook, error)

AddressBook returns the address book for the domain's environment directory.

func (EnvDir) AddressBookFilePath

func (d EnvDir) AddressBookFilePath() string

AddressBookFilePath returns the path to the address book file for the domain's environment directory.

func (EnvDir) AddressRefsFilePath

func (d EnvDir) AddressRefsFilePath() string

AddressRefsFilePath returns the path to the address refs store file for the domain's environment directory.

func (EnvDir) ArtifactsDir

func (d EnvDir) ArtifactsDir() *ArtifactsDir

ArtifactsDir returns the artifacts for the domain's environment directory.

func (EnvDir) ChainMetadataFilePath

func (d EnvDir) ChainMetadataFilePath() string

ChainMetadataFilePath returns the path to the chain metadata store file for the domain's environment directory.

func (EnvDir) ContractMetadataFilePath

func (d EnvDir) ContractMetadataFilePath() string

ContractMetadataFilePath returns the path to the contract metadata store file for the domain's environment directory.

func (EnvDir) CreateDurablePipelinesDir

func (d EnvDir) CreateDurablePipelinesDir() error

CreateDurablePipelinesDir creates the durable_pipelines directory and inputs subdirectory within the domain's environment directory if they don't exist. It also creates .gitkeep files within both directories to ensure they are tracked by git.

func (EnvDir) DataStore

func (d EnvDir) DataStore() (fdatastore.DataStore, error)

DataStore returns the datastore for the domain's environment directory as read-only.

func (EnvDir) DataStoreDirPath

func (d EnvDir) DataStoreDirPath() string

DatastoreDirPath returns the path to the datastore directory within the domain's environment.

func (EnvDir) DirPath

func (d EnvDir) DirPath() string

DirPath returns the path to the environment directory within the domain.

func (EnvDir) DomainDirPath

func (d EnvDir) DomainDirPath() string

DomainDirPath returns the path to the domain directory within the environment.

func (EnvDir) DomainKey

func (d EnvDir) DomainKey() string

DomainKey returns the domain key that the environment belongs to.

func (EnvDir) DurablePipelinesDirPath

func (d EnvDir) DurablePipelinesDirPath() string

DurablePipelinesDirPath returns the path to the durable_pipelines directory within the domain's environment.

func (EnvDir) DurablePipelinesInputsDirPath

func (d EnvDir) DurablePipelinesInputsDirPath() string

DurablePipelinesInputsDirPath returns the path to the inputs directory within the durable_pipelines directory.

func (EnvDir) EnvMetadataFilePath

func (d EnvDir) EnvMetadataFilePath() string

EnvMetadataFilePath returns the path to the environment metadata file for the domain's environment directory.

func (EnvDir) InputsDirPath

func (d EnvDir) InputsDirPath() string

InputsDirPath returns the path to the inputs directory for the domain's environment directory.

func (EnvDir) Key

func (d EnvDir) Key() string

Key returns the environment key.

func (EnvDir) LoadNodes

func (d EnvDir) LoadNodes() (*nodes.Nodes, error)

LoadNodes loads the nodes in the domain's environment directory from a nodes.json file.

func (EnvDir) LoadState

func (d EnvDir) LoadState() (JSONSerializer, error)

LoadViewState loads the view domain state as a json.Marshaler if the state file does not exist, it will return an empty json.Marshaler by default.

func (EnvDir) MergeMigrationAddressBook

func (d EnvDir) MergeMigrationAddressBook(migKey, timestamp string) error

MergeMigrationAddressBook merges a migration's address book into an existing address book for the given domain environment. It reads the existing address book and the migration's address book, merges the latter into the former, and then writes the updated address book back to the domain environment address book.

func (EnvDir) MergeMigrationDataStore

func (d EnvDir) MergeMigrationDataStore(migkey, timestamp string) error

func (EnvDir) MigrateAddressBook

func (d EnvDir) MigrateAddressBook() error

MigrateAddressBook migrates the address book for the domain's environment directory to the new datastore format. It reads the existing address book and converts its records. When converting address book entries to datastore addressRefs, some assumptions are made to guarantee the conversion is successful.

func (EnvDir) MigrationsArchiveFilePath

func (d EnvDir) MigrationsArchiveFilePath() string

MigrationsArchiveFilePath returns the path to the migrations archive file for the domain's environment directory.

func (EnvDir) MigrationsFilePath

func (d EnvDir) MigrationsFilePath() string

MigrationsFilePath returns the path to the migrations file for the domain's environment directory.

func (EnvDir) MutableDataStore

func (d EnvDir) MutableDataStore() (fdatastore.MutableDataStore, error)

MutableDataStore returns the datastore for the domain's environment directory as mutable.

func (EnvDir) NodesFilePath

func (d EnvDir) NodesFilePath() string

NodesFilePath returns the path to the file containing node information for the domain's environment directory.

func (EnvDir) PipelinesFilePath added in v0.41.0

func (d EnvDir) PipelinesFilePath() string

PipelinesFilePath returns the path to the Pipeline file for the domain's environment directory.

func (EnvDir) RemoveMigrationAddressBook

func (d EnvDir) RemoveMigrationAddressBook(migKey, timestamp string) error

RemoveAddressBooks removes a migration's address book from an existing address book for a given domain environment. It reads the existing address book and the migration's address book, removes the latter from the former, and then writes the updated address book back to the domain environment address book.

This can rollback MergeAddressBooks changes.

func (EnvDir) RootPath added in v0.27.0

func (d EnvDir) RootPath() string

RootPath returns the root path of the environment directory.

func (EnvDir) SaveNodes

func (d EnvDir) SaveNodes(nodeIDs []string) error

SaveNodes saves the node IDs to the domain's environment directory into a nodes.json file.

If the file already exists, the new nodes will be merged with the existing nodes. If a node with the same id already exists, it will be overwritten.

func (EnvDir) SaveViewState added in v0.26.0

func (d EnvDir) SaveViewState(v json.Marshaler) error

SaveViewState saves the view state of the domain's environment with the default filename.

func (EnvDir) String

func (d EnvDir) String() string

String returns the domain and key of the environment.

func (EnvDir) ViewStateFilePath

func (d EnvDir) ViewStateFilePath() string

ViewStateFilePath returns the path to the file containing view state for the domain's environment directory.

type JSONSerializer

type JSONSerializer interface {
	json.Marshaler
	json.Unmarshaler
}

JSONSerializer combines both marshaling and unmarshaling capabilities

Jump to

Keyboard shortcuts

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