Ejemplo n.º 1
0
// GetTaskConfig returns a new task for the action
func GetTaskConfig(name, action string, conf *config.JobConfig) (types.TaskConfig, error) {
	switch action {
	case "", "run":
		return types.NewTaskConfig(
			task.NewDefaultName(name, action),
			conf,
			deps(conf),
			newRunTask), nil
	case "remove", "rm":
		return types.NewTaskConfig(
			task.NewName(name, action),
			conf,
			task.NoDependencies,
			newRemoveTask), nil
	}
	if strings.HasPrefix(action, "capture") {
		variable, err := parseCapture(action)
		if err != nil {
			return nil, err
		}
		return types.NewTaskConfig(
			task.NewName(name, action),
			conf,
			deps(conf),
			newCaptureTask(variable)), nil
	}
	return nil, fmt.Errorf("invalid run action %q for task %q", action, name)
}
Ejemplo n.º 2
0
Archivo: env.go Proyecto: dnephin/dobi
// GetTaskConfig returns a new task for the action
func GetTaskConfig(name, action string, conf *config.EnvConfig) (types.TaskConfig, error) {
	switch action {
	case "", "set":
		return types.NewTaskConfig(
			task.NewDefaultName(name, "set"), conf, task.NoDependencies, newTask), nil
	case "rm":
		return types.NewTaskConfig(
			task.NewName(name, "rm"), conf, task.NoDependencies, newRemoveTask), nil
	default:
		return nil, fmt.Errorf("invalid env action %q for task %q", action, name)
	}
}
Ejemplo n.º 3
0
// GetTaskConfig returns a new TaskConfig for the action
func GetTaskConfig(name, act string, conf *config.AliasConfig) (types.TaskConfig, error) {
	switch act {
	case "", "run":
		return types.NewTaskConfig(
			task.NewDefaultName(name, "run"), conf, RunDeps(conf), NewTask), nil
	case "remove", "rm":
		return types.NewTaskConfig(
			task.NewName(name, "rm"), conf, RemoveDeps(conf), NewTask), nil
	default:
		return nil, fmt.Errorf("invalid alias action %q for task %q", act, name)
	}
}
Ejemplo n.º 4
0
// GetTaskConfig returns a new task for the action
func GetTaskConfig(name, action string, conf *config.MountConfig) (types.TaskConfig, error) {

	newTaskConfig := func(name task.Name, builder types.TaskBuilder) (types.TaskConfig, error) {
		return types.NewTaskConfig(name, conf, task.NoDependencies, builder), nil
	}
	switch action {
	case "", "create":
		return newTaskConfig(task.NewDefaultName(name, action), NewTask(runCreate))
	case "remove", "rm":
		return newTaskConfig(task.NewName(name, action), NewTask(remove))
	default:
		return nil, fmt.Errorf("invalid mount action %q for task %q", action, name)
	}
}
Ejemplo n.º 5
0
func getAction(name string, resname string, conf *config.ComposeConfig) (action, error) {
	switch name {
	case "", "up":
		return newAction(
			task.NewDefaultName(resname, "up"), RunUp, StopUp, deps(conf))
	case "remove", "rm", "down":
		return newAction(task.NewName(resname, "down"), RunDown, nil, noDeps)
	case "attach":
		return newAction(
			task.NewName(resname, "attach"), RunUpAttached, nil, deps(conf))
	default:
		return action{}, fmt.Errorf("invalid compose action %q for task %q", name, resname)
	}
}
Ejemplo n.º 6
0
// GetTaskConfig returns a new TaskConfig for the action
func GetTaskConfig(name, action string, conf *config.ImageConfig) (types.TaskConfig, error) {
	var taskName task.Name

	if action == "" {
		action = defaultAction(conf)
		taskName = task.NewDefaultName(name, action)
	} else {
		taskName = task.NewName(name, action)
	}
	imageAction, err := getAction(action, name)
	if err != nil {
		return nil, err
	}
	return types.NewTaskConfig(
		taskName,
		conf,
		deps(conf, imageAction.dependencies),
		NewTask(imageAction.run),
	), nil
}