Hi guys, sorry if this ha been answered but I could not find any info regarding this. I'm playing with custom flows and I wanted to see if I can run some checks after the plan is generated. Specifically I'm trying to run terraform-compliance. That tool requires a plan and also a folder/repo with the features specs to check. That folder in my case is in the repo's root. Now, I can see I have PLANFILE with the location of the plan file and DIR for the current folder (where the plan is executed) but I have no way to find out the root folder where the repo is checked out.
I think is composed like this: /home/atlantis/.atlantis/repos/${BASE_REPO_OWNER}/${BASE_REPO_NAME}/${PULL_NUM}/${WORKSPACE}/ but I'm not sure I can rely on that.
Thanks
Hi Cristian,
We could expose the models.ProjectCommandContext field RepoRelDir as an environment variable to custom steps. If you wanted to put up a PR for that you'd add it here: https://github.com/runatlantis/atlantis/blob/master/server/events/runtime/run_step_runner.go#L39
Otherwise, you can rely on the directory structure you've figured out. I can't see that changing in the future.
RepoRelDir is not helping me in this case, is the terraform project relative path inside repo not the clone dir. I'm new to Go but I'll keep digging.
$DIR is the absolute directory to the project so you could use repoRelDir to figure out the repo root, e.g.
DIR=/home/atlantis/.atlantis/repos/${BASE_REPO_OWNER}/${BASE_REPO_NAME}/${PULL_NUM}/${WORKSPACE}/${PROJECT}
RepoRelDir=${PROJECT}
@lkysow I needed something similar. If I am understanding your last comment correctly are you suggesting something like https://play.golang.org/p/hWTfXa8JIjt where we just remove ${RepoRelDir} from ${DIR}? This convo is quite old so perhaps things have changed on best way to approach this.
Hi @awiddersheim the directory structure hasn't changed so that should work.
Is there a reason why the REPO_REL_DIR isn't exposed in the environment? It would be rather useful, rather than having to try to reconstruct it from the DIR.
Most helpful comment
Is there a reason why the REPO_REL_DIR isn't exposed in the environment? It would be rather useful, rather than having to try to reconstruct it from the DIR.