Skip to content

Latest commit

 

History

History
104 lines (72 loc) · 4.17 KB

DEVELOPMENT.md

File metadata and controls

104 lines (72 loc) · 4.17 KB

Development guide

Building The Provider

  1. Clone the repository
  2. Enter the repository directory
  3. Build the provider using the make command:
$ make

Adding Dependencies

This provider uses Go modules. Please see the Go documentation for the most up to date information about using Go modules.

To add a new dependency github.com/author/dependency to your Terraform provider:

go get github.com/author/dependency
go mod tidy

Then commit the changes to go.mod and go.sum.

Developing the Provider

If you wish to work on the provider, you'll first need Go installed on your machine (see Requirements above).

To compile the provider, run make. This will build the provider and put the provider binary in the terraform plugin directory.

To generate or update documentation, run make generate.

Testing the Provider

Unit tests

To run the unit tests, run make test

Acceptance tests

Note: Acceptance tests create real resources, and cost money to run.

In order to run the full suite of Acceptance tests, you need do the following:

  • Configure your AWS and Azure credentials locally
  • Export the following environment variables
   export HOPSWORKSAI_API_KEY=<YOUR HOPSWORKS API KEY>
   export TF_VAR_skip_aws=false # Setting it to true will not run any acceptance tests on AWS
   export TF_VAR_skip_azure=false # Setting it to true will not run any acceptance tests on Azure
   export TF_VAR_azure_resource_group=<YOUR AZURE RESOURCE GROUP> # no need to set if you skip tests on Azure
   export TF_VAR_aws_profile=<YOUR AWS PROFILE> # If not set, the default aws profile is used
   export TF_VAR_aws_region=<YOUR AWS REGION> # If not set, us-east-2 is used
  • Run all the acceptance tests using the following command
$ make testacc 

You can also run only a single test or a some tests following some name pattern as follows

$ make testacc TESTARGS='-run=TestAcc*'

Acceptance tests provision real resources, and ideally these resources should be destroyed at the end of each test, however, it can happen that resources are leaked due to different reasons. For that, you can run the sweeper to clean up all resources created during acceptance testing.

$ make sweep 

Using the Provider

With Terraform v0.14 and later, development overrides for provider developers can be leveraged in order to use the provider built from source.

To do this, populate a Terraform CLI configuration file (~/.terraformrc for all platforms other than Windows; terraform.rc in the %APPDATA% directory when using Windows) with at least the following options:

provider_installation {
  dev_overrides {
    "logicalclocks/hopsworksai" = "[REPLACE WITH THE REPOSITORY LOCAL DIRECTORY]/bin"
  }
  direct {}
}

Releasing the Provider

We use a GitHub Action that is configured to automatically build and publish assets for release when a tag is pushed that matches the pattern v* (ie. v0.1.0).

The Goreleaser configuration produces build artifacts matching the layout required to publish the provider in the Terraform Registry.

Releases will appear as drafts. Once marked as published on the GitHub Releases page, they will become available via the Terraform Registry.

How to release

  • Update the release date at the top of CHANGELOG.md to the current date for the release and push it to main branch
  • Create a new tag with the release version (for example v1.3.1) using git tags git tag v1.3.1 and push to upstream git push upstream v1.3.1
  • Add a new section to the CHANGELOG.md for the new release and push it to main branch

Recommended Docs