grim/convey

Parents fa6ae0862e8e
Children 9a93ecb33e19
Default the workdir to ${CONVEY_WORKSPACE} when one is not specified. Fixed #167
  • +3 -0
    ChangeLog
  • +27 -5
    docker/run.go
  • --- a/ChangeLog Mon Feb 12 21:54:59 2018 -0600
    +++ b/ChangeLog Mon Feb 12 22:17:07 2018 -0600
    @@ -4,6 +4,9 @@
    * Fixed an issue where the files for clean tasks were not having their
    variables expanded
    * Fixed a bug where tasks weren't being validated. Fixed #160
    + * Set the workdir parameter for docker/run tasks to ${CONVEY_WORKSPACE} if
    + the image does not have a workdir set and the user has not specified on in
    + convey.yml. Fixed #167
    0.13.1: 20180114
    * Write warning, error, and fatal log messages to stderr. Fixed #156
    --- a/docker/run.go Mon Feb 12 21:54:59 2018 -0600
    +++ b/docker/run.go Mon Feb 12 22:17:07 2018 -0600
    @@ -224,6 +224,14 @@
    // create an id for this container
    runID := util.ShortID()
    + // Map the image name so we can use it elsewhere
    + image, err := environment.Mapper(r.Image, fullEnv)
    + if err != nil {
    + return err
    + } else if image == "" {
    + return errNoImage
    + }
    +
    // build the command
    cmd := command.NewGenerator(
    "run", "--rm",
    @@ -274,6 +282,25 @@
    }
    if workdir != "" {
    cmd.Append("-w", workdir)
    + } else {
    + // Check if the image does _not_ have a workdir set. If it doesn't,
    + // set workdir to the convey workspace
    + cmdv := []string{
    + "inspect",
    + "--format",
    + "{{.Config.WorkingDir}}",
    + image,
    + }
    + stdout, stderr, err := DockerOutput("checkWorkDir", cmdv, st)
    + if err != nil {
    + logger.Errorf("%s", stderr)
    +
    + return err
    + }
    +
    + if strings.TrimSpace(stdout) == "" {
    + cmd.Append("-w", workspaceMount)
    + }
    }
    // detach if necessary
    @@ -366,11 +393,6 @@
    }
    // add the image to the command
    - // TODO make sure image isn't an empty string
    - image, err := environment.Mapper(r.Image, fullEnv)
    - if err != nil {
    - return err
    - }
    cmd.Append(image)
    // append the command if we have one