
Prerequisites
- Install Go 1.21 or later
- Install Terraform v0.13.x or later
- Install gosec (for security scanning):
curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.18.2
Development Setup
- Clone this repository
- Set up your OneLogin API credentials:
export ONELOGIN_CLIENT_ID=<your client id>
export ONELOGIN_CLIENT_SECRET=<your client secret>
export ONELOGIN_OAPI_URL=<the api url for your region>
- Build and install the provider locally:
make sideload
Example Provider Configuration
terraform {
required_providers {
onelogin = {
source = "onelogin.com/onelogin/onelogin"
version = "0.1.10"
}
}
}
provider "onelogin" {
# Configuration options
}
Development Workflow
Adding a New Resource
- Add the service to the OneLogin SDK (see
AppsService for example)
- Define the resource in
onelogin/provider.go
- Create resource files:
onelogin/resource_onelogin_<resource>.go
onelogin/resource_onelogin<resource>_test.go
- Add schema definitions in
ol_schemas/<resource>/<sub-resource>
- Add examples in
examples/
- Add documentation in
docs/resources/
Testing
- Run unit tests:
make test
- Run security checks:
make secure
- Run acceptance tests:
make testacc (requires API credentials)
- Debug with:
export TF_LOG=trace
Helpful Commands
# Build and install locally
make sideload
# Clean terraform state
make clean-terraform
# Run tests (skips acceptance tests)
make test
# Run security checks
make secure
Release Process
- Create PR against
develop
- After approval and CI passing, merge to
develop
- Create release branch
vX.X.XX
- After testing, merge to
master and develop
- Tag the release
- Push changes and tags
- Verify release artifacts in GitHub
Terraform enables declarative infrastructure management using HashiCorp Configuration Language (HCL). It tracks the desired state in .tf files and the current state in .tfstate files.
Basic commands:
# Initialize working directory
terraform init
# Preview changes
terraform plan
# Apply changes
terraform apply
Dependency Management
We use go mod for dependency management.
To add a package:
go get -u "package-name"
To re-install dependencies for this project:
rm go.sum
go mod download
To update dependencies for this project:
go mod -u ./...
Helpful Makefile Commands
testacc runs acceptance tests (actually creates resources in OL then cleans them up)
make testacc
sideload builds and sideloads the provider for local dev/testing
make sideload
clean-terraform reset terraform state in the local folder
make clean-terraform
test runs unit tests (non-acceptance and no real requests made) and applies coverage badge
make test
secure runs gosec code analysis to warn about possible exploits specific to go
make secure