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

feat(api): add new params BaseBranch, Commit #3985

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

rgs1
Copy link

@rgs1 rgs1 commented Nov 16, 2023

what

  • add additional parameters BaseBranch and Commit

why

As of now, the /api/plan endpoint constructs a PullRequest that uses the provided Ref parameter as the base branch and head commit. This causes issues when running additional steps along with plan (e.g.: policy check, infracost, etc).

Here's an example error:

repo was already cloned but is not at correct commit, wanted \"pr-plan-test\" got \"7a19f2011...\"

This will then trigger a new clone which will override needed artifacts from the previous steps which will then cause /api/plan to fail.

By properly setting HeadCommit from the new optional APIRequest parameter this issue is avoided.

references

tests

  • I have tested my changes by adding unit tests

@rgs1 rgs1 requested a review from a team as a code owner November 16, 2023 19:25
@github-actions github-actions bot added docs Documentation go Pull requests that update Go code labels Nov 16, 2023
@rgs1
Copy link
Author

rgs1 commented Nov 16, 2023

@jamengual 2nd try – this makes HeadCommit and BaseBranch optional parameters. If they are missing, we fallback to the existing behavior which I guess works fine as long as your plan workflow consist of one step only. I wonder if the real issue is the fact that there's an attempt to re-clone on every step within the same workflow, if that wasn't happening things would work (I think).

chenrui333
chenrui333 previously approved these changes Dec 12, 2023
@chenrui333
Copy link
Member

lgtm @rgs1 can you also add some tests as well?

@rgs1 rgs1 requested a review from a team as a code owner December 28, 2023 21:21
@rgs1 rgs1 requested review from lukemassa and X-Guardian and removed request for a team December 28, 2023 21:21
@rgs1
Copy link
Author

rgs1 commented Dec 28, 2023

Thanks for the review @chenrui333. Just pushed an updated commit with the existing test updated, so that it exercises the new fields.

@rgs1 rgs1 force-pushed the extend-api branch 3 times, most recently from 108743b to 24c631c Compare January 4, 2024 17:31
As of now, the /api/plan endpoint constructs a PullRequest that uses
the provided Ref parameter as the base branch and head commit. This
causes issues when running additional steps along with plan
(e.g.: policy check, infracost, etc).

Here's an example error:

```
repo was already cloned but is not at correct commit, wanted \"pr-plan-test\" got \"7a19f2011...\"
```

This will then trigger a new clone which will override needed artifacts
from the previous steps which will then cause /api/plan to fail.

By properly setting HeadCommit from the new optional APIRequest parameter
this issue is avoided.

Signed-off-by: Raul Gutierrez Segales <[email protected]>
@rgs1
Copy link
Author

rgs1 commented Jan 10, 2024

/retest

@nitrocode nitrocode changed the title feat(api): add new params feat(api): add new params BaseBranch, Commit Jan 16, 2024
@jamengual
Copy link
Contributor

@rgs1 could you fix the conflicts please?

@jamengual jamengual added waiting-on-review Waiting for a review from a maintainer api-endpoints Adding API endpoints to Atlantis labels May 24, 2024
@X-Guardian
Copy link
Contributor

@rgs1, the tests are failing. Are you able to take a look?

@X-Guardian X-Guardian added the waiting-on-response Waiting for a response from the user label Nov 19, 2024
@X-Guardian X-Guardian removed the waiting-on-review Waiting for a review from a maintainer label Nov 19, 2024
Copy link

This issue is stale because it has been open for 1 month with no activity. Remove stale label or comment or this will be closed in 1 month.

@github-actions github-actions bot added the Stale label Dec 21, 2024
@github-actions github-actions bot removed the Stale label Dec 31, 2024
@jamengual
Copy link
Contributor

@rgs1 can you check the tests? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-endpoints Adding API endpoints to Atlantis docs Documentation go Pull requests that update Go code waiting-on-response Waiting for a response from the user
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants