Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ekasin committed Jun 9, 2021
0 parents commit bbc0f33
Show file tree
Hide file tree
Showing 18 changed files with 1,916 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This GitHub action can publish assets for release when a tag is created.
# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0).
#
# This uses an action (hashicorp/ghaction-import-gpg) that assumes you set your
# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE`
# secret. If you would rather own your own GPG handling, please fork this action
# or use an alternative one for key handling.
#
# You will need to pass the `--batch` flag to `gpg` in your signing step
# in `goreleaser` to indicate this is being used in a non-interactive mode.
#
name: release
on:
push:
tags:
- 'v*'
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Unshallow
run: git fetch --prune --unshallow
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.14
-
name: Import GPG key
id: import_gpg
uses: hashicorp/[email protected]
env:
# These secrets will need to be configured for the repository:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.PASSPHRASE }}
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
# GitHub sets this automatically
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54 changes: 54 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Visit https://goreleaser.com for documentation on how to customize this
# behavior.
before:
hooks:
# this is just an example and not a requirement for provider building/publishing
- go mod tidy
builds:
- env:
# goreleaser does not work with CGO, it could also complicate
# usage by users in CI/CD systems like Terraform Cloud where
# they are unable to install libraries.
- CGO_ENABLED=0
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath
ldflags:
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
goos:
- freebsd
- windows
- linux
- darwin
goarch:
- amd64
- '386'
- arm
- arm64
ignore:
- goos: darwin
goarch: '386'
binary: '{{ .ProjectName }}_v{{ .Version }}'
archives:
- format: zip
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
checksum:
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
algorithm: sha256
signs:
- artifacts: checksum
args:
# if you are using this in a GitHub action or some other automated pipeline, you
# need to pass the batch flag to indicate its not interactive.
- "--batch"
- "--local-user"
- "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key
- "--output"
- "${signature}"
- "--detach-sign"
- "${artifact}"
release:
# If you want to manually examine the release before its live, uncomment this line:
# draft: true
changelog:
skip: true
140 changes: 140 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# Terraform Docusign Provider

This terraform provider allows to perform Create ,Read ,Update, Delete and Import docusign User(s).


## Requirements

* [Go](https://golang.org/doc/install) 1.16 <br>
* [Terraform](https://www.terraform.io/downloads.html) 0.13.x <br/>
* [Docusign](https://developers.docusign.com/) Developers account


## Docusign Setup
:heavy_exclamation_mark: [IMPORTANT] : This provider can be successfully tested on any dcosign developer account. <br><br>

1. Create a docusign account with your required subscription (PRO Plan/Business Account). (https://www.docusign.com/products-and-pricing)<br>
2. Sign in to the docusign account (https://developers.docusign.com/)<br>
3. Go to [Apps and Keys](https://admindemo.docusign.com/apps-and-keys)<br>
4. Click on `Add App and integration key`. For our purpose we need to create an Auth Token. <br>
5. Follow this [Generate Auth Token](https://developers.docusign.com/platform/auth/authcode/authcode-get-token/) website to make an app. <br>
This app will provide us with the token and accountid which will be needed to configure our provider and make request. <br>


## Initialise Docusign Provider in local machine
1. Clone the repository to $GOPATH/src/github.com/docusign/terraform-provider-docusign <br>
2. Add the Refresh token generted in Docusign App to respective fields in `main.tf` <br>
3. Run the following command :
```golang
go mod init terraform-provider-docusign
go mod tidy
```
4. Run `go mod vendor` to create a vendor directory that contains all the provider's dependencies. <br>

## Managing plugins for terraform
1. Run the following command to create a vendor subdirectory which will comprise of all provider dependencies. <br>
```
~/.terraform.d/plugins/${host_name}/${namespace}/${type}/${version}/${target}
```
Command:
```bash
mkdir -p ~/.terraform.d/plugins/hashicorp.com/edu/docusign/0.2.0/[OS_ARCH]
```
For eg. `mkdir -p ~/.terraform.d/plugins/hashicorp.com/edu/docusign/0.2.0/windows_amd64`<br>

2. Run `go build -o terraform-provider-docusign.exe`. This will save the binary (`.exe`) file in the main/root directory. <br>
3. Run this command to move this binary file to appropriate location.
```
move terraform-provider-docusign.exe %APPDATA%\terraform.d\plugins\hashicorp.com\edu\docusign\0.2.0\[OS_ARCH]
```
Otherwise you can manually move the file from current directory to destination directory.<br>


[OR]

1. Download required binaries <br>
2. move binary `~/.terraform.d/plugins/[architecture name]/`


## Working with terraform

#### Create User
1. Add the user email, first name, last name, status, type in the respective field in `main.tf`
2. Initialize the terraform provider `terraform init`
3. Check the changes applicable using `terraform plan` and apply using `terraform apply`
4. You will see that a user has been successfully created and an account activation mail has been sent to the user.
5. Activate the account using the link provided in the mail.

#### Update the user
Update the data of the user in the `main.tf` file and apply using `terraform apply`

#### Read the User Data
Add data and output blocks in the `main.tf` file and run `terraform plan` to read user data

#### Activate/Deactivate the user
No API for activate,deactive.

#### Delete the user
Delete the resource block of the particular user from `main.tf` file and run `terraform apply`.

#### Import a User Data
1. Write manually a resource configuration block for the User in `main.tf`, to which the imported object will be mapped.
2. Run the command `terraform import docusign_user.user1 [EMAIL_ID]`
3. Check for the attributes in the `.tfstate` file and fill them accordingly in resource block.


### Testing the Provider
1. Navigate to the test file directory.
2. Run command `go test` . This command will give combined test result for the execution or errors if any failure occur.
3. If you want to see test result of each test function individually while running test in a single go, run command `go test -v`
4. To check test cover run `go test -cover`


## Example Usage
```terraform
terraform {
required_providers {
docusign = {
version = "0.2"
source = "hashicorp.com/edu/docusign"
}
}
}
provider "docusign" {
secretkey = ""
integrationkey = ""
refresh token = ""
accountid = ""
}
resource "docusign_user" "user1" {
email = "[EMAIL_ID]"
firstname = "[USER_FIRST_NAME]"
lastname = "[USER_LAST_NAME]"
jobtitle = "[USER_JOB_TITLE]"
company = "[USER_COMPANY]"
}
data "docusign_user" "user1" {
email = "[EMAIL_ID]"
}
output "user1" {
value = data.docusign_user.user1
}
```


## Argument Reference

* `secretkey`(Required,string) - The Docusing secret Key from created application
* `integrationkey`(Required,string) - The Docusing integration Key from created application
* `refreshtoken`(Required,string) - refresh token for generation of new access token.
* `accountid`(Required,string) - Account id of the Admin.
* `first_name`(Required,string) - First name of the User.
* `last_name`(Required,string) - Last Name / Family Name / Surname of the User.
* `job_title`(Optional,string) - Job title of the particular user.
* `company`(Optional,string) - Company of the particular user.
* `permissionprofilename`(Computed,string) - profile of the particular user ie.(DS Admin,DS Sender,DS Viewer)Can be managed only through docusign dashboard.

Loading

0 comments on commit bbc0f33

Please sign in to comment.