project

package
v1.54.6 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildAndRunMigrations added in v1.53.0

func BuildAndRunMigrations(fs afero.Fs, servers map[string]*sql.DatabaseServer, databasesToMigrate map[string]*resourcespb.SqlDatabaseResource) error

func BuildMigrationImage added in v1.42.0

func BuildMigrationImage(fs afero.Fs, dbName string, buildContext *runtime.RuntimeBuildContext, logs io.Writer) error

func BuildMigrationImages added in v1.42.0

func BuildMigrationImages(fs afero.Fs, migrationBuildContexts map[string]*runtime.RuntimeBuildContext) (chan ServiceBuildUpdate, error)

FIXME: This is essentially a copy of the project.BuildServiceImages function

func GetTempBuildDir added in v1.53.0

func GetTempBuildDir() string

func NewBuildUpdateWriter added in v1.53.0

func NewBuildUpdateWriter(serviceName string, buildUpdateChan chan ServiceBuildUpdate) io.Writer

func RunMigration added in v1.53.0

func RunMigration(databaseName string, connectionString string) error

Run the migrations

func RunMigrations added in v1.53.0

func RunMigrations(servers map[string]*sql.DatabaseServer) error

Types

type BaseService added in v1.54.0

type BaseService interface {
	GetBasedir() string
	GetMatch() string
	GetRuntime() string
	GetStart() string
}

type BaseServiceConfiguration added in v1.54.0

type BaseServiceConfiguration struct {
	// The base directory for source files
	Basedir string `yaml:"basedir"`

	// This is the string version
	Match string `yaml:"match"`

	// This is the custom runtime version (is custom if not nil, we auto-detect a standard language runtime)
	Runtime string `yaml:"runtime,omitempty"`

	// This is a command that will be use to run these services when using nitric start
	Start string `yaml:"start"`
}

func (BaseServiceConfiguration) GetBasedir added in v1.54.0

func (b BaseServiceConfiguration) GetBasedir() string

func (BaseServiceConfiguration) GetMatch added in v1.54.0

func (b BaseServiceConfiguration) GetMatch() string

func (BaseServiceConfiguration) GetRuntime added in v1.54.0

func (b BaseServiceConfiguration) GetRuntime() string

func (BaseServiceConfiguration) GetStart added in v1.54.0

func (b BaseServiceConfiguration) GetStart() string

type Batch added in v1.54.0

type Batch struct {
	Name string
	// contains filtered or unexported fields
}

func (*Batch) BuildImage added in v1.54.0

func (s *Batch) BuildImage(fs afero.Fs, logs io.Writer) error

FIXME: Duplicate code from service.go

func (*Batch) GetAbsoluteFilePath added in v1.54.0

func (s *Batch) GetAbsoluteFilePath() (string, error)

func (*Batch) GetFilePath added in v1.54.0

func (s *Batch) GetFilePath() string

func (*Batch) Run added in v1.54.0

func (s *Batch) Run(stop <-chan bool, updates chan<- ServiceRunUpdate, env map[string]string) error

Run - runs the service using the provided command, typically not in a container.

func (*Batch) RunContainer added in v1.54.0

func (s *Batch) RunContainer(stop <-chan bool, updates chan<- ServiceRunUpdate, opts ...RunContainerOption) error

RunContainer - Runs a container for the service, blocking until the container exits

type BatchConfiguration added in v1.54.0

type BatchConfiguration struct {
	BaseServiceConfiguration `yaml:",inline"`
}

type DatabaseMigrationState added in v1.53.0

type DatabaseMigrationState struct {
	*LocalMigration
}

type LocalMigration added in v1.53.0

type LocalMigration struct {
	DatabaseName     string
	ConnectionString string
}

type Project

type Project struct {
	Name        string
	Directory   string
	Preview     []preview.Feature
	LocalConfig localconfig.LocalConfiguration
	// contains filtered or unexported fields
}

func FromFile

func FromFile(fs afero.Fs, filepath string) (*Project, error)

FromFile - Loads a nitric project from a nitric.yaml file If no filepath is provided, the default location './nitric.yaml' is used

func (*Project) BuildBatches added in v1.54.0

func (p *Project) BuildBatches(fs afero.Fs) (chan ServiceBuildUpdate, error)

TODO: Reduce duplicate code BuildBatches - Builds all the batches in the project

func (*Project) BuildServices added in v1.34.0

func (p *Project) BuildServices(fs afero.Fs) (chan ServiceBuildUpdate, error)

BuildServices - Builds all the services in the project

func (*Project) CollectBatchRequirements added in v1.54.0

func (p *Project) CollectBatchRequirements() ([]*collector.BatchRequirements, error)

func (*Project) CollectServicesRequirements added in v1.34.0

func (p *Project) CollectServicesRequirements() ([]*collector.ServiceRequirements, error)

func (*Project) DefaultMigrationImage added in v1.42.0

func (p *Project) DefaultMigrationImage(fs afero.Fs) (string, bool)

DefaultMigrationImage - Returns the default migration image name for the project Also returns ok if image is required or not

func (*Project) GetBatchServices added in v1.54.0

func (p *Project) GetBatchServices() []Batch

func (*Project) GetServices added in v1.34.0

func (p *Project) GetServices() []Service

func (*Project) RunBatches added in v1.54.0

func (p *Project) RunBatches(localCloud *cloud.LocalCloud, stop <-chan bool, updates chan<- ServiceRunUpdate, env map[string]string) error

RunBatches - Runs all the batches as containers use the stop channel to stop all running batches

func (*Project) RunBatchesWithCommand added in v1.54.0

func (p *Project) RunBatchesWithCommand(localCloud *cloud.LocalCloud, stop <-chan bool, updates chan<- ServiceRunUpdate, env map[string]string) error

RunBatchesWithCommand - Runs all the batches locally using a startup command use the stop channel to stop all running batches

func (*Project) RunServices added in v1.34.0

func (p *Project) RunServices(localCloud *cloud.LocalCloud, stop <-chan bool, updates chan<- ServiceRunUpdate, env map[string]string) error

RunServices - Runs all the services as containers use the stop channel to stop all running services

func (*Project) RunServicesWithCommand added in v1.34.0

func (p *Project) RunServicesWithCommand(localCloud *cloud.LocalCloud, stop <-chan bool, updates chan<- ServiceRunUpdate, env map[string]string) error

RunServicesWithCommand - Runs all the services locally using a startup command use the stop channel to stop all running services

type ProjectConfiguration added in v1.34.0

type ProjectConfiguration struct {
	Name      string                          `yaml:"name"`
	Directory string                          `yaml:"-"`
	Services  []ServiceConfiguration          `yaml:"services"`
	Ports     map[string]int                  `yaml:"ports,omitempty"`
	Batches   []BatchConfiguration            `yaml:"batch-services"`
	Runtimes  map[string]RuntimeConfiguration `yaml:"runtimes,omitempty"`
	Preview   []preview.Feature               `yaml:"preview,omitempty"`
}

func ConfigurationFromFile added in v1.34.0

func ConfigurationFromFile(fs afero.Fs, filePath string) (*ProjectConfiguration, error)

func (ProjectConfiguration) ToFile added in v1.34.0

func (p ProjectConfiguration) ToFile(fs afero.Fs, filepath string) error

type RunContainerOption added in v1.34.0

type RunContainerOption func(*runContainerOptions)

func WithEnvVars added in v1.34.0

func WithEnvVars(envVars map[string]string) RunContainerOption

func WithNitricEnvironment added in v1.34.0

func WithNitricEnvironment(environment string) RunContainerOption

func WithNitricHost added in v1.34.0

func WithNitricHost(host string) RunContainerOption

func WithNitricPort added in v1.34.0

func WithNitricPort(port string) RunContainerOption

type RuntimeConfiguration added in v1.34.0

type RuntimeConfiguration struct {
	// Template dockerfile to use as the base for the custom runtime
	Dockerfile string
	// Directory path for the Docker build context for the custom runtime
	Context string
	// Additional args to pass to the custom runtime
	Args map[string]string
}

type Service added in v1.34.0

type Service struct {
	Name string
	Type string
	// contains filtered or unexported fields
}

func NewService added in v1.53.0

func NewService(name, serviceType, filepath string, buildContext runtime.RuntimeBuildContext, startCmd string) *Service

func (*Service) BuildImage added in v1.34.0

func (s *Service) BuildImage(fs afero.Fs, logs io.Writer) error

func (*Service) GetAbsoluteFilePath added in v1.34.0

func (s *Service) GetAbsoluteFilePath() (string, error)

func (*Service) GetFilePath added in v1.34.0

func (s *Service) GetFilePath() string

func (*Service) Run added in v1.34.0

func (s *Service) Run(stop <-chan bool, updates chan<- ServiceRunUpdate, env map[string]string) error

Run - runs the service using the provided command, typically not in a container.

func (*Service) RunContainer added in v1.34.0

func (s *Service) RunContainer(stop <-chan bool, updates chan<- ServiceRunUpdate, opts ...RunContainerOption) error

RunContainer - Runs a container for the service, blocking until the container exits

type ServiceBuildStatus added in v1.34.0

type ServiceBuildStatus string
const (
	ServiceBuildStatus_InProgress ServiceBuildStatus = "In Progress"
	ServiceBuildStatus_Complete   ServiceBuildStatus = "Complete"
	ServiceBuildStatus_Error      ServiceBuildStatus = "Error"
	ServiceBuildStatus_Skipped    ServiceBuildStatus = "Skipped"
)

type ServiceBuildUpdate added in v1.34.0

type ServiceBuildUpdate struct {
	ServiceName string
	Message     string
	Status      ServiceBuildStatus
	Err         error
}

type ServiceConfiguration added in v1.34.0

type ServiceConfiguration struct {
	BaseServiceConfiguration `yaml:",inline"`

	// This allows specifying a particular service type (e.g. "Job"), this is optional and custom service types can be defined for each stack
	Type string `yaml:"type,omitempty"`
}

type ServiceRunStatus added in v1.34.0

type ServiceRunStatus string
const (
	ServiceRunStatus_Running ServiceRunStatus = "Running"
	ServiceRunStatus_Done    ServiceRunStatus = "Done"
	ServiceRunStatus_Error   ServiceRunStatus = "Error"
)

type ServiceRunUpdate added in v1.34.0

type ServiceRunUpdate struct {
	ServiceName string
	Label       string
	Message     string
	Status      ServiceRunStatus
	Err         error
}

type ServiceRunUpdateWriter added in v1.34.0

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

func (*ServiceRunUpdateWriter) Write added in v1.34.0

func (s *ServiceRunUpdateWriter) Write(data []byte) (int, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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