Documentation
¶
Overview ¶
Package app provides the core application logic for JSM.
Index ¶
- Constants
- Variables
- func NewBuildDistCmd(m Manager) *cobra.Command
- func NewCheckChangesCmd(m Manager) *cobra.Command
- func NewCreateRegistryCmd(pathResolver fsh.PathResolver) *cobra.Command
- func NewCreateSchemaCmd(mgr Manager) *cobra.Command
- func NewCreateSchemaVersionCmd(mgr Manager) *cobra.Command
- func NewRenderSchemaCmd(mgr Manager) *cobra.Command
- func NewRootCmd(lazy *LazyManager, ll *slog.LevelVar, stdout, stderr io.Writer, ...) *cobra.Command
- func NewTagDeploymentCmd(mgr Manager) *cobra.Command
- func NewValidateCmd(m Manager) *cobra.Command
- func Run(ctx context.Context, args []string, stdout, stderr io.Writer, ...) error
- type CLIManager
- func (m *CLIManager) BuildDist(ctx context.Context, envName config.Env, all bool) error
- func (m *CLIManager) CheckChanges(ctx context.Context, envName config.Env) error
- func (m *CLIManager) CreateSchema(domainAndFamilyName string) (schema.Key, error)
- func (m *CLIManager) CreateSchemaVersion(k schema.Key, rt schema.ReleaseType) (schema.Key, error)
- func (m *CLIManager) Registry() *schema.Registry
- func (m *CLIManager) RenderSchema(_ context.Context, target schema.ResolvedTarget, env config.Env) ([]byte, error)
- func (m *CLIManager) TagDeployment(ctx context.Context, envName config.Env) error
- func (m *CLIManager) ValidateSchema(ctx context.Context, target schema.ResolvedTarget, verbose bool, format string, ...) error
- func (m *CLIManager) WatchValidation(ctx context.Context, target schema.ResolvedTarget, verbose bool, format string, ...) error
- type LazyManager
- func (l *LazyManager) BuildDist(ctx context.Context, envName config.Env, all bool) error
- func (l *LazyManager) CheckChanges(ctx context.Context, envName config.Env) error
- func (l *LazyManager) CreateSchema(domainAndFamilyName string) (schema.Key, error)
- func (l *LazyManager) CreateSchemaVersion(k schema.Key, rt schema.ReleaseType) (schema.Key, error)
- func (l *LazyManager) HasInner() bool
- func (l *LazyManager) Registry() *schema.Registry
- func (l *LazyManager) RenderSchema(ctx context.Context, target schema.ResolvedTarget, env config.Env) ([]byte, error)
- func (l *LazyManager) SetInner(m Manager)
- func (l *LazyManager) TagDeployment(ctx context.Context, envName config.Env) error
- func (l *LazyManager) ValidateSchema(ctx context.Context, target schema.ResolvedTarget, verbose bool, format string, ...) error
- func (l *LazyManager) WatchValidation(ctx context.Context, target schema.ResolvedTarget, verbose bool, format string, ...) error
- type Manager
Constants ¶
const ( // LogFile is the default name of the log file. LogFile = ".jsm.log" // LogEnvVar is the name of the environment variable used to override the log file path. LogEnvVar = "JSM_LOG_FILE" )
const CreateRegistryCmdName = "create-registry"
CreateRegistryCmdName is the name of the command to create a new registry.
Variables ¶
var Banner = "\033[32m" + `
_______ ____ _ __
/ / ___// __ \/ | / /
__ / /\__ \/ / / / |/ /
/ /_/ /___/ / /_/ / /| /
\____//____/\____/_/ |_/
_____ __
/ ___/_____/ /_ ___ ____ ___ ____ _
\__ \/ ___/ __ \/ _ \/ __ ` + "`" + `__ \/ __ ` + "`" + `/
___/ / /__/ / / / __/ / / / / / /_/ /
/____/\___/_/ / /_/\___/_/ /_/\__,_/
__ ___
/ |/ /___ _____ ____ _____ ____ _____
/ /|_/ / __ ` + "`" + `/ __ \/ __ ` + "`" + `/ __ ` + "`" + `/ _ \/ ___/
/ / / / /_/ / / / / /_/ / /_/ / __/ /
/_/ /_/\__,_/_/ /_/\__,_/\__, /\___/_/
/____/
` + "\033[0m"
Banner with colour codes and escaped backticks.
var LongDescription = `` /* 278-byte string literal not displayed */
LongDescription is the long description of the application.
var Version = "dev"
Version is the current version of jsm, set at build time.
Functions ¶
func NewBuildDistCmd ¶
NewBuildDistCmd creates a new build-dist command.
func NewCheckChangesCmd ¶
NewCheckChangesCmd creates a new check-changes command.
func NewCreateRegistryCmd ¶
func NewCreateRegistryCmd(pathResolver fsh.PathResolver) *cobra.Command
NewCreateRegistryCmd returns a new cobra command for creating a registry.
func NewCreateSchemaCmd ¶
NewCreateSchemaCmd returns a new cobra command for creating a schema.
func NewCreateSchemaVersionCmd ¶
NewCreateSchemaVersionCmd returns a new cobra command for creating a schema version.
func NewRenderSchemaCmd ¶
NewRenderSchemaCmd returns a new cobra command for rendering a schema.
func NewRootCmd ¶
func NewRootCmd( lazy *LazyManager, ll *slog.LevelVar, stdout, stderr io.Writer, envProvider fsh.EnvProvider, ) *cobra.Command
NewRootCmd creates the root command and wires up dependencies.
func NewTagDeploymentCmd ¶
NewTagDeploymentCmd returns a new cobra command for tagging a deployment.
func NewValidateCmd ¶
NewValidateCmd creates a new validate command.
Types ¶
type CLIManager ¶
type CLIManager struct {
// contains filtered or unexported fields
}
CLIManager is the concrete implementation of the Manager interface.
func NewCLIManager ¶
func NewCLIManager( l *slog.Logger, r *schema.Registry, t *schema.Tester, g repo.Gitter, db schema.DistBuilder, rw io.Writer, ) *CLIManager
NewCLIManager creates a new concrete Manager implementation.
func (*CLIManager) CheckChanges ¶
CheckChanges determines whether there are any changes to previously-deployed schemas for an environment which does not permit schema mutation. If so, it returns an error.
func (*CLIManager) CreateSchema ¶
func (m *CLIManager) CreateSchema(domainAndFamilyName string) (schema.Key, error)
CreateSchema creates a new schema with the given name.
func (*CLIManager) CreateSchemaVersion ¶
func (m *CLIManager) CreateSchemaVersion(k schema.Key, rt schema.ReleaseType) (schema.Key, error)
CreateSchemaVersion increments the version of an existing schema.
func (*CLIManager) Registry ¶
func (m *CLIManager) Registry() *schema.Registry
Registry returns the underlying schema registry.
func (*CLIManager) RenderSchema ¶
func (m *CLIManager) RenderSchema(_ context.Context, target schema.ResolvedTarget, env config.Env) ([]byte, error)
RenderSchema renders a schema for a specific environment.
func (*CLIManager) TagDeployment ¶
TagDeployment ensures that a successful deployment is tagged in git.
func (*CLIManager) ValidateSchema ¶
func (m *CLIManager) ValidateSchema(ctx context.Context, target schema.ResolvedTarget, verbose bool, format string, useColour bool, continueOnError bool, testScope schema.TestScope, skipCompatible bool, ) error
ValidateSchema runs tests on the target schema(s).
func (*CLIManager) WatchValidation ¶ added in v1.1.0
func (m *CLIManager) WatchValidation(ctx context.Context, target schema.ResolvedTarget, verbose bool, format string, useColour bool, continueOnError bool, testScope schema.TestScope, skipCompatible bool, readyChan chan<- struct{}, ) error
WatchValidation watches for changes in the registry and triggers validation. If you want to know when the watcher is ready to start listening to changes, pass a non-nil readyChan to be notified.
type LazyManager ¶
type LazyManager struct {
// contains filtered or unexported fields
}
LazyManager acts as a placeholder for a real Manager implementation, allowing for deferred initialization of dependencies.
func (*LazyManager) CheckChanges ¶
CheckChanges implements the Manager interface.
func (*LazyManager) CreateSchema ¶
func (l *LazyManager) CreateSchema(domainAndFamilyName string) (schema.Key, error)
CreateSchema implements the Manager interface.
func (*LazyManager) CreateSchemaVersion ¶
func (l *LazyManager) CreateSchemaVersion(k schema.Key, rt schema.ReleaseType) (schema.Key, error)
CreateSchemaVersion implements the Manager interface.
func (*LazyManager) HasInner ¶
func (l *LazyManager) HasInner() bool
HasInner returns true if the inner manager has been set. This is used by PersistentPreRunE to skip initialization if already configured (e.g., in tests).
func (*LazyManager) Registry ¶
func (l *LazyManager) Registry() *schema.Registry
Registry implements the Manager interface.
func (*LazyManager) RenderSchema ¶
func (l *LazyManager) RenderSchema(ctx context.Context, target schema.ResolvedTarget, env config.Env) ([]byte, error)
RenderSchema implements the Manager interface.
func (*LazyManager) SetInner ¶
func (l *LazyManager) SetInner(m Manager)
SetInner sets the inner manager implementation.
func (*LazyManager) TagDeployment ¶
TagDeployment implements the Manager interface.
func (*LazyManager) ValidateSchema ¶
func (l *LazyManager) ValidateSchema(ctx context.Context, target schema.ResolvedTarget, verbose bool, format string, useColour bool, continueOnError bool, testScope schema.TestScope, skipCompatible bool, ) error
ValidateSchema implements the Manager interface.
func (*LazyManager) WatchValidation ¶ added in v1.1.0
func (l *LazyManager) WatchValidation(ctx context.Context, target schema.ResolvedTarget, verbose bool, format string, useColour bool, continueOnError bool, testScope schema.TestScope, skipCompatible bool, readyChan chan<- struct{}, ) error
WatchValidation implements the Manager interface.
type Manager ¶
type Manager interface {
ValidateSchema(ctx context.Context, target schema.ResolvedTarget, verbose bool, format string,
useColour bool, continueOnError bool, testScope schema.TestScope, skipCompatible bool) error
WatchValidation(ctx context.Context, target schema.ResolvedTarget, verbose bool, format string,
useColour bool, continueOnError bool, testScope schema.TestScope, skipCompatible bool,
readyChan chan<- struct{}) error
Registry() *schema.Registry
CreateSchema(domainAndFamilyName string) (schema.Key, error)
CreateSchemaVersion(k schema.Key, rt schema.ReleaseType) (schema.Key, error)
RenderSchema(ctx context.Context, target schema.ResolvedTarget, env config.Env) ([]byte, error)
CheckChanges(ctx context.Context, envName config.Env) error
TagDeployment(ctx context.Context, envName config.Env) error
BuildDist(ctx context.Context, envName config.Env, all bool) error
}
Manager defines the business logic for JSON schema operations.