Example #1
0
// newTenet returns a new tenet.Tenet built from a cfg.
func NewTenet(tenetCfg TenetConfig) (tenet.Tenet, error) {
	return tenet.New(&driver.Base{
		Name:          tenetCfg.Name,
		Driver:        tenetCfg.Driver,
		Registry:      tenetCfg.Registry,
		Tag:           tenetCfg.Tag,
		ConfigOptions: tenetCfg.Options,
	})
}
Example #2
0
// Get a list of instantiated tenets from a config object.
func Tenets(ctx *cli.Context, cfg *Config) ([]tenet.Tenet, error) {
	var ts []tenet.Tenet
	for _, tenetCfg := range cfg.AllTenets() {
		tenet, err := tenet.New(&driver.Base{
			Name:          tenetCfg.Name,
			Driver:        tenetCfg.Driver,
			Registry:      tenetCfg.Registry,
			ConfigOptions: tenetCfg.Options,
		})
		if err != nil {
			message := fmt.Sprintf("could not create tenet '%s': %s", tenetCfg.Name, err.Error())
			return nil, errors.Annotate(err, message)
		}
		ts = append(ts, tenet)
	}

	return ts, nil
}