Skip to content

Commit

Permalink
feat: added organisation datasource & resource
Browse files Browse the repository at this point in the history
  • Loading branch information
thulasirajkomminar committed Oct 7, 2024
1 parent 84c6476 commit b63b696
Show file tree
Hide file tree
Showing 27 changed files with 1,761 additions and 7 deletions.
12 changes: 6 additions & 6 deletions .github/ISSUE_TEMPLATE/00_bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ body:
value: |
Hi there,
Thank you for opening an issue! Please note that we try to keep the this issue tracker reserved for
bug reports and feature requests related to the InfluxDB provider.
bug reports and feature requests related to the CrateDB provider.
- type: markdown
attributes:
value: |
# Terraform and InfluxDB V3 Provider Versions
# Terraform and CrateDB Provider Versions
Please run `terraform -v` to show the Terraform Core and provider version(s). If you are not running the latest version of either the provider or Terraform Core, please consider upgrading, as your issue may have already been fixed.
Expand All @@ -29,10 +29,10 @@ body:
required: true

- type: input
id: influxdb_version
id: cratedb_version
attributes:
label: InfluxDB V3 Provider Version
description: The semantic version of the InfluxDB V3 Provider used when experiencing the bug. If multiple versions have been tested, a comma separated list.
label: CrateDB Provider Version
description: The semantic version of the CrateDB Provider used when experiencing the bug. If multiple versions have been tested, a comma separated list.
placeholder: "X.Y.Z"
validations:
required: true
Expand All @@ -51,7 +51,7 @@ body:
attributes:
label: Affected Resource(s)
description: Please list the affected resource(s) and/or data source(s).
placeholder: "* influxdb3_xxx"
placeholder: "* cratedb_xxx"
validations:
required: false

Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/01_feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ labels: feature-request
Hi there,
Thank you for opening an issue! Please note that we try to keep the this issue tracker reserved for
bug reports and feature requests related to the InfluxDB V3 provider.
bug reports and feature requests related to the CrateDB provider.
-->


Expand Down
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.
version: 2

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
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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
@echo "Use this site to preview markdown rendering: https://registry.terraform.io/tools/doc-preview"
79 changes: 79 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,81 @@
# terraform-provider-cratedb
Terraform provider to manage CrateDB

## 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 {
cratedb = {
source = "komminarlabs/cratedb"
}
}
}
```

Initialize the provider

```terraform
provider "cratedb" {
api_key = "*******"
api_secret = "*******"
url = "https://console.cratedb.cloud/"
}
```

## Available functionalities

### Data Sources

*

### Resources

*

## 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
```
38 changes: 38 additions & 0 deletions docs/data-sources/organization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "cratedb_organization Data Source - terraform-provider-cratedb"
subcategory: ""
description: |-
To retrieve an organization.
---

# cratedb_organization (Data Source)

To retrieve an organization.



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

### Required

- `id` (String) The id of the organization.

### Read-Only

- `dc` (Attributes) The DublinCore of the organization. (see [below for nested schema](#nestedatt--dc))
- `email` (String) The notification email used in the organization.
- `name` (String) The name of the organization.
- `notifications_enabled` (Boolean) Whether notifications enabled for the organization.
- `plan_type` (Number) The support plan type used in the organization.
- `project_count` (Number) The project count in the organization.
- `role_fqn` (String) The role FQN.

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

Read-Only:

- `created` (String) The created time.
- `modified` (String) The modified time.
42 changes: 42 additions & 0 deletions docs/data-sources/organizations.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: "cratedb_organizations Data Source - terraform-provider-cratedb"
subcategory: ""
description: |-
To retrieve all organizations.
---

# cratedb_organizations (Data Source)

To retrieve all organizations.



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

### Read-Only

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

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

Read-Only:

- `dc` (Attributes) The DublinCore of the organization. (see [below for nested schema](#nestedatt--organizations--dc))
- `email` (String) The notification email used in the organization.
- `id` (String) The id of the organization.
- `name` (String) The name of the organization.
- `notifications_enabled` (Boolean) Whether notifications enabled for the organization.
- `plan_type` (Number) The support plan type used in the organization.
- `project_count` (Number) The project count in the organization.
- `role_fqn` (String) The role FQN.

<a id="nestedatt--organizations--dc"></a>
### Nested Schema for `organizations.dc`

Read-Only:

- `created` (String) The created time.
- `modified` (String) The modified time.
51 changes: 51 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "CrateDB Provider"
subcategory: ""
description: |-
Use the CrateDB provider to deploy and manage resources supported by CrateDB. You must configure the provider with the proper credentials before you can use it.
---

# CrateDB Provider

Use the CrateDB provider to deploy and manage resources supported by CrateDB. You must configure the provider with the proper credentials before you can use it.


## Example Usage

```terraform
terraform {
required_providers {
cratedb = {
source = "komminarlabs/cratedb"
}
}
}
provider "cratedb" {}
```

## Environment Variables

Credentials can be provided by using the `CRATEDB_API_KEY` and `CRATEDB_API_SECRET` and `CRATEDB_URL`.

### Example

```terraform
export CRATEDB_API_KEY="*******"
export CRATEDB_API_SECRET="*******"
export CRATEDB_URL="https://console.cratedb.cloud/"
provider "cratedb" {}
terraform plan
```

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

### Optional

- `api_key` (String, Sensitive) The API key
- `api_secret` (String, Sensitive) The API secret
- `url` (String) The CrateDB Cloud URL
Loading

0 comments on commit b63b696

Please sign in to comment.