Skip to content

Commit 0f84f5a

Browse files
authored
release: 3.17.0 (#181)
* release: 3.17.0 * chore: update * fix: lint * chore: update readme
1 parent dc55a27 commit 0f84f5a

59 files changed

Lines changed: 2260 additions & 148 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/release.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
name: Create Tag
2626
runs-on: ubuntu-latest
2727
steps:
28-
- uses: actions/checkout@v3
28+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2929
- name: Get Version
3030
id: get-version
3131
run: |
@@ -42,22 +42,22 @@ jobs:
4242
needs: create-tag
4343
runs-on: ubuntu-latest
4444
steps:
45-
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
45+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
4646
with:
4747
# Allow goreleaser to access older tag information.
4848
fetch-depth: 0
49-
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
49+
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
5050
with:
5151
go-version-file: "go.mod"
5252
cache: true
5353
- name: Import GPG key
54-
uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0
54+
uses: crazy-max/ghaction-import-gpg@2dc316deee8e90f13e1a351ab510b4d5bc0c82cd # v7.0.0
5555
id: import_gpg
5656
with:
5757
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
5858
passphrase: ${{ secrets.PASSPHRASE }}
5959
- name: Run GoReleaser
60-
uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6.0.0
60+
uses: goreleaser/goreleaser-action@ec59f474b9834571250b370d4735c50f8e2d1e29 # v7.0.0
6161
with:
6262
args: release --clean
6363
env:

.github/workflows/tests.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@ jobs:
1010
golangci:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v3
14-
- uses: actions/setup-go@v3
13+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
14+
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
1515
with:
16-
go-version: "1.24.1"
16+
go-version-file: "go.mod"
1717
- run: go generate ./...
1818
- name: golangci-lint
19-
uses: golangci/golangci-lint-action@v6
19+
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6.5.2
2020
with:
2121
version: v1.64.7
2222
args: --verbose --timeout 20m --max-same-issues=30 --allow-parallel-runners
2323
go-tidy:
2424
runs-on: ubuntu-latest
2525
steps:
26-
- uses: actions/checkout@v3
27-
- uses: actions/setup-go@v3
26+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
27+
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
2828
with:
29-
go-version: "1.24.1"
29+
go-version-file: "go.mod"
3030
- name: Verify tidy
3131
run: |
3232
go mod tidy
@@ -35,13 +35,13 @@ jobs:
3535
runs-on: ubuntu-latest
3636
steps:
3737
- name: Checkout
38-
uses: actions/checkout@v3
38+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3939
with:
4040
fetch-depth: 0
41-
- uses: actions/setup-go@v3
41+
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
4242
with:
43-
go-version: "1.24.1"
44-
- uses: hashicorp/setup-terraform@v2
43+
go-version-file: "go.mod"
44+
- uses: hashicorp/setup-terraform@5e8dbf3c6d9deaf4193ca7a8fb23f2ac83bb6c85 # v4.0.0
4545
with:
4646
terraform_version: "1.3.*"
4747
terraform_wrapper: false

.goreleaser.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ checksum:
4141
algorithm: sha256
4242
signs:
4343
- artifacts: checksum
44+
# Do not include the signature in the checksum file.
45+
# Terraform Registry rejects SHA256SUMS that contain the .sig file.
46+
checksum: false
4447
args:
4548
# if you are using this in a GitHub action or some other automated pipeline, you
4649
# need to pass the batch flag to indicate its not interactive.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ using Terraform Bytebase Provider to prepare those instances ready for applicati
1515

1616
- [Go](https://golang.org/doc/install) (1.19 or later)
1717
- [Terraform](https://developer.hashicorp.com/terraform/downloads?product_intent=terraform) (1.3.5 or later)
18-
- [Bytebase](https://github.com/bytebase/bytebase) (3.16.0 or later)
18+
- [Bytebase](https://github.com/bytebase/bytebase) (3.17.0 or later)
1919

2020
> If you have problems running `terraform` in MacOS with Apple Silicon, you can following https://stackoverflow.com/questions/66281882/how-can-i-get-terraform-init-to-run-on-my-apple-silicon-macbook-pro-for-the-go and use the `tfenv`.
2121

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.16.4
1+
3.17.0

api/client.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,21 @@ type Client interface {
204204
DeleteGroup(ctx context.Context, groupName string) error
205205

206206
// Workspace
207+
// GetWorkspace gets the workspace.
208+
GetWorkspace(ctx context.Context, workspaceName string) (*v1pb.Workspace, error)
209+
// UpdateWorkspace updates the workspace.
210+
UpdateWorkspace(ctx context.Context, patch *v1pb.Workspace, updateMasks []string) (*v1pb.Workspace, error)
207211
// GetWorkspaceIAMPolicy gets the workspace IAM policy.
208212
GetWorkspaceIAMPolicy(ctx context.Context) (*v1pb.IamPolicy, error)
209213
// SetWorkspaceIAMPolicy sets the workspace IAM policy.
210214
SetWorkspaceIAMPolicy(ctx context.Context, setIamPolicyRequest *v1pb.SetIamPolicyRequest) (*v1pb.IamPolicy, error)
211215

216+
// Subscription
217+
// GetSubscription gets the current subscription.
218+
GetSubscription(ctx context.Context) (*v1pb.Subscription, error)
219+
// UploadLicense uploads a license.
220+
UploadLicense(ctx context.Context, license string) (*v1pb.Subscription, error)
221+
212222
// Review config
213223
// ListReviewConfig will return review configs.
214224
ListReviewConfig(ctx context.Context) (*v1pb.ListReviewConfigsResponse, error)
@@ -229,4 +239,16 @@ type Client interface {
229239
UpdateDatabaseGroup(ctx context.Context, patch *v1pb.DatabaseGroup, updateMasks []string) (*v1pb.DatabaseGroup, error)
230240
// DeleteDatabaseGroup deletes the database group.
231241
DeleteDatabaseGroup(ctx context.Context, databaseGroupName string) error
242+
243+
// IdentityProvider
244+
// ListIdentityProvider lists all identity providers.
245+
ListIdentityProvider(ctx context.Context) ([]*v1pb.IdentityProvider, error)
246+
// GetIdentityProvider gets the identity provider by name.
247+
GetIdentityProvider(ctx context.Context, name string) (*v1pb.IdentityProvider, error)
248+
// CreateIdentityProvider creates the identity provider.
249+
CreateIdentityProvider(ctx context.Context, idpID string, idp *v1pb.IdentityProvider) (*v1pb.IdentityProvider, error)
250+
// UpdateIdentityProvider updates the identity provider.
251+
UpdateIdentityProvider(ctx context.Context, patch *v1pb.IdentityProvider, updateMasks []string) (*v1pb.IdentityProvider, error)
252+
// DeleteIdentityProvider deletes the identity provider.
253+
DeleteIdentityProvider(ctx context.Context, name string) error
232254
}

client/client.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package client
33

44
import (
55
"context"
6-
"fmt"
76
"net/http"
87
"strings"
98
"time"
@@ -41,6 +40,8 @@ type client struct {
4140
celClient bytebasev1connect.CelServiceClient
4241
serviceAccountClient bytebasev1connect.ServiceAccountServiceClient
4342
workloadIdentityClient bytebasev1connect.WorkloadIdentityServiceClient
43+
subscriptionClient bytebasev1connect.SubscriptionServiceClient
44+
idpClient bytebasev1connect.IdentityProviderServiceClient
4445
}
4546

4647
// GetWorkspaceName returns the workspace resource name.
@@ -98,13 +99,15 @@ func NewClient(url, email, password string) (api.Client, error) {
9899
c.celClient = bytebasev1connect.NewCelServiceClient(c.client, c.url, interceptors)
99100
c.serviceAccountClient = bytebasev1connect.NewServiceAccountServiceClient(c.client, c.url, interceptors)
100101
c.workloadIdentityClient = bytebasev1connect.NewWorkloadIdentityServiceClient(c.client, c.url, interceptors)
102+
c.subscriptionClient = bytebasev1connect.NewSubscriptionServiceClient(c.client, c.url, interceptors)
103+
c.idpClient = bytebasev1connect.NewIdentityProviderServiceClient(c.client, c.url, interceptors)
101104

102105
// Fetch workspace ID from actuator
103106
actuatorResp, err := c.actuatorClient.GetActuatorInfo(context.Background(), connect.NewRequest(&v1pb.GetActuatorInfoRequest{}))
104107
if err != nil {
105108
return nil, errors.Wrapf(err, "failed to get actuator info")
106109
}
107-
c.workspaceName = fmt.Sprintf("workspaces/%s", actuatorResp.Msg.GetWorkspaceId())
110+
c.workspaceName = actuatorResp.Msg.GetWorkspace()
108111

109112
return &c, nil
110113
}

client/idp.go

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
package client
2+
3+
import (
4+
"context"
5+
"errors"
6+
7+
v1pb "buf.build/gen/go/bytebase/bytebase/protocolbuffers/go/v1"
8+
"connectrpc.com/connect"
9+
"google.golang.org/protobuf/types/known/fieldmaskpb"
10+
)
11+
12+
// ListIdentityProvider lists all identity providers.
13+
func (c *client) ListIdentityProvider(ctx context.Context) ([]*v1pb.IdentityProvider, error) {
14+
if c.idpClient == nil {
15+
return nil, errors.New("identity provider service client not initialized")
16+
}
17+
18+
req := connect.NewRequest(&v1pb.ListIdentityProvidersRequest{})
19+
20+
resp, err := c.idpClient.ListIdentityProviders(ctx, req)
21+
if err != nil {
22+
return nil, err
23+
}
24+
25+
return resp.Msg.IdentityProviders, nil
26+
}
27+
28+
// GetIdentityProvider gets the identity provider by name.
29+
func (c *client) GetIdentityProvider(ctx context.Context, name string) (*v1pb.IdentityProvider, error) {
30+
if c.idpClient == nil {
31+
return nil, errors.New("identity provider service client not initialized")
32+
}
33+
34+
req := connect.NewRequest(&v1pb.GetIdentityProviderRequest{
35+
Name: name,
36+
})
37+
38+
resp, err := c.idpClient.GetIdentityProvider(ctx, req)
39+
if err != nil {
40+
return nil, err
41+
}
42+
43+
return resp.Msg, nil
44+
}
45+
46+
// CreateIdentityProvider creates the identity provider.
47+
func (c *client) CreateIdentityProvider(ctx context.Context, idpID string, idp *v1pb.IdentityProvider) (*v1pb.IdentityProvider, error) {
48+
if c.idpClient == nil {
49+
return nil, errors.New("identity provider service client not initialized")
50+
}
51+
52+
req := connect.NewRequest(&v1pb.CreateIdentityProviderRequest{
53+
IdentityProvider: idp,
54+
IdentityProviderId: idpID,
55+
})
56+
57+
resp, err := c.idpClient.CreateIdentityProvider(ctx, req)
58+
if err != nil {
59+
return nil, err
60+
}
61+
62+
return resp.Msg, nil
63+
}
64+
65+
// UpdateIdentityProvider updates the identity provider.
66+
func (c *client) UpdateIdentityProvider(ctx context.Context, patch *v1pb.IdentityProvider, updateMasks []string) (*v1pb.IdentityProvider, error) {
67+
if c.idpClient == nil {
68+
return nil, errors.New("identity provider service client not initialized")
69+
}
70+
71+
req := connect.NewRequest(&v1pb.UpdateIdentityProviderRequest{
72+
IdentityProvider: patch,
73+
UpdateMask: &fieldmaskpb.FieldMask{Paths: updateMasks},
74+
})
75+
76+
resp, err := c.idpClient.UpdateIdentityProvider(ctx, req)
77+
if err != nil {
78+
return nil, err
79+
}
80+
81+
return resp.Msg, nil
82+
}
83+
84+
// DeleteIdentityProvider deletes the identity provider.
85+
func (c *client) DeleteIdentityProvider(ctx context.Context, name string) error {
86+
if c.idpClient == nil {
87+
return errors.New("identity provider service client not initialized")
88+
}
89+
90+
req := connect.NewRequest(&v1pb.DeleteIdentityProviderRequest{
91+
Name: name,
92+
})
93+
94+
_, err := c.idpClient.DeleteIdentityProvider(ctx, req)
95+
return err
96+
}

client/subscription.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package client
2+
3+
import (
4+
"context"
5+
"errors"
6+
7+
v1pb "buf.build/gen/go/bytebase/bytebase/protocolbuffers/go/v1"
8+
"connectrpc.com/connect"
9+
)
10+
11+
// GetSubscription gets the current subscription.
12+
func (c *client) GetSubscription(ctx context.Context) (*v1pb.Subscription, error) {
13+
if c.subscriptionClient == nil {
14+
return nil, errors.New("subscription service client not initialized")
15+
}
16+
17+
resp, err := c.subscriptionClient.GetSubscription(ctx, connect.NewRequest(&v1pb.GetSubscriptionRequest{}))
18+
if err != nil {
19+
return nil, err
20+
}
21+
22+
return resp.Msg, nil
23+
}
24+
25+
// UploadLicense uploads a license.
26+
func (c *client) UploadLicense(ctx context.Context, license string) (*v1pb.Subscription, error) {
27+
if c.subscriptionClient == nil {
28+
return nil, errors.New("subscription service client not initialized")
29+
}
30+
31+
resp, err := c.subscriptionClient.UploadLicense(ctx, connect.NewRequest(&v1pb.UploadLicenseRequest{
32+
License: license,
33+
}))
34+
if err != nil {
35+
return nil, err
36+
}
37+
38+
return resp.Msg, nil
39+
}

client/workspace.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,42 @@ import (
66

77
v1pb "buf.build/gen/go/bytebase/bytebase/protocolbuffers/go/v1"
88
"connectrpc.com/connect"
9+
"google.golang.org/protobuf/types/known/fieldmaskpb"
910
)
1011

12+
// GetWorkspace gets the workspace by name.
13+
func (c *client) GetWorkspace(ctx context.Context, workspaceName string) (*v1pb.Workspace, error) {
14+
if c.workspaceClient == nil {
15+
return nil, errors.New("workspace service client not initialized")
16+
}
17+
18+
resp, err := c.workspaceClient.GetWorkspace(ctx, connect.NewRequest(&v1pb.GetWorkspaceRequest{
19+
Name: workspaceName,
20+
}))
21+
if err != nil {
22+
return nil, err
23+
}
24+
25+
return resp.Msg, nil
26+
}
27+
28+
// UpdateWorkspace updates the workspace.
29+
func (c *client) UpdateWorkspace(ctx context.Context, patch *v1pb.Workspace, updateMasks []string) (*v1pb.Workspace, error) {
30+
if c.workspaceClient == nil {
31+
return nil, errors.New("workspace service client not initialized")
32+
}
33+
34+
resp, err := c.workspaceClient.UpdateWorkspace(ctx, connect.NewRequest(&v1pb.UpdateWorkspaceRequest{
35+
Workspace: patch,
36+
UpdateMask: &fieldmaskpb.FieldMask{Paths: updateMasks},
37+
}))
38+
if err != nil {
39+
return nil, err
40+
}
41+
42+
return resp.Msg, nil
43+
}
44+
1145
// GetWorkspaceIAMPolicy gets the workspace IAM policy.
1246
func (c *client) GetWorkspaceIAMPolicy(ctx context.Context) (*v1pb.IamPolicy, error) {
1347
if c.workspaceClient == nil {

0 commit comments

Comments
 (0)