cmdapi

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2022 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Overview

Package cmdapi holds the atlas commands used to build an atlas distribution.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Root represents the root command when called without any subcommands.
	Root = &cobra.Command{
		Use:          "atlas",
		Short:        "A database toolkit.",
		SilenceUsage: true,
	}

	// GlobalFlags contains flags common to many Atlas sub-commands.
	GlobalFlags struct {
		// Config defines the path to the Atlas project/config file.
		ConfigURL string
		// SelectedEnv contains the environment selected from the active project via the --env flag.
		SelectedEnv string
		// Vars contains the input variables passed from the CLI to Atlas DDL or project files.
		Vars Vars
	}
)

Functions

func Version added in v0.8.0

func Version() string

Version returns the current Atlas binary version.

Types

type Env

type Env struct {
	// Name for this environment.
	Name string `spec:"name,name"`

	// URL of the database.
	URL string `spec:"url"`

	// URL of the dev-database for this environment.
	// See: https://atlasgo.io/dev-database
	DevURL string `spec:"dev"`

	// List of schemas in this database that are managed by Atlas.
	Schemas []string `spec:"schemas"`

	// Exclude defines a list of glob patterns used to filter
	// resources on inspection.
	Exclude []string `spec:"exclude"`

	// Migration containing the migration configuration of the env.
	Migration *Migration `spec:"migration"`

	// Lint of the environment.
	Lint *Lint `spec:"lint"`

	// Log of the environment.
	Log Log `spec:"log"`
	schemahcl.DefaultExtension
}

Env represents an Atlas environment.

func LoadEnv

func LoadEnv(name string, opts ...LoadOption) ([]*Env, error)

LoadEnv reads the project file in path, and loads the environment instances with the provided name.

func (*Env) Sources added in v0.5.0

func (e *Env) Sources() ([]string, error)

Sources returns the paths containing the Atlas schema.

type Lint added in v0.6.5

type Lint struct {
	// Log configures the --log option.
	Log string `spec:"log"`
	// Latest configures the --latest option.
	Latest int `spec:"latest"`
	Git    struct {
		// Dir configures the --git-dir option.
		Dir string `spec:"dir"`
		// Base configures the --git-base option.
		Base string `spec:"base"`
	} `spec:"git"`
	schemahcl.DefaultExtension
}

Lint represents the configuration of migration linting.

func (*Lint) Extend added in v0.6.5

func (l *Lint) Extend(global *Lint) *Lint

Extend allows extending environment blocks with a global one. For example:

lint {
  log = <<EOS
    ...
  EOS
}

env "local" {
  ...
  lint {
    latest = 1
  }
}

env "ci" {
  ...
  lint {
    git {
      dir = "../"
      base = "master"
    }
  }
}

type LoadOption

type LoadOption func(*loadConfig)

LoadOption configures the LoadEnv function.

func WithInput

func WithInput(vals map[string]cty.Value) LoadOption

WithInput is a LoadOption that sets the input values for the LoadEnv function.

type Log added in v0.8.0

type Log struct {
	Migrate struct {
		// Apply configures the logging for 'migrate apply'.
		Apply string `spec:"apply"`
		// Lint configures the logging for 'migrate lint'.
		Lint string `spec:"lint"`
		// Status configures the logging for 'migrate status'.
		Status string `spec:"status"`
	} `spec:"migrate"`
	Schema struct {
		// Apply configures the logging for 'schema apply'.
		Apply string `spec:"apply"`
	} `spec:"schema"`
	schemahcl.DefaultExtension
}

Log represents a logging configuration of an environment.

type Migration added in v0.6.0

type Migration struct {
	Dir             string `spec:"dir"`
	Format          string `spec:"format"`
	Baseline        string `spec:"baseline"`
	LockTimeout     string `spec:"lock_timeout"`
	RevisionsSchema string `spec:"revisions_schema"`
}

Migration represents the migration directory for the Env.

type Project added in v0.6.5

type Project struct {
	Envs []*Env `spec:"env"`  // List of environments
	Lint *Lint  `spec:"lint"` // Optional global lint config
}

Project represents an atlas.hcl project file.

type Vars added in v0.8.0

type Vars map[string]cty.Value

Vars implements pflag.Value.

func (Vars) Copy added in v0.8.3

func (v Vars) Copy() Vars

Copy returns a copy of the current variables.

func (*Vars) Replace added in v0.8.3

func (v *Vars) Replace(vc Vars)

Replace overrides the variables.

func (*Vars) Set added in v0.8.0

func (v *Vars) Set(s string) error

Set implements pflag.Value.Set.

func (Vars) String added in v0.8.0

func (v Vars) String() string

String implements pflag.Value.String.

func (*Vars) Type added in v0.8.0

func (v *Vars) Type() string

Type implements pflag.Value.Type.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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