Exemplo n.º 1
0
func (cc *ConvertCommand) ParseOptions(context *cli.Context) {
	cc.Verbose = context.Bool("verbose")
	cc.Logger = gull.NewLogger(cc.Verbose)
	cc.FileNameIsEnvironment = context.Bool("filenameisenvironment")
	cc.JsonEncode = context.Bool("jsonencode")

	cc.Source = context.String("source")
	if cc.Source == "" {
		fmt.Printf("No source was specified, but it is required. Run `gull convert -h` for more information.\n")
		os.Exit(1)
	}

	cc.Destination = context.String("destination")
	if cc.Destination == "" || cc.Destination == common.DefaultGullDirectory {
		if cc.Verbose {
			fmt.Printf("No destination was specified. Defaulting to [%s]\n", cc.Destination)
		}
	}
}
Exemplo n.º 2
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()
	}
}
Exemplo n.º 3
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()
	}
}