|
| 1 | +# Contributing |
| 2 | + |
| 3 | +## Common Contributions |
| 4 | + |
| 5 | +### Add a new resource |
| 6 | + |
| 7 | +Example PR: [link](https://github.com/SumoLogic/terraform-provider-sumologic/pull/710) |
| 8 | + |
| 9 | +* Code |
| 10 | + * `sumologic/sumologic_foo.go` |
| 11 | + * data type |
| 12 | + * functions to interact with [Sumo Logic API](https://help.sumologic.com/docs/api/) |
| 13 | + * `sumologic/resource_sumologic_foo.go` |
| 14 | + * schema |
| 15 | + * functions to interact with tf state |
| 16 | + * `sumologic/resource_sumologic_foo_test.go` |
| 17 | + * acceptance tests |
| 18 | + * `sumologic/provider.go` |
| 19 | + * add the new resource to the `ResourcesMap` |
| 20 | +* Documentation ([preview tool](https://registry.terraform.io/tools/doc-preview)) |
| 21 | + * `website/docs/r/foo.html.markdown` |
| 22 | + * purpose |
| 23 | + * example usage |
| 24 | + * detailed reference |
| 25 | + * `CHANGELOG.md` |
| 26 | + * leave the `## X.Y.Z (Unreleased)` header |
| 27 | + * a new version number will be selected only when a release is cut |
| 28 | + * add your new changes under `* Add new change notes here` (and do not delete this line) |
| 29 | + |
| 30 | +### Add a new data source |
| 31 | + |
| 32 | +Example PR: [link](https://github.com/SumoLogic/terraform-provider-sumologic/pull/762) |
| 33 | + |
| 34 | +* Code |
| 35 | + * `sumologic/sumologic_foo.go` |
| 36 | + * data type |
| 37 | + * functions to interact with [Sumo Logic API](https://help.sumologic.com/docs/api/) |
| 38 | + * `sumologic/data_source_sumologic_foo.go` (singular, for reading one) |
| 39 | + * schema |
| 40 | + * functions to read into the tf state |
| 41 | + * `sumologic/data_source_sumologic_foos.go` (plural, for reading multiple) |
| 42 | + * schema |
| 43 | + * functions to read into the tf state |
| 44 | + * `sumologic/resource_sumologic_foo_test.go` (singular) |
| 45 | + * acceptance tests |
| 46 | + * `sumologic/resource_sumologic_foos_test.go` (plural) |
| 47 | + * acceptance tests |
| 48 | + * update `sumologic/provider.go` |
| 49 | + * add the new data sources to the `DataSourcesMap` |
| 50 | +* Documentation ([preview tool](https://registry.terraform.io/tools/doc-preview)) |
| 51 | + * `website/docs/d/foo.html.markdown` (singular) |
| 52 | + * purpose |
| 53 | + * example usage |
| 54 | + * detailed reference |
| 55 | + * `website/docs/d/foos.html.markdown` (plural) |
| 56 | + * purpose |
| 57 | + * example usage |
| 58 | + * detailed reference |
| 59 | + * `CHANGELOG.md` |
| 60 | + * leave the `## X.Y.Z (Unreleased)` header |
| 61 | + * a new version number will be selected only when a release is cut |
| 62 | + * add your new changes under `* Add new change notes here` (and do not delete this line) |
| 63 | + |
| 64 | +If only the singular or plural versions of the data source are required, that's okay. It's not always necessary to have both. |
| 65 | + |
| 66 | +### Cut a new release (Sumo Logic team members only) |
| 67 | + |
| 68 | +Example PR: [link](https://github.com/SumoLogic/terraform-provider-sumologic/pull/759) |
| 69 | + |
| 70 | +1. Code |
| 71 | + * `CHANGELOG.md` |
| 72 | + * Choose a new version number |
| 73 | + * Add a new line, under `* Add new change notes here`, with format `## MAJOR.MINOR.PATCH (Month Day, Year)` |
| 74 | + * Tidy up any formatting inconsistencies |
| 75 | +2. Tag the commit |
| 76 | + ```bash |
| 77 | + git pull origin master |
| 78 | + git tag vX.XX.XX |
| 79 | + git push origin vX.XX.XX |
| 80 | + # where X.XX.XX is the new version of the provider |
| 81 | + ``` |
| 82 | +3. Wait for the goreleaser job |
| 83 | + * When you push the tag, it will trigger a GitHub Action job named `goreleaser`, which does the following automatically: |
| 84 | + * Create a draft release for the new tag |
| 85 | + * Build binaries |
| 86 | + * Attach those binaries to the draft release |
| 87 | + * You can find the job through the [Actions page](https://github.com/SumoLogic/terraform-provider-sumologic/actions) |
| 88 | + * [Example](https://github.com/SumoLogic/terraform-provider-sumologic/actions/runs/15145892343) |
| 89 | + * Wait for the job to finish (less than 10 minutes) |
| 90 | +4. Publish the release |
| 91 | + * Open the [Releases page](https://github.com/SumoLogic/terraform-provider-sumologic/releases) |
| 92 | + * Click the `Edit` button for the new draft release (at the top right, looks like a pencil) |
| 93 | + * Copy and paste the release notes from `CHANGELOG.md` into the description |
| 94 | + * Scroll all the way down and ensure `Set as the latest release` is checked |
| 95 | + * Click `Publish release` |
| 96 | +5. Verify that the release is published to the Terraform Registry |
| 97 | + * Open the [Terraform Registry](https://registry.terraform.io/providers/SumoLogic/sumologic/latest) |
| 98 | + * Check that the version number matches the new release |
| 99 | + * NOTE: This can sometimes take up to 30 minutes |
| 100 | + * If the registry still has not updated after a long time, you can redeliver the webhook messages: |
| 101 | + * Open the [Webhook settings](https://github.com/SumoLogic/terraform-provider-sumologic/settings/hooks) |
| 102 | + * For the Terraform Registry, click `Edit` |
| 103 | + * Select the `Recent Deliveries` tab |
| 104 | + * Select each of the recent messages and click `Redeliver` in order |
| 105 | + |
| 106 | +## PRs from the Community |
| 107 | + |
| 108 | +When a PR includes changes to the provider code, then a GitHub Action will attempt to run the acceptance tests. |
| 109 | +The acceptance tests depend on several API keys which are stored in the GitHub Secrets. For safety and security, |
| 110 | +these Secrets are not available in PRs from forked repositories. At the time of writing, our best workaround is |
| 111 | +for a Sumo Logic member to duplicate the PR. |
| 112 | + |
| 113 | +1. Review the PR changes |
| 114 | + * Correctness? |
| 115 | + * Completeness? |
| 116 | + * Security risks? |
| 117 | +2. Duplicate the branch |
| 118 | + ```bash |
| 119 | + gh pr checkout PR_NUMBER |
| 120 | + git checkout -b BRANCH_NAME |
| 121 | + git push origin BRANCH_NAME |
| 122 | + ``` |
| 123 | +3. Create a new PR ([Example](https://github.com/SumoLogic/terraform-provider-sumologic/pull/797)) |
0 commit comments