Skip to content

Commit

Permalink
Merge pull request #10 from trocco-io/add-user-api
Browse files Browse the repository at this point in the history
Add User Resource
  • Loading branch information
yosuke-oka authored Nov 18, 2024
2 parents b959c8b + 9eed13e commit 7a40ba4
Show file tree
Hide file tree
Showing 18 changed files with 1,145 additions and 54 deletions.
34 changes: 16 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,34 +54,32 @@ jobs:
git diff --compact-summary --exit-code || \
(echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./...' command and commit."; exit 1)
# Run acceptance tests in a matrix with Terraform CLI versions
test:
name: Terraform Provider Acceptance Tests
name: Tests
needs: build
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
# list whatever Terraform versions here you would like to support
terraform:
- "1.0.*"
- "1.1.*"
- "1.2.*"
- "1.3.*"
- "1.4.*"
# enable strategy when run acceptance tests
# strategy:
# fail-fast: false
# matrix:
# # list whatever Terraform versions here you would like to support
# terraform:
# - "1.0.*"
# - "1.1.*"
# - "1.2.*"
# - "1.3.*"
# - "1.4.*"
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version-file: "go.mod"
cache: true
- uses: hashicorp/setup-terraform@651471c36a6092792c552e8b1bef71e592b462d8 # v3.1.1
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false
# with:
# terraform_version: ${{ matrix.terraform }}
# terraform_wrapper: false
- run: go mod download
- env:
TF_ACC: "1"
run: go test -v -cover ./internal/*
- run: go test -v -cover ./internal/*
timeout-minutes: 10
49 changes: 49 additions & 0 deletions docs/resources/user.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "trocco_user Resource - trocco"
subcategory: ""
description: |-
Provides a TROCCO user resource.
---

# trocco_user (Resource)

Provides a TROCCO user resource.

## Example Usage

```terraform
resource "trocco_user" "example" {
email = "trocco@example.com"
password = "Jb1p4f1uuC"
role = "member"
can_use_audit_log = false
is_restricted_connection_modify = false
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `email` (String) The email of the user.
- `role` (String) The role of the user. Valid value is `super_admin`, `admin`, or `member`.

### Optional

- `can_use_audit_log` (Boolean) Whether the user can use the audit log.
- `is_restricted_connection_modify` (Boolean) Whether the user is restricted to modify connections.
- `password` (String, Sensitive) The password of the user. It must be at least 8 characters long and contain at least one letter and one number. It is required when creating a new user but optional during updates.

### Read-Only

- `id` (Number) The ID of the user.

## Import

Import is supported using the following syntax:

```shell
terraform import trocco_user.example <user_id>
```
1 change: 1 addition & 0 deletions examples/resources/trocco_user/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import trocco_user.example <user_id>
7 changes: 7 additions & 0 deletions examples/resources/trocco_user/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resource "trocco_user" "example" {
email = "trocco@example.com"
password = "Jb1p4f1uuC"
role = "member"
can_use_audit_log = false
is_restricted_connection_modify = false
}
30 changes: 24 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@ require (
github.com/hashicorp/terraform-plugin-go v0.23.0
)

require (
github.com/agext/levenshtein v1.2.2 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
github.com/hashicorp/hcl/v2 v2.21.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/samber/lo v1.47.0 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/appengine v1.6.8 // indirect
)

require (
github.com/BurntSushi/toml v1.2.1 // indirect
github.com/Kunde21/markdownfmt/v3 v3.1.0 // indirect
Expand All @@ -33,10 +50,11 @@ require (
github.com/hashicorp/go-plugin v1.6.0 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/hashicorp/hc-install v0.7.0 // indirect
github.com/hashicorp/hc-install v0.8.0 // indirect
github.com/hashicorp/terraform-exec v0.21.0 // indirect
github.com/hashicorp/terraform-json v0.22.1 // indirect
github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect
github.com/hashicorp/terraform-plugin-testing v1.10.0
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
Expand All @@ -56,14 +74,14 @@ require (
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/yuin/goldmark v1.7.1 // indirect
github.com/yuin/goldmark-meta v1.1.0 // indirect
github.com/zclconf/go-cty v1.14.4 // indirect
github.com/zclconf/go-cty v1.15.0 // indirect
go.abhg.dev/goldmark/frontmatter v0.2.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/mod v0.19.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/sys v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.34.0 // indirect
Expand Down
Loading

0 comments on commit 7a40ba4

Please sign in to comment.