Skip to content

Commit

Permalink
Merge pull request #2 from komminarlabs/tk/initial-version
Browse files Browse the repository at this point in the history
Initial Version `0.1.0`
  • Loading branch information
thulasirajkomminar committed May 1, 2024
2 parents b56ea58 + b3ea85a commit 9528fab
Show file tree
Hide file tree
Showing 48 changed files with 3,269 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ jobs:
install-only: true

- name: Run GoReleaser
run: goreleaser build --clean --skip=validate
run: goreleaser build --clean --skip=validate --snapshot
27 changes: 27 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Visit https://golangci-lint.run/ for usage documentation
# and information on other useful linters
issues:
max-per-linter: 0
max-same-issues: 0

linters:
disable-all: true
enable:
- durationcheck
- errcheck
- exportloopref
- forcetypeassert
- godot
- gofmt
- gosimple
- ineffassign
- makezero
- misspell
- nilerr
- predeclared
- staticcheck
- tenv
- unconvert
- unparam
- unused
- vet
60 changes: 60 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# 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:
extra_files:
- glob: 'terraform-registry-manifest.json'
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
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:
extra_files:
- glob: 'terraform-registry-manifest.json'
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
# If you want to manually examine the release before its live, uncomment this line:
# draft: true
changelog:
skip: true
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## [0.1.0] - 2024-05-01

### Added:

* **New Data Source:** `influxdb3_database`
* **New Data Source:** `influxdb3_databases`
* **New Data Source:** `influxdb3_token`
* **New Data Source:** `influxdb3_tokens`

* **New Resource:** `influxdb3_database`
* **New Resource:** `influxdb3_token`
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
default: testacc

# Run acceptance tests
.PHONY: testacc
testacc:
TF_ACC=1 go test ./... -v $(TESTARGS) -timeout 120m

.PHONY: lint
lint:
golangci-lint run

.PHONY: docs
docs:
go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs
tfplugindocs generate
84 changes: 84 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,86 @@
# terraform-provider-influxdb3
Terraform provider to manage InfluxDB V3

## Requirements

- [Terraform](https://developer.hashicorp.com/terraform/downloads) >= 1.0
- [Go](https://golang.org/doc/install) >= 1.20

## Building The Provider

1. Clone the repository
1. Enter the repository directory
1. Build the provider using the Go `install` command:

```shell
go install
```

## Adding Dependencies

This provider uses [Go modules](https://github.com/golang/go/wiki/Modules).
Please see the Go documentation for the most up to date information about using Go modules.

To add a new dependency `github.com/author/dependency` to your Terraform provider:

```shell
go get github.com/author/dependency
go mod tidy
```

Then commit the changes to `go.mod` and `go.sum`.

## Using the provider

Add the below code to your configuration.

```terraform
terraform {
required_providers {
influxdb3 = {
source = "komminarlabs/influxdb3"
}
}
}
```

Initialize the provider

```terraform
provider "influxdb3" {
account_id = "*******"
cluster_id = "*******"
token = "*******"
url = "https://console.influxdata.com"
}
```

## Available functionalities

### Data Sources

* `influxdb3_database`
* `influxdb3_databases`
* `influxdb3_token`
* `influxdb3_tokens`

### Resources

* `influxdb3_database`
* `influxdb3_token`

## Developing the Provider

If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (see [Requirements](#requirements) above).

To compile the provider, run `go install`. This will build the provider and put the provider binary in the `$GOPATH/bin` directory.

To generate or update documentation, run `make docs`.

In order to run the full suite of Acceptance tests, run `make testacc`.

*Note:* Acceptance tests create real resources, and often cost money to run.

```shell
make testacc
```
37 changes: 37 additions & 0 deletions docs/data-sources/database.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "influxdb3_database Data Source - terraform-provider-influxdb3"
subcategory: ""
description: |-
Retrieves a database. Use this data source to retrieve information for a specific database.
---

# influxdb3_database (Data Source)

Retrieves a database. Use this data source to retrieve information for a specific database.



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

### Required

- `name` (String) The name of the cluster database. The Length should be between `[ 1 .. 64 ]` characters.

### Read-Only

- `account_id` (String) The ID of the account that the cluster belongs to.
- `cluster_id` (String) The ID of the cluster that you want to manage.
- `max_columns_per_table` (Number) The maximum number of columns per table for the cluster database. The default is `200`
- `max_tables` (Number) The maximum number of tables for the cluster database. The default is `500`
- `partition_template` (Attributes List) A [template](https://docs.influxdata.com/influxdb/cloud-dedicated/admin/custom-partitions/partition-templates/) for partitioning a cluster database. (see [below for nested schema](#nestedatt--partition_template))
- `retention_period` (Number) The retention period of the cluster database in nanoseconds. The default is `0`. If the retention period is not set or is set to `0`, the database will have infinite retention.

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

Read-Only:

- `type` (String) The type of the template part.
- `value` (String) The value of the template part.
41 changes: 41 additions & 0 deletions docs/data-sources/databases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "influxdb3_databases Data Source - terraform-provider-influxdb3"
subcategory: ""
description: |-
Gets all databases for a cluster.
---

# influxdb3_databases (Data Source)

Gets all databases for a cluster.



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

### Read-Only

- `databases` (Attributes List) (see [below for nested schema](#nestedatt--databases))

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

Read-Only:

- `account_id` (String) The ID of the account that the cluster belongs to.
- `cluster_id` (String) The ID of the cluster that you want to manage.
- `max_columns_per_table` (Number) The maximum number of columns per table for the cluster database. The default is `200`
- `max_tables` (Number) The maximum number of tables for the cluster database. The default is `500`
- `name` (String) The name of the cluster database. The Length should be between `[ 1 .. 64 ]` characters.
- `partition_template` (Attributes List) A [template](https://docs.influxdata.com/influxdb/cloud-dedicated/admin/custom-partitions/partition-templates/) for partitioning a cluster database. (see [below for nested schema](#nestedatt--databases--partition_template))
- `retention_period` (Number) The retention period of the cluster database in nanoseconds. The default is `0`. If the retention period is not set or is set to `0`, the database will have infinite retention.

<a id="nestedatt--databases--partition_template"></a>
### Nested Schema for `databases.partition_template`

Read-Only:

- `type` (String) The type of the template part.
- `value` (String) The value of the template part.
37 changes: 37 additions & 0 deletions docs/data-sources/token.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "influxdb3_token Data Source - terraform-provider-influxdb3"
subcategory: ""
description: |-
Gets a database token. Use this data source to retrieve information about a database token, including the token's permissions.
---

# influxdb3_token (Data Source)

Gets a database token. Use this data source to retrieve information about a database token, including the token's permissions.



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

### Required

- `id` (String) The ID of the database token.

### Read-Only

- `access_token` (String, Sensitive) The access token that can be used to authenticate query and write requests to the cluster. The access token is never stored by InfluxDB and is only returned once when the token is created. If the access token is lost, a new token must be created.
- `account_id` (String) The ID of the account that the database token belongs to.
- `cluster_id` (String) The ID of the cluster that the database token belongs to.
- `created_at` (String) The date and time that the database token was created. Uses RFC3339 format.
- `description` (String) The description of the database token.
- `permissions` (Attributes List) The list of permissions the database token allows. (see [below for nested schema](#nestedatt--permissions))

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

Read-Only:

- `action` (String) The action the database token permission allows. Valid values are `read` or `write`.
- `resource` (String) The resource the database token permission applies to. `*` refers to all databases.
44 changes: 44 additions & 0 deletions docs/data-sources/tokens.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "influxdb3_tokens Data Source - terraform-provider-influxdb3"
subcategory: ""
description: |-
Gets all database tokens for a cluster.
---

# influxdb3_tokens (Data Source)

Gets all database tokens for a cluster.



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

### Read-Only

- `tokens` (Attributes List) (see [below for nested schema](#nestedatt--tokens))

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

Required:

- `id` (String) The ID of the database token.

Read-Only:

- `access_token` (String, Sensitive) The access token that can be used to authenticate query and write requests to the cluster. The access token is never stored by InfluxDB and is only returned once when the token is created. If the access token is lost, a new token must be created.
- `account_id` (String) The ID of the account that the database token belongs to.
- `cluster_id` (String) The ID of the cluster that the database token belongs to.
- `created_at` (String) The date and time that the database token was created. Uses RFC3339 format.
- `description` (String) The description of the database token.
- `permissions` (Attributes List) The list of permissions the database token allows. (see [below for nested schema](#nestedatt--tokens--permissions))

<a id="nestedatt--tokens--permissions"></a>
### Nested Schema for `tokens.permissions`

Read-Only:

- `action` (String) The action the database token permission allows. Valid values are `read` or `write`.
- `resource` (String) The resource the database token permission applies to. `*` refers to all databases.
Loading

0 comments on commit 9528fab

Please sign in to comment.