Skip to content

Commit

Permalink
V0.3.0 (#3)
Browse files Browse the repository at this point in the history
* use env variable for version

* add templates for registry release

* update deps and use tf sdk v2 instead

* use gsm v0.2.6's built-in feature to wait until drive is ready

* add drive restrictions

* add possible restrictions to example drive

* update version in example

* draft release

* dont run go mod tidy

* fix description

* add data types

* add setting to retry on specific HTTP errors

* remove a few comments

* add docs

* update example

* use go 1.16

* fix some lint issues

* add report card badge

* update dep
  • Loading branch information
hanneshayashi committed May 2, 2021
1 parent ba5cf0e commit 91c6173
Show file tree
Hide file tree
Showing 23 changed files with 841 additions and 327 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# 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.16
- 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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# terraform-provider-gdrive
A Terraform Provider for Google Drive

[![Go Report Card](https://goreportcard.com/badge/github.com/hanneshayashi/terraform-provider-gdrive)](https://goreportcard.com/report/github.com/hanneshayashi/terraform-provider-gdrive)

## Features
* Manage Shared Drives
* Manage Google Drive files (including file uploads)
Expand Down
1 change: 0 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash
APP_VERSION="0.2.0"
APP_NAME="terraform-provider-gdrive"
BINARY_NAME=${APP_NAME}_v${APP_VERSION}
VERSIONS=("win-amd64" "linux-amd64" "linux-arm64" "mac-amd64" "mac-arm64")
Expand Down
42 changes: 42 additions & 0 deletions docs/data-sources/drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "gdrive_drive Data Source - terraform-provider-gdrive"
subcategory: ""
description: |-
---

# gdrive_drive (Data Source)





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

### Required

- **drive_id** (String) ID of the Shared Drive

### Optional

- **id** (String) The ID of this resource.
- **use_domain_admin_access** (Boolean) Use domain admin access

### Read-Only

- **name** (String)
- **restrictions** (List of Object) (see [below for nested schema](#nestedatt--restrictions))

<a id="nestedatt--restrictions"></a>
### Nested Schema for `restrictions`

Read-Only:

- **admin_managed_restrictions** (Boolean)
- **copy_requires_writer_permission** (Boolean)
- **domain_users_only** (Boolean)
- **drive_members_only** (Boolean)


33 changes: 33 additions & 0 deletions docs/data-sources/file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "gdrive_file Data Source - terraform-provider-gdrive"
subcategory: ""
description: |-
---

# gdrive_file (Data Source)





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

### Required

- **file_id** (String) ID of the file

### Optional

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

### Read-Only

- **drive_id** (String)
- **mime_type** (String)
- **name** (String)
- **parent** (String)


35 changes: 35 additions & 0 deletions docs/data-sources/permission.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "gdrive_permission Data Source - terraform-provider-gdrive"
subcategory: ""
description: |-
---

# gdrive_permission (Data Source)





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

### Required

- **file_id** (String) ID of the file or Shared Drive
- **permission_id** (String) ID of the permission

### Optional

- **id** (String) The ID of this resource.
- **use_domain_admin_access** (Boolean) Use domain admin access

### Read-Only

- **domain** (String)
- **email_address** (String)
- **role** (String)
- **type** (String)


25 changes: 25 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "gdrive Provider"
subcategory: ""
description: |-
---

# gdrive Provider





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

### Optional

- **retry_on** (List of Number) A list of HTTP error codes you want the provider to retry on (e.g. 404).
- **service_account** (String) The email address of the Service Account you want to impersonate with Application Default Credentials (ADC).
Leave empty if you want to use the Service Account of a GCE instance directly.
- **service_account_key** (String) The path to a key file for your Service Account.
Leave empty if you want to use Application Default Credentials (ADC).
- **subject** (String) The email address of the Workspace user you want to impersonate with Domain Wide Delegation (DWD)
40 changes: 40 additions & 0 deletions docs/resources/drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "gdrive_drive Resource - terraform-provider-gdrive"
subcategory: ""
description: |-
---

# gdrive_drive (Resource)





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

### Required

- **name** (String) Name of the Shared Drive

### Optional

- **id** (String) The ID of this resource.
- **restrictions** (Block List, Max: 1) (see [below for nested schema](#nestedblock--restrictions))
- **use_domain_admin_access** (Boolean) Use domain admin access

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

Optional:

- **admin_managed_restrictions** (Boolean) Whether administrative privileges on this shared drive are required to modify restrictions
- **copy_requires_writer_permission** (Boolean) Whether the options to copy, print, or download files inside this shared drive, should be disabled for readers and commenters.
When this restriction is set to true, it will override the similarly named field to true for any file inside this shared drive
- **domain_users_only** (Boolean) Whether access to this shared drive and items inside this shared drive is restricted to users of the domain to which this shared drive belongs.
This restriction may be overridden by other sharing policies controlled outside of this shared drive
- **drive_members_only** (Boolean) Whether access to items inside this shared drive is restricted to its members


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

# gdrive_file (Resource)





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

### Required

- **mime_type** (String) MIME type
- **name** (String) name of the file / folder
- **parent** (String) fileId of the parent

### Optional

- **content** (String) path to a file to upload
- **drive_id** (String) driveId of the Shared Drive
- **id** (String) The ID of this resource.


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

# gdrive_permission (Resource)





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

### Required

- **file_id** (String) ID of the file or Shared Drive
- **role** (String) The role
- **type** (String) The type of the trustee. Can be 'user', 'domain', 'group' or 'anyone'

### Optional

- **domain** (String) The domain that should be granted access
- **email_address** (String) The email address of the trustee
- **email_message** (String) An optional email message that will be sent when the permission is created
- **id** (String) The ID of this resource.
- **send_notification_email** (Boolean) Wether to send a notfication email
- **use_domain_admin_access** (Boolean) Use domain admin access


10 changes: 9 additions & 1 deletion example/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
gdrive = {
source = "github.com/hanneshayashi/gdrive"
version = "0.2.0"
version = "0.3.0"
}
}
}
Expand All @@ -11,10 +11,18 @@ provider "gdrive" {
service_account_key = "/path/to/sa.json" # This is the Key file for your Service Account
# service_account = "[email protected]" # This is the email address of your Service Account. You can leave this empty on GCE, if you want to use the instance's account
subject = "[email protected]" # This is the user you want to impersonate with Domain Wide Delegation
# retry_on = [ 404 ] # Retry on specific HTTP error codes such as 404
}

resource "gdrive_drive" "example_drive" {
name = "terraform-1"

# restrictions {
# admin_managed_restrictions = true
# drive_members_only = true
# copy_requires_writer_permission = true
# domain_users_only = true
# }
}

resource "gdrive_file" "folder_1" {
Expand Down
Loading

0 comments on commit 91c6173

Please sign in to comment.