Skip to content

Commit d58223d

Browse files
authored
chore: Initial file setup (#1)
* go file * license * security * conduct * contributing * readme * license note * codeowners * changelog * issues workflow, same as TF * release GHA * main go file * pr linter GHA * dependabot settings * stale GHA * PR template * code-health GHA * git ignore * readme code-health badge * issue template * go linter * simplify code-health * wip comment * makefile small refactor
1 parent 3a889a6 commit d58223d

24 files changed

+845
-0
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Maintained by the MongoDB APIx-Integrations team
2+
* @mongodb-labs/APIx-Integrations

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Bug report
2+
description: Something unexpected happen? Report an error, crash, or an incorrect behavior here.
3+
title: "[Bug]: <your-title>"
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
Thank you for opening an issue. **These GitHub issues** are only for community reporting and assistance; as such, we don't have a guaranteed SLA.
9+
10+
**If your issue relates to Terraform itself**, please open it in the [Terraform repository](https://github.com/hashicorp/terraform/issues).
11+
12+
**If you have an active MongoDB Atlas Support contract**, the best way for us to assist you with the Terraform MongoDB Atlas Provider is through a support ticket.
13+
14+
**Please note:** In order for us to provide the best experience in supporting our customers, we kindly ask to make sure that all the following sections are correctly filled with all the required information.
15+
Our support will prioritise issues that contain all the required information that follows the [one-click reproducible issues principle](../../README.md#one-click-reproducible-issues-principle).
16+
17+
- type: checkboxes
18+
attributes:
19+
label: Is there an existing issue for this?
20+
description: Please search to see if an issue already exists for the bug you encountered. If the issue has been reported add a reaction, i.e. +1, to the issue.
21+
options:
22+
- label: I have searched the existing issues
23+
required: true
24+
25+
- type: textarea
26+
id: current_behaviour
27+
attributes:
28+
label: Current Behavior
29+
description: A concise description of what you're experiencing.
30+
validations:
31+
required: true
32+
33+
- type: textarea
34+
attributes:
35+
label: Steps To Reproduce
36+
description: Steps to reproduce the behaviour.
37+
placeholder: |
38+
1. In this environment...
39+
2. With this config...
40+
3. Run '...'
41+
4. See error...
42+
validations:
43+
required: true
44+
45+
- type: textarea
46+
id: logs
47+
attributes:
48+
label: Logs
49+
description: Additional logs that can help us investigate the issue. This will be automatically formatted into code, so no need for backticks.
50+
render: txt
51+
validations:
52+
required: false
53+
54+
- type: checkboxes
55+
id: terms
56+
attributes:
57+
label: Code of Conduct
58+
description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/mongodb-labs/atlas-cli-plugin-terraform/blob/master/CODE_OF_CONDUCT.md)
59+
options:
60+
- label: I agree to follow this project's Code of Conduct
61+
required: true

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
blank_issues_enabled: true
2+
contact_links:
3+
- name: Terraform MongoDB Atlas Provider Feature Request
4+
url: https://feedback.mongodb.com/forums/924145-atlas?category_id=370723
5+
about: Request a feature or up-vote an existing suggestion!
6+
- name: MongoDB Atlas Support
7+
url: https://support.mongodb.com/
8+
about: Support is provided under MongoDB Atlas support plans. Please submit support questions within the Atlas UI.
9+
- name: MongoDB Atlas
10+
url: https://www.mongodb.com/cloud/atlas
11+
about: Learn more about MongoDB Atlas

.github/actionlint-matcher.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "actionlint",
5+
"severity": "warning",
6+
"pattern": [
7+
{
8+
"regexp": "^(?:\\x1b\\[\\d+m)?(.+?)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*: (?:\\x1b\\[\\d+m)*(.+?)(?:\\x1b\\[\\d+m)* \\[(.+?)\\]$",
9+
"file": 1,
10+
"line": 2,
11+
"column": 3,
12+
"message": 4,
13+
"code": 5
14+
}
15+
]
16+
}
17+
]
18+
}

.github/dependabot.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: gomod
4+
directory: "/"
5+
schedule:
6+
interval: weekly
7+
day: tuesday
8+
commit-message:
9+
prefix: "chore"
10+
reviewers:
11+
- "mongodb-labs/apix-integrations"
12+
- package-ecosystem: github-actions
13+
directory: "/"
14+
schedule:
15+
interval: weekly
16+
day: tuesday
17+
commit-message:
18+
prefix: "chore"
19+
reviewers:
20+
- "mongodb-labs/apix-integrations"

.github/pr-labeler.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 1
2+
labels:
3+
- label: "breaking-change"
4+
title: "!"
5+
- label: "enhancement"
6+
title: "feat:*"
7+
- label: "enhancement"
8+
title: "feature:*"
9+
- label: "bug"
10+
title: "fix:*"

.github/pull_request_template.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Description
2+
3+
Please include a summary of the fix/feature/change, including any relevant motivation and context.
4+
5+
Link to any related issue(s):
6+
7+
## Type of change:
8+
9+
- [ ] Bug fix (non-breaking change which fixes an issue). Please, add the "bug" label to the PR.
10+
- [ ] New feature (non-breaking change which adds functionality). Please, add the "enhancement" label to the PR. A migration guide must be created or updated if the new feature will go in a major version.
11+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR. A migration guide must be created or updated.
12+
- [ ] This change requires a documentation update
13+
- [ ] Documentation fix/enhancement
14+
15+
## Required Checklist:
16+
17+
- [ ] I have signed the [MongoDB CLA](https://www.mongodb.com/legal/contributor-agreement)
18+
- [ ] I have read the [contributing guides](https://github.com/mongodb-labs/atlas-cli-plugin-terraform/blob/master/CONTRIBUTING.md)
19+
- [ ] I have checked that this change does not generate any credentials and that **they are NOT accidentally logged anywhere**.
20+
- [ ] I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
21+
- [ ] I have added any necessary documentation (if appropriate)
22+
- [ ] I have run make fmt and formatted my code
23+
- [ ] If changes include deprecations or removals I have added appropriate changelog entries.
24+
- [ ] If changes include removal or addition of 3rd party GitHub actions, I updated our internal document. Reach out to the APIx Integration slack channel to get access to the internal document.
25+
26+
## Further comments

.github/workflows/code-health.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: 'Code Health'
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
permissions: {}
14+
steps:
15+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
16+
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a
17+
with:
18+
go-version-file: 'go.mod'
19+
- name: Build
20+
run: make build
21+
lint:
22+
runs-on: ubuntu-latest
23+
permissions: {}
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
27+
- name: Install Go
28+
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a
29+
with:
30+
go-version-file: 'go.mod'
31+
cache: false # see https://github.com/golangci/golangci-lint-action/issues/807
32+
- name: golangci-lint
33+
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8
34+
with:
35+
version: v1.63.4 # Also update GOLANGCI_VERSION variable in GNUmakefile when updating this version
36+
- name: actionlint
37+
run: |
38+
make tools
39+
echo "::add-matcher::.github/actionlint-matcher.json"
40+
actionlint -color
41+
shell: bash
42+
- name: shellcheck
43+
uses: bewuethr/shellcheck-action@d01912909579c4b1a335828b8fca197fbb8e0aa4

.github/workflows/issues.yml

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
---
2+
name: Create JIRA ticket for new issues
3+
4+
# Creates and updates jira tickets that sync with GitHub Issues events.
5+
on:
6+
issues:
7+
types: [opened, reopened, closed]
8+
jobs:
9+
jira_task:
10+
name: Create Jira issue
11+
if: github.event.action == 'opened'
12+
runs-on: ubuntu-latest
13+
env:
14+
GITHUB_TOKEN: ${{ secrets.APIX_BOT_PAT }}
15+
steps:
16+
- name: Create JIRA ticket
17+
id: create
18+
shell: bash
19+
env:
20+
ISSUE_NUMBER: ${{ github.event.issue.number }}
21+
ISSUE_URL: ${{ github.event.issue.html_url }}
22+
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
23+
JIRA_ASSIGNEE: ${{ secrets.ASSIGNEE_JIRA_TICKET }}
24+
run: |
25+
json_response=$(curl --request POST \
26+
--url 'https://jira.mongodb.org/rest/api/2/issue' \
27+
--header 'Authorization: Bearer '"${JIRA_API_TOKEN}" \
28+
--header 'Accept: application/json' \
29+
--header 'Content-Type: application/json' \
30+
--data '{
31+
"fields": {
32+
"project": {
33+
"id": "10984"
34+
},
35+
"summary": "HELP: GitHub Issue n. '"${ISSUE_NUMBER}"'",
36+
"issuetype": {
37+
"id": "12"
38+
},
39+
"customfield_12751": [{
40+
"id": "25550"
41+
}],
42+
"description": "This ticket tracks the following GitHub issue: '"${ISSUE_URL}"'.",
43+
"components": [
44+
{
45+
"id": "34035"
46+
}
47+
]
48+
}
49+
}')
50+
51+
echo "Response: ${json_response}"
52+
53+
JIRA_TICKET_ID=$(echo "${json_response}" | jq -r '.key')
54+
55+
echo "The following JIRA ticket has been created: ${JIRA_TICKET_ID}"
56+
echo "jira-ticket-id=${JIRA_TICKET_ID}" >> "${GITHUB_OUTPUT}"
57+
- name: Add comment
58+
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043
59+
with:
60+
issue-number: ${{ github.event.issue.number }}
61+
body: |
62+
Thanks for opening this issue! Please make sure you've followed [our guidelines](https://github.com/mongodb/terraform-provider-mongodbatlas/issues/new?assignees=&labels=&projects=&template=Bug_Report.md) when opening the issue. In short, to help us reproduce the issue we need:
63+
- Terraform configuration file used to reproduce the issue
64+
- Terraform log files from the run where the issue occurred
65+
- Terraform Atlas provider version used to reproduce the issue
66+
- Terraform version used to reproduce the issue
67+
- Confirmation if Terraform OSS, Terraform Cloud, or Terraform Enterprise deployment
68+
69+
The ticket [${{ steps.create.outputs.jira-ticket-id }}](https://jira.mongodb.org/browse/${{ steps.create.outputs.jira-ticket-id }}) was created for internal tracking.
70+
reopen_jira_ticket:
71+
name: Reopen JIRA ticket
72+
if: github.event.action == 'reopened'
73+
runs-on: ubuntu-latest
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.APIX_BOT_PAT }}
76+
steps:
77+
- name: Reopened JIRA ticket if exists
78+
run: |
79+
ISSUE_NUMBER=${{ github.event.issue.number }}
80+
JIRA_API_TOKEN=${{ secrets.JIRA_API_TOKEN }}
81+
82+
JIRA_QUERY="project = CLOUDP AND issuetype = Story AND resolution = Declined AND text ~ \"HELP: GitHub Issue n. $ISSUE_NUMBER\""
83+
84+
# URL encode the query
85+
JIRA_URL=$(echo "$JIRA_QUERY" | jq -s -R -r @uri)
86+
87+
json_response=$(curl -s --request GET \
88+
--url "https://jira.mongodb.org/rest/api/2/search?fields=id&jql=${JIRA_URL}" \
89+
--header 'Authorization: Bearer '"${JIRA_API_TOKEN}" \
90+
--header 'Accept: application/json')
91+
92+
JIRA_TICKET_ID=$(echo "${json_response}" | jq -r '.issues[0].id')
93+
if [ -z "$JIRA_TICKET_ID" ]; then
94+
echo "JIRA_TICKET_ID is not defined. Exiting the script."
95+
exit 1
96+
fi
97+
98+
JIRA_REOPENED_URL="https://jira.mongodb.org/rest/api/2/issue/${JIRA_TICKET_ID}/transitions"
99+
100+
json_response=$(curl -s --request POST \
101+
--url "${JIRA_REOPENED_URL}" \
102+
--header 'Authorization: Bearer '"${JIRA_API_TOKEN}" \
103+
--header 'Accept: application/json' \
104+
--header 'Content-Type: application/json' \
105+
--data '{
106+
"transition": {
107+
"id": 3
108+
},
109+
"update": {
110+
"comment": [
111+
{
112+
"add": {
113+
"body": "The related GitHub issue was reopened. Updated via automated process."
114+
}
115+
}
116+
]
117+
}
118+
}')
119+
echo "Response: ${json_response}"
120+
close_jira_ticket:
121+
name: Close JIRA ticket
122+
if: github.event.action == 'closed'
123+
runs-on: ubuntu-latest
124+
env:
125+
GITHUB_TOKEN: ${{ secrets.APIX_BOT_PAT }}
126+
steps:
127+
- name: Close JIRA ticket if exists
128+
run: |
129+
ISSUE_NUMBER=${{ github.event.issue.number }}
130+
JIRA_API_TOKEN=${{ secrets.JIRA_API_TOKEN }}
131+
132+
JIRA_QUERY="project = CLOUDP AND issuetype = Story AND resolution = Unresolved AND text ~ \"HELP: GitHub Issue n. $ISSUE_NUMBER\""
133+
134+
# URL encode the query
135+
JIRA_URL=$(echo "$JIRA_QUERY" | jq -s -R -r @uri)
136+
137+
json_response=$(curl -s --request GET \
138+
--url "https://jira.mongodb.org/rest/api/2/search?fields=id&jql=${JIRA_URL}" \
139+
--header 'Authorization: Bearer '"${JIRA_API_TOKEN}" \
140+
--header 'Accept: application/json')
141+
142+
JIRA_TICKET_ID=$(echo "${json_response}" | jq -r '.issues[0].id')
143+
if [ -z "$JIRA_TICKET_ID" ]; then
144+
echo "JIRA_TICKET_ID is not defined. Exiting the script."
145+
exit 1
146+
fi
147+
148+
JIRA_CLOSE_URL="https://jira.mongodb.org/rest/api/2/issue/${JIRA_TICKET_ID}/transitions"
149+
150+
json_response=$(curl -s --request POST \
151+
--url "${JIRA_CLOSE_URL}" \
152+
--header 'Authorization: Bearer '"${JIRA_API_TOKEN}" \
153+
--header 'Accept: application/json' \
154+
--header 'Content-Type: application/json' \
155+
--data '{
156+
"transition": {
157+
"id": 1371
158+
},
159+
"update": {
160+
"comment": [
161+
{
162+
"add": {
163+
"body": "The related GitHub issue was closed. Resolved via automated process."
164+
}
165+
}
166+
]
167+
},
168+
"fields": {
169+
"resolution": {
170+
"name": "Declined"
171+
}
172+
}
173+
}')
174+
echo "Response: ${json_response}"

0 commit comments

Comments
 (0)