We compile again, but stuff is broken including tests
--- a/docker/build.go Mon Dec 31 23:09:04 2018 -0600
+++ b/docker/build.go Thu Mar 28 04:40:01 2019 -0500
@@ -44,35 +44,15 @@
func (b *Build) Execute(name string, logger *gomol.LogAdapter, env *environment.Environment, rt *runtime.Runtime) error {
fullEnv := env.Copy().Merge(rt.Environment)
- files, err := fullEnv.MapSlice(b.Files)
// create out build directory
buildDir := filepath.Join(rt.State.Directory, name)
- err = os.MkdirAll(buildDir, 0700)
+ err := os.MkdirAll(buildDir, 0700) dockerfile := fullEnv.Map(b.Dockerfile)
- // Export the files from the workspace
- Files: append(files, dockerfile),
- err = fileExport.Valid()
- err = fileExport.Execute(name, logger, fullEnv, rt)
tags, err := fullEnv.MapSlice(b.Tags)
--- a/docker/docker.go Mon Dec 31 23:09:04 2018 -0600
+++ b/docker/docker.go Thu Mar 28 04:40:01 2019 -0500
@@ -27,7 +27,6 @@
// Tasks is a map of all docker tasks.
Tasks = map[string]tasks.Task{
--- a/docker/environment.go Mon Dec 31 23:09:04 2018 -0600
+++ b/docker/environment.go Thu Mar 28 04:40:01 2019 -0500
@@ -63,7 +63,7 @@
// structure of the file (for ease of error messages, so we
// get the file a/b/c/env instead of env).
--- a/docker/export.go Mon Dec 31 23:09:04 2018 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,164 +0,0 @@
-// Copyright 2016-2018 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"
- "bitbucket.org/rw_grim/convey/environment"
- "bitbucket.org/rw_grim/convey/path"
- "bitbucket.org/rw_grim/convey/runtime"
- "bitbucket.org/rw_grim/convey/tasks"
- "bitbucket.org/rw_grim/convey/yaml"
-// Export represents an export task which exports files from the workspace to
- Files yaml.StringOrSlice `yaml:"files"`
-func checkFilePattern(file string) error {
- if strings.ContainsRune(file, '*') && strings.ContainsRune(file, ':') {
- return errWildcardWithDestination
-func (e *Export) file(name, workSpace, src, dest string, rt *runtime.Runtime) error {
- dir := filepath.Dir(dest)
- if err := os.MkdirAll(dir, 0700); err != nil {
- // build out the source path
- source := workSpace + ":" + filepath.Join("/workspace", src)
- return Docker(name, cmdv, rt)
-func (e *Export) glob(name, workSpace, mountPoint, pattern string, rt *runtime.Runtime) error {
- mountPoint + ":/workspace",
- "convey/workspace-tools:latest",
- out, _, err := DockerOutput(fmt.Sprintf("%s-zglob", name), cmdv, rt)
- for _, match := range strings.Split(out, "\n") {
- dest = path.DestFromSrc(match)
- err = e.file(name, workSpace, match, dest, rt)
-// Execute runs the export task.
-func (e *Export) Execute(name string, logger *gomol.LogAdapter, env *environment.Environment, rt *runtime.Runtime) error {
- fullEnv := env.Copy().Merge(rt.Environment)
- files, err := fullEnv.MapSlice(e.Files)
- for _, file := range files {
- if err := checkFilePattern(file); err != nil {
- dockerWorkspace := rt.State.Workspace.(*Workspace)
- if strings.ContainsRune(file, '*') {
- mountPoint := fullEnv.Map(dockerWorkspace.mountPoint)
- if err := e.glob(name, rt.State.Workspace.Name(), mountPoint, file, rt); err != nil {
- src, dest := path.ParseFilePath("", file)
- // make sure the destination is in our build context
- realDest, err := path.TraversesNonExistent(rt.State.CfgPath, dest)
- if err := e.file(name, rt.State.Workspace.Name(), src, realDest, rt); err != nil {
-// New creates a new Export task.
-func (e *Export) New() tasks.Task {
-// Valid validates the export task.
-func (e *Export) Valid() error {
- for _, file := range e.Files {
- if err := checkFilePattern(file); err != nil {
--- a/docker/import.go Mon Dec 31 23:09:04 2018 -0600
+++ b/docker/import.go Thu Mar 28 04:40:01 2019 -0500
@@ -62,7 +62,7 @@
- rt.State.Workspace.Name() + ":/workspace/" + dest,
+ rt.State.Workspace.Path() + ":/workspace/" + dest, if err := Docker(name, cmdv, rt); err != nil {
--- a/docker/run.go Mon Dec 31 23:09:04 2018 -0600
+++ b/docker/run.go Thu Mar 28 04:40:01 2019 -0500
@@ -264,10 +264,6 @@
cmd.Append("--network-alias", hostname)
- // figure out the workspace variables
- dockerWorkspace := rt.State.Workspace.(*Workspace)
- workspacePath := fullEnv.Map(dockerWorkspace.mountPoint)
// assign a default workspace location
@@ -277,7 +273,7 @@
workspaceMount := fullEnv.Map(workSpace)
- "-v", workspacePath+":"+workspaceMount,
+ "-v", rt.State.Workspace.Path()+":"+workspaceMount, "-e", "CONVEY_WORKSPACE="+workspaceMount,
--- a/kubectl/command.go Mon Dec 31 23:09:04 2018 -0600
+++ b/kubectl/command.go Thu Mar 28 04:40:01 2019 -0500
@@ -24,9 +24,9 @@
"github.com/aphistic/gomol"
"bitbucket.org/rw_grim/convey/command"
- "bitbucket.org/rw_grim/convey/docker"
"bitbucket.org/rw_grim/convey/environment"
"bitbucket.org/rw_grim/convey/runtime"
+ "bitbucket.org/rw_grim/convey/tasks" "bitbucket.org/rw_grim/convey/yaml"
@@ -49,7 +49,7 @@
// now create an export task to get our files out of the workspace
- export := &docker.Export{
+ export := &tasks.Export{ @@ -159,7 +159,7 @@
// create our scratch directory
- path, err := rt.State.TaskDirectory(name)
+ path, err := rt.State.Workspace.TaskDirectory(name) --- a/loaders/codebuild/loader.go Mon Dec 31 23:09:04 2018 -0600
+++ b/loaders/codebuild/loader.go Thu Mar 28 04:40:01 2019 -0500
@@ -163,7 +163,7 @@
- export := &docker.Export{
+ export := &tasks.Export{ Files: cb.Artifacts.Files,
--- a/plans/plans.go Mon Dec 31 23:09:04 2018 -0600
+++ b/plans/plans.go Thu Mar 28 04:40:01 2019 -0500
@@ -81,24 +81,6 @@
- // create the workspace
- if lErr := logger.Info("creating workspace..."); lErr != nil {
- fmt.Printf("error reporting info: %s\n", lErr)
- ws, err := docker.NewWorkspace(rt)
- if lErr := logger.Fatal("failed to create workspace"); lErr != nil {
- fmt.Printf("error reporting fatal: %s\n", lErr)
- rt.State.Workspace = ws
- if lErr := logger.Infof("created workspace %s", rt.State.Workspace.Name()); lErr != nil {
- fmt.Printf("error reporting info: %s\n", lErr)
--- a/state/state.go Mon Dec 31 23:09:04 2018 -0600
+++ b/state/state.go Thu Mar 28 04:40:01 2019 -0500
@@ -19,16 +19,13 @@
"github.com/aphistic/gomol"
"bitbucket.org/rw_grim/convey/logging"
"bitbucket.org/rw_grim/convey/network"
- "bitbucket.org/rw_grim/convey/workspace"
// State holds all of the runtime data during a run.
@@ -38,7 +35,7 @@
- Workspace workspace.Workspace
@@ -53,13 +50,18 @@
// New creates a new state.
- dir, err := createDirectory()
+ ws, err := newWorkspace(pwd)
logger: logging.NewAdapter("state"),
@@ -69,51 +71,8 @@
func (st *State) Destroy() {
// finally remove the workspace if requested
- if err := os.RemoveAll(st.Directory); err != nil {
- if lErr := st.logger.Warningf("error removing %s: %s\n", st.Directory, err.Error()); lErr != nil {
- fmt.Printf("error reporting warning: %s\n", lErr)
- // try to remove the .convey directory. This will only succeed when
- // our state is the only one and that's intentional.
- dir := filepath.Dir(st.Directory)
- if err := os.Remove(dir); err != nil {
- if lErr := st.logger.Warningf("error removing directory: %s : %s", dir, err); lErr != nil {
- fmt.Printf("error reporting warning: %s\n", lErr)
-// createDirectory creates the state directory for this run.
-func createDirectory() (string, error) {
- parent := filepath.Join(pwd, ".convey")
- err = os.MkdirAll(parent, 0700)
- dir, err := ioutil.TempDir(parent, "")
-// TaskDirectory will create a directory in the state directory for the named task.
-func (st *State) TaskDirectory(name string) (string, error) {
- dir := filepath.Join(st.Directory, name)
- err := os.MkdirAll(dir, 0700)
// Valid validates whether the state is correct or not.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/state/workspace.go Thu Mar 28 04:40:01 2019 -0500
@@ -0,0 +1,72 @@
+// Copyright 2016-2018 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/>. +func newWorkspace(root string) (*Workspace, error) { + parent := filepath.Join(root, ".convey") + err := os.MkdirAll(parent, 0700) + path, err := ioutil.TempDir(parent, "") + workspace := &Workspace{ +func (ws *Workspace) Destroy() { + if err := os.RemoveAll(ws.path); err != nil { + fmt.Printf("error removing worksace: %s\n", err) + // try to remove the .convey directory. This will only succeed when + // our state is the only one and that's intentional. + dir := filepath.Dir(ws.path) + if err := os.Remove(dir); err != nil { + fmt.Printf("error removing .convey: %s\n", err) +func (ws *Workspace) TaskDirectory(name string) (string, error) { + dir := filepath.Join(ws.path, name) + err := os.MkdirAll(dir, 0700) +func (ws *Workspace) Path() string { --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tasks/errors.go Thu Mar 28 04:40:01 2019 -0500
@@ -0,0 +1,25 @@
+// Copyright 2016-2019 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/>. + errNoFiles = errors.New("no files specified") --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tasks/export.go Thu Mar 28 04:40:01 2019 -0500
@@ -0,0 +1,70 @@
+// Copyright 2016-2019 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" + "bitbucket.org/rw_grim/convey/environment" + "bitbucket.org/rw_grim/convey/runtime" + Files []string `yaml:"files"` + Path string `yaml:"path"` +// New creates a new Export task. +func (e *Export) New() Task { +// Valid validates the export task. +func (e *Export) Valid() error { +func (e *Export) copyFile(filename string) error { + return errors.New("Not implemented") +func (e *Export) Execute(name string, logger *gomol.LogAdapter, env *environment.Environment, rt *runtime.Runtime) error { + for _, patterns := range e.Files { + matches, err := filepath.Glob(filepath.Join(rt.State.CfgPath, patterns)) + for _, match := range matches { + err = e.copyFile(match) --- a/tasks/tasks.go Mon Dec 31 23:09:04 2018 -0600
+++ b/tasks/tasks.go Thu Mar 28 04:40:01 2019 -0500
@@ -28,6 +28,7 @@
// Tasks is the list of tasks defined in this package.
--- a/tests/breakout.yml Mon Dec 31 23:09:04 2018 -0600
+++ b/tests/breakout.yml Thu Mar 28 04:40:01 2019 -0500
@@ -15,14 +15,14 @@
--- a/tests/convey-clean-task.yml Mon Dec 31 23:09:04 2018 -0600
+++ b/tests/convey-clean-task.yml Thu Mar 28 04:40:01 2019 -0500
@@ -13,5 +13,5 @@
--- a/tests/tasks-types.yml Mon Dec 31 23:09:04 2018 -0600
+++ b/tests/tasks-types.yml Thu Mar 28 04:40:01 2019 -0500
@@ -51,11 +51,11 @@