Documentation ¶
Index ¶
- Variables
- func TempFile(content, ext string) (string, func() error, error)
- type AppliedFile
- type Changes
- type Check
- type Client
- func (c *Client) Login(ctx context.Context, params *LoginParams) error
- func (c *Client) Logout(ctx context.Context) error
- func (c *Client) MigrateApply(ctx context.Context, params *MigrateApplyParams) (*MigrateApply, error)
- func (c *Client) MigrateApplySlice(ctx context.Context, params *MigrateApplyParams) ([]*MigrateApply, error)
- func (c *Client) MigrateDown(ctx context.Context, params *MigrateDownParams) (*MigrateDown, error)
- func (c *Client) MigrateLint(ctx context.Context, params *MigrateLintParams) (*SummaryReport, error)
- func (c *Client) MigrateLintError(ctx context.Context, params *MigrateLintParams) error
- func (c *Client) MigratePush(ctx context.Context, params *MigratePushParams) (string, error)
- func (c *Client) MigrateStatus(ctx context.Context, params *MigrateStatusParams) (*MigrateStatus, error)
- func (c *Client) MigrateTest(ctx context.Context, params *MigrateTestParams) (string, error)
- func (c *Client) SchemaApply(ctx context.Context, params *SchemaApplyParams) (*SchemaApply, error)
- func (c *Client) SchemaApplySlice(ctx context.Context, params *SchemaApplyParams) ([]*SchemaApply, error)
- func (c *Client) SchemaClean(ctx context.Context, params *SchemaCleanParams) (*SchemaClean, error)
- func (c *Client) SchemaInspect(ctx context.Context, params *SchemaInspectParams) (string, error)
- func (c *Client) SchemaPlan(ctx context.Context, params *SchemaPlanParams) (*SchemaPlan, error)
- func (c *Client) SchemaPlanApprove(ctx context.Context, params *SchemaPlanApproveParams) (*SchemaPlanApprove, error)
- func (c *Client) SchemaPlanLint(ctx context.Context, params *SchemaPlanLintParams) (*SchemaPlan, error)
- func (c *Client) SchemaPlanList(ctx context.Context, params *SchemaPlanListParams) ([]SchemaPlanFile, error)
- func (c *Client) SchemaPlanPull(ctx context.Context, params *SchemaPlanPullParams) (string, error)
- func (c *Client) SchemaPlanPush(ctx context.Context, params *SchemaPlanPushParams) (string, error)
- func (c *Client) SchemaPlanValidate(ctx context.Context, params *SchemaPlanValidateParams) error
- func (c *Client) SchemaPush(ctx context.Context, params *SchemaPushParams) (*SchemaPush, error)
- func (c *Client) SchemaTest(ctx context.Context, params *SchemaTestParams) (string, error)
- func (c *Client) SetEnv(env map[string]string) error
- func (c *Client) Version(ctx context.Context) (*Version, error)
- func (c *Client) WhoAmI(ctx context.Context) (*WhoAmI, error)
- func (c *Client) WithWorkDir(dir string, fn func(*Client) error) error
- type DeployRunContext
- type Env
- type Environ
- type Error
- type File
- type FileChecks
- type FileReport
- type InvalidParamsError
- type LoginParams
- type MigrateApply
- type MigrateApplyError
- type MigrateApplyParams
- type MigrateDown
- type MigrateDownParams
- type MigrateExecOrder
- type MigrateLintParams
- type MigratePushParams
- type MigrateStatus
- type MigrateStatusParams
- type MigrateTestParams
- type Option
- type RevertedFile
- type Revision
- type RunContext
- type SCMType
- type SchemaApply
- type SchemaApplyError
- type SchemaApplyParams
- type SchemaClean
- type SchemaCleanParams
- type SchemaInspectParams
- type SchemaPlan
- type SchemaPlanApprove
- type SchemaPlanApproveParams
- type SchemaPlanFile
- type SchemaPlanLintParams
- type SchemaPlanListParams
- type SchemaPlanParams
- type SchemaPlanPullParams
- type SchemaPlanPushParams
- type SchemaPlanValidateParams
- type SchemaPush
- type SchemaPushParams
- type SchemaTestParams
- type StepReport
- type StmtError
- type SummaryReport
- type TriggerType
- type VarArgs
- type Varsdeprecated
- type Vars2
- type Version
- type WhoAmI
- type WorkingDir
- func (ce *WorkingDir) Close() error
- func (cs *WorkingDir) CopyFS(name string, src fs.FS) error
- func (ce *WorkingDir) CreateFile(name string, fn func(w io.Writer) error) error
- func (ce *WorkingDir) DirFS() fs.FS
- func (ce *WorkingDir) Path(elem ...string) string
- func (ce *WorkingDir) RunCommand(cmd *exec.Cmd) error
- func (ce *WorkingDir) WriteFile(name string, data []byte) (string, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrLint is returned when the 'migrate lint' finds a diagnostic that is configured to // be reported as an error, such as destructive changes by default. ErrLint = errors.New("lint error") // Deprecated: Use ErrLint instead. LintErr = ErrLint )
var ErrRequireLogin = errors.New("command requires 'atlas login'")
ErrRequireLogin is returned when a command requires the user to be logged in. It exists here to be shared between the different packages that require login.
Functions ¶
Types ¶
type AppliedFile ¶
type AppliedFile struct { File Start time.Time End time.Time Skipped int // Amount of skipped SQL statements in a partially applied file. Applied []string // SQL statements applied with success Checks []*FileChecks // Assertion checks Error *struct { Stmt string // SQL statement that failed. Text string // Error returned by the database. } }
AppliedFile is part of a MigrateApply containing information about an applied file in a migration attempt.
type Changes ¶
type Changes struct { Applied []string `json:"Applied,omitempty"` // SQL changes applied with success Pending []string `json:"Pending,omitempty"` // SQL changes that were not applied Error *StmtError `json:"Error,omitempty"` // Error that occurred during applying }
Changes represents a list of changes that are pending or applied.
type Check ¶ added in v0.5.5
type Check struct { Stmt string `json:"Stmt,omitempty"` // Assertion statement. Error *string `json:"Error,omitempty"` // Assertion error, if any. }
Check represents an assertion and its status.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a client for the Atlas CLI.
func (*Client) Login ¶ added in v0.2.0
func (c *Client) Login(ctx context.Context, params *LoginParams) error
Login runs the 'login' command.
func (*Client) MigrateApply ¶ added in v0.2.0
func (c *Client) MigrateApply(ctx context.Context, params *MigrateApplyParams) (*MigrateApply, error)
MigrateApply runs the 'migrate apply' command.
func (*Client) MigrateApplySlice ¶ added in v0.4.0
func (c *Client) MigrateApplySlice(ctx context.Context, params *MigrateApplyParams) ([]*MigrateApply, error)
MigrateApplySlice runs the 'migrate apply' command for multiple targets.
func (*Client) MigrateDown ¶ added in v0.5.3
func (c *Client) MigrateDown(ctx context.Context, params *MigrateDownParams) (*MigrateDown, error)
MigrateDown runs the 'migrate down' command.
func (*Client) MigrateLint ¶ added in v0.2.0
func (c *Client) MigrateLint(ctx context.Context, params *MigrateLintParams) (*SummaryReport, error)
MigrateLint runs the 'migrate lint' command.
func (*Client) MigrateLintError ¶ added in v0.2.0
func (c *Client) MigrateLintError(ctx context.Context, params *MigrateLintParams) error
MigrateLintError runs the 'migrate lint' command, the output is written to params.Writer and reports if an error occurred. If the error is a setup error, a Error is returned. If the error is a lint error, LintErr is returned.
func (*Client) MigratePush ¶ added in v0.2.0
MigratePush runs the 'migrate push' command.
func (*Client) MigrateStatus ¶ added in v0.2.0
func (c *Client) MigrateStatus(ctx context.Context, params *MigrateStatusParams) (*MigrateStatus, error)
MigrateStatus runs the 'migrate status' command.
func (*Client) MigrateTest ¶ added in v0.5.6
MigrateTest runs the 'migrate test' command.
func (*Client) SchemaApply ¶
func (c *Client) SchemaApply(ctx context.Context, params *SchemaApplyParams) (*SchemaApply, error)
SchemaApply runs the 'schema apply' command.
func (*Client) SchemaApplySlice ¶ added in v0.4.0
func (c *Client) SchemaApplySlice(ctx context.Context, params *SchemaApplyParams) ([]*SchemaApply, error)
SchemaApplySlice runs the 'schema apply' command for multiple targets.
func (*Client) SchemaClean ¶ added in v0.6.0
func (c *Client) SchemaClean(ctx context.Context, params *SchemaCleanParams) (*SchemaClean, error)
SchemaClean runs the `schema clean` command.
func (*Client) SchemaInspect ¶
SchemaInspect runs the 'schema inspect' command.
func (*Client) SchemaPlan ¶ added in v0.6.0
func (c *Client) SchemaPlan(ctx context.Context, params *SchemaPlanParams) (*SchemaPlan, error)
SchemaPlan runs the `schema plan` command.
func (*Client) SchemaPlanApprove ¶ added in v0.6.0
func (c *Client) SchemaPlanApprove(ctx context.Context, params *SchemaPlanApproveParams) (*SchemaPlanApprove, error)
SchemaPlanApprove runs the `schema plan approve` command.
func (*Client) SchemaPlanLint ¶ added in v0.6.0
func (c *Client) SchemaPlanLint(ctx context.Context, params *SchemaPlanLintParams) (*SchemaPlan, error)
SchemaPlanLint runs the `schema plan lint` command.
func (*Client) SchemaPlanList ¶ added in v0.6.0
func (c *Client) SchemaPlanList(ctx context.Context, params *SchemaPlanListParams) ([]SchemaPlanFile, error)
SchemaPlanList runs the `schema plan list` command.
func (*Client) SchemaPlanPull ¶ added in v0.6.0
SchemaPlanPush runs the `schema plan pull` command.
func (*Client) SchemaPlanPush ¶ added in v0.6.0
SchemaPlanPush runs the `schema plan push` command.
func (*Client) SchemaPlanValidate ¶ added in v0.6.0
func (c *Client) SchemaPlanValidate(ctx context.Context, params *SchemaPlanValidateParams) error
SchemaPlanValidate runs the `schema plan validate` command.
func (*Client) SchemaPush ¶ added in v0.6.0
func (c *Client) SchemaPush(ctx context.Context, params *SchemaPushParams) (*SchemaPush, error)
SchemaPush runs the 'schema push' command.
func (*Client) SchemaTest ¶ added in v0.5.6
SchemaTest runs the 'schema test' command.
func (*Client) SetEnv ¶ added in v0.5.8
SetEnv allows we override the environment variables for the atlas-cli. To append new environment variables to environment from OS, use NewOSEnviron() then add new variables.
func (*Client) WithWorkDir ¶ added in v0.2.2
WithWorkDir creates a new client with the given working directory. It is useful to run multiple commands in the multiple directories.
Example:
client := atlasexec.NewClient("", "atlas") err := client.WithWorkDir("dir1", func(c *atlasexec.Client) error { _, err := c.MigrateApply(ctx, &atlasexec.MigrateApplyParams{ }) return err })
type DeployRunContext ¶ added in v0.2.0
type DeployRunContext struct { TriggerType TriggerType `json:"triggerType,omitempty"` TriggerVersion string `json:"triggerVersion,omitempty"` }
DeployRunContext is an input type for describing the context in which `migrate-apply` and `migrate down` were used. For example, a GitHub Action with version v1.2.3
type Env ¶
type Env struct { Driver string `json:"Driver,omitempty"` // Driver name. URL *sqlclient.URL `json:"URL,omitempty"` // URL to dev database. Dir string `json:"Dir,omitempty"` // Path to migration directory. }
Env holds the environment information.
type Environ ¶ added in v0.5.8
Environ is a map of environment variables.
func NewOSEnviron ¶ added in v0.5.8
func NewOSEnviron() Environ
NewOSEnviron returns the current environment variables from the OS.
type Error ¶ added in v0.5.4
type Error struct { Stdout string // Stdout of the command. Stderr string // Stderr of the command. // contains filtered or unexported fields }
Error is an error returned by the atlasexec package, when it executes the atlas-cli command.
type File ¶
type File struct { Name string `json:"Name,omitempty"` Version string `json:"Version,omitempty"` Description string `json:"Description,omitempty"` }
File wraps migrate.File to implement json.Marshaler.
type FileChecks ¶ added in v0.5.5
type FileChecks struct { Name string `json:"Name,omitempty"` // File/group name. Stmts []*Check `json:"Stmts,omitempty"` // Checks statements executed. Error *StmtError `json:"Error,omitempty"` // Assertion error. Start time.Time `json:"Start,omitempty"` // Start assertion time. End time.Time `json:"End,omitempty"` // End assertion time. }
FileChecks represents a set of checks to run before applying a file.
type FileReport ¶
type FileReport struct { Name string `json:"Name,omitempty"` // Name of the file. Text string `json:"Text,omitempty"` // Contents of the file. Reports []sqlcheck.Report `json:"Reports,omitempty"` // List of reports. Error string `json:"Error,omitempty"` // File specific error. }
FileReport contains a summary of the analysis of a single file.
type InvalidParamsError ¶ added in v0.6.0
type InvalidParamsError struct {
// contains filtered or unexported fields
}
InvalidParamsError is an error type for invalid parameters.
func (*InvalidParamsError) Error ¶ added in v0.6.0
func (e *InvalidParamsError) Error() string
Error returns the error message.
type LoginParams ¶ added in v0.2.0
type LoginParams struct {
Token string
}
LoginParams are the parameters for the `login` command.
type MigrateApply ¶ added in v0.2.0
type MigrateApply struct { Env Pending []File `json:"Pending,omitempty"` // Pending migration files Applied []*AppliedFile `json:"Applied,omitempty"` // Applied files Current string `json:"Current,omitempty"` // Current migration version Target string `json:"Target,omitempty"` // Target migration version Start time.Time End time.Time // Error is set even then, if it was not caused by a statement in a migration file, // but by Atlas, e.g. when committing or rolling back a transaction. Error string `json:"Error,omitempty"` }
MigrateApply contains a summary of a migration applying attempt on a database.
func (*MigrateApply) Summary ¶ added in v0.5.5
func (a *MigrateApply) Summary(ident string) string
Summary of the migration attempt.
type MigrateApplyError ¶ added in v0.3.0
type MigrateApplyError struct { Result []*MigrateApply Stderr string }
MigrateApplyError is returned when an error occurred during a migration applying attempt.
func (*MigrateApplyError) Error ¶ added in v0.3.0
func (e *MigrateApplyError) Error() string
Error implements the error interface.
type MigrateApplyParams ¶ added in v0.2.0
type MigrateApplyParams struct { ConfigURL string Env string Vars VarArgs Context *DeployRunContext DirURL string URL string RevisionsSchema string BaselineVersion string TxMode string ExecOrder MigrateExecOrder Amount uint64 AllowDirty bool DryRun bool }
MigrateApplyParams are the parameters for the `migrate apply` command.
type MigrateDown ¶ added in v0.5.3
type MigrateDown struct { Planned []File `json:"Planned,omitempty"` // Planned migration files Reverted []*RevertedFile `json:"Reverted,omitempty"` // Reverted files Current string `json:"Current,omitempty"` // Current migration version Target string `json:"Target,omitempty"` // Target migration version Total int `json:"Total,omitempty"` // Total number of migrations to revert Start time.Time End time.Time // URL and Status are set only when the migration is planned or executed in the cloud. URL string `json:"URL,omitempty"` Status string `json:"Status,omitempty"` // Error is set even then, if it was not caused by a statement in a migration file, // but by Atlas, e.g. when committing or rolling back a transaction. Error string `json:"Error,omitempty"` }
MigrateDown contains a summary of a migration down attempt on a database.
type MigrateDownParams ¶ added in v0.5.3
type MigrateDownParams struct { ConfigURL string Env string Vars VarArgs Context *DeployRunContext DevURL string DirURL string URL string RevisionsSchema string Amount uint64 ToVersion string ToTag string }
MigrateDownParams are the parameters for the `migrate down` command.
type MigrateExecOrder ¶ added in v0.2.1
type MigrateExecOrder string
MigrateExecOrder define how Atlas computes and executes pending migration files to the database. See: https://atlasgo.io/versioned/apply#execution-order
const ( ExecOrderLinear MigrateExecOrder = "linear" // Default ExecOrderLinearSkip MigrateExecOrder = "linear-skip" ExecOrderNonLinear MigrateExecOrder = "non-linear" )
ExecutionOrder values.
type MigrateLintParams ¶ added in v0.2.0
type MigrateLintParams struct { ConfigURL string Env string Vars VarArgs Context *RunContext Format string DevURL string DirURL string Latest uint64 Writer io.Writer Base string Web bool }
MigrateLintParams are the parameters for the `migrate lint` command.
func (*MigrateLintParams) AsArgs ¶ added in v0.5.8
func (p *MigrateLintParams) AsArgs() ([]string, error)
AsArgs returns the parameters as arguments.
type MigratePushParams ¶ added in v0.2.0
type MigratePushParams struct { ConfigURL string Env string Vars VarArgs Context *RunContext DevURL string Name string Tag string DirURL string DirFormat string LockTimeout string }
MigratePushParams are the parameters for the `migrate push` command.
type MigrateStatus ¶ added in v0.2.0
type MigrateStatus struct { Available []File `json:"Available,omitempty"` // Available migration files Pending []File `json:"Pending,omitempty"` // Pending migration files Applied []*Revision `json:"Applied,omitempty"` // Applied migration files Current string `json:"Current,omitempty"` // Current migration version Next string `json:"Next,omitempty"` // Next migration version Count int `json:"Count,omitempty"` // Count of applied statements of the last revision Total int `json:"Total,omitempty"` // Total statements of the last migration Status string `json:"Status,omitempty"` // Status of migration (OK, PENDING) Error string `json:"Error,omitempty"` // Last Error that occurred SQL string `json:"SQL,omitempty"` // SQL that caused the last Error }
MigrateStatus contains a summary of the migration status of a database.
func (MigrateStatus) Amount ¶ added in v0.2.0
func (r MigrateStatus) Amount(version string) (amount uint64, ok bool)
Amount returns the number of migrations need to apply for the given version.
The second return value is true if the version is found and the database is up-to-date.
If the version is not found, it returns 0 and the second return value is false.
func (MigrateStatus) LatestVersion ¶ added in v0.2.0
func (r MigrateStatus) LatestVersion() string
LatestVersion returns the latest version of the migration directory.
type MigrateStatusParams ¶ added in v0.2.0
type MigrateStatusParams struct { ConfigURL string Env string Vars VarArgs DirURL string URL string RevisionsSchema string }
MigrateStatusParams are the parameters for the `migrate status` command.
type MigrateTestParams ¶ added in v0.5.6
type MigrateTestParams struct { ConfigURL string Env string Vars VarArgs Context *RunContext DevURL string DirURL string DirFormat string Run string RevisionsSchema string }
MigrateTestParams are the parameters for the `migrate test` command.
type Option ¶ added in v0.2.0
type Option func(ce *WorkingDir) error
Option is a function that modifies a ContextExecer.
func WithAtlasHCL ¶ added in v0.2.0
WithAtlasHCL accept a function to create the atlas.hcl file.
func WithAtlasHCLPath ¶ added in v0.2.0
WithAtlasHCLPath creates the atlas.hcl file by copying the file at the given path.
func WithAtlasHCLString ¶ added in v0.2.0
WithAtlasHCLString creates the atlas.hcl file with the given string.
func WithMigrations ¶ added in v0.2.0
WithMigrations copies all files from dir to the migrations directory. If dir is nil, no files are copied.
type RevertedFile ¶ added in v0.5.3
type RevertedFile struct { File Start time.Time End time.Time Skipped int // Amount of skipped SQL statements in a partially applied file. Applied []string // SQL statements applied with success Scope string // Scope of the revert. e.g., statement, versions, etc. Error *struct { Stmt string // SQL statement that failed. Text string // Error returned by the database. } }
RevertedFile is part of a MigrateDown containing information about a reverted file in a downgrade attempt.
type Revision ¶
type Revision struct { Version string `json:"Version"` // Version of the migration. Description string `json:"Description"` // Description of this migration. Type string `json:"Type"` // Type of the migration. Applied int `json:"Applied"` // Applied amount of statements in the migration. Total int `json:"Total"` // Total amount of statements in the migration. ExecutedAt time.Time `json:"ExecutedAt"` // ExecutedAt is the starting point of execution. ExecutionTime time.Duration `json:"ExecutionTime"` // ExecutionTime of the migration. Error string `json:"Error,omitempty"` // Error of the migration, if any occurred. ErrorStmt string `json:"ErrorStmt,omitempty"` // ErrorStmt is the statement that raised Error. OperatorVersion string `json:"OperatorVersion"` // OperatorVersion that executed this migration. }
A Revision denotes an applied migration in a deployment. Used to track migration executions state of a database.
type RunContext ¶ added in v0.2.0
type RunContext struct { Repo string `json:"repo,omitempty"` Path string `json:"path,omitempty"` Branch string `json:"branch,omitempty"` Commit string `json:"commit,omitempty"` URL string `json:"url,omitempty"` Username string `json:"username,omitempty"` // The username that triggered the event that initiated the command. UserID string `json:"userID,omitempty"` // The user ID that triggered the event that initiated the command. SCMType SCMType `json:"scmType,omitempty"` // Source control management system type. }
RunContext is an input type for describing the context of where the command is triggered from. For example, a GitHub Action on the master branch.
type SCMType ¶ added in v0.6.0
type SCMType string // Only GITHUB is supported for now.
SCMType is a type for the "scm_type" enum field.
type SchemaApply ¶
type SchemaApply struct { Env // Changes holds the changes applied to the database. // Exists for backward compatibility with the old schema // apply structure as old SDK versions rely on it. Changes Changes `json:"Changes,omitempty"` Error string `json:"Error,omitempty"` // Any error that occurred during execution. Start time.Time `json:"Start,omitempty"` // When apply (including plan) started. End time.Time `json:"End,omitempty"` // When apply ended. Applied *AppliedFile `json:"Applied,omitempty"` // Applied migration file (pre-planned or computed). // Plan information might be partially filled. For example, if lint is done // during plan-stage, the linting report is available in the Plan field. If // the migration is pre-planned migration, the File.URL is set, etc. Plan *SchemaPlan `json:"Plan,omitempty"` }
SchemaApply represents the result of a 'schema apply' command.
type SchemaApplyError ¶ added in v0.3.0
type SchemaApplyError struct { Result []*SchemaApply Stderr string }
SchemaApplyError is returned when an error occurred during a schema applying attempt.
func (*SchemaApplyError) Error ¶ added in v0.3.0
func (e *SchemaApplyError) Error() string
Error implements the error interface.
type SchemaApplyParams ¶
type SchemaApplyParams struct { ConfigURL string Env string Vars VarArgs DevURL string URL string To string // TODO: change to []string TxMode string Exclude []string Schema []string DryRun bool // If true, --dry-run is set. AutoApprove bool // If true, --auto-approve is set. PlanURL string // URL of the plan in Atlas format (atlas://<repo>/plans/<id>). (optional) }
SchemaApplyParams are the parameters for the `schema apply` command.
type SchemaClean ¶ added in v0.6.1
type SchemaClean struct { Env Start time.Time `json:"Start,omitempty"` // When clean started. End time.Time `json:"End,omitempty"` // When clean ended. Applied *AppliedFile `json:"Applied,omitempty"` // Applied migration file. Error string `json:"Error,omitempty"` // Any error that occurred during execution. }
SchemaClean represents the result of a 'schema clean' command.
type SchemaCleanParams ¶ added in v0.6.0
type SchemaCleanParams struct { ConfigURL string Env string Vars VarArgs URL string // URL of the schema to clean. (required) DryRun bool // If true, --dry-run is set. AutoApprove bool // If true, --auto-approve is set. }
SchemaCleanParams are the parameters for the `schema clean` command.
type SchemaInspectParams ¶
type SchemaInspectParams struct { ConfigURL string Env string Vars VarArgs Format string DevURL string URL string Exclude []string Schema []string }
SchemaInspectParams are the parameters for the `schema inspect` command.
type SchemaPlan ¶ added in v0.6.0
type SchemaPlan struct { Env Env `json:"Env,omitempty"` // Environment info. Repo string `json:"Repo,omitempty"` // Repository name. Lint *SummaryReport `json:"Lint,omitempty"` // Lint report. File *SchemaPlanFile `json:"File,omitempty"` // Plan file. Error string `json:"Error,omitempty"` // Any error occurred during planning. }
SchemaPlan is the result of a 'schema plan' command.
type SchemaPlanApprove ¶ added in v0.6.0
type SchemaPlanApprove struct { URL string `json:"URL,omitempty"` // URL of the plan in Atlas format. Link string `json:"Link,omitempty"` // Link to the plan in the registry. Status string `json:"Status,omitempty"` // Status of the plan in the registry. }
SchemaPlanApprove is the result of a 'schema plan approve' command.
type SchemaPlanApproveParams ¶ added in v0.6.0
SchemaPlanApproveParams are the parameters for the `schema plan approve` command.
type SchemaPlanFile ¶ added in v0.6.0
type SchemaPlanFile struct { Name string `json:"Name,omitempty"` // Name of the plan. FromHash string `json:"FromHash,omitempty"` // Hash of the 'from' realm. FromDesc string `json:"FromDesc,omitempty"` // Optional description of the 'from' state. ToHash string `json:"ToHash,omitempty"` // Hash of the 'to' realm. ToDesc string `json:"ToDesc,omitempty"` // Optional description of the 'to' state. Migration string `json:"Migration,omitempty"` // Migration SQL. Stmts []*migrate.Stmt `json:"Stmts,omitempty"` // Statements in the migration (available only in the JSON output). // registry only fields. URL string `json:"URL,omitempty"` // URL of the plan in Atlas format. Link string `json:"Link,omitempty"` // Link to the plan in the registry. Status string `json:"Status,omitempty"` // Status of the plan in the registry. }
SchemaPlanFile is a JSON representation of a schema plan file.
type SchemaPlanLintParams ¶ added in v0.6.0
type SchemaPlanLintParams struct { ConfigURL string Env string Vars VarArgs Context *RunContext DevURL string Schema []string From, To []string Repo string File string }
SchemaPlanLintParams are the parameters for the `schema plan lint` command.
type SchemaPlanListParams ¶ added in v0.6.0
type SchemaPlanListParams struct { ConfigURL string Env string Vars VarArgs Context *RunContext DevURL string Schema []string From, To []string Repo string Pending bool // If true, only pending plans are listed. }
SchemaPlanListParams are the parameters for the `schema plan list` command.
type SchemaPlanParams ¶ added in v0.6.0
type SchemaPlanParams struct { ConfigURL string Env string Vars VarArgs Context *RunContext DevURL string Schema []string From, To []string Repo string Name string Directives []string // The below are mutually exclusive and can be replaced // with the 'schema plan' sub-commands instead. DryRun bool // If false, --auto-approve is set. Pending bool Push, Save bool }
SchemaPlanParams are the parameters for the `schema plan` command.
type SchemaPlanPullParams ¶ added in v0.6.0
type SchemaPlanPullParams struct { ConfigURL string Env string Vars VarArgs URL string // URL to the plan in Atlas format. (required) }
SchemaPlanPullParams are the parameters for the `schema plan pull` command.
type SchemaPlanPushParams ¶ added in v0.6.0
type SchemaPlanPushParams struct { ConfigURL string Env string Vars VarArgs Context *RunContext DevURL string Schema []string From, To []string Repo string Pending bool // Push plan in pending state. File string // File to push. (optional) }
SchemaPlanPushParams are the parameters for the `schema plan push` command.
type SchemaPlanValidateParams ¶ added in v0.6.0
type SchemaPlanValidateParams struct { ConfigURL string Env string Vars VarArgs Context *RunContext DevURL string Schema []string From, To []string Repo string Name string File string }
SchemaPlanValidateParams are the parameters for the `schema plan validate` command.
type SchemaPush ¶ added in v0.6.0
SchemaPush represents the result of a 'schema push' command.
type SchemaPushParams ¶ added in v0.6.0
type SchemaPushParams struct { ConfigURL string Env string Vars VarArgs Context *RunContext DevURL string URL []string // Desired schema URL(s) to push Schema []string // If set, only the specified schemas are pushed. Name string // Name of the schema (repo) to push to. Tag string // Tag to push the schema with Version string // Version of the schema to push. Defaults to the current timestamp. Description string // Description of the schema changes. }
SchemaPushParams are the parameters for the `schema push` command.
type SchemaTestParams ¶ added in v0.5.6
type SchemaTestParams struct { ConfigURL string Env string Vars VarArgs DevURL string URL string Run string }
SchemaTestParams are the parameters for the `schema test` command.
type StepReport ¶ added in v0.2.0
type StepReport struct { Name string `json:"Name,omitempty"` // Step name. Text string `json:"Text,omitempty"` // Step description. Error string `json:"Error,omitempty"` // Error that cause the execution to halt. Result *FileReport `json:"Result,omitempty"` // Result of the step. For example, a diagnostic. }
StepReport contains a summary of the analysis of a single step.
type StmtError ¶
type StmtError struct { Stmt string `json:"Stmt,omitempty"` // SQL statement that failed. Text string `json:"Text,omitempty"` // Error message as returned by the database. }
StmtError groups a statement with its execution error.
type SummaryReport ¶
type SummaryReport struct { URL string `json:"URL,omitempty"` // URL of the report, if exists. // Env holds the environment information. Env struct { Driver string `json:"Driver,omitempty"` // Driver name. URL *sqlclient.URL `json:"URL,omitempty"` // URL to dev database. Dir string `json:"Dir,omitempty"` // Path to migration directory. } // Schema versions found by the runner. Schema struct { Current string `json:"Current,omitempty"` // Current schema. Desired string `json:"Desired,omitempty"` // Desired schema. } // Steps of the analysis. Added in verbose mode. Steps []*StepReport `json:"Steps,omitempty"` // Files reports. Non-empty in case there are findings. Files []*FileReport `json:"Files,omitempty"` }
A SummaryReport contains a summary of the analysis of all files. It is used as an input to templates to report the CI results.
func (*SummaryReport) DiagnosticsCount ¶ added in v0.2.0
func (r *SummaryReport) DiagnosticsCount() int
DiagnosticsCount returns the total number of diagnostics in the report.
func (*SummaryReport) Errors ¶ added in v0.6.5
func (r *SummaryReport) Errors() []error
Errors returns the errors in the summary report, if exists.
type TriggerType ¶ added in v0.2.0
type TriggerType string
TriggerType defines the type for the "trigger_type" enum field.
const ( TriggerTypeCLI TriggerType = "CLI" TriggerTypeKubernetes TriggerType = "KUBERNETES" TriggerTypeTerraform TriggerType = "TERRAFORM" TriggerTypeGithubAction TriggerType = "GITHUB_ACTION" TriggerTypeCircleCIOrb TriggerType = "CIRCLECI_ORB" TriggerTypeGitlab TriggerType = "GITLAB" TriggerTypeBitbucket TriggerType = "BITBUCKET" )
TriggerType values.
type VarArgs ¶ added in v0.5.8
type VarArgs interface { // AsArgs returns the variables as arguments. AsArgs() []string }
VarArgs is a map of variables for the command.
type Vars2 ¶ added in v0.5.8
Vars2 is a map of variables for the command. It supports multiple values for the same key (list).
type Version ¶ added in v0.2.0
type Version struct { Version string `json:"Version"` SHA string `json:"SHA,omitempty"` Canary bool `json:"Canary,omitempty"` }
Version contains the result of an 'atlas version' run.
type WhoAmI ¶ added in v0.6.4
type WhoAmI struct {
Org string `json:"Org,omitempty"`
}
WhoAmI contains the result of an 'atlas whoami' run.
type WorkingDir ¶ added in v0.2.0
type WorkingDir struct {
// contains filtered or unexported fields
}
WorkingDir is a temporary directory with a copy of the files from dir. It can be used to run commands in the temporary directory. The temporary directory is removed when Close is called.
func NewWorkingDir ¶ added in v0.2.0
func NewWorkingDir(opts ...Option) (*WorkingDir, error)
NewWorkingDir creates a new ContextExecer. It creates a temporary directory and copies all files from dir to the temporary directory. The atlasHCL function is called with a writer to create the atlas.hcl file. If atlasHCL is nil, no atlas.hcl file is created.
func (*WorkingDir) Close ¶ added in v0.2.0
func (ce *WorkingDir) Close() error
Close removes the temporary directory.
func (*WorkingDir) CopyFS ¶ added in v0.2.0
func (cs *WorkingDir) CopyFS(name string, src fs.FS) error
CopyFS copies all files from source FileSystem to the destination directory in the temporary directory. If source is nil, an error is returned.
func (*WorkingDir) CreateFile ¶ added in v0.2.0
CreateFile creates the file in the temporary directory.
func (*WorkingDir) DirFS ¶ added in v0.2.0
func (ce *WorkingDir) DirFS() fs.FS
DirFS returns a fs.FS for the temporary directory.
func (*WorkingDir) Path ¶ added in v0.2.0
func (ce *WorkingDir) Path(elem ...string) string
Dir returns the path to the temporary directory.
func (*WorkingDir) RunCommand ¶ added in v0.2.0
func (ce *WorkingDir) RunCommand(cmd *exec.Cmd) error
RunCommand runs the command in the temporary directory.