예제 #1
0
파일: actions.go 프로젝트: dnephin/dobi
// 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)
}
예제 #2
0
파일: env.go 프로젝트: 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)
	}
}
예제 #3
0
파일: actions.go 프로젝트: dnephin/dobi
// 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)
	}
}
예제 #4
0
파일: actions.go 프로젝트: dnephin/dobi
// GetTaskConfig returns a new task for the action
func GetTaskConfig(name, action string, conf *config.ComposeConfig) (types.TaskConfig, error) {
	act, err := getAction(action, name, conf)
	if err != nil {
		return nil, err
	}
	return types.NewTaskConfig(act.name, conf, act.deps, NewTask(act.Run, act.Stop)), nil
}
예제 #5
0
파일: actions.go 프로젝트: dnephin/dobi
// 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)
	}
}
예제 #6
0
파일: actions.go 프로젝트: dnephin/dobi
// 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
}