-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Import kypo library from separate repository * Sort imports * Pass context structure to kypo client library * Add timeouts to create sandbox_allocation_unit_resource * Generate documentation * Implement timeouts for sandbox_allocation_unit_resource read, update and delete * Update documentation * Generate documentation * Restore docs/guides on go generate * Update timeouts default to no timeout * Update error handling from kypo client * Extract allocation request list plan modifier * Add poll times to sandbox allocation unit * Generate documentation * Handle ErrNotFound properly in Delete methods * Move provider tests to a separate package * Update README * Delete unused CHANGELOG * Add License information * Add retry_count to provider configuration * Generate documentation * Bump dependencies * Upgrade to Go 1.21
- Loading branch information
Showing
42 changed files
with
752 additions
and
1,849 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,51 @@ | ||
# Terraform KYPO Provider | ||
|
||
This [KYPO Provider]() allows [Terraform](https://www.terraform.io/) to manage [KYPO CRP](https://crp.kypo.muni.cz/) resources. | ||
Terraform provider for KYPO allows [Terraform](https://www.terraform.io/) to manage [KYPO CRP](https://crp.kypo.muni.cz/) resources. | ||
|
||
**This Terraform provider is in early development and not intended for use yet. Documentation is missing and breaking changes will occur.** | ||
See documentation at the [Terraform Registry](https://registry.terraform.io/providers/vydrazde/kypo/latest/docs). | ||
|
||
## Example Usage | ||
|
||
## Requirements | ||
|
||
- [Terraform](https://www.terraform.io/downloads.html) >= 1.0 | ||
- [Go](https://golang.org/doc/install) >= 1.18 | ||
|
||
## Building The Provider | ||
|
||
1. Clone the repository | ||
2. Enter the repository directory | ||
3. Install dependencies using the Go `mod tidy` command: | ||
```shell | ||
go mod tidy | ||
``` | ||
|
||
4. Build the provider using the Go `install` command: | ||
|
||
```shell | ||
go install | ||
``` | ||
|
||
## Using the provider | ||
|
||
1. Find the `GOBIN` path where Go installs your binaries. Your path may vary depending on how your Go environment variables are configured. | ||
```shell | ||
go env GOBIN | ||
``` | ||
If the `GOBIN` go environment variable is not set, use the default path, `/home/<Username>/go/bin`. | ||
|
||
2. Create a new file called `.terraformrc` in the root directory (`~`), then add the `dev_overrides` block below. | ||
Change the `<PATH>` to the value returned from the `echo $GOBIN` command above. | ||
``` | ||
provider_installation { | ||
dev_overrides { | ||
"registry.terraform.io/vydrazde/kypo" = "<PATH>" | ||
```terraform | ||
terraform { | ||
required_providers { | ||
kypo = { | ||
source = "vydrazde/kypo" | ||
version = "0.3.1" | ||
} | ||
} | ||
# For all other providers, install them directly from their origin provider | ||
# registries as normal. If you omit this, Terraform will _only_ use | ||
# the dev_overrides block, and so no other providers will be available. | ||
direct {} | ||
} | ||
``` | ||
3. Set up your provider configuration. You can either copy the `examples/provider/provider.tf` file to a folder of one of the | ||
other `examples` and modify it, or fill the environment variables `KYPO_ENDPOINT`, `KYPO_CLIENT_ID`, `KYPO_USERNAME` and `KYPO_PASSWORD`. | ||
|
||
4. Now you can use one of the examples in the `examples` directory and run | ||
```shell | ||
terraform plan | ||
``` | ||
|
||
## Adding Dependencies | ||
provider "kypo" { | ||
endpoint = "https://your.kypo.ex" # Or use KYPO_ENDPOINT env var | ||
client_id = "***" # Or use KYPO_CLIENT_ID env var | ||
username = "user" # Or use KYPO_USERNAME env var | ||
password = "***" # Or use KYPO_PASSWORD env var | ||
} | ||
This provider uses [Go modules](https://github.com/golang/go/wiki/Modules). | ||
Please see the Go documentation for the most up-to-date information about using Go modules. | ||
resource "kypo_sandbox_definition" "example" { | ||
url = "[email protected]:muni-kypo-trainings/games/junior-hacker.git" | ||
rev = "master" | ||
} | ||
To add a new dependency `github.com/author/dependency` to your Terraform provider: | ||
resource "kypo_sandbox_pool" "example" { | ||
definition = { | ||
id = kypo_sandbox_definition.example.id | ||
} | ||
max_size = 1 | ||
} | ||
```shell | ||
go get github.com/author/dependency | ||
go mod tidy | ||
resource "kypo_sandbox_allocation_unit" "example" { | ||
pool_id = kypo_sandbox_pool.example.id | ||
} | ||
``` | ||
|
||
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](http://www.golang.org) installed on your machine (see [Requirements](#requirements) above). | ||
|
||
To compile the provider, run `go install`. This will build the provider and put the provider binary in the `$GOPATH/bin` directory. | ||
# License | ||
Parts of the Source Code, namely [GNUmakefile](./GNUmakefile), [.golangci.yml](./.golangci.yml), [.goreleaser.yml](./.goreleaser.yml), | ||
[tools/tools.go](./tools/tools.go), | ||
[internal/validators/timeduration.go](./internal/validators/timeduration.go) and [internal/validators/timeduration_test.go](./internal/validators/timeduration_test.go), | ||
is subject to the terms of the Mozilla Public License, v. 2.0. You can obtain the license at https://mozilla.org/MPL/2.0/. | ||
The Source Code was used from [HashiCorp terraform-provider-scaffolding-framework](https://github.com/hashicorp/terraform-provider-scaffolding-framework) and [HashiCorp terraform-plugin-framework-timeouts](https://github.com/hashicorp/terraform-plugin-framework-timeouts) repositories. | ||
|
||
To generate or update documentation, run `go generate`. | ||
The rest of the Source Code is subject to the [MIT License](./LICENSE). | ||
|
||
In order to run the full suite of Acceptance tests, run `make testacc`. | ||
|
||
*Note:* Acceptance tests create real resources, and often cost money to run. | ||
|
||
```shell | ||
make testacc | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
page_title: "How to get client_id of KYPO CRP" | ||
--- | ||
[client_id](https://registry.terraform.io/providers/vydrazde/kypo/latest/docs#client_id) is one of the parameters for using the Terraform KYPO provider. As of KYPO version `23.12`, the default value `KYPO-Client` should work, for older KYPO instances or cases where the `client_id` has been changed follow this guide. | ||
|
||
To get the `client_id` value for your KYPO CRP instance, visit the homepage of the KYPO instance in an anonymous window and open browser developer tools. | ||
|
||
![image](https://github.com/vydrazde/terraform-provider-kypo/assets/80331839/60c9f152-e1c7-49e9-a386-80634b1f633a) | ||
|
||
Click the `Login with local issuer` or `Login with local Keycloak` button and see one of the first network requests, where you will see the `client_id` among request headers. | ||
|
||
![screenshot](https://github.com/vydrazde/terraform-provider-kypo/assets/80331839/a6a015d4-1e25-4aaa-895f-e265a171732f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.