Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linter fixes on redshift schema group #43

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ terraform-provider-redshift
#Intellij
*.iml
.idea

# Don't include binaries in version control
dist/

goreleaser
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
86 changes: 86 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# CHANGELOG

## 1.0.0

- Don't include binaries in version control (Raymond Berg)
- Improve version tooling (Raymond Berg)
- Add support for terraform 0.12 (Raymond Berg)
- Merge pull request #1 from raymondberg/master (Raymond Berg)
- Linter fixes on redshift schema group (Raymond Berg)
- Fix property name (Orion Delwaterman)
- Remove copy/pasted comment (Orion Delwaterman)
- Add schema data source (Orion Delwaterman)
- Set passwords as sensitive (Orion Delwaterman)
- Change log.fatal to log.print (sam.corzine)
- fix location of thrift (Orion Delwaterman)
- chore: Update go import in main.go (frankfarrell)
- Restrict redshift_group_schema_privilege on system schemas (Ryan Carlson)
- Add support for granting access to system schemas (Ryan Carlson)
- Fix issues with schema level permissions (Ryan Carlson)
- Add support for managing schema GRANT for CREATE, USAGE (Ryan Carlson)
- Upgrade dependencies, switch from govendor to Go Modules (Jeppe Fihl-Pearson)
- chore: Fix typo in USER resource in readme (frankfarrell)
- fix grant all privilege redshift query (Mijail Gomez)


## v0.0.2

- chore: release version 0.0.2 (frankfarrell)
- chore: Add comment about md5 to readme (frankfarrell)
- Added validation for missing both password_disabled and password (Pawel Hajduk)
- Fixed user resource with disabled password (Pawel Hajduk)
- prettier gitter img (Stephen)
- Fix shabang (frankfarrell)
- Revert changes to resetPassword (Stephen Paulger)
- Golint warning 'don't use underscores' (Stephen Paulger)
- Fix golint warning 'should remove type'. (Stephen Paulger)
- Fix golint warning about if block (Stephen Paulger)
- Make error visible when user already exists (Stephen Paulger)
- chore: Add computed to terraform database owner property (frankfarrell)
- chore: Fix formatting issues (frankfarrell)
- chore: Update readme with badges and links to distributions (frankfarrell)
- chore: Include some distributions (frankfarrell)
- chore: Update readme (frankfarrell)
- chore: Add computed to owner of schema, resolves #12 (frankfarrell)
- chore: Update README with examples (frankfarrell)
- chore: Fix schema typo (frankfarrell)
- chore: Compilation errors (frankfarrell)
- feat: Group privilege delete (frankfarrell)
- feat: Group schema privileges update (frankfarrell)
- feat: Schame group privileges read, exists and create (frankfarrell)
- chore: Update README; add resource to provider (frankfarrell)
- feat: Schema resource (frankfarrell)
- feat: Drop all privileges from users and groups on delete (frankfarrell)
- chore: Added multiple databases to example (frankfarrell)
- Fail gracefully when db connection fails (Stephen Paulger)
- Don't return error when resource doesn't exist (Stephen Paulger)
- chore: Add Queryer interface for tx and db queries (frankfarrell)
- feat: Create DB outside of transaction (frankfarrell)
- feat: On drop user reassign owner of all its owned resources to client user (frankfarrell)
- chore: Return client config along with datase connection (frankfarrell)
- Removed return that prevented transaction being commited (Stephen Paulger)
- More formatting changes (Stephen Paulger)
- Alter error logging, removed use of log.Fatal (Stephen Paulger)
- Fix log message and DROP GROUP query (Stephen Paulger)
- Change database docs links to equivalent group links (Stephen Paulger)
- go fmt and other formatting changes (Stephen Paulger)
- Rename file resouce->resource (Stephen Paulger)
- chore: Added .gitattributes file (frankfarrell)
- Merge pull request #4 from stephenpaulger/feature/sslmode-option (frankfarrell)
- Add sslmode option to provider config (Stephen Paulger)
- doc: Update README (frankfarrell)
- chore: Placeholders for future resources (frankfarrell)
- feat: Multi query actions in transactions (frankfarrell)
- doc: Update readme (frankfarrell)
- chore: Add users to groups; improved logging (frankfarrell)
- chore: Fix issues in database resource with user id (frankfarrell)
- feat: Added redshift group resource (frankfarrell)
- chore: Added Redshift database resource (frankfarrell)
- chore: Update readme (frankfarrell)
- chore: Add example (frankfarrell)
- chore: Few minor fixes to make build work; sql connection params (frankfarrell)
- chore: Run govendor (frankfarrell)
- chore: Added travis.yml and various scripts (frankfarrell)
- chore: Fix compilation issues (frankfarrell)
- feat: Add Redshift user resource (frankfarrell)
- feat: Redshift provider with client setup (frankfarrell)
6 changes: 6 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor)

default: build

dist: fmtcheck build test testacc vet
@scripts/dist.sh

build: fmtcheck
go install

Expand Down Expand Up @@ -30,6 +33,9 @@ fmtcheck:
errcheck:
@sh -c "'$(CURDIR)/scripts/errcheck.sh'"

release: dist
@scripts/release.sh

test-compile:
@if [ "$(TEST)" = "./..." ]; then \
echo "ERROR: Set TEST to a specific package. For example,"; \
Expand Down
80 changes: 65 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,24 @@ Currently supports users, groups, schemas and databases. You can set privileges
Note that schemas are the lowest level of granularity here, tables should be created by some other tool, for instance flyway.

# Get it:
Download for amd64 (for other architectures and OSes you can build from source as descibed below)
* [Windows](https://github.com/frankfarrell/terraform-provider-redshift/raw/master/dist/windows/amd64/terraform-provider-redshift_v0.0.2_x4.exe)
* [Linux](https://github.com/frankfarrell/terraform-provider-redshift/raw/master/dist/linux/amd64/terraform-provider-redshift_v0.0.2_x4)
* [Mac](https://github.com/frankfarrell/terraform-provider-redshift/raw/master/dist/darwin/amd64/terraform-provider-redshift_v0.0.2_x4)

Add to terraform plugins directory: https://www.terraform.io/docs/configuration/providers.html#third-party-plugins
1. Navigate to the [latest release][latest_release] and download the applicable
plugin binary.
1. [Add to terraform plugins directory][installing_plugin] installed
1. Run `terraform init` to register the plugin in your project


## Legacy download links (0.0.2)

You wll need to run `terraform init to download install the plugin from here`
Download for amd64 (for other architectures and OSes you can build from source as descibed below)
* [Windows](https://github.com/frankfarrell/terraform-provider-redshift/raw/cff73548b/dist/windows/amd64/terraform-provider-redshift_v0.0.2_x4.exe)
* [Linux](https://github.com/frankfarrell/terraform-provider-redshift/raw/cff73548b/dist/linux/amd64/terraform-provider-redshift_v0.0.2_x4)
* [Mac](https://github.com/frankfarrell/terraform-provider-redshift/raw/cff73548b/dist/darwin/amd64/terraform-provider-redshift_v0.0.1_x4)

## Examples:
## Examples:

Provider configuration

```
provider redshift {
"url" = "localhost",
Expand Down Expand Up @@ -122,30 +128,74 @@ resource "redshift_user" "testuser"{

## Things to note
### Limitations
For authoritative limitations, please see the Redshift documentations.
1) You cannot delete the database you are currently connected to.
For authoritative limitations, please see the Redshift documentations.
1) You cannot delete the database you are currently connected to.
2) You cannot set table specific privileges since this provider is table agnostic (for now, if you think it would be feasible to manage tables let me know)
3) On importing a user, it is impossible to read the password (or even the md hash of the password, since Redshift restricts access to pg_shadow)

### I usually connect through an ssh tunnel, what do I do?
The easiest thing is probably to update your hosts file so that the url resolves to localhost

## Contributing:
## Contributing:

### Prequisites to development
1. Go installed
2. Terraform installed locally

### Building:
1. Run `go build -o terraform-provider-redshift_v0.0.1_x4.exe`. You will need to tweak this with GOOS and GOARCH if you are planning to build it for different OSes and architectures
2. Add to terraform plugins directory: https://www.terraform.io/docs/configuration/providers.html#third-party-plugins
### Building
Run `make dist` to generate binaries for the supported os/architectures. This
process relies on GNUMake and bash, but you can always fallback to generating
your own binaries with `go build -o your-binary-here`.

Once generated, you can add the binary to your terraform plugins directory to
get it working. (e.g.
terraform.d/linux/amd64/terraform-provider-redshift_vblah) Note that the prefix
of the binary must match, and follow guidelines for [Terraform
directories][installing_plugin]

After installing the plugin you can debug crudely by setting the TF_LOG env
variable to DEBUG. Eg

You can debug crudely by setting the TF_LOG env variable to DEBUG. Eg
```
$ TF_LOG=DEBUG terraform apply
```

## TODO
### Releasing
If you are cutting a new release, update the `VERSION` file to the new release
number prior to running `make release`. You will be prompted for the prior
version to auto-generate a changelog entry. Review the diffs in CHANGELOG.md
before committing.

Generate binaries hr each system by running `make dist`. Once gathered,
add a final tag to mark the github SHA for the release:

```
git tag -m $(cat VERSION) $(cat VERSION)
git push $(cat VERSION)
```

Navigate to the [project
tag](https://github.com/frankfarrell/terraform-provider-redshift/tags) to edit
the release. Add the compiled binaries and publish the release.

### Terraform Registry

To add this to the/a terraform registry, install gorelease, ensure you have a GPG
for signing the binaries (you'll need the key ID) and a Github Token with public_repo
access. All of this is documented in the [Terraform Registry
guide](https://www.terraform.io/docs/registry/providers/publishing.html)

Publishing is as easy as running the following:

```
GPG_FINGERPRINT=YOUR_GPG_KEY_ID GITHUB_TOKEN=YOUR_GITHUB_TOKEN ./bin/goreleaser release --rm-dist
```

## TODO
1. Database property for Schema
2. Schema privileges on a per user basis
3. Add privileges for languages and functions

[installing_plugin]: https://www.terraform.io/docs/extend/how-terraform-works.html#implied-local-mirror-directories

[latest_release]: https://github.com/frankfarrell/terraform-provider-redshift/releases/tag/1.0.0
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.0
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.12

require (
github.com/hashicorp/terraform v0.12.2
github.com/hashicorp/terraform-plugin-sdk/v2 v2.4.2
github.com/lib/pq v1.1.1
)

Expand Down
Loading