func AppAssign(configStore *config.Store, app, env, pool string) error { // Don't allow deleting runtime hosts entries if app == "hosts" || app == "pools" { return fmt.Errorf("invalid app name: %s", app) } exists, err := configStore.PoolExists(env, pool) if err != nil { return err } if !exists { log.Warnf("WARN: Pool %s does not exist.", pool) } created, err := configStore.AssignApp(app, env, pool) if err != nil { return err } if created { log.Printf("Assigned %s in env %s to pool %s.\n", app, env, pool) } else { log.Printf("%s already assigned to pool %s in env %s.\n", app, pool, env) } return nil }
// Create a pool for an environment func PoolCreate(configStore *config.Store, env, pool string) error { exists, err := configStore.PoolExists(env, pool) if err != nil { return err } else if exists { return fmt.Errorf("pool '%s' exists", pool) } _, err = configStore.CreatePool(pool, env) if err != nil { return err } return nil }
func PoolDelete(configStore *config.Store, env, pool string) error { exists, err := configStore.PoolExists(env, pool) if err != nil { return err } else if !exists { return fmt.Errorf("pool '%s' does not exist", pool) } empty, err := configStore.DeletePool(pool, env) if err != nil { return err } if !empty { return fmt.Errorf("pool '%s' is not epmty", pool) } return nil }