From 5d7fdbe38855e1ec7b4173b192881d75013098b0 Mon Sep 17 00:00:00 2001 From: u110 Date: Thu, 20 Feb 2025 15:54:00 +0900 Subject: [PATCH 01/21] add driver for snowflake/mysql --- docs/resources/connection.md | 6 ++++- internal/client/connection.go | 4 ++-- internal/provider/connection_resource.go | 28 +++++++++++++++++++----- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/docs/resources/connection.md b/docs/resources/connection.md index 45a216ed..d63d525a 100644 --- a/docs/resources/connection.md +++ b/docs/resources/connection.md @@ -198,7 +198,11 @@ resource "trocco_connection" "s3_with_assume_role" { - `aws_auth_type` (String) S3: The authentication type for the S3 connection. It must be one of `iam_user` or `assume_role`. - `aws_iam_user` (Attributes) S3: IAM User configuration. (see [below for nested schema](#nestedatt--aws_iam_user)) - `description` (String) The description of the connection. -- `driver` (String) PostgreSQL: The name of a PostgreSQL driver. +- `driver` (String) Snowflake, MySQL, PostgreSQL: The name of a Database driver. +Possible values are: + - MySQL: `` (not set), `mysql_connector_java_5_1_49` + - Snowflake: `` (not set), `snowflake_jdbc_3_14_2`, `snowflake_jdbc_3_17_0` + - PostgreSQL: `postgresql_42_5_1`, `postgresql_9_4_1205_jdbc41` - `gateway` (Attributes) MySQL, PostgreSQL: Whether to connect via SSH (see [below for nested schema](#nestedatt--gateway)) - `host` (String) Snowflake, PostgreSQL: The host of a (Snowflake, PostgreSQL) account. - `password` (String, Sensitive) Snowflake, PostgreSQL: The password for the (Snowflake, PostgreSQL) user. diff --git a/internal/client/connection.go b/internal/client/connection.go index 62defafb..85a78227 100644 --- a/internal/client/connection.go +++ b/internal/client/connection.go @@ -109,7 +109,7 @@ type CreateConnectionInput struct { SSLClientCa *string `json:"ssl_client_ca,omitempty"` SSLClientKey *string `json:"ssl_client_key,omitempty"` SSLMode *parameter.NullableString `json:"ssl_mode,omitempty"` - Driver *string `json:"driver,omitempty"` + Driver *parameter.NullableString `json:"driver,omitempty"` } type UpdateConnectionInput struct { @@ -163,7 +163,7 @@ type UpdateConnectionInput struct { SSLClientCa *string `json:"ssl_client_ca,omitempty"` SSLClientKey *string `json:"ssl_client_key,omitempty"` SSLMode *parameter.NullableString `json:"ssl_mode,omitempty"` - Driver *string `json:"driver,omitempty"` + Driver *parameter.NullableString `json:"driver,omitempty"` } func (c *TroccoClient) GetConnections(connectionType string, in *GetConnectionsInput) (*ConnectionList, error) { diff --git a/internal/provider/connection_resource.go b/internal/provider/connection_resource.go index 26028e0b..35b337a6 100644 --- a/internal/provider/connection_resource.go +++ b/internal/provider/connection_resource.go @@ -104,7 +104,7 @@ func (m *connectionResourceModel) ToCreateConnectionInput() *client.CreateConnec AWSAuthType: m.AWSAuthType.ValueStringPointer(), // PostgreSQL Fields - Driver: m.Driver.ValueStringPointer(), + Driver: model.NewNullableString(m.Driver), } // SSL Fields @@ -182,7 +182,7 @@ func (m *connectionResourceModel) ToUpdateConnectionInput() *client.UpdateConnec AWSAuthType: m.AWSAuthType.ValueStringPointer(), // PostgreSQL Fields - Driver: m.Driver.ValueStringPointer(), + Driver: model.NewNullableString(m.Driver), } // SSL Fields @@ -569,10 +569,28 @@ func (r *connectionResource) Schema( // PostgreSQL Fields "driver": schema.StringAttribute{ - MarkdownDescription: "PostgreSQL: The name of a PostgreSQL driver.", - Optional: true, + MarkdownDescription: strings.Join( + []string{ + "Snowflake, MySQL, PostgreSQL: The name of a Database driver.", + "Possible values are:", + " - MySQL: null, `mysql_connector_java_5_1_49`", + " - Snowflake: null, `snowflake_jdbc_3_14_2`, `snowflake_jdbc_3_17_0`", + " - PostgreSQL: `postgresql_42_5_1`, `postgresql_9_4_1205_jdbc41`", + }, + "\n", + ), + Optional: true, Validators: []validator.String{ - stringvalidator.OneOf("postgresql_42_5_1", "postgresql_9_4_1205_jdbc41"), + stringvalidator.OneOf( + // MySQL + "mysql_connector_java_5_1_49", + // Snowflake + "snowflake_jdbc_3_14_2", + "snowflake_jdbc_3_17_0", + // PostgreSQL + "postgresql_42_5_1", + "postgresql_9_4_1205_jdbc41", + ), }, }, }, From 8b00e07c83ed7323acec027bac8b022e6a435894 Mon Sep 17 00:00:00 2001 From: u110 Date: Fri, 21 Feb 2025 10:38:11 +0900 Subject: [PATCH 02/21] docs --- docs/resources/connection.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/resources/connection.md b/docs/resources/connection.md index d63d525a..313226cb 100644 --- a/docs/resources/connection.md +++ b/docs/resources/connection.md @@ -200,8 +200,8 @@ resource "trocco_connection" "s3_with_assume_role" { - `description` (String) The description of the connection. - `driver` (String) Snowflake, MySQL, PostgreSQL: The name of a Database driver. Possible values are: - - MySQL: `` (not set), `mysql_connector_java_5_1_49` - - Snowflake: `` (not set), `snowflake_jdbc_3_14_2`, `snowflake_jdbc_3_17_0` + - MySQL: null, `mysql_connector_java_5_1_49` + - Snowflake: null, `snowflake_jdbc_3_14_2`, `snowflake_jdbc_3_17_0` - PostgreSQL: `postgresql_42_5_1`, `postgresql_9_4_1205_jdbc41` - `gateway` (Attributes) MySQL, PostgreSQL: Whether to connect via SSH (see [below for nested schema](#nestedatt--gateway)) - `host` (String) Snowflake, PostgreSQL: The host of a (Snowflake, PostgreSQL) account. From 69e4751018ba7a9aec9da06a09aa0fd6d0819374 Mon Sep 17 00:00:00 2001 From: u110 Date: Sun, 23 Feb 2025 14:36:44 +0900 Subject: [PATCH 03/21] add validator --- internal/provider/connection_resource.go | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/internal/provider/connection_resource.go b/internal/provider/connection_resource.go index 35b337a6..710c13e5 100644 --- a/internal/provider/connection_resource.go +++ b/internal/provider/connection_resource.go @@ -903,6 +903,7 @@ func (r *connectionResource) ValidateConfig( if plan.AuthMethod.ValueString() == "user_password" { validateRequiredString(plan.Password, "password", "Snowflake", resp) } + validatePatterns(plan.Driver, "driver", "Snowflake", resp, "snowflake_jdbc_3_14_2", "snowflake_jdbc_3_17_0") case "gcs": validateRequiredString(plan.ApplicationName, "application_name", "GCS", resp) validateRequiredString(plan.ServiceAccountEmail, "service_account_email", "GCS", resp) @@ -914,6 +915,7 @@ func (r *connectionResource) ValidateConfig( validateRequiredInt(plan.Port, "port", "MySQL", resp) validateRequiredString(plan.UserName, "user_name", "MySQL", resp) validateRequiredString(plan.Password, "password", "MySQL", resp) + validatePatterns(plan.Driver, "driver", "MySQL", resp, "mysql_connector_java_5_1_49") if plan.Gateway != nil { validateRequiredString(plan.Gateway.Host, "gateway.host", "MySQL", resp) validateRequiredInt(plan.Gateway.Port, "gateway.port", "MySQL", resp) @@ -966,6 +968,7 @@ func (r *connectionResource) ValidateConfig( validateRequiredInt(plan.Port, "port", "PostgreSQL", resp) validateRequiredString(plan.UserName, "user_name", "PostgreSQL", resp) validateRequiredString(plan.Driver, "driver", "PostgreSQL", resp) + validatePatterns(plan.Driver, "driver", "PostgreSQL", resp, "postgresql_42_5_1", "postgresql_9_4_1205_jdbc41") if plan.Gateway != nil { validateRequiredString(plan.Gateway.Host, "gateway.host", "PostgreSQL", resp) validateRequiredInt(plan.Gateway.Port, "gateway.port", "PostgreSQL", resp) @@ -974,6 +977,28 @@ func (r *connectionResource) ValidateConfig( } } +func validatePatterns(field types.String, fieldName, connectionType string, resp *resource.ValidateConfigResponse, patterns ...string) { + if field.IsNull() { + return + } + + for _, pattern := range patterns { + if field.ValueString() == pattern { + return + } + } + + resp.Diagnostics.AddError( + fieldName, + fmt.Sprintf("%s: `%s` is invalid for %s connection. Valid values are: %s", + fieldName, + field.ValueString(), + connectionType, + strings.Join(patterns, ", "), + ), + ) +} + func validateRequiredString(field types.String, fieldName, connectionType string, resp *resource.ValidateConfigResponse) { if field.IsNull() { resp.Diagnostics.AddError( From 2b6a36bcc5657c4a7e3894c7d7086b100e7767cd Mon Sep 17 00:00:00 2001 From: u110 Date: Sun, 23 Feb 2025 14:36:57 +0900 Subject: [PATCH 04/21] add tests --- internal/provider/connection_resource_test.go | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) diff --git a/internal/provider/connection_resource_test.go b/internal/provider/connection_resource_test.go index 49b0d205..32d539bc 100644 --- a/internal/provider/connection_resource_test.go +++ b/internal/provider/connection_resource_test.go @@ -2,6 +2,7 @@ package provider import ( "fmt" + "regexp" "testing" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -19,6 +20,7 @@ func TestAccConnectionResource(t *testing.T) { name = "test" description = "The quick brown fox jumps over the lazy dog." + project_id = "test" service_account_json_key = "{\"type\":\"service_account\",\"project_id\":\"\",\"private_key_id\":\"\",\"private_key\":\"\"}" } @@ -42,6 +44,127 @@ func TestAccConnectionResource(t *testing.T) { return fmt.Sprintf("bigquery,%s", connectionID), nil }, }, + // Snowflake + { + Config: providerConfig + ` + resource "trocco_connection" "snowflake_test" { + connection_type = "snowflake" + auth_method = "user_password" + + name = "snowflake test" + host = "example.snowflakecomputing.com" + user_name = "root" + password = "password" + } + `, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("trocco_connection.snowflake_test", "connection_type", "snowflake"), + resource.TestCheckResourceAttr("trocco_connection.snowflake_test", "name", "snowflake test"), + resource.TestCheckResourceAttrSet("trocco_connection.snowflake_test", "id"), + ), + }, + // MySQL + { + Config: providerConfig + ` + resource "trocco_connection" "mysql_test" { + connection_type = "mysql" + + name = "mysql test" + host = "localhost" + user_name = "root" + password = "password" + port = 3306 + } + `, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("trocco_connection.mysql_test", "connection_type", "mysql"), + resource.TestCheckResourceAttr("trocco_connection.mysql_test", "name", "mysql test"), + resource.TestCheckResourceAttrSet("trocco_connection.mysql_test", "id"), + ), + }, + // PostgreSQL + { + Config: providerConfig + ` + resource "trocco_connection" "postgresql_test" { + connection_type = "postgresql" + name = "postgresql test" + host = "localhost" + user_name = "root" + password = "password" + port = 5432 + driver = "postgresql_42_5_1" + } + `, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("trocco_connection.postgresql_test", "connection_type", "postgresql"), + resource.TestCheckResourceAttrSet("trocco_connection.postgresql_test", "id"), + ), + }, + }, + }) +} + +func TestInvalidDriver(t *testing.T) { + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: providerConfig + ` + resource "trocco_connection" "invalid_driver_test" { + connection_type = "postgresql" + name = "invalid driver test" + host = "localhost" + user_name = "root" + password = "password" + port = 5432 + driver = "invalid_driver" + } + `, + ExpectError: regexp.MustCompile("driver: `invalid_driver` is invalid for PostgreSQL connection. "), + }, + { + Config: providerConfig + ` + resource "trocco_connection" "mismatch_driver_test_postgresql" { + connection_type = "postgresql" + name = "invalid driver test" + host = "localhost" + user_name = "root" + password = "password" + port = 5432 + driver = "mysql_connector_java_5_1_49" + } + `, + ExpectError: regexp.MustCompile("are: postgresql_42_5_1, postgresql_9_4_1205_jdbc41"), + }, + { + Config: providerConfig + ` + resource "trocco_connection" "mismatch_driver_test_mysql" { + connection_type = "mysql" + name = "invalid driver test" + host = "localhost" + user_name = "root" + password = "password" + port = 3306 + driver = "snowflake_jdbc_3_14_2" + } + `, + ExpectError: regexp.MustCompile("are: mysql_connector_java_5_1_49"), + }, + { + Config: providerConfig + ` + resource "trocco_connection" "mismatch_driver_test_snowflake" { + connection_type = "snowflake" + name = "invalid driver test" + + auth_method = "user_password" + host = "example.snowflakecomputing.com" + user_name = "root" + password = "password" + driver = "mysql_connector_java_5_1_49" + } + `, + ExpectError: regexp.MustCompile("are: snowflake_jdbc_3_14_2, snowflake_jdbc_3_17_0"), + }, }, }) } From 82b14bbcbf0c1f61baeee1397c2e8c05da7f3fec Mon Sep 17 00:00:00 2001 From: u110 Date: Sun, 23 Feb 2025 14:37:11 +0900 Subject: [PATCH 05/21] add example --- GNUmakefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/GNUmakefile b/GNUmakefile index 7771cd69..5786d0d4 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -4,3 +4,8 @@ default: testacc .PHONY: testacc testacc: TF_ACC=1 go test ./... -v $(TESTARGS) -timeout 120m + +# example) +# $ TROCCO_TEST_URL=https://localhost:4000 \ +# TROCCO_API_KEY=**** \ +# make testacc TESTARGS="-run TestSample" From 9b9a1e800bd80a323f90770198cf796c7b995ef9 Mon Sep 17 00:00:00 2001 From: u110 Date: Tue, 18 Feb 2025 06:40:28 +0900 Subject: [PATCH 06/21] add gh-actions for e2e test --- .github/workflows/e2e_test.yml | 67 ++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/e2e_test.yml diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml new file mode 100644 index 00000000..befee2eb --- /dev/null +++ b/.github/workflows/e2e_test.yml @@ -0,0 +1,67 @@ +name: E2E tests + +on: + push: + branches: + - main + pull_request: + branches: + - main + +permissions: + contents: read + +jobs: + e2e_test: + name: E2E tests + runs-on: ubuntu-latest + timeout-minutes: 15 + if: >- + github.actor == 'u110' || + github.actor == 'okeyaki' || + github.actor == 'katamotokosuke' || + github.actor == 'yosuke-oka' || + github.actor == 'gtnao' + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + with: + go-version-file: "go.mod" + cache: true + - uses: hashicorp/setup-terraform@651471c36a6092792c552e8b1bef71e592b462d8 # v3.1.1 + - run: go mod download + - run: | + make testacc + env: + TROCCO_API_KEY: ${{ secrets.TROCCO_API_KEY }} + TROCCO_TEST_URL: https://trocco.io + + e2e_test_for_others: + name: E2E tests for others + runs-on: ubuntu-latest + timeout-minutes: 15 + # if the actor is not in team member, run the e2e tests after approval + if: >- + !( + github.actor == 'u110' || + github.actor == 'okeyaki' || + github.actor == 'katamotokosuke' || + github.actor == 'yosuke-oka' || + github.actor == 'gtnao' + ) + # see https://github.com/trocco-io/terraform-provider-trocco/settings/environments + environment: production + # REFACTOR: use composite actions + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + with: + go-version-file: "go.mod" + cache: true + - uses: hashicorp/setup-terraform@651471c36a6092792c552e8b1bef71e592b462d8 # v3.1.1 + - run: go mod download + - run: | + make testacc + env: + TROCCO_API_KEY: ${{ secrets.TROCCO_API_KEY }} + TROCCO_TEST_URL: https://trocco.io From e000ed5b3a78cebfb0b9b207c0f28728f0b8177d Mon Sep 17 00:00:00 2001 From: u110 Date: Tue, 18 Feb 2025 14:28:09 +0900 Subject: [PATCH 07/21] fix --- .github/workflows/e2e_test.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index befee2eb..06627dea 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -17,11 +17,11 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 15 if: >- - github.actor == 'u110' || - github.actor == 'okeyaki' || + github.actor == 'gtnao' || github.actor == 'katamotokosuke' || - github.actor == 'yosuke-oka' || - github.actor == 'gtnao' + github.actor == 'okeyaki' || + github.actor == 'u110' || + github.actor == 'yosuke-oka' steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 @@ -41,13 +41,14 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 15 # if the actor is not in team member, run the e2e tests after approval + # REFACTOR: use org teams if: >- !( - github.actor == 'u110' || - github.actor == 'okeyaki' || + github.actor == 'gtnao' || github.actor == 'katamotokosuke' || - github.actor == 'yosuke-oka' || - github.actor == 'gtnao' + github.actor == 'okeyaki' || + github.actor == 'u110' || + github.actor == 'yosuke-oka' ) # see https://github.com/trocco-io/terraform-provider-trocco/settings/environments environment: production From 8b0d2fafee180c1aff4ed07e2528ea98477ed61b Mon Sep 17 00:00:00 2001 From: u110 Date: Fri, 21 Feb 2025 10:50:42 +0900 Subject: [PATCH 08/21] removed specifying each members and adding settings for `Require approval for all external contributors` for Actions permissions --- .github/workflows/e2e_test.yml | 37 ---------------------------------- 1 file changed, 37 deletions(-) diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index 06627dea..e1e56825 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -16,43 +16,6 @@ jobs: name: E2E tests runs-on: ubuntu-latest timeout-minutes: 15 - if: >- - github.actor == 'gtnao' || - github.actor == 'katamotokosuke' || - github.actor == 'okeyaki' || - github.actor == 'u110' || - github.actor == 'yosuke-oka' - steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 - with: - go-version-file: "go.mod" - cache: true - - uses: hashicorp/setup-terraform@651471c36a6092792c552e8b1bef71e592b462d8 # v3.1.1 - - run: go mod download - - run: | - make testacc - env: - TROCCO_API_KEY: ${{ secrets.TROCCO_API_KEY }} - TROCCO_TEST_URL: https://trocco.io - - e2e_test_for_others: - name: E2E tests for others - runs-on: ubuntu-latest - timeout-minutes: 15 - # if the actor is not in team member, run the e2e tests after approval - # REFACTOR: use org teams - if: >- - !( - github.actor == 'gtnao' || - github.actor == 'katamotokosuke' || - github.actor == 'okeyaki' || - github.actor == 'u110' || - github.actor == 'yosuke-oka' - ) - # see https://github.com/trocco-io/terraform-provider-trocco/settings/environments - environment: production - # REFACTOR: use composite actions steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 From 04fd80e92ff7c08310cf397884480401788f9bc6 Mon Sep 17 00:00:00 2001 From: u110 Date: Sat, 22 Feb 2025 10:14:29 +0900 Subject: [PATCH 09/21] wip: fix test for e2e --- internal/provider/connection_resource_test.go | 1 - .../provider/job_definition_resource_test.go | 52 +++++++++++++++---- .../provider/resource_group_resource_test.go | 48 ++++++++++++----- internal/provider/team_resource_test.go | 10 ++-- 4 files changed, 81 insertions(+), 30 deletions(-) diff --git a/internal/provider/connection_resource_test.go b/internal/provider/connection_resource_test.go index 32d539bc..098d5aa4 100644 --- a/internal/provider/connection_resource_test.go +++ b/internal/provider/connection_resource_test.go @@ -17,7 +17,6 @@ func TestAccConnectionResource(t *testing.T) { Config: providerConfig + ` resource "trocco_connection" "test" { connection_type = "bigquery" - name = "test" description = "The quick brown fox jumps over the lazy dog." project_id = "test" diff --git a/internal/provider/job_definition_resource_test.go b/internal/provider/job_definition_resource_test.go index 49f25d8d..7e5e3057 100644 --- a/internal/provider/job_definition_resource_test.go +++ b/internal/provider/job_definition_resource_test.go @@ -14,20 +14,57 @@ func TestAccJobDefinitionResource(t *testing.T) { Steps: []resource.TestStep{ { Config: providerConfig + ` - - +resource "trocco_connection" "test_mysql" { + connection_type = "mysql" + name = "MySQL Example" + host = "db.example.com" + port = 65535 + user_name = "root" + password = "password" +} +resource "trocco_connection" "test_bq" { + connection_type = "bigquery" + name = "BigQuery Example" + project_id = "example" + service_account_json_key = <" is duplicated in the list.`), }, }, }) diff --git a/internal/provider/team_resource_test.go b/internal/provider/team_resource_test.go index 03af6179..2c01da92 100644 --- a/internal/provider/team_resource_test.go +++ b/internal/provider/team_resource_test.go @@ -19,7 +19,7 @@ func TestAccTeamResource(t *testing.T) { description = "test" members = [ { - user_id = 1 + user_id = 10626 role = "team_admin" } ] @@ -29,7 +29,6 @@ func TestAccTeamResource(t *testing.T) { resource.TestCheckResourceAttr("trocco_team.test", "name", "test"), resource.TestCheckResourceAttr("trocco_team.test", "description", "test"), resource.TestCheckResourceAttr("trocco_team.test", "members.#", "1"), - resource.TestCheckResourceAttr("trocco_team.test", "members.0.user_id", "1"), resource.TestCheckResourceAttr("trocco_team.test", "members.0.role", "team_admin"), ), }, @@ -43,16 +42,17 @@ func TestAccTeamResource(t *testing.T) { // Update testing { Config: providerConfig + ` + resource "trocco_team" "test" { name = "updated" description = "updated" members = [ { - user_id = 1 + user_id = 10626 role = "team_admin" }, { - user_id = 2 + user_id = 10652 role = "team_member" } ] @@ -62,9 +62,7 @@ func TestAccTeamResource(t *testing.T) { resource.TestCheckResourceAttr("trocco_team.test", "name", "updated"), resource.TestCheckResourceAttr("trocco_team.test", "description", "updated"), resource.TestCheckResourceAttr("trocco_team.test", "members.#", "2"), - resource.TestCheckResourceAttr("trocco_team.test", "members.0.user_id", "1"), resource.TestCheckResourceAttr("trocco_team.test", "members.0.role", "team_admin"), - resource.TestCheckResourceAttr("trocco_team.test", "members.1.user_id", "2"), resource.TestCheckResourceAttr("trocco_team.test", "members.1.role", "team_member"), ), }, From 3b08b9c761bd3f2bde110a0e3029f29672d015f3 Mon Sep 17 00:00:00 2001 From: u110 Date: Sun, 23 Feb 2025 14:51:47 +0900 Subject: [PATCH 10/21] fix tests --- internal/provider/label_resource_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/provider/label_resource_test.go b/internal/provider/label_resource_test.go index c9bc7117..cb6b3bbd 100644 --- a/internal/provider/label_resource_test.go +++ b/internal/provider/label_resource_test.go @@ -72,7 +72,7 @@ func TestAccLabelResource(t *testing.T) { }, { Config: providerConfig + ` - resource "trocco_label" "test" { + resource "trocco_label" "test_empty_description" { name = "Updated Label, Second Time" color = "#000000" } @@ -81,13 +81,13 @@ func TestAccLabelResource(t *testing.T) { }, { Config: providerConfig + ` - resource "trocco_label" "test2" { + resource "trocco_label" "test_empty_description_test2" { name = "Updated Label, Third Time" color = "#000000" description = "" } `, - Check: resource.TestCheckResourceAttr("trocco_label.test_empty_description", "description", ""), + Check: resource.TestCheckResourceAttr("trocco_label.test_empty_description_test2", "description", ""), }, }, }) From f5043ba32401b606df16d12a913dc5f6caec2794 Mon Sep 17 00:00:00 2001 From: u110 Date: Sun, 23 Feb 2025 14:58:33 +0900 Subject: [PATCH 11/21] fix tests --- internal/provider/job_definition_resource_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/provider/job_definition_resource_test.go b/internal/provider/job_definition_resource_test.go index 7e5e3057..1563a75a 100644 --- a/internal/provider/job_definition_resource_test.go +++ b/internal/provider/job_definition_resource_test.go @@ -1,7 +1,6 @@ package provider import ( - "fmt" "testing" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -242,6 +241,7 @@ resource "trocco_job_definition" "mysql_to_bigquery" { bigquery_connection_id = trocco_connection.test_bq.id location = "us-west1" bigquery_output_option_clustering_fields = [] + bigquery_output_option_column_options = [] bigquery_output_option_merge_keys = [] } } @@ -264,7 +264,7 @@ resource "trocco_job_definition" "mysql_to_bigquery" { ImportStateIdFunc: func(s *terraform.State) (string, error) { jobDefinitionId := s.RootModule().Resources["trocco_job_definition.mysql_to_bigquery"].Primary.ID - return fmt.Sprintf("job_definition,%s", jobDefinitionId), nil + return jobDefinitionId, nil }, }, }, From 38d1a65a8c64ef219a17b28e2afe03ca0f39e766 Mon Sep 17 00:00:00 2001 From: u110 Date: Thu, 20 Feb 2025 15:54:00 +0900 Subject: [PATCH 12/21] add driver for snowflake/mysql --- docs/resources/connection.md | 6 ++++- internal/client/connection.go | 4 ++-- internal/provider/connection_resource.go | 28 +++++++++++++++++++----- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/docs/resources/connection.md b/docs/resources/connection.md index 45a216ed..d63d525a 100644 --- a/docs/resources/connection.md +++ b/docs/resources/connection.md @@ -198,7 +198,11 @@ resource "trocco_connection" "s3_with_assume_role" { - `aws_auth_type` (String) S3: The authentication type for the S3 connection. It must be one of `iam_user` or `assume_role`. - `aws_iam_user` (Attributes) S3: IAM User configuration. (see [below for nested schema](#nestedatt--aws_iam_user)) - `description` (String) The description of the connection. -- `driver` (String) PostgreSQL: The name of a PostgreSQL driver. +- `driver` (String) Snowflake, MySQL, PostgreSQL: The name of a Database driver. +Possible values are: + - MySQL: `` (not set), `mysql_connector_java_5_1_49` + - Snowflake: `` (not set), `snowflake_jdbc_3_14_2`, `snowflake_jdbc_3_17_0` + - PostgreSQL: `postgresql_42_5_1`, `postgresql_9_4_1205_jdbc41` - `gateway` (Attributes) MySQL, PostgreSQL: Whether to connect via SSH (see [below for nested schema](#nestedatt--gateway)) - `host` (String) Snowflake, PostgreSQL: The host of a (Snowflake, PostgreSQL) account. - `password` (String, Sensitive) Snowflake, PostgreSQL: The password for the (Snowflake, PostgreSQL) user. diff --git a/internal/client/connection.go b/internal/client/connection.go index 62defafb..85a78227 100644 --- a/internal/client/connection.go +++ b/internal/client/connection.go @@ -109,7 +109,7 @@ type CreateConnectionInput struct { SSLClientCa *string `json:"ssl_client_ca,omitempty"` SSLClientKey *string `json:"ssl_client_key,omitempty"` SSLMode *parameter.NullableString `json:"ssl_mode,omitempty"` - Driver *string `json:"driver,omitempty"` + Driver *parameter.NullableString `json:"driver,omitempty"` } type UpdateConnectionInput struct { @@ -163,7 +163,7 @@ type UpdateConnectionInput struct { SSLClientCa *string `json:"ssl_client_ca,omitempty"` SSLClientKey *string `json:"ssl_client_key,omitempty"` SSLMode *parameter.NullableString `json:"ssl_mode,omitempty"` - Driver *string `json:"driver,omitempty"` + Driver *parameter.NullableString `json:"driver,omitempty"` } func (c *TroccoClient) GetConnections(connectionType string, in *GetConnectionsInput) (*ConnectionList, error) { diff --git a/internal/provider/connection_resource.go b/internal/provider/connection_resource.go index 26028e0b..35b337a6 100644 --- a/internal/provider/connection_resource.go +++ b/internal/provider/connection_resource.go @@ -104,7 +104,7 @@ func (m *connectionResourceModel) ToCreateConnectionInput() *client.CreateConnec AWSAuthType: m.AWSAuthType.ValueStringPointer(), // PostgreSQL Fields - Driver: m.Driver.ValueStringPointer(), + Driver: model.NewNullableString(m.Driver), } // SSL Fields @@ -182,7 +182,7 @@ func (m *connectionResourceModel) ToUpdateConnectionInput() *client.UpdateConnec AWSAuthType: m.AWSAuthType.ValueStringPointer(), // PostgreSQL Fields - Driver: m.Driver.ValueStringPointer(), + Driver: model.NewNullableString(m.Driver), } // SSL Fields @@ -569,10 +569,28 @@ func (r *connectionResource) Schema( // PostgreSQL Fields "driver": schema.StringAttribute{ - MarkdownDescription: "PostgreSQL: The name of a PostgreSQL driver.", - Optional: true, + MarkdownDescription: strings.Join( + []string{ + "Snowflake, MySQL, PostgreSQL: The name of a Database driver.", + "Possible values are:", + " - MySQL: null, `mysql_connector_java_5_1_49`", + " - Snowflake: null, `snowflake_jdbc_3_14_2`, `snowflake_jdbc_3_17_0`", + " - PostgreSQL: `postgresql_42_5_1`, `postgresql_9_4_1205_jdbc41`", + }, + "\n", + ), + Optional: true, Validators: []validator.String{ - stringvalidator.OneOf("postgresql_42_5_1", "postgresql_9_4_1205_jdbc41"), + stringvalidator.OneOf( + // MySQL + "mysql_connector_java_5_1_49", + // Snowflake + "snowflake_jdbc_3_14_2", + "snowflake_jdbc_3_17_0", + // PostgreSQL + "postgresql_42_5_1", + "postgresql_9_4_1205_jdbc41", + ), }, }, }, From 61e700418bfe6841a187ebb3f7eff9bff34e307c Mon Sep 17 00:00:00 2001 From: u110 Date: Fri, 21 Feb 2025 10:38:11 +0900 Subject: [PATCH 13/21] docs --- docs/resources/connection.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/resources/connection.md b/docs/resources/connection.md index d63d525a..313226cb 100644 --- a/docs/resources/connection.md +++ b/docs/resources/connection.md @@ -200,8 +200,8 @@ resource "trocco_connection" "s3_with_assume_role" { - `description` (String) The description of the connection. - `driver` (String) Snowflake, MySQL, PostgreSQL: The name of a Database driver. Possible values are: - - MySQL: `` (not set), `mysql_connector_java_5_1_49` - - Snowflake: `` (not set), `snowflake_jdbc_3_14_2`, `snowflake_jdbc_3_17_0` + - MySQL: null, `mysql_connector_java_5_1_49` + - Snowflake: null, `snowflake_jdbc_3_14_2`, `snowflake_jdbc_3_17_0` - PostgreSQL: `postgresql_42_5_1`, `postgresql_9_4_1205_jdbc41` - `gateway` (Attributes) MySQL, PostgreSQL: Whether to connect via SSH (see [below for nested schema](#nestedatt--gateway)) - `host` (String) Snowflake, PostgreSQL: The host of a (Snowflake, PostgreSQL) account. From 4b18e01c84ba164053bf619dcd9a14f18d6b8b61 Mon Sep 17 00:00:00 2001 From: u110 Date: Sun, 23 Feb 2025 14:36:44 +0900 Subject: [PATCH 14/21] add validator --- internal/provider/connection_resource.go | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/internal/provider/connection_resource.go b/internal/provider/connection_resource.go index 35b337a6..710c13e5 100644 --- a/internal/provider/connection_resource.go +++ b/internal/provider/connection_resource.go @@ -903,6 +903,7 @@ func (r *connectionResource) ValidateConfig( if plan.AuthMethod.ValueString() == "user_password" { validateRequiredString(plan.Password, "password", "Snowflake", resp) } + validatePatterns(plan.Driver, "driver", "Snowflake", resp, "snowflake_jdbc_3_14_2", "snowflake_jdbc_3_17_0") case "gcs": validateRequiredString(plan.ApplicationName, "application_name", "GCS", resp) validateRequiredString(plan.ServiceAccountEmail, "service_account_email", "GCS", resp) @@ -914,6 +915,7 @@ func (r *connectionResource) ValidateConfig( validateRequiredInt(plan.Port, "port", "MySQL", resp) validateRequiredString(plan.UserName, "user_name", "MySQL", resp) validateRequiredString(plan.Password, "password", "MySQL", resp) + validatePatterns(plan.Driver, "driver", "MySQL", resp, "mysql_connector_java_5_1_49") if plan.Gateway != nil { validateRequiredString(plan.Gateway.Host, "gateway.host", "MySQL", resp) validateRequiredInt(plan.Gateway.Port, "gateway.port", "MySQL", resp) @@ -966,6 +968,7 @@ func (r *connectionResource) ValidateConfig( validateRequiredInt(plan.Port, "port", "PostgreSQL", resp) validateRequiredString(plan.UserName, "user_name", "PostgreSQL", resp) validateRequiredString(plan.Driver, "driver", "PostgreSQL", resp) + validatePatterns(plan.Driver, "driver", "PostgreSQL", resp, "postgresql_42_5_1", "postgresql_9_4_1205_jdbc41") if plan.Gateway != nil { validateRequiredString(plan.Gateway.Host, "gateway.host", "PostgreSQL", resp) validateRequiredInt(plan.Gateway.Port, "gateway.port", "PostgreSQL", resp) @@ -974,6 +977,28 @@ func (r *connectionResource) ValidateConfig( } } +func validatePatterns(field types.String, fieldName, connectionType string, resp *resource.ValidateConfigResponse, patterns ...string) { + if field.IsNull() { + return + } + + for _, pattern := range patterns { + if field.ValueString() == pattern { + return + } + } + + resp.Diagnostics.AddError( + fieldName, + fmt.Sprintf("%s: `%s` is invalid for %s connection. Valid values are: %s", + fieldName, + field.ValueString(), + connectionType, + strings.Join(patterns, ", "), + ), + ) +} + func validateRequiredString(field types.String, fieldName, connectionType string, resp *resource.ValidateConfigResponse) { if field.IsNull() { resp.Diagnostics.AddError( From 9a857f880eedd08d8182b37965611738bdf2ef79 Mon Sep 17 00:00:00 2001 From: u110 Date: Sun, 23 Feb 2025 14:36:57 +0900 Subject: [PATCH 15/21] add tests --- internal/provider/connection_resource_test.go | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) diff --git a/internal/provider/connection_resource_test.go b/internal/provider/connection_resource_test.go index 49b0d205..32d539bc 100644 --- a/internal/provider/connection_resource_test.go +++ b/internal/provider/connection_resource_test.go @@ -2,6 +2,7 @@ package provider import ( "fmt" + "regexp" "testing" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -19,6 +20,7 @@ func TestAccConnectionResource(t *testing.T) { name = "test" description = "The quick brown fox jumps over the lazy dog." + project_id = "test" service_account_json_key = "{\"type\":\"service_account\",\"project_id\":\"\",\"private_key_id\":\"\",\"private_key\":\"\"}" } @@ -42,6 +44,127 @@ func TestAccConnectionResource(t *testing.T) { return fmt.Sprintf("bigquery,%s", connectionID), nil }, }, + // Snowflake + { + Config: providerConfig + ` + resource "trocco_connection" "snowflake_test" { + connection_type = "snowflake" + auth_method = "user_password" + + name = "snowflake test" + host = "example.snowflakecomputing.com" + user_name = "root" + password = "password" + } + `, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("trocco_connection.snowflake_test", "connection_type", "snowflake"), + resource.TestCheckResourceAttr("trocco_connection.snowflake_test", "name", "snowflake test"), + resource.TestCheckResourceAttrSet("trocco_connection.snowflake_test", "id"), + ), + }, + // MySQL + { + Config: providerConfig + ` + resource "trocco_connection" "mysql_test" { + connection_type = "mysql" + + name = "mysql test" + host = "localhost" + user_name = "root" + password = "password" + port = 3306 + } + `, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("trocco_connection.mysql_test", "connection_type", "mysql"), + resource.TestCheckResourceAttr("trocco_connection.mysql_test", "name", "mysql test"), + resource.TestCheckResourceAttrSet("trocco_connection.mysql_test", "id"), + ), + }, + // PostgreSQL + { + Config: providerConfig + ` + resource "trocco_connection" "postgresql_test" { + connection_type = "postgresql" + name = "postgresql test" + host = "localhost" + user_name = "root" + password = "password" + port = 5432 + driver = "postgresql_42_5_1" + } + `, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("trocco_connection.postgresql_test", "connection_type", "postgresql"), + resource.TestCheckResourceAttrSet("trocco_connection.postgresql_test", "id"), + ), + }, + }, + }) +} + +func TestInvalidDriver(t *testing.T) { + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: providerConfig + ` + resource "trocco_connection" "invalid_driver_test" { + connection_type = "postgresql" + name = "invalid driver test" + host = "localhost" + user_name = "root" + password = "password" + port = 5432 + driver = "invalid_driver" + } + `, + ExpectError: regexp.MustCompile("driver: `invalid_driver` is invalid for PostgreSQL connection. "), + }, + { + Config: providerConfig + ` + resource "trocco_connection" "mismatch_driver_test_postgresql" { + connection_type = "postgresql" + name = "invalid driver test" + host = "localhost" + user_name = "root" + password = "password" + port = 5432 + driver = "mysql_connector_java_5_1_49" + } + `, + ExpectError: regexp.MustCompile("are: postgresql_42_5_1, postgresql_9_4_1205_jdbc41"), + }, + { + Config: providerConfig + ` + resource "trocco_connection" "mismatch_driver_test_mysql" { + connection_type = "mysql" + name = "invalid driver test" + host = "localhost" + user_name = "root" + password = "password" + port = 3306 + driver = "snowflake_jdbc_3_14_2" + } + `, + ExpectError: regexp.MustCompile("are: mysql_connector_java_5_1_49"), + }, + { + Config: providerConfig + ` + resource "trocco_connection" "mismatch_driver_test_snowflake" { + connection_type = "snowflake" + name = "invalid driver test" + + auth_method = "user_password" + host = "example.snowflakecomputing.com" + user_name = "root" + password = "password" + driver = "mysql_connector_java_5_1_49" + } + `, + ExpectError: regexp.MustCompile("are: snowflake_jdbc_3_14_2, snowflake_jdbc_3_17_0"), + }, }, }) } From d48b43cefb96d2e07d998cf8dd714560d06c9e7a Mon Sep 17 00:00:00 2001 From: u110 Date: Sun, 23 Feb 2025 14:37:11 +0900 Subject: [PATCH 16/21] add example for make testacc --- GNUmakefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/GNUmakefile b/GNUmakefile index 7771cd69..42544ae5 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -4,3 +4,8 @@ default: testacc .PHONY: testacc testacc: TF_ACC=1 go test ./... -v $(TESTARGS) -timeout 120m + +# example) +# $ TROCCO_TEST_URL=https://localhost:4000 \ +# TROCCO_API_KEY=**** \ +# make testacc TESTARGS="-run TestAccConnectionResource" From 8221270d2c11012512649a97f6fabf5bd230cd5b Mon Sep 17 00:00:00 2001 From: u110 Date: Sun, 23 Feb 2025 19:06:48 +0900 Subject: [PATCH 17/21] use string syntax for markdown --- docs/resources/connection.md | 7 +++---- internal/provider/connection_resource.go | 15 +++++---------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/docs/resources/connection.md b/docs/resources/connection.md index 313226cb..d9cc6af7 100644 --- a/docs/resources/connection.md +++ b/docs/resources/connection.md @@ -199,10 +199,9 @@ resource "trocco_connection" "s3_with_assume_role" { - `aws_iam_user` (Attributes) S3: IAM User configuration. (see [below for nested schema](#nestedatt--aws_iam_user)) - `description` (String) The description of the connection. - `driver` (String) Snowflake, MySQL, PostgreSQL: The name of a Database driver. -Possible values are: - - MySQL: null, `mysql_connector_java_5_1_49` - - Snowflake: null, `snowflake_jdbc_3_14_2`, `snowflake_jdbc_3_17_0` - - PostgreSQL: `postgresql_42_5_1`, `postgresql_9_4_1205_jdbc41` + - MySQL: null, mysql_connector_java_5_1_49 + - Snowflake: null, snowflake_jdbc_3_14_2, snowflake_jdbc_3_17_0, + - PostgreSQL: postgresql_42_5_1, postgresql_9_4_1205_jdbc41 - `gateway` (Attributes) MySQL, PostgreSQL: Whether to connect via SSH (see [below for nested schema](#nestedatt--gateway)) - `host` (String) Snowflake, PostgreSQL: The host of a (Snowflake, PostgreSQL) account. - `password` (String, Sensitive) Snowflake, PostgreSQL: The password for the (Snowflake, PostgreSQL) user. diff --git a/internal/provider/connection_resource.go b/internal/provider/connection_resource.go index 710c13e5..2035311d 100644 --- a/internal/provider/connection_resource.go +++ b/internal/provider/connection_resource.go @@ -569,16 +569,11 @@ func (r *connectionResource) Schema( // PostgreSQL Fields "driver": schema.StringAttribute{ - MarkdownDescription: strings.Join( - []string{ - "Snowflake, MySQL, PostgreSQL: The name of a Database driver.", - "Possible values are:", - " - MySQL: null, `mysql_connector_java_5_1_49`", - " - Snowflake: null, `snowflake_jdbc_3_14_2`, `snowflake_jdbc_3_17_0`", - " - PostgreSQL: `postgresql_42_5_1`, `postgresql_9_4_1205_jdbc41`", - }, - "\n", - ), + MarkdownDescription: `Snowflake, MySQL, PostgreSQL: The name of a Database driver. + - MySQL: null, mysql_connector_java_5_1_49 + - Snowflake: null, snowflake_jdbc_3_14_2, snowflake_jdbc_3_17_0, + - PostgreSQL: postgresql_42_5_1, postgresql_9_4_1205_jdbc41 +`, Optional: true, Validators: []validator.String{ stringvalidator.OneOf( From a18ee9595bada0356ce836d5fb08d4f34cc8a612 Mon Sep 17 00:00:00 2001 From: u110 Date: Sun, 23 Feb 2025 19:08:53 +0900 Subject: [PATCH 18/21] rename --- internal/provider/connection_resource.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/provider/connection_resource.go b/internal/provider/connection_resource.go index 2035311d..8cfc35ec 100644 --- a/internal/provider/connection_resource.go +++ b/internal/provider/connection_resource.go @@ -898,7 +898,7 @@ func (r *connectionResource) ValidateConfig( if plan.AuthMethod.ValueString() == "user_password" { validateRequiredString(plan.Password, "password", "Snowflake", resp) } - validatePatterns(plan.Driver, "driver", "Snowflake", resp, "snowflake_jdbc_3_14_2", "snowflake_jdbc_3_17_0") + validateStringAgainstPatterns(plan.Driver, "driver", "Snowflake", resp, "snowflake_jdbc_3_14_2", "snowflake_jdbc_3_17_0") case "gcs": validateRequiredString(plan.ApplicationName, "application_name", "GCS", resp) validateRequiredString(plan.ServiceAccountEmail, "service_account_email", "GCS", resp) @@ -910,7 +910,7 @@ func (r *connectionResource) ValidateConfig( validateRequiredInt(plan.Port, "port", "MySQL", resp) validateRequiredString(plan.UserName, "user_name", "MySQL", resp) validateRequiredString(plan.Password, "password", "MySQL", resp) - validatePatterns(plan.Driver, "driver", "MySQL", resp, "mysql_connector_java_5_1_49") + validateStringAgainstPatterns(plan.Driver, "driver", "MySQL", resp, "mysql_connector_java_5_1_49") if plan.Gateway != nil { validateRequiredString(plan.Gateway.Host, "gateway.host", "MySQL", resp) validateRequiredInt(plan.Gateway.Port, "gateway.port", "MySQL", resp) @@ -963,7 +963,7 @@ func (r *connectionResource) ValidateConfig( validateRequiredInt(plan.Port, "port", "PostgreSQL", resp) validateRequiredString(plan.UserName, "user_name", "PostgreSQL", resp) validateRequiredString(plan.Driver, "driver", "PostgreSQL", resp) - validatePatterns(plan.Driver, "driver", "PostgreSQL", resp, "postgresql_42_5_1", "postgresql_9_4_1205_jdbc41") + validateStringAgainstPatterns(plan.Driver, "driver", "PostgreSQL", resp, "postgresql_42_5_1", "postgresql_9_4_1205_jdbc41") if plan.Gateway != nil { validateRequiredString(plan.Gateway.Host, "gateway.host", "PostgreSQL", resp) validateRequiredInt(plan.Gateway.Port, "gateway.port", "PostgreSQL", resp) @@ -972,7 +972,7 @@ func (r *connectionResource) ValidateConfig( } } -func validatePatterns(field types.String, fieldName, connectionType string, resp *resource.ValidateConfigResponse, patterns ...string) { +func validateStringAgainstPatterns(field types.String, fieldName, connectionType string, resp *resource.ValidateConfigResponse, patterns ...string) { if field.IsNull() { return } From 178db940d24950480b5e5c1b11e005580893d486 Mon Sep 17 00:00:00 2001 From: u110 Date: Wed, 26 Feb 2025 09:38:35 +0900 Subject: [PATCH 19/21] fix hook target --- .github/workflows/e2e_test.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index e1e56825..9d712178 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -2,11 +2,15 @@ name: E2E tests on: push: - branches: - - main + paths-ignore: + - "README.md" + - docs/** + - examples/** pull_request: - branches: - - main + paths-ignore: + - "README.md" + - docs/** + - examples/** permissions: contents: read From ee031ed564de0ed111fc7e60c551dbf3292083e9 Mon Sep 17 00:00:00 2001 From: u110 Date: Wed, 26 Feb 2025 09:43:32 +0900 Subject: [PATCH 20/21] fix --- .github/workflows/e2e_test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index 9d712178..373440be 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -11,6 +11,8 @@ on: - "README.md" - docs/** - examples/** + branches: + - main permissions: contents: read From 1f3c469ad6fba78048a25f1cb5a2ef6211c9506b Mon Sep 17 00:00:00 2001 From: Yuu Ito Date: Thu, 27 Feb 2025 11:33:12 +0900 Subject: [PATCH 21/21] Update .github/workflows/e2e_test.yml --- .github/workflows/e2e_test.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index 373440be..807c1d84 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -1,11 +1,6 @@ name: E2E tests on: - push: - paths-ignore: - - "README.md" - - docs/** - - examples/** pull_request: paths-ignore: - "README.md"