cmdext

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2023 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Overview

Package cmdext provides extensions to the Atlas CLI that may be moved to a separate repository in the future.

Index

Constants

This section is empty.

Variables

DataSources exposes the data sources provided by this package.

View Source
var States = registry{
	"ent": EntLoader{},
}

States is a global registry for external state loaders.

Functions

func AtlasConfig added in v0.10.0

func AtlasConfig(ctx *hcl.EvalContext, block *hclsyntax.Block) (cty.Value, error)

AtlasConfig is the handler for the "atlas" init block.

atlas {
  cloud {
    token = data.runtimevar.token	// User token.
    url   = var.cloud_url			// Optional URL.
  }
}

func QuerySrc

func QuerySrc(ctx *hcl.EvalContext, block *hclsyntax.Block) (cty.Value, error)

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 RemoteDir added in v0.10.0

func RemoteDir(ctx *hcl.EvalContext, block *hclsyntax.Block) (cty.Value, error)

RemoteDir is a data source that reads a remote migration directory.

func RuntimeVarSrc

func RuntimeVarSrc(c *hcl.EvalContext, block *hclsyntax.Block) (cty.Value, error)

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 added in v0.9.1

func TemplateDir(ctx *hcl.EvalContext, block *hclsyntax.Block) (cty.Value, error)

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 EntLoader added in v0.9.1

type EntLoader struct{}

EntLoader is a StateLoader for loading ent.Schema's as StateReader's.

func (EntLoader) LoadState added in v0.9.1

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 added in v0.9.1

func (l EntLoader) MigrateDiff(ctx context.Context, opts *MigrateDiffOptions) error

MigrateDiff returns the diff between ent.Schema and a directory.

type LoadStateOptions added in v0.9.1

type LoadStateOptions struct {
	URLs []*url.URL
	Dev  *sqlclient.Client // Client for the dev database.
}

LoadStateOptions for external state loaders.

type MigrateDiffOptions added in v0.9.1

type MigrateDiffOptions struct {
	Name   string
	Indent string
	To     []string
	Dir    migrate.Dir
	Dev    *sqlclient.Client
}

MigrateDiffOptions for external migration differ.

type MigrateDiffer added in v0.9.1

type MigrateDiffer interface {
	MigrateDiff(context.Context, *MigrateDiffOptions) error
	// contains filtered or unexported methods
}

MigrateDiffer allows external sources to implement custom migration differs.

type StateLoader added in v0.9.1

type StateLoader interface {
	LoadState(context.Context, *LoadStateOptions) (migrate.StateReader, error)
}

StateLoader allows loading StateReader's from external sources.

Jump to

Keyboard shortcuts

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