Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repo checkout root dir variable in custom flows #806

Closed
crisp2u opened this issue Oct 17, 2019 · 6 comments · Fixed by #1063
Closed

Repo checkout root dir variable in custom flows #806

crisp2u opened this issue Oct 17, 2019 · 6 comments · Fixed by #1063
Labels
question Further information is requested

Comments

@crisp2u
Copy link

crisp2u commented Oct 17, 2019

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

@lkysow lkysow added the question Further information is requested label Oct 17, 2019
@lkysow
Copy link
Member

lkysow commented Oct 17, 2019

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.

@crisp2u
Copy link
Author

crisp2u commented Oct 17, 2019

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.

@lkysow
Copy link
Member

lkysow commented Oct 17, 2019

$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}

@awiddersheim
Copy link

@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.

@lkysow
Copy link
Member

lkysow commented May 19, 2020

Hi @awiddersheim the directory structure hasn't changed so that should work.

@llamahunter
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants