Skip to content

chmurakrajowa/terraform-provider-ochk

Repository files navigation

OChK Terraform Provider

Test

This repository contains Terraform Provider for managing cloud resources in OChK.

Requirements

  • Terraform 1.3.7+
  • Go 1.18+ (to build the provider plugin)

Building The Provider

Clone the repository.

$ git clone git@github.com:chmurakrajowa/ochk-terraform-provider.git

Enter the provider directory and build the provider. Output binary will be placed examples directory.

$ cd ochk-terraform-provider
$ go build -o examples/ ./...

Using the provider

Provide connection details in terraform.tfvars file.

$ cd examples
$ terraform init
$ terraform apply

Developing the Provider


Update/generate API client for Platforma OChK V3.

  1. To generate new client from swagger, you need to download new swagger definition file in json format from https://pckproxy-at.ochk.pilot if you are working on AUTOTEST enviroment.

Swagger.json file is available at: https://pckproxy-at.ochk.pilot/swagger/v1/swagger.json

  1. Place downloaded file in location ./api/v3/swagger.json
  2. Run script:
./tools/swagger_gen.sh
  1. New proxy client will be generated. Do not modify any file under /api/v3/ location

If you wish to work on the provider, you'll first need Go installed on your machine (version 1.13+ is required).

To compile the provider, run go build ./.... This will build the provider and put the provider binary in the current directory.

$ go build ./...

In order to unit test the provider, you can simply run go test ./....

$ go test ./...

In order to run the full suite of Acceptance tests you need to provide connection details in environment variables. Also enable running Acceptance tests by setting TF_ACC=true.

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

$ export TF_ACC=true
$ export TF_VAR_host=host
$ export TF_VAR_platform=platform
$ export TF_VAR_api_key=api_key
$ export TF_VAR_platform_type=VMWARE / OPENSTACK

$ go test ./...