app

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package app provides the core application logic for JSM.

Index

Constants

View Source
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"
)
View Source
const CreateRegistryCmdName = "create-registry"

CreateRegistryCmdName is the name of the command to create a new registry.

Variables

View Source
       _______ ____  _   __                 
      / / ___// __ \/ | / /                 
 __  / /\__ \/ / / /  |/ /                  
/ /_/ /___/ / /_/ / /|  /                   
\____//____/\____/_/ |_/                    
                                            
   _____      __                            
  / ___/_____/ /_  ___  ____ ___  ____ _    
  \__ \/ ___/ __ \/ _ \/ __ ` + "`" + `__ \/ __ ` + "`" + `/    
 ___/ / /__/ / / /  __/ / / / / / /_/ /     
/____/\___/_/ / /_/\___/_/ /_/\__,_/      
                                            
    __  ___                                 
   /  |/  /___ _____  ____ _____ ____  _____
  / /|_/ / __ ` + "`" + `/ __ \/ __ ` + "`" + `/ __ ` + "`" + `/ _ \/ ___/
 / /  / / /_/ / / / / /_/ / /_/ /  __/ /    
/_/  /_/\__,_/_/ /_/\__,_/\__, /\___/_/     
                         /____/             
` + "\033[0m"

Banner with colour codes and escaped backticks.

View Source
var LongDescription = `` /* 278-byte string literal not displayed */

LongDescription is the long description of the application.

View Source
var Version = "dev"

Version is the current version of jsm, set at build time.

Functions

func NewBuildDistCmd

func NewBuildDistCmd(m Manager) *cobra.Command

NewBuildDistCmd creates a new build-dist command.

func NewCheckChangesCmd

func NewCheckChangesCmd(m Manager) *cobra.Command

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

func NewCreateSchemaCmd(mgr Manager) *cobra.Command

NewCreateSchemaCmd returns a new cobra command for creating a schema.

func NewCreateSchemaVersionCmd

func NewCreateSchemaVersionCmd(mgr Manager) *cobra.Command

NewCreateSchemaVersionCmd returns a new cobra command for creating a schema version.

func NewRenderSchemaCmd

func NewRenderSchemaCmd(mgr Manager) *cobra.Command

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

func NewTagDeploymentCmd(mgr Manager) *cobra.Command

NewTagDeploymentCmd returns a new cobra command for tagging a deployment.

func NewValidateCmd

func NewValidateCmd(m Manager) *cobra.Command

NewValidateCmd creates a new validate command.

func Run

func Run(ctx context.Context, args []string, stdout, stderr io.Writer, envProvider fsh.EnvProvider) error

Run executes the application with the given arguments.

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) BuildDist

func (m *CLIManager) BuildDist(ctx context.Context, envName config.Env, all bool) error

BuildDist builds a distribution directory for the given environment.

func (*CLIManager) CheckChanges

func (m *CLIManager) CheckChanges(ctx context.Context, envName config.Env) error

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

func (m *CLIManager) TagDeployment(ctx context.Context, envName config.Env) error

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) BuildDist

func (l *LazyManager) BuildDist(ctx context.Context, envName config.Env, all bool) error

BuildDist implements the Manager interface.

func (*LazyManager) CheckChanges

func (l *LazyManager) CheckChanges(ctx context.Context, envName config.Env) error

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

func (l *LazyManager) TagDeployment(ctx context.Context, envName config.Env) error

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.

Jump to

Keyboard shortcuts

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