* I want a "docker-tag" to run as the first post-processor step. Then, I want the "docker-tag" step to pass an appropriate Docker artifact to the next step - "shell-local" (though, "shell-local" won't use that artifact for anything - just keep track of it for subsequent steps).
* I want "shell-local" to run a bash script which starts up a container based on the newly tagged image. If the test fails, I want the Packer build to fail (this works great right now!). If the test passes, I want the "shell-local" post-processor to pass the same artifact it was given to the next post-processor step - "docker-push" so that the now tested image will be pushed to ECR.
Now, perhaps "keep_input_artifact" is indeed passing along the appropriate artifact - in fact, when I look at
the code for the "shell-local" post processor, it looks like it _always_ passes along the input artifact. Though, admittedly, I haven't familiarized myself with the rest of the code and I'm not proficient in the Go language. But, it sure looks like it should work.
But, instead, what actually happens is that the "docker-push" step fails with "Can only import from docker-import and docker-tag artifacts". If I remove the "shell-local" post-processing step from between "docker-tag" and "docker-push" (see original post for example), it works great - the appropriate image is pushed to ECR (though, obviously untested).
If I look at
the "docker-push" post-processor code, I believe I see the exact condition check that's leading to the error:
if artifact.BuilderId() != dockerimport.BuilderId &&
artifact.BuilderId() != dockertag.BuilderId {
err := fmt.Errorf(
"Unknown artifact type: %s\nCan only import from docker-import and docker-tag artifacts.",
artifact.BuilderId())
return nil, false, err
}
My comment about the "passthrough_input_artifact" might be irrelevant - what I was trying to say was that I want it to work like I describe above - such that "shell-local" can be put between "docker-tag" and "docker-push" without breaking the build. Does this make sense?
--
Nathan