File tree Expand file tree Collapse file tree 8 files changed +21
-0
lines changed Expand file tree Collapse file tree 8 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ Required:
6868- ` private_key ` (String, Sensitive)
6969- ` private_key_id ` (String)
7070- ` project_id ` (String)
71+ - ` type ` (String)
7172
7273
7374
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ require (
1010 github.com/hashicorp/terraform-plugin-framework v1.15.1
1111 github.com/hashicorp/terraform-plugin-framework-jsontypes v0.2.0
1212 github.com/hashicorp/terraform-plugin-framework-timetypes v0.5.0
13+ github.com/hashicorp/terraform-plugin-framework-validators v0.18.0
1314 github.com/hashicorp/terraform-plugin-go v0.28.0
1415 github.com/hashicorp/terraform-plugin-log v0.9.0
1516 github.com/hashicorp/terraform-plugin-testing v1.13.3
Original file line number Diff line number Diff line change @@ -121,6 +121,8 @@ github.com/hashicorp/terraform-plugin-framework-jsontypes v0.2.0 h1:SJXL5FfJJm17
121121github.com/hashicorp/terraform-plugin-framework-jsontypes v0.2.0 /go.mod h1:p0phD0IYhsu9bR4+6OetVvvH59I6LwjXGnTVEr8ox6E =
122122github.com/hashicorp/terraform-plugin-framework-timetypes v0.5.0 h1:v3DapR8gsp3EM8fKMh6up9cJUFQ2iRaFsYLP8UJnCco =
123123github.com/hashicorp/terraform-plugin-framework-timetypes v0.5.0 /go.mod h1:c3PnGE9pHBDfdEVG9t1S1C9ia5LW+gkFR0CygXlM8ak =
124+ github.com/hashicorp/terraform-plugin-framework-validators v0.18.0 h1:OQnlOt98ua//rCw+QhBbSqfW3QbwtVrcdWeQN5gI3Hw =
125+ github.com/hashicorp/terraform-plugin-framework-validators v0.18.0 /go.mod h1:lZvZvagw5hsJwuY7mAY6KUz45/U6fiDR0CzQAwWD0CA =
124126github.com/hashicorp/terraform-plugin-go v0.28.0 h1:zJmu2UDwhVN0J+J20RE5huiF3XXlTYVIleaevHZgKPA =
125127github.com/hashicorp/terraform-plugin-go v0.28.0 /go.mod h1:FDa2Bb3uumkTGSkTFpWSOwWJDwA7bf3vdP3ltLDTH6o =
126128github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0 =
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ type BigQuerySourceCredentials struct {
2323}
2424
2525type BigQuerySourceCredentialsServiceAccountKey struct {
26+ Type types.String `tfsdk:"type"`
2627 ProjectID types.String `tfsdk:"project_id"`
2728 PrivateKeyID types.String `tfsdk:"private_key_id"`
2829 PrivateKey types.String `tfsdk:"private_key"`
Original file line number Diff line number Diff line change @@ -74,6 +74,10 @@ func (c BigQuerySourceCredentials) Encode(enc *jx.Encoder) {
7474
7575func (c BigQuerySourceCredentialsServiceAccountKey ) Encode (enc * jx.Encoder ) {
7676 enc .Obj (func (enc * jx.Encoder ) {
77+ enc .Field ("type" , func (e * jx.Encoder ) {
78+ e .Str (c .Type .ValueString ())
79+ })
80+
7781 enc .Field ("project_id" , func (e * jx.Encoder ) {
7882 e .Str (c .ProjectID .ValueString ())
7983 })
Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ func (r *bigQuerySourceResource) MoveState(ctx context.Context) []resource.State
6767 }
6868
6969 type sourceCredentialsServiceAccountKeyModel struct {
70+ Type * string `json:"type"`
7071 ProjectID * string `json:"project_id"`
7172 PrivateKeyID * string `json:"private_key_id"`
7273 PrivateKey * string `json:"private_key"`
@@ -90,6 +91,7 @@ func (r *bigQuerySourceResource) MoveState(ctx context.Context) []resource.State
9091
9192 if sourceCredentials .ServiceAccountKey != nil {
9293 serviceAccountKey := NewTypedObject (BigQuerySourceCredentialsServiceAccountKey {
94+ Type : types .StringPointerValue (sourceCredentials .ServiceAccountKey .Type ),
9395 ProjectID : types .StringPointerValue (sourceCredentials .ServiceAccountKey .ProjectID ),
9496 PrivateKeyID : types .StringPointerValue (sourceCredentials .ServiceAccountKey .PrivateKeyID ),
9597 PrivateKey : types .StringPointerValue (sourceCredentials .ServiceAccountKey .PrivateKey ),
Original file line number Diff line number Diff line change @@ -4,8 +4,10 @@ import (
44 "context"
55 "maps"
66
7+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
78 "github.com/hashicorp/terraform-plugin-framework/resource/identityschema"
89 "github.com/hashicorp/terraform-plugin-framework/resource/schema"
10+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
911)
1012
1113func BigQuerySourceResourceIdentitySchema (_ context.Context ) identityschema.Schema {
@@ -58,6 +60,12 @@ func BigQuerySourceCredentialsResourceSchemaAttributes(ctx context.Context) map[
5860
5961func BigQuerySourceCredentialsServiceAccountKeyResourceSchemaAttributes (_ context.Context ) map [string ]schema.Attribute {
6062 return map [string ]schema.Attribute {
63+ "type" : schema.StringAttribute {
64+ Required : true ,
65+ Validators : []validator.String {
66+ stringvalidator .OneOf ("service_account" ),
67+ },
68+ },
6169 "project_id" : schema.StringAttribute {
6270 Required : true ,
6371 },
Original file line number Diff line number Diff line change @@ -129,6 +129,7 @@ func TestAccBigQuerySourceResourceCreateUpdateDelete(t *testing.T) {
129129 "project_id" : config .StringVariable ("project-id" ),
130130 "location" : config .StringVariable ("US" ),
131131 "service_account_key" : config .ObjectVariable (map [string ]config.Variable {
132+ "type" : config .StringVariable ("service_account" ),
132133 "project_id" : config .StringVariable ("project-id" ),
133134 "private_key_id" : config .StringVariable ("private-key-id" ),
134135 "private_key" : config .StringVariable ("private-key" ),
@@ -216,6 +217,7 @@ func TestAccBigQuerySourceResourceMovedFromSourceWithServiceAccountKey(t *testin
216217 "project_id" : config .StringVariable ("project-id" ),
217218 "location" : config .StringVariable ("US" ),
218219 "service_account_key" : config .ObjectVariable (map [string ]config.Variable {
220+ "type" : config .StringVariable ("service_account" ),
219221 "project_id" : config .StringVariable ("project-id" ),
220222 "private_key_id" : config .StringVariable ("private-key-id" ),
221223 "private_key" : config .StringVariable ("private-key" ),
You can’t perform that action at this time.
0 commit comments