Skip to content

Commit 3b21bc2

Browse files
authored
Merge pull request #8 from bytebase/chore/update
chore: several updates
2 parents 4fa2553 + b3a317c commit 3b21bc2

File tree

14 files changed

+218
-44
lines changed

14 files changed

+218
-44
lines changed

.github/workflows/release.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,31 @@
1212
name: release
1313
on:
1414
push:
15-
tags:
16-
- 'v*'
15+
branches:
16+
- main
17+
paths:
18+
- "VERSION"
1719
permissions:
1820
contents: write
1921
jobs:
22+
create-tag:
23+
name: Create Tag
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v3
27+
- name: Get Version
28+
id: get-version
29+
run: |
30+
verion=`cat VERSION`
31+
echo "::set-output name=version::$verion"
32+
- name: Create Tag
33+
uses: negz/create-tag@v1
34+
with:
35+
version: v${{ steps.get-version.outputs.version }}
36+
message: "Release v${{ steps.get-version.outputs.version }}"
37+
token: ${{ secrets.GITHUB_TOKEN }}
2038
goreleaser:
39+
needs: create-tag
2140
runs-on: ubuntu-latest
2241
steps:
2342
-

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
TEST?=$$(go list ./... | grep -v 'vendor')
2-
HOSTNAME=registry.terraform.io
2+
HOSTNAME=terraform.local
33
NAMESPACE=bytebase
44
NAME=bytebase
55
BINARY=terraform-provider-${NAMESPACE}
6-
VERSION=0.0.1
6+
VERSION=${shell cat ./VERSION}
77
OS_ARCH=darwin_amd64
88

99
default: install

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs --provider-na
6161

6262
Follow [this doc](https://developer.hashicorp.com/terraform/registry/providers/publishing) to publish the provider.
6363

64-
Note:
64+
> Note:
65+
> We need to publish a new tag for a new version, the tag must be a valid [Semantic Version](https://semver.org/) **preceded with a v (for example, v1.2.3)**. There must not be a branch name with the same name as the tag.
6566
66-
We need to publish a new tag for a new version, the tag must be a valid [Semantic Version](https://semver.org/) **preceded with a v (for example, v1.2.3)**. There must not be a branch name with the same name as the tag.
67+
1. Develop and merge the feature code.
68+
2. Create a new PR to update the version in [`./VERSION`](./VERSION)
69+
3. After the version is updated, the action [`./.github/workflows/release.yml`](./.github/workflows/release.yml) will use the newest version `x.y.z` to create a new tag `vx.y.z`, then use the tag to create the release.

VERSION

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

docs/data-sources/environments.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,20 @@ description: |-
88

99
# bytebase_environments (Data Source)
1010

11-
The environment data source.
11+
The environment data source. You can list environments through `bytebase_environments` data source.
1212

13+
## Example Usage
1314

15+
```terraform
16+
# List environments
17+
data "bytebase_environments" "all" {}
18+
19+
output "all_environments" {
20+
value = data.bytebase_environments.all.environments
21+
}
22+
```
23+
24+
You can check [examples](https://github.com/bytebase/terraform-provider-bytebase/blob/main/examples/main.tf) for more usage examples.
1425

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

docs/data-sources/instances.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,20 @@ description: |-
88

99
# bytebase_instances (Data Source)
1010

11-
The instance data source.
11+
The instance data source. You can list instances through `bytebase_instances` data source.
1212

13+
## Example Usage
1314

15+
```terraform
16+
# List instances
17+
data "bytebase_instances" "all" {}
18+
19+
output "all_instances" {
20+
value = data.bytebase_instances.all.instances
21+
}
22+
```
23+
24+
You can check [examples](https://github.com/bytebase/terraform-provider-bytebase/blob/main/examples/main.tf) for more usage examples.
1425

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

docs/index.md

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,53 @@
11
---
22
# generated by https://github.com/hashicorp/terraform-plugin-docs
3-
page_title: "bytebase Provider"
3+
page_title: "Bytebase Provider"
44
subcategory: ""
55
description: |-
6-
6+
The Bytebase Terraform provider to manage your Bytebase resources.
77
---
88

9-
# bytebase Provider
9+
# Bytebase Provider
1010

11+
This is the Bytebase Terraform provider to manage your Bytebase resources. For now we support manage the Bytebase instances and environments.
1112

13+
## Example Usage
1214

15+
> Require Terraform 0.13+
1316
17+
```terraform
18+
# Configure the Bytebase Provider
19+
20+
terraform {
21+
required_providers {
22+
bytebase = {
23+
source = "bytebase/bytebase"
24+
version = "0.0.1"
25+
}
26+
}
27+
}
28+
29+
provider "bytebase" {
30+
email = "<Your Bytebase account email>"
31+
password = "<Your Bytebase account password>"
32+
bytebase_url = "<Your Bytebase OpenAPI URL>"
33+
}
34+
```
35+
36+
```terraform
37+
# Usage example
38+
# Create a new environment named "dev"
39+
resource "bytebase_environment" "dev" {
40+
name = "dev"
41+
}
42+
```
43+
44+
You can check [examples](https://github.com/bytebase/terraform-provider-bytebase/blob/main/examples/main.tf) for more usage examples.
1445

1546
<!-- schema generated by tfplugindocs -->
1647
## Schema
1748

1849
### Optional
1950

20-
- `bytebase_url` (String) The OpenAPI URL for your Bytebase server.
21-
- `email` (String) The Bytebase user account email.
22-
- `password` (String, Sensitive) The Bytebase user account password.
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.

docs/resources/environment.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,18 @@ description: |-
88

99
# bytebase_environment (Resource)
1010

11-
The environment resource.
11+
The environment resource. You can read, create, update or delete a single environment through `bytebase_environment` resource.
1212

13+
## Example Usage
1314

15+
```terraform
16+
# Create a new environment named "dev"
17+
resource "bytebase_environment" "dev" {
18+
name = "dev"
19+
}
20+
```
21+
22+
You can check [examples](https://github.com/bytebase/terraform-provider-bytebase/blob/main/examples/main.tf) for more usage examples.
1423

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

docs/resources/instance.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,21 @@ description: |-
88

99
# bytebase_instance (Resource)
1010

11-
The instance resource.
11+
The instance resource. You can read, create, update or delete a single instance through `bytebase_instance` resource.
1212

13+
## Example Usage
1314

15+
```terraform
16+
# Create a new instance named "dev instance"
17+
resource "bytebase_instance" "dev_instance" {
18+
name = "dev instance"
19+
engine = "POSTGRES"
20+
host = "127.0.0.1"
21+
environment = "dev"
22+
}
23+
```
24+
25+
You can check [examples](https://github.com/bytebase/terraform-provider-bytebase/blob/main/examples/main.tf) for more usage examples.
1426

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

examples/environments/main.tf

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
terraform {
2+
required_providers {
3+
bytebase = {
4+
version = "0.0.2"
5+
source = "terraform.local/bytebase/bytebase"
6+
}
7+
}
8+
}
9+
10+
variable "environment_name" {
11+
type = string
12+
default = ""
13+
}
14+
15+
# List all environment
16+
data "bytebase_environments" "all" {}
17+
18+
output "all_environments" {
19+
value = data.bytebase_environments.all.environments
20+
}
21+
22+
# Only returns specific environment
23+
output "environment" {
24+
value = {
25+
for environment in data.bytebase_environments.all.environments :
26+
environment.id => environment
27+
if environment.name == var.environment_name
28+
}
29+
}

0 commit comments

Comments
 (0)