grim/convey

Parents 3f70720d5621
Children 6e3f61dd9135
Fix the kubectl/* commands to actually use files from the workspace. Fixed #170
--- a/kubectl/command.go Thu Feb 15 17:23:51 2018 -0600
+++ b/kubectl/command.go Fri Feb 16 14:07:47 2018 -0600
@@ -18,9 +18,12 @@
package kubectl
import (
+ "path/filepath"
+
"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/state"
"bitbucket.org/rw_grim/convey/yaml"
@@ -65,14 +68,40 @@
cmd.Append("-l", selector)
}
+ // create our scratch directory
+ path, err := st.TaskDirectory(name)
+ if err != nil {
+ return err
+ }
+
+ // update the files we're going to run by joining them with our scratch directory
for _, file := range c.Files {
realFile, err := environment.Mapper(file, fullEnv)
if err != nil {
return err
}
- cmd.Append("-f", realFile)
+ cmd.Append("-f", filepath.Join(path, realFile))
+ }
+
+ // now create an export task to get our files out of the workspace
+ export := &docker.Export{
+ Files: c.Files,
+ Path: path,
}
+ // make sure the export task is valid
+ err = export.Valid()
+ if err != nil {
+ return err
+ }
+
+ // run the export
+ err = export.Execute(name, logger, env, st)
+ if err != nil {
+ return err
+ }
+
+ // finally run the command
return command.Run(name, cmd.Command(), st.PlanTimeout)
}
--- a/state/state.go Thu Feb 15 17:23:51 2018 -0600
+++ b/state/state.go Fri Feb 16 14:07:47 2018 -0600
@@ -128,6 +128,15 @@
return dir, nil
}
+// 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)
+
+ return dir, err
+}
+
// Valid validates whether the state is correct or not.
func (st *State) Valid() error {
if st.parent == nil && st.detachedContainers == nil {