Example #1
0
func (c *SyncToolsCommand) Run(ctx *cmd.Context) error {
	// Register writer for output on screen.
	loggo.RegisterWriter("synctools", sync.NewSyncLogWriter(ctx.Stdout, ctx.Stderr), loggo.INFO)
	defer loggo.RemoveWriter("synctools")
	// Prepare syncing.
	sctx := &sync.SyncContext{
		EnvName:      c.EnvName,
		AllVersions:  c.allVersions,
		DryRun:       c.dryRun,
		PublicBucket: c.publicBucket,
		Dev:          c.dev,
		Source:       c.source,
	}
	return syncTools(sctx)
}
Example #2
0
// ensureToolsAvailability verifies the tools are available. If no tools are
// found, it will automatically synchronize them.
func (c *BootstrapCommand) ensureToolsAvailability(env environs.Environ, ctx *cmd.Context) error {
	// Capture possible logging while syncing and write it on the screen.
	loggo.RegisterWriter("bootstrap", sync.NewSyncLogWriter(ctx.Stdout, ctx.Stderr), loggo.INFO)
	defer loggo.RemoveWriter("bootstrap")

	// Try to find bootstrap tools.
	_, err := environs.FindBootstrapTools(env, c.Constraints)
	if errors.IsNotFoundError(err) {
		// Not tools available, so synchronize.
		sctx := &sync.SyncContext{
			EnvName: c.EnvName,
			Source:  c.Source,
		}
		if err = syncTools(sctx); err != nil {
			return err
		}
		// Synchronization done, try again.
		_, err = environs.FindBootstrapTools(env, c.Constraints)
	} else if err != nil {
		return err
	}
	return err
}