* Copyright 2016-2017 Gary Kramlich <grim@reaperworld.com> * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. "github.com/aphistic/gomol" "github.com/mohae/deepcopy" "bitbucket.org/rw_grim/convey/state" "bitbucket.org/rw_grim/convey/tasks" "bitbucket.org/rw_grim/convey/yaml" Task string `yaml:"task"` Environment yaml.StringOrSlice `yaml:"environment"` Expand yaml.StringOrSlice `yaml:"expand"` ExpandDelimiter string `yaml:"expand_delimiter"` // A copy of the extended task. Must be public so that deepcopy // can serialize it properly in case an extended task is extended // itself (when private the innerTask is nil and causes a bad // data access exception). func (e *Extend) Execute(name string, logger *gomol.LogAdapter, env []string, st *state.State) error { // While extending, certain environment variables can be expanded into // lists. We store this meta information as a stack on the state, which // is passed into the inner task execute method (and so on). return e.InnerTask.Execute(name, logger, env, st.WrapWithExpandableEnv( func (e *Extend) New() tasks.Task { func (e *Extend) Valid() error { if e.ExpandDelimiter == "" { func (e *Extend) Dependencies() []string { func (e *Extend) Resolve(taskMap map[string]tasks.Task) error { task, ok := taskMap[e.Task] // Should never happen due to dependency order return fmt.Errorf("Extending undeclared task '%s'", e.Task) // Some tasks may set their own fields, e.g. when mapping things // to the correct runtime environment. In order to make sure that // the inner task doesn't cache something from another run, we // do a clone of the task here so we get our own copy to muck with. e.InnerTask = deepcopy.Copy(task).(tasks.Task)