Skip to content

Commit 8b616c6

Browse files
authored
Merge pull request #9 from bytebase/chore/update
chore: update variables and release 0.0.3
2 parents 3b21bc2 + 9a5200e commit 8b616c6

File tree

15 files changed

+132
-80
lines changed

15 files changed

+132
-80
lines changed

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ jobs:
5151
go test -v -cover ./...
5252
env:
5353
TF_ACC: '1'
54-
BYTEBASE_USER_EMAIL: 'test_email'
55-
BYTEBASE_USER_PASSWORD: 'test_pwd'
56-
BYTEBASE_URL: 'test_url'
54+
BYTEBASE_SERVICE_ACCOUNT: '[email protected]'
55+
BYTEBASE_SERVICE_KEY: 'test_secret'
56+
BYTEBASE_URL: 'https://bytebase.example.com'

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ air -c scripts/.air.toml
3232
# install the provider in your local machine
3333
cd terraform-provider-bytebase && make install
3434

35-
# initial the terraform for your example
36-
# you may need to change the username and password
35+
# initialize the terraform for your example
36+
# you need to set the service_account and service_key to your own
3737
cd examples && terraform init
3838

3939
# check the changes

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.2
1+
0.0.3

api/environment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type Environment struct {
1313
type EnvironmentCreate struct {
1414
// Domain specific fields
1515
Name string `json:"name"`
16-
Order *int `json:"order,omitempty"`
16+
Order int `json:"order"`
1717
}
1818

1919
// EnvironmentPatch is the API message for patching an environment.

docs/index.md

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ terraform {
2727
}
2828
2929
provider "bytebase" {
30-
email = "<Your Bytebase account email>"
31-
password = "<Your Bytebase account password>"
32-
bytebase_url = "<Your Bytebase OpenAPI URL>"
30+
service_account = "<Your Bytebase service account email>"
31+
service_key = "<Your Bytebase service account key>"
32+
url = "<Your Bytebase external URL>"
3333
}
3434
```
3535

@@ -41,13 +41,60 @@ resource "bytebase_environment" "dev" {
4141
}
4242
```
4343

44+
```bash
45+
# install the provider
46+
terraform init
47+
48+
# check changes
49+
terraform plan
50+
51+
# apply changes
52+
terraform apply
53+
54+
# remove resources
55+
terraform destory
56+
```
57+
4458
You can check [examples](https://github.com/bytebase/terraform-provider-bytebase/blob/main/examples/main.tf) for more usage examples.
4559

4660
<!-- schema generated by tfplugindocs -->
4761
## Schema
4862

4963
### Optional
5064

51-
- `bytebase_url` (String) The OpenAPI URL for your Bytebase server. If not provided in the configuration, you must set the `BYTEBASE_URL` variable in the environment.
52-
- `email` (String) The Bytebase user account email. If not provided in the configuration, you must set the `BYTEBASE_USER_EMAIL` variable in the environment.
53-
- `password` (String, Sensitive) The Bytebase user account password. If not provided in the configuration, you must set the `BYTEBASE_USER_PASSWORD` variable in the environment.
65+
- `url`: Required. The [external URL](/docs/get-started/install/external-url) for your Bytebase server. Alternatively, you can set `BYTEBASE_URL` environment variable.
66+
- `service_account`: Required. The Bytebase service account email. The user must have **Owner** or **DBA** role. Alternatively, you can set `BYTEBASE_SERVICE_ACCOUNT` environment variable.
67+
- `service_key`: Required. The Bytebase service account key. Alternatively, you can set `BYTEBASE_SERVICE_KEY` environment variable.
68+
69+
It's optional to provide these configuration through the provider:
70+
71+
```terraform
72+
provider "bytebase" {
73+
service_account = "<Your Bytebase service account email>"
74+
service_key = "<Your Bytebase service account key>"
75+
url = "<Your Bytebase external URL>"
76+
}
77+
```
78+
79+
But you can also write them into the environment:
80+
81+
```terraform
82+
# Configure the Bytebase Provider without options
83+
84+
terraform {
85+
required_providers {
86+
bytebase = {
87+
source = "bytebase/bytebase"
88+
version = "0.0.3"
89+
}
90+
}
91+
}
92+
93+
provider "bytebase" {}
94+
```
95+
96+
```bash
97+
export BYTEBASE_URL=<Your Bytebase EXTERNAL URL> BYTEBASE_SERVICE_ACCOUNT=<Your Bytebase service account email> BYTEBASE_SERVICE_KEY=<Your Bytebase service account key>
98+
99+
terraform init && terraform plan
100+
```

docs/resources/environment.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ The environment resource. You can read, create, update or delete a single enviro
1515
```terraform
1616
# Create a new environment named "dev"
1717
resource "bytebase_environment" "dev" {
18-
name = "dev"
18+
name = "dev"
19+
order = 1
1920
}
2021
```
2122

@@ -27,13 +28,8 @@ You can check [examples](https://github.com/bytebase/terraform-provider-bytebase
2728
### Required
2829

2930
- `name` (String) The environment unique name.
30-
31-
### Optional
32-
3331
- `order` (Number) The environment sorting order.
3432

3533
### Read-Only
3634

3735
- `id` (String) The ID of this resource.
38-
39-

examples/environments/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
terraform {
22
required_providers {
33
bytebase = {
4-
version = "0.0.2"
4+
version = "0.0.3"
55
source = "terraform.local/bytebase/bytebase"
66
}
77
}

examples/instances/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
terraform {
22
required_providers {
33
bytebase = {
4-
version = "0.0.2"
4+
version = "0.0.3"
55
source = "terraform.local/bytebase/bytebase"
66
}
77
}

examples/main.tf

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,37 @@
11
# This is an example for using Bytebase Terraform provider to manage your resource.
2+
# Docs: https://www.bytebase.com/docs/get-started/work-with-terraform/overview
23
# To run this provider in your local machine,
34
# 1. Run your Bytebase service, then you can access the OpenAPI via http://localhost:8080/v1
4-
# 2. Replace the email and password with your own Bytebase account
5+
# 2. Replace the service_account and service_key with your own Bytebase service account
56
# 3. Run `make install` under terraform-provider-bytebase folder
67
# 4. Run `cd examples && terraform init`
78
# 5. Run `terraform plan` to check the changes
89
# 6. Run `terraform apply` to apply the changes
910
# 7. Run `terraform output` to find the outputs
1011
# 8. Run `terraform destory` to delete the test resources
1112
provider "bytebase" {
12-
# You need to replace the email and password with your own Bytebase account.
13-
14-
password = "ed"
15-
# The source is only used in the local example.
16-
bytebase_url = "http://localhost:8080/v1"
13+
# You need to replace the account and key with your Bytebase service account.
14+
service_account = "[email protected]"
15+
service_key = "bbs_qHX6CswQ1nMMELSCc2lk"
16+
url = "https://bytebase.example.com"
1717
}
1818

1919
locals {
20-
environment_name = "dev"
21-
instance_name = "dev instance"
20+
environment_name_dev = "dev"
21+
environment_name_prod = "prod"
22+
instance_name = "dev instance"
2223
}
2324

2425
# Create a new environment named "dev"
2526
resource "bytebase_environment" "dev" {
26-
name = local.environment_name
27-
# You can specific the environment order
28-
# order = 1
27+
name = local.environment_name_dev
28+
order = 0
29+
}
30+
31+
# Create another environment named "prod"
32+
resource "bytebase_environment" "prod" {
33+
name = local.environment_name_prod
34+
order = 1
2935
}
3036

3137
# Print the new environment
@@ -56,7 +62,7 @@ output "dev_instance" {
5662
# import environments module and filter by environment name
5763
module "environment" {
5864
source = "./environments"
59-
environment_name = local.environment_name
65+
environment_name = local.environment_name_dev
6066
# Make sure the module exec after the "dev" environment is created
6167
depends_on = [
6268
bytebase_environment.dev

examples/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
terraform {
22
required_providers {
33
bytebase = {
4-
version = "0.0.2"
4+
version = "0.0.3"
55
source = "terraform.local/bytebase/bytebase"
66
}
77
}

0 commit comments

Comments
 (0)