Skip to content

Commit

Permalink
Add support for resource and datasource gocd_role
Browse files Browse the repository at this point in the history
Bumping gocd-sdk-go version to v0.1.2
  • Loading branch information
nikhilsbhat committed Apr 28, 2023
1 parent 1d72037 commit ad8caf4
Show file tree
Hide file tree
Showing 16 changed files with 692 additions and 20 deletions.
53 changes: 53 additions & 0 deletions docs/data-sources/role.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "gocd_role Data Source - terraform-provider-gocd"
subcategory: ""
description: |-
---

# gocd_role (Data Source)
Fetches the role information of specified role from GoCD by interacting with GoCD roles [api](https://api.gocd.org/current/#roles).

## Example Usage
```terraform
data "gocd_role" "sample" {
name = "sample"
}
```


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

### Required

- `name` (String) The name of the role.

### Optional

- `auth_config_id` (String) The authorization configuration identifier.
- `etag` (String) Etag used to track the role
- `policy` (List of Map of String) Policy is fine-grained permissions attached to the users belonging to the current role.
- `properties` (Block List) Attributes are used to describes the configuration for gocd role or plugin role. (see [below for nested schema](#nestedblock--properties))
- `type` (String) Type of the role. Use GoCD to create core role and plugin to create plugin role.
- `users` (List of String) The list of users belongs to the role.

### Read-Only

- `id` (String) The ID of this resource.

<a id="nestedblock--properties"></a>
### Nested Schema for `properties`

Required:

- `key` (String) the name of the property key.

Optional:

- `encrypted_value` (String) The encrypted value of the property
- `is_secure` (Boolean) Specify whether the given property is secure or not. If true and encrypted_value is not specified, GoCD will store the value in encrypted format.
- `value` (String) The value of the property


91 changes: 91 additions & 0 deletions docs/resources/role.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "gocd_role Resource - terraform-provider-gocd"
subcategory: ""
description: |-
---

# gocd_role (Resource)
Creates role in GoCD with all below passed parameters by interacting with GoCD roles [api](https://api.gocd.org/current/#roles).

## Example Usage
```terraform
# For role type gocd
resource "gocd_role" "sample" {
name = "sample"
type = "gocd"
users = ["nikhil"]
policy = [{
"permission" : "allow",
"action" : "administer",
"type" : "*",
"resource" : "*"
}]
}
# For role type plugin
resource "gocd_role" "sample_ldap" {
name = "sample-ldap"
type = "plugin"
auth_config_id = "ldap-config"
policy = [{
"permission" : "allow",
"action" : "administer",
"type" : "*",
"resource" : "*"
}]
properties {
key = "UserGroupMembershipAttribute"
value = "testing"
}
properties {
key = "GroupIdentifiers"
value = "CN=opts,OU=Groups,OU=TESTCOM,DC=TESTCOM,DC=COM"
}
properties {
key = "GroupSearchBases"
value = "OU=Groups,OU=TESTCOM,DC=TESTCOM,DC=COM"
}
properties {
key = "GroupMembershipFilter"
value = "(&(member={dn})(cn=opts))"
}
}
```


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

### Required

- `name` (String) The name of the role.
- `policy` (List of Map of String) Policy is fine-grained permissions attached to the users belonging to the current role.
- `type` (String) Type of the role. Use GoCD to create core role and plugin to create plugin role.

### Optional

- `auth_config_id` (String) The authorization configuration identifier.
- `etag` (String) Etag used to track the role
- `properties` (Block Set) The list of configuration properties that represent the configuration of the profile. (see [below for nested schema](#nestedblock--properties))
- `users` (List of String) The list of users belongs to the role.

### Read-Only

- `id` (String) The ID of this resource.

<a id="nestedblock--properties"></a>
### Nested Schema for `properties`

Required:

- `key` (String) the name of the property key.

Optional:

- `encrypted_value` (String) The encrypted value of the property
- `is_secure` (Boolean) Specify whether the given property is secure or not. If true and encrypted_value is not specified, GoCD will store the value in encrypted format.
- `value` (String) The value of the property


8 changes: 8 additions & 0 deletions examples/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,12 @@ output "helm_drift" {

output "docker_artifact_store" {
value = data.gocd_artifact_store.docker.properties
}

output "sample_role" {
value = data.gocd_role.sample.users
}

output "sample_ldap_role" {
value = data.gocd_role.sample_ldap.properties
}
48 changes: 48 additions & 0 deletions examples/roles.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
resource "gocd_role" "sample" {
name = "sample"
type = "gocd"
users = ["nikhil"]
policy = [{
"permission" : "allow",
"action" : "administer",
"type" : "*",
"resource" : "*"
}]
}

resource "gocd_role" "sample_ldap" {
name = "sample-ldap"
type = "plugin"
auth_config_id = "ldap-config"
policy = [{
"permission" : "allow",
"action" : "administer",
"type" : "*",
"resource" : "*"
}]
properties {
key = "UserGroupMembershipAttribute"
value = "testing"
}
properties {
key = "GroupIdentifiers"
value = "CN=opts,OU=Groups,OU=TESTCOM,DC=TESTCOM,DC=COM"
}
properties {
key = "GroupSearchBases"
value = "OU=Groups,OU=TESTCOM,DC=TESTCOM,DC=COM"
}
properties {
key = "GroupMembershipFilter"
value = "(&(member={dn})(cn=opts))"
}
}


data "gocd_role" "sample" {
name = gocd_role.sample.id
}

data "gocd_role" "sample_ldap" {
name = gocd_role.sample_ldap.id
}
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1
github.com/mitchellh/mapstructure v1.5.0
github.com/nikhilsbhat/gocd-cli v0.1.0
github.com/nikhilsbhat/gocd-sdk-go v0.1.2-0.20230329165757-c14e7e1af7ef
github.com/nikhilsbhat/gocd-sdk-go v0.1.2
github.com/sirupsen/logrus v1.9.0
github.com/spf13/cast v1.5.0
gopkg.in/yaml.v3 v3.0.1
Expand Down Expand Up @@ -68,9 +68,9 @@ require (
github.com/vmihailenco/tagparser v0.1.1 // indirect
github.com/zclconf/go-cty v1.12.1 // indirect
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect
google.golang.org/grpc v1.50.1 // indirect
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nikhilsbhat/gocd-cli v0.1.0 h1:k7myHhSy6tuPZm0dO3RBVjAqBZFQh4XalQZvxpd2VfM=
github.com/nikhilsbhat/gocd-cli v0.1.0/go.mod h1:gfczP6M7WOOXIEc9QdAJ7R846+3CfQsdSEXC44fg3Ng=
github.com/nikhilsbhat/gocd-sdk-go v0.1.2-0.20230329165757-c14e7e1af7ef h1:nS5OeMuKV0nEGU1roq/XJV0XSc+7fLX3bjvAaoREq9I=
github.com/nikhilsbhat/gocd-sdk-go v0.1.2-0.20230329165757-c14e7e1af7ef/go.mod h1:3XwSMe/nFH/I0Kt2+ToKKWFyD6yvJb4HaoP0dBHytY4=
github.com/nikhilsbhat/gocd-sdk-go v0.1.2 h1:O84UWArpzc4CRDmjUYgQzkfWYRIrlm9rW9Z/Kv+8mNs=
github.com/nikhilsbhat/gocd-sdk-go v0.1.2/go.mod h1:qco6B1kpMYtTkWqNhxjDajjQBYKrab7G52SFAvuhmT0=
github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce h1:RPclfga2SEJmgMmz2k+Mg7cowZ8yv4Trqw9UsJby758=
github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
Expand Down Expand Up @@ -297,8 +297,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down Expand Up @@ -329,16 +329,16 @@ golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
Expand Down
Loading

0 comments on commit ad8caf4

Please sign in to comment.