You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We happily welcome contributions to databricks-terraform. We use GitHub Issues to track community reported issues and GitHub Pull Requests for accepting changes.
The following command (tested on Ubuntu 20.04) will install `make`, `golang`, `git` with all of the dependent packages as well as Databricks Terrafrom provider from sources. Required version of GoLang is at least 1.13. Required version of terraform is at least 0.12.
31
-
32
22
On MacOS X, you can install GoLang through `brew install go`, on Debian-based Linux, you can install it by `sudo apt-get install golang -y`.
33
23
34
24
```bash
@@ -41,6 +31,18 @@ Most likely, `terraform init -upgrade -verify-plugins=false -lock=false` would b
41
31
42
32
## Developing provider
43
33
34
+
In order to simplify development workflow, you should use [dev_overrides](https://www.terraform.io/cli/config/config-file#development-overrides-for-provider-developers) section in your `~/.terraformrc` file. Please run `make build` and replace "provider-binary" with the path to `terraform-provider-databricks` executable in your current working directory:
35
+
36
+
```
37
+
$ cat ~/.terraformrc
38
+
provider_installation {
39
+
dev_overrides {
40
+
"databrickslabs/databricks" = "provider-binary"
41
+
}
42
+
direct {}
43
+
}
44
+
```
45
+
44
46
After installing necessary software for building provider from sources, you should install `staticcheck` and `gotestsum` in order to run `make test`.
45
47
46
48
Make sure you have `$GOPATH/bin` in your `$PATH`:
@@ -63,39 +65,11 @@ Installing `goimports`:
63
65
go get golang.org/x/tools/cmd/goimports
64
66
```
65
67
66
-
After this, you should be able to run `make test`.
67
-
68
-
## Developing with Visual Studio Code Devcontainers
69
-
70
-
This project has configuration for working with [Visual Studio Code Devcontainers](https://code.visualstudio.com/docs/remote/containers) - this allows you to containerise your development prerequisites (e.g. golang, terraform). To use this you will need [Visual Studio Code](https://code.visualstudio.com/) and [Docker](https://www.docker.com/products/docker-desktop).
71
-
72
-
To get started, clone this repo and open the folder with Visual Studio Code. If you don't have the [Remote Development extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) then you should be prompted to install it.
73
-
74
-
Once the folder is loaded and the extension is installed you should be prompted to re-open the folder in a devcontainer. This will built and run the container image with the correct tools (and versions) ready to start working on and building the code. The in-built terminal will launch a shell inside the container for running `make` commands etc.
75
-
76
-
See the docs for more details on working with [devcontainers](https://code.visualstudio.com/docs/remote/containers).
77
-
78
-
## Building and Installing with Docker
68
+
After this, you should be able to run `make coverage` to run the tests and see the coverage.
79
69
80
-
To install and build the code if you dont want to install golang, terraform, etc. All you need is docker and git.
81
-
82
-
First make sure you clone the repository and you are in the directory.
83
-
84
-
Then build the docker image with this command:
85
-
86
-
```bash
87
-
$ docker build -t databricks-terraform .
88
-
```
70
+
## Debugging
89
71
90
-
Then run the execute the terraform binary via the following command and volume mount. Make sure that you are in the directory
91
-
with the terraform code. The following command you can execute the following commands and additional ones as part of
92
-
the terraform binary.
93
-
94
-
```bash
95
-
$ docker run -it -v $(pwd):/workpace -w /workpace databricks-terraform init
96
-
$ docker run -it -v $(pwd):/workpace -w /workpace databricks-terraform plan
97
-
$ docker run -it -v $(pwd):/workpace -w /workpace databricks-terraform apply
98
-
```
72
+
**TF_LOG=DEBUG terraform apply** allows you to see the internal logs from `terraform apply`.
99
73
100
74
## Adding a new resource
101
75
@@ -125,7 +99,7 @@ Some interesting points to note here:
125
99
*`default:X` to set a default value for a field
126
100
*`max_items:N` to set the maximum number of items for a multi-valued parameter
127
101
*`slice_set` to indicate that a the parameter should accept a set instead of a list
128
-
* Do not use bare references to structs in the model; rather, use pointers to structs. Maps and slices are permitted, as well as the following primitive types: int, int32, int64, float64, bool, string.
102
+
* Do not use bare references to structs in the model; rather, use pointers to structs. Maps and slices are permitted, as well as the following primitive types: int, int32, int64, float64, bool, string.
129
103
See `typeToSchema` in `common/reflect_resource.go` for the up-to-date list of all supported field types and values for the `tf` tag.
130
104
131
105
*Define the Terraform schema.* This is made easy for you by the `StructToSchema` method in the `common` package, which converts your struct automatically to a Terraform schema, accepting also a function allowing the user to post-process the automatically generated schema, if needed.
Please use makefile for linting. If you run `staticcheck` by itself it will fail due to different tags containing same functions.
298
268
So please run `make lint` instead.
299
269
300
-
## Unit testing resources
301
-
302
-
Eventually, all of resources would be automatically checked for a unit test presence. `TestGenerateTestCodeStubs` is going to fail, when resource has certain test cases missing. Until all existing resources have tests, you can generate stub code, which will be logged to stdout by changing these lines of `generate_test.go` with name of resource you're creating:
303
-
304
-
```go
305
-
forname, resource:=range p.ResourcesMap {
306
-
if name != "databricks_user" {
307
-
continue
308
-
}
309
-
//...
310
-
```
311
-
312
-
In order to unit test a resource, which runs fast and could be included in code coverage, one should use `ResourceTester`, that launches embedded HTTP server with `HTTPFixture`'s containing all calls that should have been made in given scenario. Some may argue that this is not a pure unit test, because it creates a side effect in form of embedded server, though it's always on different random port, making it possible to execute these tests in parallel. Therefore comments about non-pure unit tests will be ignored, if they use `ResourceTester` helper.
Terraform SDK provides `randomName:= acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)` for convenient random names generation.
270
+
## Developing with Visual Studio Code Devcontainers
382
271
383
-
## Integration Testing
272
+
This project has configuration for working with [Visual Studio Code Devcontainers](https://code.visualstudio.com/docs/remote/containers) - this allows you to containerise your development prerequisites (e.g. golang, terraform). To use this you will need [Visual Studio Code](https://code.visualstudio.com/) and [Docker](https://www.docker.com/products/docker-desktop).
384
273
385
-
Currently Databricks supports two cloud providers `azure` and `aws` thus integration testing with the correct cloud service provider is
386
-
crucial for making sure that the provider behaves as expected on all supported clouds. Please read [dedicated instructions](scripts/README.md) for details.
274
+
To get started, clone this repo and open the folder with Visual Studio Code. If you don't have the [Remote Development extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) then you should be prompted to install it.
387
275
388
-
## Pre-release procedure
276
+
Once the folder is loaded and the extension is installed you should be prompted to re-open the folder in a devcontainer. This will built and run the container image with the correct tools (and versions) ready to start working on and building the code. The in-built terminal will launch a shell inside the container for running `make` commands etc.
389
277
390
-
1. `make test-azure`
391
-
2. `make test-mws` if MWS related code changed given release.
392
-
3. Create release notes.
393
-
4. Perfrom backwards-compatibility checks and make proper notes.
278
+
See the docs for more details on working with [devcontainers](https://code.visualstudio.com/docs/remote/containers).
0 commit comments