CONTRIBUTING.md 2.29 KB
Newer Older
Daisuke Fujita's avatar
Daisuke Fujita committed
1 2
# Contributing

Daisuke Fujita's avatar
Daisuke Fujita committed
3
I love pull requests from everyone! By the way, I have a favor to ask you with your contribution :bow:
Daisuke Fujita's avatar
Daisuke Fujita committed
4 5 6 7 8 9 10

## Making changes

- Currently, this gem supports only __AWS__ resources. Other providers are supported as separated gems.
  - Datadog: [terraforming-datadog](https://github.com/dtan4/terraforming-datadog)
  - DNSimple: [terraforming-dnsimple](https://github.com/dtan4/terraforming-dnsimple)
- Do not bump gem version in your pull request.
11
- Please follow the coding style of _existing_ code. Most of trivial rules can be checked by [RuboCop](https://github.com/bbatsov/rubocop) ([`rubocop.yml`](https://github.com/dtan4/terraforming/blob/master/.rubocop.yml)).
Daisuke Fujita's avatar
Daisuke Fujita committed
12
  - Coding style is checked automatically by [SideCI](https://sideci.com) right after creating pull request. If there is error, SideCI comments at the point error occured.
13
- Please write tests for your changes. All tests are written with [RSpec](http://rspec.info/).
Daisuke Fujita's avatar
Daisuke Fujita committed
14 15 16 17 18 19 20 21 22 23 24

## Adding new resource

- Class name must match to Terraforming's resource name without `aws_` prefix, and be a complete resource name.
  - e.g. `aws_iam_group_membership`: `IAMGroupMembership`
  - Yes, I know that some of resources I added a long ago don't follow to this rule...
- File name must also match to Terraforming's resource name without `aws_` prefix.
  - e.g. `aws_iam_group_membership`: `iam_group_membership.rb`
- Command name should be abbreviation.
  - e.g. `aws_iam_group_membership`: `iamgp`
- Please check generation result by executing `terraform plan` with real resources. There should be NO diff with generated `.tf` and `.tfstate`.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62

`script/generate` generates new resource code / test skeletons.

```bash
$ script/generate ec2
==> Generate ec2.rb
==> Generate ec2_spec.rb
==> Generate ec2.erb

Add below code by hand.

lib/terraforming.rb:

    require "terraforming/resource/ec2"

lib/terraforming/cli.rb:

    module Terraforming
      class CLI < Thor

        # Subcommand name should be acronym.
        desc "ec2", "Ec2"
        def ec2
          execute(Terraforming::Resource::Ec2, options)
        end

spec/lib/terraforming/cli_spec.rb:

module Terraforming
  describe CLI do
    context "resources" do
    describe "ec2" do
        let(:klass)   { Terraforming::Resource::Ec2
        let(:command) { :ec2 }

        it_behaves_like "CLI examples"
      end
```