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

docs: Contributor Guide on the Website #4514

Merged
merged 8 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ tmp-CHANGELOG.md
# IDE files
*.code-workspace

# draw.io backup files
*.bkp

# vuepress
**/.vuepress/*
!runatlantis.io/.vuepress/config.*
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"@vuepress/plugin-sitemap": "2.0.0-rc.21",
"@vuepress/theme-default": "2.0.0-rc.21",
"@vuepress/utils": "2.0.0-rc.9",
"sass-loader": "14.1.1",
"vue": "3.4.21",
"sass-loader": "14.2.1",
"vue": "3.4.27",
"vuepress": "2.0.0-rc.9"
},
"scripts": {
"website:dev": "vuepress dev runatlantis.io",
"website:dev": "vuepress dev --host localhost runatlantis.io",
"website:build": "NODE_OPTIONS=--openssl-legacy-provider vuepress build runatlantis.io",
"e2e": "playwright test"
}
Expand Down
971 changes: 517 additions & 454 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions runatlantis.io/.vuepress/navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const en = [
{ text: 'Home', link: '/' },
{ text: 'Guide', link: '/guide/' },
{ text: 'Docs', link: '/docs/' },
{ text: "Contributing", link: "/contributing/" },
{ text: 'Blog', link: 'https://medium.com/runatlantis' },
];

Expand Down
11 changes: 10 additions & 1 deletion runatlantis.io/.vuepress/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,16 @@ const en = {
'/docs/troubleshooting-https',
]
}
]
],
'/contributing/': [
{
text: 'Implementation Details',
children: [
'/contributing/events-controller',
]
},
'/contributing/glossary',
],
};

export default { en };
14 changes: 14 additions & 0 deletions runatlantis.io/contributing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Atlantis Contributing Documentation

These docs are for users who want to contribute to the Atlantis project. This
can vary from writing documentation, helping the community on Slack, discussing
issues, or writing code.

:::tip Looking to get started or use Atlantis?
If you're new, check out the [Guide](../guide/README.md) or the
[Documentation](./../docs/README.md).
:::

### Next Steps

- [Events Controller](events-controller.md)  –  How do the events work?
71 changes: 71 additions & 0 deletions runatlantis.io/contributing/events-controller.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Events Controller

Webhooks are the primary interaction between the Version Control System (VCS)
and Atlantis. Each VCS sends the requests to the `/events` endpoint. The
implementation of this endpoint can be found in the
[events_controller.go](https://github.com/runatlantis/atlantis/blob/main/server/controllers/events/events_controller.go)
file. This file contains the Post function `func (e *VCSEventsController)
Post(w http.ResponseWriter, r *http.Request`)` that parses the request
according to the configured VCS.

Atlantis currently handles one of the following events:

- Comment Event
- Pull Request Event

All the other events are ignored.

![Events Controller flow](./images/events-controller.png)

## Comment Event

This event is triggered whenever a user enters a comment on the Pull Request,
Merge Request, or whatever it's called for the respective VCS. After parsing the
VCS-specific request, the code calls the `handleCommentEvent` function, which
then passes the processing to the `handleCommentEvent` function in the
[command_runner.go](https://github.com/runatlantis/atlantis/blob/main/server/events/command_runner.go)
file. This function first calls the pre-workflow hooks, then executes one of the
below-listed commands and, at last, the post-workflow hooks.

- [plan_command_runner.go](https://github.com/runatlantis/atlantis/blob/main/server/events/plan_command_runner.go)
- [apply_command_runner.go](https://github.com/runatlantis/atlantis/blob/main/server/events/apply_command_runner.go)
- [approve_policies_command_runner.go](https://github.com/runatlantis/atlantis/blob/main/server/events/approve_policies_command_runner.go)
- [unlock_command_runner.go](https://github.com/runatlantis/atlantis/blob/main/server/events/unlock_command_runner.go)
- [version_command_runner.go](https://github.com/runatlantis/atlantis/blob/main/server/events/version_command_runner.go)
- [import_command_runner.go](https://github.com/runatlantis/atlantis/blob/main/server/events/import_command_runner.go)
- [state_command_runner.go](https://github.com/runatlantis/atlantis/blob/main/server/events/state_command_runner.go)

## Pull Request Event

To handle comment events on Pull Requests, they must be created first. Atlantis
also allows the running of commands for certain Pull Requests events.

<details>
<summary>Pull Request Webhooks</summary>

The list below links to the supported VCSs and their Pull Request Webhook
documentation.

- [Azure DevOps Pull Request Created](https://learn.microsoft.com/en-us/azure/devops/service-hooks/events?view=azure-devops#pull-request-created)
- [BitBucket Pull Request](https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Pull-request-events)
- [GitHub Pull Request](https://docs.github.com/en/webhooks/webhook-events-and-payloads#pull_request)
- [GitLab Merge Request](https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#merge-request-events)
- [Gitea Webhooks](https://docs.gitea.com/next/usage/webhooks)
</details>

The following list shows the supported events:
elft3r marked this conversation as resolved.
Show resolved Hide resolved

- Opened Pull Request
- Updated Pull Request
- Closed Pull Request
- Other Pull Request event

The `RunAutoPlanCommand` function in the
[command_runner.go](https://github.com/runatlantis/atlantis/blob/main/server/events/command_runner.go)
file is called for the _Open_ and _Update_ Pull Request events. When enabled on
the project, this automatically runs the `plan` for the specific repository.

Whenever a Pull Request is closed, the `CleanUpPull` function in the
[instrumented_pull_closed_executor.go](https://github.com/runatlantis/atlantis/blob/main/server/events/instrumented_pull_closed_executor.go)
file is called. This function cleans up all the closed Pull Request files,
locks, and other related information.
26 changes: 26 additions & 0 deletions runatlantis.io/contributing/glossary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Glossary

The Atlantis community uses many words and phrases to work more efficiently.
You will find the most common ones and their meaning on this page.

## Pull / Merge Request Event

The different VCSs have different names for merging changes. Atlantis uses the
name Pull Request as the abstraction. The VCS provider implements this
abstraction and forwards the call to the respective function.

## VCS

VCS stands for Version Control System.

Atlantis supports only git as a Version Control System. However, there is
support for multiple VCS Providers. Currently, it supports the following
providers:

- [Azure DevOps](https://azure.microsoft.com/en-us/products/devops)
- [BitBucket](https://bitbucket.org/)
- [GitHub](https://github.com/)
- [GitLab](https://gitlab.com/)
- [Gitea](https://gitea.com/)

The term VCS is used for both git and the different VCS providers.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading