Skip to content

Add TiDB Resource Controls #1

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

Merged
merged 26 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5f37d7e
Initial implementation of managing resource groups in terraform
zph Jun 28, 2024
efb4088
WIP
zph Jul 4, 2024
f0c9384
Fix issue with burstable
zph Jul 4, 2024
b104c63
Revert changes to data_source_tables
zph Jul 4, 2024
b94c78e
Add comments about TiDB syntax
zph Jul 4, 2024
cf9f09e
Merge branch 'master' into zh-resource-controls
zph Jul 5, 2024
fbe2c05
Remove stubbed in validation fn
zph Jul 5, 2024
7a2e770
Remove stubbed in validation fn
zph Jul 5, 2024
403e7c0
Stop dual running CI
zph Jul 5, 2024
52b1986
Improve error message about absent user
zph Jul 5, 2024
3a90834
Remove terraform lock from examples
zph Jul 6, 2024
8447f2b
Shorten the tagging scheme
zph Jul 6, 2024
30063b9
Add helper for releasing
zph Jul 6, 2024
42d531c
Stop using govendor according to their README since go v1.13
zph Jul 6, 2024
2385dfd
Build doc creation into the publishing pipeline
zph Jul 6, 2024
9a8ad15
Iterate on publishing docs with each release
zph Jul 6, 2024
08a697a
Try again with doc creation
zph Jul 6, 2024
e044410
Use tools.go to ensure we keep necessary dependencies
zph Jul 6, 2024
4aee5e1
Remove legacy website and publish from docs
zph Jul 6, 2024
deb9a82
Revert "Remove legacy website and publish from docs"
zph Jul 6, 2024
00de0c2
Rename legacy docs per https://developer.hashicorp.com/terraform/regi…
zph Jul 6, 2024
d01dbc8
Update some of docs but not all
zph Jul 6, 2024
2cd272c
Disable auto-generation of docs
zph Jul 6, 2024
723b6bd
Remove old website folder now that its migrated to docs
zph Jul 6, 2024
d1005e3
Try formatting go tools
zph Jul 6, 2024
364a36e
pull from not
Jul 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Main (test, releases)
on:
# # Indicates I want to run this workflow on all branches, PR, and tags
push:
branches: ["*"]
branches: ["master"]
tags: ["*"]
pull_request:
branches: [ "master" ]
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
example.tf
terraform.tfplan
terraform.tfstate
.terraform.lock*
terraform-provider-mysql
bin/
modules-dev/
Expand Down
4 changes: 3 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
version: 2
before:
hooks:
# this is just an example and not a requirement for provider building/publishing
- go mod tidy
# Disabled until auto-generated docs and manual docs operate peacefully
# - go generate ./...

builds:
- env:
# goreleaser does not work with CGO, it could also complicate
Expand Down
40 changes: 37 additions & 3 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,30 @@ TERRAFORM_VERSION=0.14.7
TERRAFORM_OS=$(shell uname -s | tr A-Z a-z)
TEST_USER=root
TEST_PASSWORD=my-secret-pw
DATESTAMP=$(shell date "+%Y%m%d%H%M%S")
DATESTAMP=$(shell date "+%Y%m%d")
SHA_SHORT=$(shell git describe --match=FORCE_NEVER_MATCH --always --abbrev=40 --dirty --abbrev)
MOST_RECENT_UPSTREAM_TAG=$(shell git for-each-ref refs/tags --sort=-taggerdate --format="%(refname)" | head -1 | grep -E -o "v\d+\.\d+\.\d+")

OS_ARCH=linux_amd64
# Set correct OS_ARCH on Mac
UNAME := $(shell uname -s)
ifeq ($(UNAME),Darwin)
HW := $(shell uname -m)
ifeq ($(HW),arm64)
ARCH=$(HW)
else
ARCH=amd64
endif
OS_ARCH=darwin_$(ARCH)
endif

HOSTNAME=registry.terraform.io
NAMESPACE=zph
NAME=mysql
VERSION=9.9.9
## on linux base os
TERRAFORM_PLUGINS_DIRECTORY=~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}

default: build

build: fmtcheck
Expand Down Expand Up @@ -121,12 +141,26 @@ endif

@$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME)

install:
mkdir -p ${TERRAFORM_PLUGINS_DIRECTORY}
go build -o ${TERRAFORM_PLUGINS_DIRECTORY}/terraform-provider-${NAME}
cd examples && rm -rf .terraform
cd examples && make init

re-install:
rm -f examples/.terraform.lock.hcl
rm -f ${TERRAFORM_PLUGINS_DIRECTORY}/terraform-provider-${NAME}
go build -o ${TERRAFORM_PLUGINS_DIRECTORY}/terraform-provider-${NAME}
cd examples && rm -rf .terraform
cd examples && terraform init

format-tag:
@echo $(MOST_RECENT_UPSTREAM_TAG)-$(DATESTAMP)-$(SHA_SHORT)

tag:
@echo git tag -a $(MOST_RECENT_UPSTREAM_TAG)-$(DATESTAMP)-$(SHA_SHORT) -m $(MOST_RECENT_UPSTREAM_TAG)-$(DATESTAMP)-$(SHA_SHORT)
@git tag -a $(MOST_RECENT_UPSTREAM_TAG)-$(DATESTAMP)-$(SHA_SHORT) -m $(MOST_RECENT_UPSTREAM_TAG)-$(DATESTAMP)-$(SHA_SHORT)


.PHONY: build test testacc vet fmt fmtcheck errcheck vendor-status test-compile website website-test tag
release:
@goreleaser release --clean --verbose
.PHONY: build test testacc vet fmt fmtcheck errcheck vendor-status test-compile website website-test tag format-tag
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fragmentation. We will update this readme if those design choices change.

zph fork will use release naming in the following form:

v3.0.62-20240705125429-3c7af6a
v3.0.62-20240705-3c7af6a

{petoju version}-{date}-{sha}

Expand Down
25 changes: 25 additions & 0 deletions docs/data-sources/databases.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: "mysql_databases Data Source - terraform-provider-mysql"
subcategory: ""
description: |-

---

# mysql_databases (Data Source)





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

### Optional

- `pattern` (String)

### Read-Only

- `databases` (List of String)
- `id` (String) The ID of this resource.
29 changes: 29 additions & 0 deletions docs/data-sources/tables.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "mysql_tables Data Source - terraform-provider-mysql"
subcategory: ""
description: |-

---

# mysql_tables (Data Source)





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

### Required

- `database` (String)

### Optional

- `pattern` (String)

### Read-Only

- `id` (String) The ID of this resource.
- `tables` (List of String)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
26 changes: 26 additions & 0 deletions docs/resources/sql.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "mysql_sql Resource - terraform-provider-mysql"
subcategory: ""
description: |-

---

# mysql_sql (Resource)





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

### Required

- `create_sql` (String)
- `delete_sql` (String)
- `name` (String)

### Read-Only

- `id` (String) The ID of this resource.
30 changes: 30 additions & 0 deletions docs/resources/ti_config.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: "mysql_ti_config Resource - terraform-provider-mysql"
subcategory: ""
description: |-

---

# mysql_ti_config (Resource)





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

### Required

- `name` (String)
- `type` (String)
- `value` (String)

### Optional

- `instance` (String)

### Read-Only

- `id` (String) The ID of this resource.
31 changes: 31 additions & 0 deletions docs/resources/ti_resource_group.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "mysql_ti_resource_group Resource - terraform-provider-mysql"
subcategory: ""
description: |-

---

# mysql_ti_resource_group (Resource)





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

### Required

- `name` (String)
- `resource_units` (Number)

### Optional

- `burstable` (Boolean)
- `priority` (String)
- `query_limit` (String)

### Read-Only

- `id` (String) The ID of this resource.
25 changes: 25 additions & 0 deletions docs/resources/ti_resource_group_user_assignment.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: "mysql_ti_resource_group_user_assignment Resource - terraform-provider-mysql"
subcategory: ""
description: |-

---

# mysql_ti_resource_group_user_assignment (Resource)





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

### Required

- `resource_group` (String)
- `user` (String)

### Read-Only

- `id` (String) The ID of this resource.
File renamed without changes.
17 changes: 17 additions & 0 deletions examples/tidb/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
terraform {
required_version = ">= 1.5.7"

required_providers {
mongodb = {
source = "registry.terraform.io/zph/mysql"
version = "9.9.9"
}
}
}

provider "mysql" {
endpoint = "localhost:4000"
username = "root"
#alias = "tidb"
#password = "admin"
}
6 changes: 6 additions & 0 deletions examples/tidb/resource_groups/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
re-install:
@cd ../../.. && \
make re-install && \
cd - && \
rm -rf .terraform* && \
terraform init
40 changes: 40 additions & 0 deletions examples/tidb/resource_groups/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
terraform {
required_version = ">= 1.5.7"

required_providers {
mysql = {
source = "registry.terraform.io/zph/mysql"
version = "9.9.9"
}
}
}

provider "mysql" {
endpoint = "127.0.0.1:4000"

username = "root"
}

resource "mysql_ti_resource_group" "rg1" {
name = "rg1"
resource_units = 4000
}

resource "mysql_ti_resource_group" "rg2" {
name = "rg2"
resource_units = 2000
burstable = true
priority = "high"
}

resource "mysql_ti_resource_group_user_assignment" "rg1_user1" {
user = "user1"
resource_group = mysql_ti_resource_group.rg1.name
depends_on = [ mysql_ti_resource_group.rg1 ]
}

resource "mysql_ti_resource_group_user_assignment" "rg111_rg" {
user = "user2"
resource_group = mysql_ti_resource_group.rg1.name
depends_on = [ mysql_ti_resource_group.rg1 ]
}
Loading
Loading