Documentation ¶
Overview ¶
Package cmdext provides extensions to the Atlas CLI that may be moved to a separate repository in the future.
Index ¶
- Constants
- Variables
- func QuerySrc(ctx *hcl.EvalContext, block *hclsyntax.Block) (cty.Value, error)
- func RemoteDir(ctx *hcl.EvalContext, block *hclsyntax.Block) (cty.Value, error)
- func RuntimeVarSrc(c *hcl.EvalContext, block *hclsyntax.Block) (cty.Value, error)
- func TemplateDir(ctx *hcl.EvalContext, block *hclsyntax.Block) (cty.Value, error)
- type AtlasConfig
- type EntLoader
- type LoadStateOptions
- type MigrateDiffOptions
- type MigrateDiffer
- type StateLoader
Constants ¶
const DefaultProjectName = "default"
DefaultProjectName is the default name for projects.
Variables ¶
var DataSources = []schemahcl.Option{ schemahcl.WithDataSource("sql", QuerySrc), schemahcl.WithDataSource("runtimevar", RuntimeVarSrc), schemahcl.WithDataSource("template_dir", TemplateDir), schemahcl.WithDataSource("remote_dir", RemoteDir), }
DataSources exposes the data sources provided by this package.
var States = registry{ "ent": EntLoader{}, }
States is a global registry for external state loaders.
Functions ¶
func QuerySrc ¶
QuerySrc exposes the database/sql.Query as a schemahcl datasource.
data "sql" "tenants" { url = var.url query = <query> args = [<arg1>, <arg2>, ...] } env "prod" { for_each = toset(data.sql.tenants.values) url = urlsetpath(var.url, each.value) }
func RuntimeVarSrc ¶
RuntimeVarSrc exposes the gocloud.dev/runtimevar as a schemahcl datasource.
data "runtimevar" "pass" { url = "driver://path?query=param" } locals { url = "mysql://root:${data.runtimevar.pass}@:3306/" }
func TemplateDir ¶
TemplateDir implements migrate.Dir interface for template directories.
data "template_dir" "name" { path = "path/to/directory" vars = { Env = atlas.env Seed = var.seed } } env "dev" { url = "driver://path?query=param" migration { dir = data.template_dir.name.url } }
Types ¶
type AtlasConfig ¶
type AtlasConfig struct { Client *cloudapi.Client // Client attached to Atlas Cloud. Project string // Optional project. }
AtlasConfig exposes non-sensitive information returned by the "atlas" init-block. By invoking AtlasInitBlock() a new config is returned that is set by the init block defined and executed on schemahcl Eval functions.
func (*AtlasConfig) InitBlock ¶
func (c *AtlasConfig) InitBlock() schemahcl.Option
InitBlock returns the handler for the "atlas" init block.
atlas { cloud { token = data.runtimevar.token // User token. url = var.cloud_url // Optional URL. project = var.project // Optional project. If set, cloud reporting is enabled. } }
type EntLoader ¶
type EntLoader struct{}
EntLoader is a StateLoader for loading ent.Schema's as StateReader's.
func (EntLoader) LoadState ¶
func (l EntLoader) LoadState(ctx context.Context, opts *LoadStateOptions) (migrate.StateReader, error)
LoadState returns a migrate.StateReader that reads the schema from an ent.Schema.
func (EntLoader) MigrateDiff ¶
func (l EntLoader) MigrateDiff(ctx context.Context, opts *MigrateDiffOptions) error
MigrateDiff returns the diff between ent.Schema and a directory.
type LoadStateOptions ¶
type LoadStateOptions struct { URLs []*url.URL Dev *sqlclient.Client // Client for the dev database. }
LoadStateOptions for external state loaders.
type MigrateDiffOptions ¶
type MigrateDiffOptions struct { Name string Indent string To []string Dir migrate.Dir Dev *sqlclient.Client Options []schema.DiffOption }
MigrateDiffOptions for external migration differ.
type MigrateDiffer ¶
type MigrateDiffer interface { MigrateDiff(context.Context, *MigrateDiffOptions) error // contains filtered or unexported methods }
MigrateDiffer allows external sources to implement custom migration differs.
type StateLoader ¶
type StateLoader interface {
LoadState(context.Context, *LoadStateOptions) (migrate.StateReader, error)
}
StateLoader allows loading StateReader's from external sources.