Exemple #1
0
func (dc *DestroyCommand) Destroy() {
	logger := gull.NewVerboseLogger()
	logger.Info("Destroying environment [%s] on etcd host [%s]", dc.Environment, dc.EtcdHostUrl)
	target := gull.NewEtcdMigrationTarget(dc.EtcdHostUrl, dc.Application, dc.Environment, false, logger)
	destroy := gull.NewDestroy(target)
	err := destroy.Execute()
	if err != nil {
		dc.Logger.Info("An error occurred while deleting the environment: [%+v]\n", err)
		os.Exit(1)
	}
}
Exemple #2
0
func (sc *StatusCommand) Status() {
	logger := gull.NewVerboseLogger()
	logger.Info("Checking migration status of environment [%s] on etcd host [%s]", sc.Environment, sc.EtcdHostUrl)
	target := gull.NewEtcdMigrationTarget(sc.EtcdHostUrl, sc.Application, sc.Environment, false, logger)
	status := gull.NewStatus(target)
	err := status.Check()
	if err != nil {
		sc.Logger.Info("An error occurred while checking status: [%+v]\n", err)
		os.Exit(1)
	}
}
Exemple #3
0
func (uc *UpCommand) Up() {
	// An 'Up' will walk through all migrations and apply 'default' to the target environment.
	// All migrations will then be walked again, applying any migrations containing the target environment.
	logger := gull.NewLogger(uc.Verbose)
	var target gull.MigrationTarget
	if uc.DryRun {
		target = gull.NewMockMigrationTarget(uc.Application, uc.Environment, logger)
	} else {
		target = gull.NewEtcdMigrationTarget(uc.EtcdHostUrl, uc.Application, uc.Environment, uc.Full, logger)
	}
	up := gull.NewUp(uc.SourceDirectory, target)
	err := up.Migrate()
	if err != nil {
		fmt.Printf("An error occurred while performing the migration: [%+v]\n", err)
		os.Exit(1)
	}
	if uc.DryRun {
		target.Debug()
	}
}
Exemple #4
0
func (dc *DownCommand) Down() {
	// A 'Down' will remove all the current configuration for an environment.
	// Then all migrations that were stored in etcd for that environment are applied, ignoring the latest migration.
	logger := gull.NewLogger(dc.Verbose)
	var target gull.MigrationTarget
	if dc.DryRun {
		target = gull.NewMockMigrationTarget(dc.Application, dc.Environment, logger)
	} else {
		target = gull.NewEtcdMigrationTarget(dc.EtcdHostUrl, dc.Application, dc.Environment, false, logger)
	}
	down := gull.NewDown(target)
	err := down.Migrate()
	if err != nil {
		fmt.Printf("An error occurred while performing the migration: [%+v]\n", err)
		os.Exit(1)
	}
	if dc.DryRun {
		target.Debug()
	}
}