From 47a950c257f28404f6e81cf4b8c487ddb57c7253 Mon Sep 17 00:00:00 2001 From: Thomas Rodgers Date: Tue, 12 Dec 2023 22:29:25 +0000 Subject: [PATCH] Un-migrate connection --- mmv1/products/cloudbuildv2/Connection.yaml | 185 +---- .../resource_cloudbuildv2_connection_test.go | 679 ------------------ .../cloudbuildv2/samples/ghe.repository.json | 10 + .../samples/ghe_complete.connection.json | 13 + .../samples/ghe_complete_connection.yaml | 26 + .../cloudbuildv2/samples/ghe_connection.yaml | 29 + .../samples/ghe_initial.connection.json | 8 + .../samples/ghe_priv.connection.json | 12 + .../samples/ghe_priv_connection.yaml | 26 + .../samples/ghe_priv_update_connection.yaml | 29 + .../cloudbuildv2/samples/ghe_repository.yaml | 30 + .../samples/github.repository.json | 7 + .../samples/github_connection.yaml | 29 + .../samples/github_initial.connection.json | 13 + .../samples/github_repository.yaml | 30 + .../samples/github_update.connection.json | 16 + .../samples/gitlab.connection.json | 14 + .../samples/gitlab.repository.json | 10 + .../samples/gitlab_connection.yaml | 24 + .../samples/gitlab_repository.yaml | 28 + .../cloudbuildv2/samples/gle.connection.json | 15 + .../cloudbuildv2/samples/gle.repository.json | 10 + .../cloudbuildv2/samples/gle_connection.yaml | 27 + .../samples/gle_old.connection.json | 15 + .../samples/gle_old_connection.yaml | 27 + .../samples/gle_priv.connection.json | 19 + .../samples/gle_priv_connection.yaml | 24 + .../samples/gle_priv_update_connection.yaml | 27 + .../cloudbuildv2/samples/gle_repository.yaml | 28 + .../samples/gle_update.connection.json | 13 + .../cloudbuildv2/beta/connection.yaml | 4 + .../cloudbuildv2/beta/repository.yaml | 22 + .../cloudbuildv2/beta/tpgtools_product.yaml | 9 + .../overrides/cloudbuildv2/connection.yaml | 4 + .../samples/connection/ghe.tf.tmpl | 0 .../samples/connection/github.tf.tmpl | 8 +- .../samples/connection/github.yaml | 16 + .../cloudbuildv2/samples/connection/meta.yaml | 20 + .../cloudbuildv2/tpgtools_product.yaml | 9 + 39 files changed, 652 insertions(+), 863 deletions(-) delete mode 100644 mmv1/third_party/terraform/services/cloudbuildv2/resource_cloudbuildv2_connection_test.go create mode 100755 tpgtools/api/cloudbuildv2/samples/ghe.repository.json create mode 100755 tpgtools/api/cloudbuildv2/samples/ghe_complete.connection.json create mode 100755 tpgtools/api/cloudbuildv2/samples/ghe_complete_connection.yaml create mode 100755 tpgtools/api/cloudbuildv2/samples/ghe_connection.yaml create mode 100755 tpgtools/api/cloudbuildv2/samples/ghe_initial.connection.json create mode 100755 tpgtools/api/cloudbuildv2/samples/ghe_priv.connection.json create mode 100755 tpgtools/api/cloudbuildv2/samples/ghe_priv_connection.yaml create mode 100755 tpgtools/api/cloudbuildv2/samples/ghe_priv_update_connection.yaml create mode 100755 tpgtools/api/cloudbuildv2/samples/ghe_repository.yaml create mode 100755 tpgtools/api/cloudbuildv2/samples/github.repository.json create mode 100755 tpgtools/api/cloudbuildv2/samples/github_connection.yaml create mode 100755 tpgtools/api/cloudbuildv2/samples/github_initial.connection.json create mode 100755 tpgtools/api/cloudbuildv2/samples/github_repository.yaml create mode 100755 tpgtools/api/cloudbuildv2/samples/github_update.connection.json create mode 100755 tpgtools/api/cloudbuildv2/samples/gitlab.connection.json create mode 100755 tpgtools/api/cloudbuildv2/samples/gitlab.repository.json create mode 100755 tpgtools/api/cloudbuildv2/samples/gitlab_connection.yaml create mode 100755 tpgtools/api/cloudbuildv2/samples/gitlab_repository.yaml create mode 100755 tpgtools/api/cloudbuildv2/samples/gle.connection.json create mode 100755 tpgtools/api/cloudbuildv2/samples/gle.repository.json create mode 100755 tpgtools/api/cloudbuildv2/samples/gle_connection.yaml create mode 100755 tpgtools/api/cloudbuildv2/samples/gle_old.connection.json create mode 100755 tpgtools/api/cloudbuildv2/samples/gle_old_connection.yaml create mode 100755 tpgtools/api/cloudbuildv2/samples/gle_priv.connection.json create mode 100755 tpgtools/api/cloudbuildv2/samples/gle_priv_connection.yaml create mode 100755 tpgtools/api/cloudbuildv2/samples/gle_priv_update_connection.yaml create mode 100755 tpgtools/api/cloudbuildv2/samples/gle_repository.yaml create mode 100755 tpgtools/api/cloudbuildv2/samples/gle_update.connection.json create mode 100644 tpgtools/overrides/cloudbuildv2/beta/connection.yaml create mode 100644 tpgtools/overrides/cloudbuildv2/beta/repository.yaml create mode 100644 tpgtools/overrides/cloudbuildv2/beta/tpgtools_product.yaml create mode 100644 tpgtools/overrides/cloudbuildv2/connection.yaml rename mmv1/templates/terraform/examples/cloudbuildv2_connection_ghe.tf.erb => tpgtools/overrides/cloudbuildv2/samples/connection/ghe.tf.tmpl (100%) rename mmv1/templates/terraform/examples/cloudbuildv2_connection_github.tf.erb => tpgtools/overrides/cloudbuildv2/samples/connection/github.tf.tmpl (77%) create mode 100644 tpgtools/overrides/cloudbuildv2/samples/connection/github.yaml create mode 100644 tpgtools/overrides/cloudbuildv2/samples/connection/meta.yaml create mode 100644 tpgtools/overrides/cloudbuildv2/tpgtools_product.yaml diff --git a/mmv1/products/cloudbuildv2/Connection.yaml b/mmv1/products/cloudbuildv2/Connection.yaml index 61173b9be897..e4607930dc3f 100644 --- a/mmv1/products/cloudbuildv2/Connection.yaml +++ b/mmv1/products/cloudbuildv2/Connection.yaml @@ -14,19 +14,10 @@ --- !ruby/object:Api::Resource name: 'Connection' base_url: projects/{{project}}/locations/{{location}}/connections -create_url: projects/{{project}}/locations/{{location}}/connections?connectionId={{name}} self_link: projects/{{project}}/locations/{{location}}/connections/{{name}} -references: !ruby/object:Api::Resource::ReferenceLinks - guides: - 'Official Documentation': 'https://cloud.google.com/build/docs' - api: 'https://cloud.google.com/build/docs/api/reference/rest' -autogen_async: true -async: !ruby/object:Api::OpAsync - operation: !ruby/object:Api::OpAsync::Operation - base_url: '{{op_id}}' -update_verb: :PATCH +exclude_resource: true description: | - A connection to a SCM like GitHub, GitHub Enterprise, Bitbucket Data Center or GitLab. + Only used to generate IAM resources. exclude_tgc: true iam_policy: !ruby/object:Api::Resource::IamPolicy skip_import_test: true @@ -49,174 +40,8 @@ examples: ])" vars: connection_name: 'tf-test-connection' - - !ruby/object:Provider::Terraform::Examples - name: 'cloudbuildv2_connection_ghe' - skip_test: true - - !ruby/object:Provider::Terraform::Examples - name: 'cloudbuildv2_connection_github' - skip_test: true -parameters: - - !ruby/object:Api::Type::String - name: name - description: Immutable. The resource name of the connection. - url_param_only: true - required: true - immutable: true - - !ruby/object:Api::Type::String - name: location - description: The location for the resource - url_param_only: true - required: true - immutable: true properties: - !ruby/object:Api::Type::String - name: createTime - description: Output only. Server assigned timestamp for when the connection was created. - output: true - - !ruby/object:Api::Type::String - name: updateTime - description: Output only. Server assigned timestamp for when the connection was updated. - output: true - - !ruby/object:Api::Type::NestedObject - name: githubConfig - description: Configuration for connections to github.com. - properties: - - !ruby/object:Api::Type::NestedObject - name: authorizerCredential - description: OAuth credential of the account that authorized the Cloud Build GitHub App. It is recommended to use a robot account instead of a human user account. The OAuth token must be tied to the Cloud Build GitHub App. - properties: - - !ruby/object:Api::Type::String - name: oauthTokenSecretVersion - description: 'A SecretManager resource containing the OAuth token that authorizes the Cloud Build connection. Format: `projects/*/secrets/*/versions/*`.' - - !ruby/object:Api::Type::String - name: username - description: Output only. The username associated to this token. - output: true - - !ruby/object:Api::Type::Integer - name: appInstallationId - description: GitHub App installation id. - - !ruby/object:Api::Type::NestedObject - name: githubEnterpriseConfig - description: Configuration for connections to an instance of GitHub Enterprise. - properties: - - !ruby/object:Api::Type::String - name: hostUri - description: Required. The URI of the GitHub Enterprise host this connection is for. - required: true - - !ruby/object:Api::Type::Integer - name: appId - description: Id of the GitHub App created from the manifest. - - !ruby/object:Api::Type::String - name: appSlug - description: The URL-friendly name of the GitHub App. - - !ruby/object:Api::Type::String - name: privateKeySecretVersion - description: SecretManager resource containing the private key of the GitHub App, formatted as `projects/*/secrets/*/versions/*`. - - !ruby/object:Api::Type::String - name: webhookSecretSecretVersion - description: SecretManager resource containing the webhook secret of the GitHub App, formatted as `projects/*/secrets/*/versions/*`. - - !ruby/object:Api::Type::Integer - name: appInstallationId - description: ID of the installation of the GitHub App. - - !ruby/object:Api::Type::NestedObject - name: serviceDirectoryConfig - description: Configuration for using Service Directory to privately connect to a GitHub Enterprise server. This should only be set if the GitHub Enterprise server is hosted on-premises and not reachable by public internet. If this field is left empty, calls to the GitHub Enterprise server will be made over the public internet. - properties: - - !ruby/object:Api::Type::String - name: service - description: 'Required. The Service Directory service name. Format: projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}.' - required: true - - !ruby/object:Api::Type::String - name: sslCa - description: SSL certificate to use for requests to GitHub Enterprise. - - !ruby/object:Api::Type::NestedObject - name: gitlabConfig - description: Configuration for connections to gitlab.com or an instance of GitLab Enterprise. - properties: - - !ruby/object:Api::Type::String - name: hostUri - description: The URI of the GitLab Enterprise host this connection is for. If not specified, the default value is https://gitlab.com. - default_from_api: true - - !ruby/object:Api::Type::String - name: webhookSecretSecretVersion - description: Required. Immutable. SecretManager resource containing the webhook secret of a GitLab Enterprise project, formatted as `projects/*/secrets/*/versions/*`. - required: true - immutable: true - - !ruby/object:Api::Type::NestedObject - name: readAuthorizerCredential - description: Required. A GitLab personal access token with the minimum `read_api` scope access. - required: true - properties: - - !ruby/object:Api::Type::String - name: userTokenSecretVersion - description: 'Required. A SecretManager resource containing the user token that authorizes the Cloud Build connection. Format: `projects/*/secrets/*/versions/*`.' - required: true - - !ruby/object:Api::Type::String - name: username - description: Output only. The username associated to this token. - output: true - - !ruby/object:Api::Type::NestedObject - name: authorizerCredential - description: Required. A GitLab personal access token with the `api` scope access. - required: true - properties: - - !ruby/object:Api::Type::String - name: userTokenSecretVersion - description: 'Required. A SecretManager resource containing the user token that authorizes the Cloud Build connection. Format: `projects/*/secrets/*/versions/*`.' - required: true - - !ruby/object:Api::Type::String - name: username - description: Output only. The username associated to this token. - output: true - - !ruby/object:Api::Type::NestedObject - name: serviceDirectoryConfig - description: Configuration for using Service Directory to privately connect to a GitLab Enterprise server. This should only be set if the GitLab Enterprise server is hosted on-premises and not reachable by public internet. If this field is left empty, calls to the GitLab Enterprise server will be made over the public internet. - properties: - - !ruby/object:Api::Type::String - name: service - description: 'Required. The Service Directory service name. Format: projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}.' - required: true - - !ruby/object:Api::Type::String - name: sslCa - description: SSL certificate to use for requests to GitLab Enterprise. - - !ruby/object:Api::Type::String - name: serverVersion - description: Output only. Version of the GitLab Enterprise server running on the `host_uri`. - output: true - - !ruby/object:Api::Type::NestedObject - name: installationState - description: Output only. Installation state of the Connection. - output: true - properties: - - !ruby/object:Api::Type::Enum - name: stage - description: Output only. Current step of the installation process. - output: true - values: - - :STAGE_UNSPECIFIED - - :PENDING_CREATE_APP - - :PENDING_USER_OAUTH - - :PENDING_INSTALL_APP - - :COMPLETE - - !ruby/object:Api::Type::String - name: message - description: Output only. Message of what the user should do next to continue the installation. Empty string if the installation is already complete. - output: true - - !ruby/object:Api::Type::String - name: actionUri - description: Output only. Link to follow for next action. Empty string if the installation is already complete. - output: true - - !ruby/object:Api::Type::Boolean - name: disabled - description: If disabled is set to true, functionality is disabled for this connection. Repository based API methods and webhooks processing for repositories in this connection will be disabled. - - !ruby/object:Api::Type::Boolean - name: reconciling - description: Output only. Set to true when the connection is being set up or updated in the background. - output: true - - !ruby/object:Api::Type::KeyValueAnnotations - name: annotations - description: Allows clients to store small amounts of arbitrary data. - - !ruby/object:Api::Type::String - name: etag - description: This checksum is computed by the server based on the value of other fields, and may be sent on update and delete requests to ensure the client has an up-to-date value before proceeding. - output: true + name: 'name' + description: Dummy property. + required: true diff --git a/mmv1/third_party/terraform/services/cloudbuildv2/resource_cloudbuildv2_connection_test.go b/mmv1/third_party/terraform/services/cloudbuildv2/resource_cloudbuildv2_connection_test.go deleted file mode 100644 index ecbfc8ba465e..000000000000 --- a/mmv1/third_party/terraform/services/cloudbuildv2/resource_cloudbuildv2_connection_test.go +++ /dev/null @@ -1,679 +0,0 @@ -package cloudbuildv2_test - -import ( - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-provider-google/google/acctest" - "github.com/hashicorp/terraform-provider-google/google/envvar" -) - -func TestAccCloudbuildv2Connection_GheCompleteConnection(t *testing.T) { - t.Parallel() - - context := map[string]interface{}{ - "project_name": envvar.GetTestProjectFromEnv(), - "region": envvar.GetTestRegionFromEnv(), - "random_suffix": acctest.RandString(t, 10), - } - - acctest.VcrTest(t, resource.TestCase{ - PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), - CheckDestroy: testAccCheckCloudbuildv2ConnectionDestroyProducer(t), - Steps: []resource.TestStep{ - { - Config: testAccCloudbuildv2Connection_GheCompleteConnection(context), - }, - { - ResourceName: "google_cloudbuildv2_connection.primary", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"annotations"}, - }, - }, - }) -} - -func TestAccCloudbuildv2Connection_GheConnection(t *testing.T) { - t.Parallel() - - context := map[string]interface{}{ - "project_name": envvar.GetTestProjectFromEnv(), - "region": envvar.GetTestRegionFromEnv(), - "random_suffix": acctest.RandString(t, 10), - } - - acctest.VcrTest(t, resource.TestCase{ - PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), - CheckDestroy: testAccCheckCloudbuildv2ConnectionDestroyProducer(t), - Steps: []resource.TestStep{ - { - Config: testAccCloudbuildv2Connection_GheConnection(context), - }, - { - ResourceName: "google_cloudbuildv2_connection.primary", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"annotations"}, - }, - { - Config: testAccCloudbuildv2Connection_GheConnectionUpdate0(context), - }, - { - ResourceName: "google_cloudbuildv2_connection.primary", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"annotations"}, - }, - }, - }) -} - -func TestAccCloudbuildv2Connection_GhePrivConnection(t *testing.T) { - t.Parallel() - - context := map[string]interface{}{ - "project_name": envvar.GetTestProjectFromEnv(), - "region": envvar.GetTestRegionFromEnv(), - "random_suffix": acctest.RandString(t, 10), - } - - acctest.VcrTest(t, resource.TestCase{ - PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), - CheckDestroy: testAccCheckCloudbuildv2ConnectionDestroyProducer(t), - Steps: []resource.TestStep{ - { - Config: testAccCloudbuildv2Connection_GhePrivConnection(context), - }, - { - ResourceName: "google_cloudbuildv2_connection.primary", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"annotations"}, - }, - }, - }) -} - -func TestAccCloudbuildv2Connection_GhePrivUpdateConnection(t *testing.T) { - t.Parallel() - - context := map[string]interface{}{ - "project_name": envvar.GetTestProjectFromEnv(), - "region": envvar.GetTestRegionFromEnv(), - "random_suffix": acctest.RandString(t, 10), - } - - acctest.VcrTest(t, resource.TestCase{ - PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), - CheckDestroy: testAccCheckCloudbuildv2ConnectionDestroyProducer(t), - Steps: []resource.TestStep{ - { - Config: testAccCloudbuildv2Connection_GhePrivUpdateConnection(context), - }, - { - ResourceName: "google_cloudbuildv2_connection.primary", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"annotations"}, - }, - { - Config: testAccCloudbuildv2Connection_GhePrivUpdateConnectionUpdate0(context), - }, - { - ResourceName: "google_cloudbuildv2_connection.primary", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"annotations"}, - }, - }, - }) -} - -func TestAccCloudbuildv2Connection_GithubConnection(t *testing.T) { - t.Parallel() - - context := map[string]interface{}{ - "project_name": envvar.GetTestProjectFromEnv(), - "region": envvar.GetTestRegionFromEnv(), - "random_suffix": acctest.RandString(t, 10), - } - - acctest.VcrTest(t, resource.TestCase{ - PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), - CheckDestroy: testAccCheckCloudbuildv2ConnectionDestroyProducer(t), - Steps: []resource.TestStep{ - { - Config: testAccCloudbuildv2Connection_GithubConnection(context), - }, - { - ResourceName: "google_cloudbuildv2_connection.primary", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"annotations"}, - }, - { - Config: testAccCloudbuildv2Connection_GithubConnectionUpdate0(context), - }, - { - ResourceName: "google_cloudbuildv2_connection.primary", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"annotations"}, - }, - }, - }) -} - -func TestAccCloudbuildv2Connection_GitlabConnection(t *testing.T) { - t.Parallel() - - context := map[string]interface{}{ - "project_name": envvar.GetTestProjectFromEnv(), - "random_suffix": acctest.RandString(t, 10), - } - - acctest.VcrTest(t, resource.TestCase{ - PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), - CheckDestroy: testAccCheckCloudbuildv2ConnectionDestroyProducer(t), - Steps: []resource.TestStep{ - { - Config: testAccCloudbuildv2Connection_GitlabConnection(context), - }, - { - ResourceName: "google_cloudbuildv2_connection.primary", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"annotations"}, - }, - }, - }) -} - -func TestAccCloudbuildv2Connection_GleConnection(t *testing.T) { - t.Parallel() - - context := map[string]interface{}{ - "project_name": envvar.GetTestProjectFromEnv(), - "random_suffix": acctest.RandString(t, 10), - } - - acctest.VcrTest(t, resource.TestCase{ - PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), - CheckDestroy: testAccCheckCloudbuildv2ConnectionDestroyProducer(t), - Steps: []resource.TestStep{ - { - Config: testAccCloudbuildv2Connection_GleConnection(context), - }, - { - ResourceName: "google_cloudbuildv2_connection.primary", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"annotations"}, - }, - { - Config: testAccCloudbuildv2Connection_GleConnectionUpdate0(context), - }, - { - ResourceName: "google_cloudbuildv2_connection.primary", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"annotations"}, - }, - }, - }) -} - -func TestAccCloudbuildv2Connection_GleOldConnection(t *testing.T) { - t.Parallel() - - context := map[string]interface{}{ - "project_name": envvar.GetTestProjectFromEnv(), - "random_suffix": acctest.RandString(t, 10), - } - - acctest.VcrTest(t, resource.TestCase{ - PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), - CheckDestroy: testAccCheckCloudbuildv2ConnectionDestroyProducer(t), - Steps: []resource.TestStep{ - { - Config: testAccCloudbuildv2Connection_GleOldConnection(context), - }, - { - ResourceName: "google_cloudbuildv2_connection.primary", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"annotations"}, - }, - { - Config: testAccCloudbuildv2Connection_GleOldConnectionUpdate0(context), - }, - { - ResourceName: "google_cloudbuildv2_connection.primary", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"annotations"}, - }, - }, - }) -} - -func TestAccCloudbuildv2Connection_GlePrivConnection(t *testing.T) { - t.Parallel() - - context := map[string]interface{}{ - "project_name": envvar.GetTestProjectFromEnv(), - "random_suffix": acctest.RandString(t, 10), - } - - acctest.VcrTest(t, resource.TestCase{ - PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), - CheckDestroy: testAccCheckCloudbuildv2ConnectionDestroyProducer(t), - Steps: []resource.TestStep{ - { - Config: testAccCloudbuildv2Connection_GlePrivConnection(context), - }, - { - ResourceName: "google_cloudbuildv2_connection.primary", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"annotations"}, - }, - }, - }) -} - -func TestAccCloudbuildv2Connection_GlePrivUpdateConnection(t *testing.T) { - t.Parallel() - - context := map[string]interface{}{ - "project_name": envvar.GetTestProjectFromEnv(), - "random_suffix": acctest.RandString(t, 10), - } - - acctest.VcrTest(t, resource.TestCase{ - PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), - CheckDestroy: testAccCheckCloudbuildv2ConnectionDestroyProducer(t), - Steps: []resource.TestStep{ - { - Config: testAccCloudbuildv2Connection_GleConnection(context), - }, - { - ResourceName: "google_cloudbuildv2_connection.primary", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"annotations"}, - }, - { - Config: testAccCloudbuildv2Connection_GlePrivConnection(context), - }, - { - ResourceName: "google_cloudbuildv2_connection.primary", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"annotations"}, - }, - }, - }) -} - -func testAccCloudbuildv2Connection_GheCompleteConnection(context map[string]interface{}) string { - return acctest.Nprintf(` -resource "google_cloudbuildv2_connection" "primary" { - location = "%{region}" - name = "tf-test-connection%{random_suffix}" - - github_enterprise_config { - host_uri = "https://ghe.proctor-staging-test.com" - app_id = 516 - app_installation_id = 243 - app_slug = "myapp" - private_key_secret_version = "projects/gcb-terraform-creds/secrets/ghe-private-key/versions/latest" - webhook_secret_secret_version = "projects/gcb-terraform-creds/secrets/ghe-webhook-secret/versions/latest" - } - - project = "%{project_name}" - annotations = {} -} - - -`, context) -} - -func testAccCloudbuildv2Connection_GheConnection(context map[string]interface{}) string { - return acctest.Nprintf(` -resource "google_cloudbuildv2_connection" "primary" { - location = "%{region}" - name = "tf-test-connection%{random_suffix}" - - github_enterprise_config { - host_uri = "https://ghe.proctor-staging-test.com" - } - - project = "%{project_name}" - annotations = {} -} - - -`, context) -} - -func testAccCloudbuildv2Connection_GheConnectionUpdate0(context map[string]interface{}) string { - return acctest.Nprintf(` -resource "google_cloudbuildv2_connection" "primary" { - location = "%{region}" - name = "tf-test-connection%{random_suffix}" - - github_enterprise_config { - host_uri = "https://ghe.proctor-staging-test.com" - app_id = 516 - app_installation_id = 243 - app_slug = "myapp" - private_key_secret_version = "projects/gcb-terraform-creds/secrets/ghe-private-key/versions/latest" - webhook_secret_secret_version = "projects/gcb-terraform-creds/secrets/ghe-webhook-secret/versions/latest" - } - - project = "%{project_name}" - annotations = {} -} - - -`, context) -} - -func testAccCloudbuildv2Connection_GhePrivConnection(context map[string]interface{}) string { - return acctest.Nprintf(` -resource "google_cloudbuildv2_connection" "primary" { - location = "%{region}" - name = "tf-test-connection%{random_suffix}" - - github_enterprise_config { - host_uri = "https://ghe.proctor-private-ca.com" - - service_directory_config { - service = "projects/gcb-terraform-creds/locations/%{region}/namespaces/myns/services/serv" - } - - ssl_ca = "-----BEGIN CERTIFICATE-----\nMIIEXTCCA0WgAwIBAgIUANaBCc9j/xdKJHU0sgmv6yE2WCIwDQYJKoZIhvcNAQEL\nBQAwLDEUMBIGA1UEChMLUHJvY3RvciBFbmcxFDASBgNVBAMTC1Byb2N0b3ItZW5n\nMB4XDTIxMDcxNTIwMDcwMloXDTIyMDcxNTIwMDcwMVowADCCASIwDQYJKoZIhvcN\nAQEBBQADggEPADCCAQoCggEBAMVel7I88DkhwW445BNPBZvJNTV1AreHdz4um4U1\nop2+4L7JeNrUs5SRc0fzeOyOmA9ZzTDu9hBC7zj/sVNUy6cIQGCj32sr5SCAEIat\nnFZlzmVqJPT4J5NAaE37KO5347myTJEBrvpq8az4CtvX0yUzPK0gbUmaSaztVi4o\ndbJLKyv575xCLC/Hu6fIHBDH19eG1Ath9VpuAOkttRRoxu2VqijJZrGqaS+0o+OX\nrLi5HMtZbZjgQB4mc1g3ZDKX/gynxr+CDNaqNOqxuog33Tl5OcOk9DrR3MInaE7F\nyQFuH9mzF64AqOoTf7Tr/eAIz5XVt8K51nk+fSybEfKVwtMCAwEAAaOCAaEwggGd\nMA4GA1UdDwEB/wQEAwIFoDAMBgNVHRMBAf8EAjAAMB0GA1UdDgQWBBQU/9dYyqMz\nv9rOMwPZcoIRMDAQCjAfBgNVHSMEGDAWgBTkQGTiCkLCmv/Awxdz5TAVRmyFfDCB\njQYIKwYBBQUHAQE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MBIGA1UEAxMLUHJvY3Rvci1lbmcwggEiMA0GCSqGSIb3DQEBAQUA\nA4IBDwAwggEKAoIBAQCYqJP5Qt90jIbld2dtuUV/zIkBFsTe4fapJfhBji03xBpN\nO1Yxj/jPSZ67Kdeoy0lEwvc2hL5FQGhIjLMR0mzOyN4fk/DZiA/4tAVi7hJyqpUC\n71JSwp7MwXL1b26CSE1MhcoCqA/E4iZxfJfF/ef4lhmC24UEmu8FEbldoy+6OysB\nRu7dGDwicW5F9h7eSkpGAsCRdJHh65iUx/IH0C4Ux2UZRDZdj6wVbuVu9tb938xF\nyRuVClONoLSn/lwdzeV7hQmBSm8qmfgbNPbYRaNLz3hOpsT+27aDQp2/pxue8hFJ\nd7We3+Lr5O4IL45PBwhVEAiFZqde6d4qViNEB2qTAgMBAAGjYzBhMA4GA1UdDwEB\n/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTkQGTiCkLCmv/Awxdz\n5TAVRmyFfDAfBgNVHSMEGDAWgBTkQGTiCkLCmv/Awxdz5TAVRmyFfDANBgkqhkiG\n9w0BAQsFAAOCAQEAfy5BJsWdx0oWWi7SFg9MbryWjBVPJl93UqACgG0Cgh813O/x\nlDZQhGO/ZFVhHz/WgooE/HgVNoVJTubKLLzz+zCkOB0wa3GMqJDyFjhFmUtd/3VM\nZh0ZQ+JWYsAiZW4VITj5xEn/d/B3xCFWGC1vhvhptEJ8Fo2cE1yM2pzk08NqFWoY\n4FaH0sbxWgyCKwTmtcYDbnx4FYuddryGCIxbYizqUK1dr4DGKeHonhm/d234Ew3x\n3vIBPoHMOfBec/coP1xAf5o+F+MRMO/sQ3tTGgyOH18lwsHo9SmXCrmOwVQPKrEw\nm+A+5TjXLmenyaBhqXa0vkAZYJhWdROhWC0VTA==\n-----END CERTIFICATE-----\n" - } - - project = "%{project_name}" - annotations = {} -} - - -`, context) -} - -func testAccCloudbuildv2Connection_GhePrivUpdateConnection(context map[string]interface{}) string { - return acctest.Nprintf(` -resource "google_cloudbuildv2_connection" "primary" { - location = "%{region}" - name = "tf-test-connection%{random_suffix}" - - github_enterprise_config { - host_uri = "https://ghe.proctor-staging-test.com" - } - - project = "%{project_name}" - annotations = {} -} - - -`, context) -} - -func testAccCloudbuildv2Connection_GhePrivUpdateConnectionUpdate0(context map[string]interface{}) string { - return acctest.Nprintf(` -resource "google_cloudbuildv2_connection" "primary" { - location = "%{region}" - name = "tf-test-connection%{random_suffix}" - - github_enterprise_config { - host_uri = "https://ghe.proctor-private-ca.com" - - service_directory_config { - service = "projects/gcb-terraform-creds/locations/%{region}/namespaces/myns/services/serv" - } - - ssl_ca = "-----BEGIN CERTIFICATE-----\nMIIEXTCCA0WgAwIBAgIUANaBCc9j/xdKJHU0sgmv6yE2WCIwDQYJKoZIhvcNAQEL\nBQAwLDEUMBIGA1UEChMLUHJvY3RvciBFbmcxFDASBgNVBAMTC1Byb2N0b3ItZW5n\nMB4XDTIxMDcxNTIwMDcwMloXDTIyMDcxNTIwMDcwMVowADCCASIwDQYJKoZIhvcN\nAQEBBQADggEPADCCAQoCggEBAMVel7I88DkhwW445BNPBZvJNTV1AreHdz4um4U1\nop2+4L7JeNrUs5SRc0fzeOyOmA9ZzTDu9hBC7zj/sVNUy6cIQGCj32sr5SCAEIat\nnFZlzmVqJPT4J5NAaE37KO5347myTJEBrvpq8az4CtvX0yUzPK0gbUmaSaztVi4o\ndbJLKyv575xCLC/Hu6fIHBDH19eG1Ath9VpuAOkttRRoxu2VqijJZrGqaS+0o+OX\nrLi5HMtZbZjgQB4mc1g3ZDKX/gynxr+CDNaqNOqxuog33Tl5OcOk9DrR3MInaE7F\nyQFuH9mzF64AqOoTf7Tr/eAIz5XVt8K51nk+fSybEfKVwtMCAwEAAaOCAaEwggGd\nMA4GA1UdDwEB/wQEAwIFoDAMBgNVHRMBAf8EAjAAMB0GA1UdDgQWBBQU/9dYyqMz\nv9rOMwPZcoIRMDAQCjAfBgNVHSMEGDAWgBTkQGTiCkLCmv/Awxdz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YDVQQKEwtQcm9j\ndG9yIEVuZzEUMBIGA1UEAxMLUHJvY3Rvci1lbmcwggEiMA0GCSqGSIb3DQEBAQUA\nA4IBDwAwggEKAoIBAQCYqJP5Qt90jIbld2dtuUV/zIkBFsTe4fapJfhBji03xBpN\nO1Yxj/jPSZ67Kdeoy0lEwvc2hL5FQGhIjLMR0mzOyN4fk/DZiA/4tAVi7hJyqpUC\n71JSwp7MwXL1b26CSE1MhcoCqA/E4iZxfJfF/ef4lhmC24UEmu8FEbldoy+6OysB\nRu7dGDwicW5F9h7eSkpGAsCRdJHh65iUx/IH0C4Ux2UZRDZdj6wVbuVu9tb938xF\nyRuVClONoLSn/lwdzeV7hQmBSm8qmfgbNPbYRaNLz3hOpsT+27aDQp2/pxue8hFJ\nd7We3+Lr5O4IL45PBwhVEAiFZqde6d4qViNEB2qTAgMBAAGjYzBhMA4GA1UdDwEB\n/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTkQGTiCkLCmv/Awxdz\n5TAVRmyFfDAfBgNVHSMEGDAWgBTkQGTiCkLCmv/Awxdz5TAVRmyFfDANBgkqhkiG\n9w0BAQsFAAOCAQEAfy5BJsWdx0oWWi7SFg9MbryWjBVPJl93UqACgG0Cgh813O/x\nlDZQhGO/ZFVhHz/WgooE/HgVNoVJTubKLLzz+zCkOB0wa3GMqJDyFjhFmUtd/3VM\nZh0ZQ+JWYsAiZW4VITj5xEn/d/B3xCFWGC1vhvhptEJ8Fo2cE1yM2pzk08NqFWoY\n4FaH0sbxWgyCKwTmtcYDbnx4FYuddryGCIxbYizqUK1dr4DGKeHonhm/d234Ew3x\n3vIBPoHMOfBec/coP1xAf5o+F+MRMO/sQ3tTGgyOH18lwsHo9SmXCrmOwVQPKrEw\nm+A+5TjXLmenyaBhqXa0vkAZYJhWdROhWC0VTA==\n-----END CERTIFICATE-----\n" - } - - project = "%{project_name}" - annotations = {} -} - - -`, context) -} - -func testAccCloudbuildv2Connection_GithubConnection(context map[string]interface{}) string { - return acctest.Nprintf(` -resource "google_cloudbuildv2_connection" "primary" { - location = "%{region}" - name = "tf-test-connection%{random_suffix}" - disabled = true - - github_config { - app_installation_id = 0 - - authorizer_credential { - oauth_token_secret_version = "projects/gcb-terraform-creds/secrets/github-pat/versions/1" - } - } - - project = "%{project_name}" - - annotations = { - somekey = "somevalue" - } -} - - -`, context) -} - -func testAccCloudbuildv2Connection_GithubConnectionUpdate0(context map[string]interface{}) string { - return acctest.Nprintf(` -resource "google_cloudbuildv2_connection" "primary" { - location = "%{region}" - name = "tf-test-connection%{random_suffix}" - disabled = false - - github_config { - app_installation_id = 31300675 - - authorizer_credential { - oauth_token_secret_version = "projects/gcb-terraform-creds/secrets/github-pat/versions/latest" - } - } - - project = "%{project_name}" - - annotations = { - otherkey = "othervalue" - - somekey = "somevalue" - } -} - - -`, context) -} - -func testAccCloudbuildv2Connection_GitlabConnection(context map[string]interface{}) string { - return acctest.Nprintf(` -resource "google_cloudbuildv2_connection" "primary" { - location = "us-west1" - name = "tf-test-connection%{random_suffix}" - - gitlab_config { - authorizer_credential { - user_token_secret_version = "projects/407304063574/secrets/gitlab-api-pat/versions/latest" - } - - read_authorizer_credential { - user_token_secret_version = "projects/407304063574/secrets/gitlab-read-pat/versions/latest" - } - - webhook_secret_secret_version = "projects/407304063574/secrets/gle-webhook-secret/versions/latest" - } - - project = "%{project_name}" - annotations = {} -} - - -`, context) -} - -func testAccCloudbuildv2Connection_GleConnection(context map[string]interface{}) string { - return acctest.Nprintf(` -resource "google_cloudbuildv2_connection" "primary" { - location = "us-west1" - name = "tf-test-connection%{random_suffix}" - - gitlab_config { - authorizer_credential { - user_token_secret_version = "projects/407304063574/secrets/gle-api-token/versions/latest" - } - - read_authorizer_credential { - user_token_secret_version = "projects/407304063574/secrets/gle-read-token/versions/latest" - } - - webhook_secret_secret_version = "projects/407304063574/secrets/gle-webhook-secret/versions/latest" - host_uri = "https://gle-us-central1.gcb-test.com" - } - - project = "%{project_name}" - annotations = {} -} - - -`, context) -} - -func testAccCloudbuildv2Connection_GleConnectionUpdate0(context map[string]interface{}) string { - return acctest.Nprintf(` -resource "google_cloudbuildv2_connection" "primary" { - location = "us-west1" - name = "tf-test-connection%{random_suffix}" - - gitlab_config { - authorizer_credential { - user_token_secret_version = "projects/407304063574/secrets/gle-old-api-token/versions/2" - } - - read_authorizer_credential { - user_token_secret_version = "projects/407304063574/secrets/gle-old-read-token/versions/3" - } - - webhook_secret_secret_version = "projects/407304063574/secrets/gle-webhook-secret/versions/latest" - host_uri = "https://gle-old.gcb-test.com" - } - - project = "%{project_name}" - annotations = {} -} - - -`, context) -} - -func testAccCloudbuildv2Connection_GleOldConnection(context map[string]interface{}) string { - return acctest.Nprintf(` -resource "google_cloudbuildv2_connection" "primary" { - location = "us-west1" - name = "tf-test-connection%{random_suffix}" - - gitlab_config { - authorizer_credential { - user_token_secret_version = "projects/407304063574/secrets/gle-old-api-token/versions/2" - } - - read_authorizer_credential { - user_token_secret_version = "projects/407304063574/secrets/gle-old-read-token/versions/3" - } - - webhook_secret_secret_version = "projects/407304063574/secrets/gle-webhook-secret/versions/latest" - host_uri = "https://gle-old.gcb-test.com" - } - - project = "%{project_name}" - annotations = {} -} - - -`, context) -} - -func testAccCloudbuildv2Connection_GleOldConnectionUpdate0(context map[string]interface{}) string { - return acctest.Nprintf(` -resource "google_cloudbuildv2_connection" "primary" { - location = "us-west1" - name = "tf-test-connection%{random_suffix}" - - gitlab_config { - authorizer_credential { - user_token_secret_version = "projects/407304063574/secrets/gle-api-token/versions/latest" - } - - read_authorizer_credential { - user_token_secret_version = "projects/407304063574/secrets/gle-read-token/versions/latest" - } - - webhook_secret_secret_version = "projects/407304063574/secrets/gle-webhook-secret/versions/latest" - host_uri = "https://gle-us-central1.gcb-test.com" - } - - project = "%{project_name}" - annotations = {} -} - - -`, context) -} - -func testAccCloudbuildv2Connection_GlePrivConnection(context map[string]interface{}) string { - return acctest.Nprintf(` -resource "google_cloudbuildv2_connection" "primary" { - location = "us-west1" - name = "tf-test-connection%{random_suffix}" - - gitlab_config { - authorizer_credential { - user_token_secret_version = "projects/407304063574/secrets/gle-private-api/versions/1" - } - - read_authorizer_credential { - user_token_secret_version = "projects/407304063574/secrets/gle-private-read-token/versions/1" - } - - webhook_secret_secret_version = "projects/407304063574/secrets/gle-webhook-secret/versions/latest" - host_uri = "https://gle-us.gle-us-private.com" - - service_directory_config { - service = "projects/407304063574/locations/us-west1/namespaces/private-conn/services/gitlab-private" - } - - ssl_ca = "-----BEGIN CERTIFICATE-----\nMIIDcTCCAlmgAwIBAgIUbxJ3jxaRf5IPcUiQWRPRqpLL4s4wDQYJKoZIhvcNAQEL\nBQAwTjELMAkGA1UEBhMCVVMxGzAZBgNVBAoMEkdvb2dsZSBDbG91ZCBCdWlsZDEi\nMCAGA1UEAwwZZ2xlLXVzLmdsZS11cy1wcml2YXRlLmNvbTAeFw0yMzEwMjAxNjQ3\nNDJaFw0yNDEwMTkxNjQ3NDJaME4xCzAJBgNVBAYTAlVTMRswGQYDVQQKDBJHb29n\nbGUgQ2xvdWQgQnVpbGQxIjAgBgNVBAMMGWdsZS11cy5nbGUtdXMtcHJpdmF0ZS5j\nb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDRE84wKcuzc+beQ323\nIsNVVOF1+WZ975LvXpIt8Mw1bcYeYUcvgBXSXAByHGMtef8OBb9BUvLOVZdT3Xow\nCUbhCiK3zQy29pCn0rsneIvzGUXQgQRXK/Zap1N/hif4E7CIgjuvCN0Mn6BfDV/H\nXFm6EV3YUJrRPBr1rZik7doaYYwaJshCSTBtZxXZdvsG/OBuAXbJ9GB0B62EiTBz\n5g6yRdATut+PbgfzaWlPsgL3TTH+HPNCMO+ULnFupfZwRCtV+dJng76QYGs8fmFo\ntiWeElcsU8W7aqmjOkKRWcFsHpxPNXp8GG+jsZrVAnMOR3QeRLvowysSQD99IrGH\nAhwlAgMBAAGjRzBFMCQGA1UdEQQdMBuCGWdsZS11cy5nbGUtdXMtcHJpdmF0ZS5j\nb20wHQYDVR0OBBYEFKCIp5BruT4fpeDFQ2bKgdUvpfbWMA0GCSqGSIb3DQEBCwUA\nA4IBAQAQ4pUQmmd7eNIu9MQGna9lHYRFL0/G3mrK6Dcfm2As9qdcRw3dph8/iute\nxKDdBsnt6jDHrsjN0Na7Eq0040oBJrxG/NtqGX0zHNdpAT61bQ6j9reAT+KOrHys\nDJXH2lPuFW183AU7mmvcbXTEwkKex1i+DNoEdGYUbBfnWWeuhGzFog+/f9mtjoHL\nplcmx0VWHBQ5KO9Aq4OR/86DSg5QRPk76W9k3cM2ShXMm3TmTBZ+taJFfjZo5jP+\n7PLt2z9grSvFSXh2jnMyAs2yP4c+WezOXZLijqROr378AGBaksQK0CP+CYjZRpn1\nvndr1njLbvSjIypwKgZROb4P6XVa\n-----END CERTIFICATE-----\n" - } - - project = "%{project_name}" - annotations = {} -} - - -`, context) -} diff --git a/tpgtools/api/cloudbuildv2/samples/ghe.repository.json b/tpgtools/api/cloudbuildv2/samples/ghe.repository.json new file mode 100755 index 000000000000..63f88267fb86 --- /dev/null +++ b/tpgtools/api/cloudbuildv2/samples/ghe.repository.json @@ -0,0 +1,10 @@ +{ + "project": "{{project}}", + "location": "{{region}}", + "connection": "{{ref:ghe_complete.connection.json:name}}", + "name": "{{repository}}", + "remoteUri": "https://ghe.proctor-staging-test.com/proctorteam/regional_test.git", + "annotations": { + "some-key": "some-value" + } +} diff --git a/tpgtools/api/cloudbuildv2/samples/ghe_complete.connection.json b/tpgtools/api/cloudbuildv2/samples/ghe_complete.connection.json new file mode 100755 index 000000000000..4c8f5dba6460 --- /dev/null +++ b/tpgtools/api/cloudbuildv2/samples/ghe_complete.connection.json @@ -0,0 +1,13 @@ +{ + "name": "{{connection}}", + "githubEnterpriseConfig": { + "hostUri": "https://ghe.proctor-staging-test.com", + "privateKeySecretVersion":"projects/gcb-terraform-creds/secrets/ghe-private-key/versions/latest", + "webhookSecretSecretVersion":"projects/gcb-terraform-creds/secrets/ghe-webhook-secret/versions/latest", + "appId":516, + "appSlug":"myapp", + "appInstallationId": 243 + }, + "project": "{{project}}", + "location": "{{region}}" +} diff --git a/tpgtools/api/cloudbuildv2/samples/ghe_complete_connection.yaml b/tpgtools/api/cloudbuildv2/samples/ghe_complete_connection.yaml new file mode 100755 index 000000000000..aa8975d661d7 --- /dev/null +++ b/tpgtools/api/cloudbuildv2/samples/ghe_complete_connection.yaml @@ -0,0 +1,26 @@ +# Copyright 2023 Google LLC. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +name: ghe_complete_connection +description: Creates a GitHub Enterprise connection. +type: connection +versions: +- ga +resource: samples/ghe_complete.connection.json +variables: +- name: connection + type: resource_name +- name: project + type: project +- name: region + type: region diff --git a/tpgtools/api/cloudbuildv2/samples/ghe_connection.yaml b/tpgtools/api/cloudbuildv2/samples/ghe_connection.yaml new file mode 100755 index 000000000000..87f8316550a8 --- /dev/null +++ b/tpgtools/api/cloudbuildv2/samples/ghe_connection.yaml @@ -0,0 +1,29 @@ +# Copyright 2023 Google LLC. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +name: ghe_connection +description: Creates and updates a GitHub Enterprise connection. +type: connection +versions: +- ga +resource: samples/ghe_initial.connection.json +updates: +- resource: samples/ghe_complete.connection.json + dependencies: [] +variables: +- name: connection + type: resource_name +- name: project + type: project +- name: region + type: region diff --git a/tpgtools/api/cloudbuildv2/samples/ghe_initial.connection.json b/tpgtools/api/cloudbuildv2/samples/ghe_initial.connection.json new file mode 100755 index 000000000000..d9fa4a5477ce --- /dev/null +++ b/tpgtools/api/cloudbuildv2/samples/ghe_initial.connection.json @@ -0,0 +1,8 @@ +{ + "name": "{{connection}}", + "githubEnterpriseConfig": { + "hostUri": "https://ghe.proctor-staging-test.com" + }, + "project": "{{project}}", + "location": "{{region}}" +} diff --git a/tpgtools/api/cloudbuildv2/samples/ghe_priv.connection.json b/tpgtools/api/cloudbuildv2/samples/ghe_priv.connection.json new file mode 100755 index 000000000000..5f979968ef88 --- /dev/null +++ b/tpgtools/api/cloudbuildv2/samples/ghe_priv.connection.json @@ -0,0 +1,12 @@ +{ + "name": "{{connection}}", + "githubEnterpriseConfig": { + "hostUri": "https://ghe.proctor-private-ca.com", + "serviceDirectoryConfig": { + "service": "projects/gcb-terraform-creds/locations/{{region}}/namespaces/myns/services/serv" + }, + "sslCa": "-----BEGIN CERTIFICATE-----\nMIIEXTCCA0WgAwIBAgIUANaBCc9j/xdKJHU0sgmv6yE2WCIwDQYJKoZIhvcNAQEL\nBQAwLDEUMBIGA1UEChMLUHJvY3RvciBFbmcxFDASBgNVBAMTC1Byb2N0b3ItZW5n\nMB4XDTIxMDcxNTIwMDcwMloXDTIyMDcxNTIwMDcwMVowADCCASIwDQYJKoZIhvcN\nAQEBBQADggEPADCCAQoCggEBAMVel7I88DkhwW445BNPBZvJNTV1AreHdz4um4U1\nop2+4L7JeNrUs5SRc0fzeOyOmA9ZzTDu9hBC7zj/sVNUy6cIQGCj32sr5SCAEIat\nnFZlzmVqJPT4J5NAaE37KO5347myTJEBrvpq8az4CtvX0yUzPK0gbUmaSaztVi4o\ndbJLKyv575xCLC/Hu6fIHBDH19eG1Ath9VpuAOkttRRoxu2VqijJZrGqaS+0o+OX\nrLi5HMtZbZjgQB4mc1g3ZDKX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bnx4FYuddryGCIxbYizqUK1dr4DGKeHonhm/d234Ew3x\n3vIBPoHMOfBec/coP1xAf5o+F+MRMO/sQ3tTGgyOH18lwsHo9SmXCrmOwVQPKrEw\nm+A+5TjXLmenyaBhqXa0vkAZYJhWdROhWC0VTA==\n-----END CERTIFICATE-----\n" + }, + "project": "{{project}}", + "location": "{{region}}" +} diff --git a/tpgtools/api/cloudbuildv2/samples/ghe_priv_connection.yaml b/tpgtools/api/cloudbuildv2/samples/ghe_priv_connection.yaml new file mode 100755 index 000000000000..73025a7cf763 --- /dev/null +++ b/tpgtools/api/cloudbuildv2/samples/ghe_priv_connection.yaml @@ -0,0 +1,26 @@ +# Copyright 2023 Google LLC. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +name: ghe_priv_connection +description: Creates a connection to a private server using Service Directory. +type: connection +versions: +- ga +resource: samples/ghe_priv.connection.json +variables: +- name: connection + type: resource_name +- name: project + type: project +- name: region + type: region diff --git a/tpgtools/api/cloudbuildv2/samples/ghe_priv_update_connection.yaml b/tpgtools/api/cloudbuildv2/samples/ghe_priv_update_connection.yaml new file mode 100755 index 000000000000..5e12dbf3d70e --- /dev/null +++ b/tpgtools/api/cloudbuildv2/samples/ghe_priv_update_connection.yaml @@ -0,0 +1,29 @@ +# Copyright 2023 Google LLC. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +name: ghe_priv_update_connection +description: Creates and updates a connection to a private server using Service Directory. +type: connection +versions: +- ga +resource: samples/ghe_initial.connection.json +updates: +- resource: samples/ghe_priv.connection.json + dependencies: [] +variables: +- name: connection + type: resource_name +- name: project + type: project +- name: region + type: region diff --git a/tpgtools/api/cloudbuildv2/samples/ghe_repository.yaml b/tpgtools/api/cloudbuildv2/samples/ghe_repository.yaml new file mode 100755 index 000000000000..0e457ebaa459 --- /dev/null +++ b/tpgtools/api/cloudbuildv2/samples/ghe_repository.yaml @@ -0,0 +1,30 @@ +# Copyright 2023 Google LLC. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +name: ghe_repository +description: Creates a GitHub repository. +type: repository +versions: +- ga +resource: samples/ghe.repository.json +dependencies: +- samples/ghe_complete.connection.json +variables: +- name: connection + type: resource_name +- name: project + type: project +- name: region + type: region +- name: repository + type: resource_name diff --git a/tpgtools/api/cloudbuildv2/samples/github.repository.json b/tpgtools/api/cloudbuildv2/samples/github.repository.json new file mode 100755 index 000000000000..8c809423b494 --- /dev/null +++ b/tpgtools/api/cloudbuildv2/samples/github.repository.json @@ -0,0 +1,7 @@ +{ + "project": "{{project}}", + "location": "{{region}}", + "connection": "{{ref:github_update.connection.json:name}}", + "name": "{{repository}}", + "remoteUri": "https://github.com/gcb-repos-robot/tf-demo.git" +} diff --git a/tpgtools/api/cloudbuildv2/samples/github_connection.yaml b/tpgtools/api/cloudbuildv2/samples/github_connection.yaml new file mode 100755 index 000000000000..f96c3d242533 --- /dev/null +++ b/tpgtools/api/cloudbuildv2/samples/github_connection.yaml @@ -0,0 +1,29 @@ +# Copyright 2023 Google LLC. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +name: github_connection +description: Creates and updates a GitHub connection. +type: connection +versions: +- ga +resource: samples/github_initial.connection.json +updates: +- resource: samples/github_update.connection.json + dependencies: [] +variables: +- name: connection + type: resource_name +- name: project + type: project +- name: region + type: region diff --git a/tpgtools/api/cloudbuildv2/samples/github_initial.connection.json b/tpgtools/api/cloudbuildv2/samples/github_initial.connection.json new file mode 100755 index 000000000000..2a651a6abe37 --- /dev/null +++ b/tpgtools/api/cloudbuildv2/samples/github_initial.connection.json @@ -0,0 +1,13 @@ +{ + "name": "{{connection}}", + "githubConfig": { + "appInstallationId": 0, + "authorizerCredential": { + "oauthTokenSecretVersion": "projects/gcb-terraform-creds/secrets/github-pat/versions/1" + } + }, + "project": "{{project}}", + "location": "{{region}}", + "annotations": {"somekey": "somevalue"}, + "disabled": true +} diff --git a/tpgtools/api/cloudbuildv2/samples/github_repository.yaml b/tpgtools/api/cloudbuildv2/samples/github_repository.yaml new file mode 100755 index 000000000000..416dc48815f9 --- /dev/null +++ b/tpgtools/api/cloudbuildv2/samples/github_repository.yaml @@ -0,0 +1,30 @@ +# Copyright 2023 Google LLC. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +name: github_repository +description: Creates a GitHub repository. +type: repository +versions: +- ga +resource: samples/github.repository.json +dependencies: +- samples/github_update.connection.json +variables: +- name: connection + type: resource_name +- name: project + type: project +- name: region + type: region +- name: repository + type: resource_name diff --git a/tpgtools/api/cloudbuildv2/samples/github_update.connection.json b/tpgtools/api/cloudbuildv2/samples/github_update.connection.json new file mode 100755 index 000000000000..edf9d0a78b16 --- /dev/null +++ b/tpgtools/api/cloudbuildv2/samples/github_update.connection.json @@ -0,0 +1,16 @@ +{ + "name": "{{connection}}", + "githubConfig": { + "appInstallationId": 31300675, + "authorizerCredential": { + "oauthTokenSecretVersion": "projects/gcb-terraform-creds/secrets/github-pat/versions/latest" + } + }, + "project": "{{project}}", + "location": "{{region}}", + "annotations": { + "somekey": "somevalue", + "otherkey": "othervalue" + }, + "disabled": false +} diff --git a/tpgtools/api/cloudbuildv2/samples/gitlab.connection.json b/tpgtools/api/cloudbuildv2/samples/gitlab.connection.json new file mode 100755 index 000000000000..6c64584d8859 --- /dev/null +++ b/tpgtools/api/cloudbuildv2/samples/gitlab.connection.json @@ -0,0 +1,14 @@ +{ + "name": "{{connection}}", + "gitlabConfig": { + "authorizerCredential": { + "userTokenSecretVersion": "projects/407304063574/secrets/gitlab-api-pat/versions/latest" + }, + "readAuthorizerCredential": { + "userTokenSecretVersion": "projects/407304063574/secrets/gitlab-read-pat/versions/latest" + }, + "webhookSecretSecretVersion":"projects/407304063574/secrets/gle-webhook-secret/versions/latest" + }, + "project": "{{project}}", + "location": "us-west1" +} diff --git a/tpgtools/api/cloudbuildv2/samples/gitlab.repository.json b/tpgtools/api/cloudbuildv2/samples/gitlab.repository.json new file mode 100755 index 000000000000..83d58f1e374c --- /dev/null +++ b/tpgtools/api/cloudbuildv2/samples/gitlab.repository.json @@ -0,0 +1,10 @@ +{ + "project": "{{project}}", + "location": "us-west1", + "connection": "{{ref:gitlab.connection.json:name}}", + "name": "{{repository}}", + "remoteUri": "https://gitlab.com/proctor-eng-team/terraform-testing.git", + "annotations": { + "some-key": "some-value" + } +} diff --git a/tpgtools/api/cloudbuildv2/samples/gitlab_connection.yaml b/tpgtools/api/cloudbuildv2/samples/gitlab_connection.yaml new file mode 100755 index 000000000000..af304f627f0f --- /dev/null +++ b/tpgtools/api/cloudbuildv2/samples/gitlab_connection.yaml @@ -0,0 +1,24 @@ +# Copyright 2023 Google LLC. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +name: gitlab_connection +description: Creates a gitlab.com connection. +type: connection +versions: +- ga +resource: samples/gitlab.connection.json +variables: +- name: connection + type: resource_name +- name: project + type: project diff --git a/tpgtools/api/cloudbuildv2/samples/gitlab_repository.yaml b/tpgtools/api/cloudbuildv2/samples/gitlab_repository.yaml new file mode 100755 index 000000000000..8c6ec92cff67 --- /dev/null +++ b/tpgtools/api/cloudbuildv2/samples/gitlab_repository.yaml @@ -0,0 +1,28 @@ +# Copyright 2023 Google LLC. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +name: gitlab_repository +description: Creates a gitlab repository. +type: repository +versions: +- ga +resource: samples/gitlab.repository.json +dependencies: +- samples/gitlab.connection.json +variables: +- name: connection + type: resource_name +- name: project + type: project +- name: repository + type: resource_name diff --git a/tpgtools/api/cloudbuildv2/samples/gle.connection.json b/tpgtools/api/cloudbuildv2/samples/gle.connection.json new file mode 100755 index 000000000000..b12e32c9eb29 --- /dev/null +++ b/tpgtools/api/cloudbuildv2/samples/gle.connection.json @@ -0,0 +1,15 @@ +{ + "name": "{{connection}}", + "gitlabConfig": { + "hostUri": "https://gle-us-central1.gcb-test.com", + "authorizerCredential": { + "userTokenSecretVersion": "projects/407304063574/secrets/gle-api-token/versions/latest" + }, + "readAuthorizerCredential": { + "userTokenSecretVersion": "projects/407304063574/secrets/gle-read-token/versions/latest" + }, + "webhookSecretSecretVersion":"projects/407304063574/secrets/gle-webhook-secret/versions/latest" + }, + "project": "{{project}}", + "location": "us-west1" +} diff --git a/tpgtools/api/cloudbuildv2/samples/gle.repository.json b/tpgtools/api/cloudbuildv2/samples/gle.repository.json new file mode 100755 index 000000000000..0f04872dd47f --- /dev/null +++ b/tpgtools/api/cloudbuildv2/samples/gle.repository.json @@ -0,0 +1,10 @@ +{ + "project": "{{project}}", + "location": "us-west1", + "connection": "{{ref:gle.connection.json:name}}", + "name": "{{repository}}", + "remoteUri": "https://gle-us-central1.gcb-test.com/proctor-test/smoketest.git", + "annotations": { + "some-key": "some-value" + } +} diff --git a/tpgtools/api/cloudbuildv2/samples/gle_connection.yaml b/tpgtools/api/cloudbuildv2/samples/gle_connection.yaml new file mode 100755 index 000000000000..08c141636bb1 --- /dev/null +++ b/tpgtools/api/cloudbuildv2/samples/gle_connection.yaml @@ -0,0 +1,27 @@ +# Copyright 2023 Google LLC. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +name: gle_connection +description: Creates a GLE connection then update to an older version. +type: connection +versions: +- ga +resource: samples/gle.connection.json +updates: +- resource: samples/gle_old.connection.json + dependencies: [] +variables: +- name: connection + type: resource_name +- name: project + type: project diff --git a/tpgtools/api/cloudbuildv2/samples/gle_old.connection.json b/tpgtools/api/cloudbuildv2/samples/gle_old.connection.json new file mode 100755 index 000000000000..fe441053ea8a --- /dev/null +++ b/tpgtools/api/cloudbuildv2/samples/gle_old.connection.json @@ -0,0 +1,15 @@ +{ + "name": "{{connection}}", + "gitlabConfig": { + "hostUri": "https://gle-old.gcb-test.com", + "authorizerCredential": { + "userTokenSecretVersion": "projects/407304063574/secrets/gle-old-api-token/versions/2" + }, + "readAuthorizerCredential": { + "userTokenSecretVersion": "projects/407304063574/secrets/gle-old-read-token/versions/3" + }, + "webhookSecretSecretVersion":"projects/407304063574/secrets/gle-webhook-secret/versions/latest" + }, + "project": "{{project}}", + "location": "us-west1" +} diff --git a/tpgtools/api/cloudbuildv2/samples/gle_old_connection.yaml b/tpgtools/api/cloudbuildv2/samples/gle_old_connection.yaml new file mode 100755 index 000000000000..ba81509db2c7 --- /dev/null +++ b/tpgtools/api/cloudbuildv2/samples/gle_old_connection.yaml @@ -0,0 +1,27 @@ +# Copyright 2023 Google LLC. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +name: gle_old_connection +description: Creates a GLE connection on an old version then update to a newer version. +type: connection +versions: +- ga +resource: samples/gle_old.connection.json +updates: +- resource: samples/gle.connection.json + dependencies: [] +variables: +- name: connection + type: resource_name +- name: project + type: project diff --git a/tpgtools/api/cloudbuildv2/samples/gle_priv.connection.json b/tpgtools/api/cloudbuildv2/samples/gle_priv.connection.json new file mode 100755 index 000000000000..8c716bd7e24b --- /dev/null +++ b/tpgtools/api/cloudbuildv2/samples/gle_priv.connection.json @@ -0,0 +1,19 @@ +{ + "name": "{{connection}}", + "gitlabConfig": { + "hostUri": "https://gle-test.proctor-staging-test.com", + "serviceDirectoryConfig": { + "service": "projects/proctor-gitlab-enterprise/locations/us-west1/namespaces/gle-uw-1/services/private-smoketest" + }, + "sslCa": "-----BEGIN CERTIFICATE-----\nMIIDajCCAlKgAwIBAgIUedXFQAw0eUDTe6gmPKVyRvBlDi8wDQYJKoZIhvcNAQEL\nBQAwVjELMAkGA1UEBhMCVVMxGzAZBgNVBAoMEkdvb2dsZSBDbG91ZCBCdWlsZDEq\nMCgGA1UEAwwhZ2xlLXRlc3QucHJvY3Rvci1zdGFnaW5nLXRlc3QuY29tMB4XDTIy\nMDcyNTE3Mzg0MFoXDTIzMDcyNTE3Mzg0MFowVjELMAkGA1UEBhMCVVMxGzAZBgNV\nBAoMEkdvb2dsZSBDbG91ZCBCdWlsZDEqMCgGA1UEAwwhZ2xlLXRlc3QucHJvY3Rv\nci1zdGFnaW5nLXRlc3QuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\nAQEAr7H0J4nZBL0ed3duVDbOdlnqJuLHZVBWIOp0DBVWPzdx+4eDCi86czxzXmVG\nuZXSpvg3az4QHGWs2HwlBCDk6tp2QT6F1gR6TE8S2yp+04BDhtg1DUopWY+f+Xi7\ni1tXQG7OTDByez3V6MR0t0bVv/LOJlvOngWbJ32qZqfbj5W8MACR/3u7KBjGs/bm\nrbDMga3YOOIa+DVLdLCwzc7kFlM9W7sezkUM/FhhellaxLu4i5O86sywJYMEo7VG\nj3FUS3XiDyKW68xOpE4svW7LiZEAnnLSsPdELO2bzhR/md84Jjvm99i6yP0StrMB\n+X2EwPYmTLMktdJyMUn/vhFYzQIDAQABozAwLjAsBgNVHREEJTAjgiFnbGUtdGVz\ndC5wcm9jdG9yLXN0YWdpbmctdGVzdC5jb20wDQYJKoZIhvcNAQELBQADggEBAJ+6\nH7WI9+hqrT4zpyc/CpH6VuviYezo1qd4/6M496dKlrHd11+xAXkBRZ4FFyoDFMgz\nO7YihNTBuONwiv21YN3OV9xoTExGx/IIkHNaueL2ZPkbVcJWQEWtEITp9Mo0qDIj\nkKjEQ5A+I4T4CiQ/OAhqtN8gR8ZUKGRJw+s2sE+yCIvRfoeJ4YU7NfUL1vSXxKfy\nHz3awR7t5qnCsvcShZtmiZ4xsc6o/tKqL5nAwNk1M6rPMY/+/PY70juLf1GNNDoZ\nA2Co+g6uI/FwAFAO5ZYKRLlstgNcPXerNdxXhpRZKMxGj8WfQ3z0Eu4cGtTUmDz5\npTam4bqToj22/MN2IhA=\n-----END CERTIFICATE-----\n", + "authorizerCredential": { + "userTokenSecretVersion": "projects/407304063574/secrets/gle-api-token/versions/latest" + }, + "readAuthorizerCredential": { + "userTokenSecretVersion": "projects/407304063574/secrets/gle-read-token/versions/latest" + }, + "webhookSecretSecretVersion":"projects/407304063574/secrets/gle-webhook-secret/versions/latest" + }, + "project": "{{project}}", + "location": "us-west1" +} diff --git a/tpgtools/api/cloudbuildv2/samples/gle_priv_connection.yaml b/tpgtools/api/cloudbuildv2/samples/gle_priv_connection.yaml new file mode 100755 index 000000000000..9a416479ae7b --- /dev/null +++ b/tpgtools/api/cloudbuildv2/samples/gle_priv_connection.yaml @@ -0,0 +1,24 @@ +# Copyright 2023 Google LLC. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +name: gle_priv_connection +description: Creates a connection to a private server using Service Directory. +type: connection +versions: +- ga +resource: samples/gle_priv.connection.json +variables: +- name: connection + type: resource_name +- name: project + type: project diff --git a/tpgtools/api/cloudbuildv2/samples/gle_priv_update_connection.yaml b/tpgtools/api/cloudbuildv2/samples/gle_priv_update_connection.yaml new file mode 100755 index 000000000000..d38c63343248 --- /dev/null +++ b/tpgtools/api/cloudbuildv2/samples/gle_priv_update_connection.yaml @@ -0,0 +1,27 @@ +# Copyright 2023 Google LLC. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +name: gle_priv_update_connection +description: Creates and updates a connection to a private server using Service Directory. +type: connection +versions: +- ga +resource: samples/gle.connection.json +updates: +- resource: samples/gle_priv.connection.json + dependencies: [] +variables: +- name: connection + type: resource_name +- name: project + type: project diff --git a/tpgtools/api/cloudbuildv2/samples/gle_repository.yaml b/tpgtools/api/cloudbuildv2/samples/gle_repository.yaml new file mode 100755 index 000000000000..11997f3a30e2 --- /dev/null +++ b/tpgtools/api/cloudbuildv2/samples/gle_repository.yaml @@ -0,0 +1,28 @@ +# Copyright 2023 Google LLC. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +name: gle_repository +description: Creates a GLE repository. +type: repository +versions: +- ga +resource: samples/gle.repository.json +dependencies: +- samples/gle.connection.json +variables: +- name: connection + type: resource_name +- name: project + type: project +- name: repository + type: resource_name diff --git a/tpgtools/api/cloudbuildv2/samples/gle_update.connection.json b/tpgtools/api/cloudbuildv2/samples/gle_update.connection.json new file mode 100755 index 000000000000..2a77427c701a --- /dev/null +++ b/tpgtools/api/cloudbuildv2/samples/gle_update.connection.json @@ -0,0 +1,13 @@ +{ + "name": "{{connection}}", + "gitlabConfig": { + "hostUri": "https://gle-us-central1.gcb-test.com", + "authorizerCredential": { + "userTokenSecretVersion": "projects/212465313333/secrets/proctor-repo-gle-api-token/versions/latest" + }, + "webhookSecretSecretVersion":"projects/407304063574/secrets/gle-webhook-secret/versions/latest" + }, + "project": "{{project}}", + "annotations": {"somekey": "somevalue"}, + "location": "{{region}}" +} diff --git a/tpgtools/overrides/cloudbuildv2/beta/connection.yaml b/tpgtools/overrides/cloudbuildv2/beta/connection.yaml new file mode 100644 index 000000000000..af851d79a0c9 --- /dev/null +++ b/tpgtools/overrides/cloudbuildv2/beta/connection.yaml @@ -0,0 +1,4 @@ +- type: CUSTOMIZE_DIFF + details: + functions: + - tpgresource.DefaultProviderProject diff --git a/tpgtools/overrides/cloudbuildv2/beta/repository.yaml b/tpgtools/overrides/cloudbuildv2/beta/repository.yaml new file mode 100644 index 000000000000..8de5a79b7fc7 --- /dev/null +++ b/tpgtools/overrides/cloudbuildv2/beta/repository.yaml @@ -0,0 +1,22 @@ +- type: CUSTOM_NAME + # Rename to parent_connection as connection is a reserved word in terraform. + field: connection + details: + name: parent_connection +# TODO: remove once DCL is updpated to not have these fields required. +- type: CUSTOM_SCHEMA_VALUES + field: project + details: + required: false + optional: true + computed: true +- type: CUSTOM_SCHEMA_VALUES + field: location + details: + required: false + optional: true + computed: true +- type: CUSTOMIZE_DIFF + details: + functions: + - tpgresource.DefaultProviderProject diff --git a/tpgtools/overrides/cloudbuildv2/beta/tpgtools_product.yaml b/tpgtools/overrides/cloudbuildv2/beta/tpgtools_product.yaml new file mode 100644 index 000000000000..dd8f9eabb9de --- /dev/null +++ b/tpgtools/overrides/cloudbuildv2/beta/tpgtools_product.yaml @@ -0,0 +1,9 @@ +## product level overrides + +- type: PRODUCT_DOCS_SECTION + details: + docssection: Cloud Build v2 + +- type: PRODUCT_BASE_PATH + details: + skip: true diff --git a/tpgtools/overrides/cloudbuildv2/connection.yaml b/tpgtools/overrides/cloudbuildv2/connection.yaml new file mode 100644 index 000000000000..af851d79a0c9 --- /dev/null +++ b/tpgtools/overrides/cloudbuildv2/connection.yaml @@ -0,0 +1,4 @@ +- type: CUSTOMIZE_DIFF + details: + functions: + - tpgresource.DefaultProviderProject diff --git a/mmv1/templates/terraform/examples/cloudbuildv2_connection_ghe.tf.erb b/tpgtools/overrides/cloudbuildv2/samples/connection/ghe.tf.tmpl similarity index 100% rename from mmv1/templates/terraform/examples/cloudbuildv2_connection_ghe.tf.erb rename to tpgtools/overrides/cloudbuildv2/samples/connection/ghe.tf.tmpl diff --git a/mmv1/templates/terraform/examples/cloudbuildv2_connection_github.tf.erb b/tpgtools/overrides/cloudbuildv2/samples/connection/github.tf.tmpl similarity index 77% rename from mmv1/templates/terraform/examples/cloudbuildv2_connection_github.tf.erb rename to tpgtools/overrides/cloudbuildv2/samples/connection/github.tf.tmpl index 0a37ce2b9276..05bd5d6b81dc 100644 --- a/mmv1/templates/terraform/examples/cloudbuildv2_connection_github.tf.erb +++ b/tpgtools/overrides/cloudbuildv2/samples/connection/github.tf.tmpl @@ -14,8 +14,8 @@ resource "google_secret_manager_secret_version" "github-token-secret-version" { data "google_iam_policy" "p4sa-secretAccessor" { binding { role = "roles/secretmanager.secretAccessor" - // Here, 123456789 is the Google Cloud project number for the project that contains the connection. - members = ["serviceAccount:service-123456789@gcp-sa-cloudbuild.iam.gserviceaccount.com"] + // Here, {{projectNum}} is the Google Cloud project number for {{project}}. + members = ["serviceAccount:service-{{projectNum}}@gcp-sa-cloudbuild.iam.gserviceaccount.com"] } } @@ -25,11 +25,11 @@ resource "google_secret_manager_secret_iam_policy" "policy" { } resource "google_cloudbuildv2_connection" "my-connection" { - location = "us-central1" + location = "{{region}}" name = "my-connection" github_config { - app_installation_id = 123123 + app_installation_id = {{installation-id}} authorizer_credential { oauth_token_secret_version = google_secret_manager_secret_version.github-token-secret-version.id } diff --git a/tpgtools/overrides/cloudbuildv2/samples/connection/github.yaml b/tpgtools/overrides/cloudbuildv2/samples/connection/github.yaml new file mode 100644 index 000000000000..fedc68b1c72a --- /dev/null +++ b/tpgtools/overrides/cloudbuildv2/samples/connection/github.yaml @@ -0,0 +1,16 @@ +name: GitHub Connection +description: Creates a Connection to github.com +variables: + - name: "project" + type: "project" + - name: "projectNum" + type: "project_number" + docs_value: 123456789 + - name: "region" + type: "region" + - name: "github-token-secret" + type: "resource_name" + - name: "installation-id" + type: "custom" + docs_value: 123123 + diff --git a/tpgtools/overrides/cloudbuildv2/samples/connection/meta.yaml b/tpgtools/overrides/cloudbuildv2/samples/connection/meta.yaml new file mode 100644 index 000000000000..5703e8f9d682 --- /dev/null +++ b/tpgtools/overrides/cloudbuildv2/samples/connection/meta.yaml @@ -0,0 +1,20 @@ +test_hide: +# These examples are a good approximation of how users will use the resources, +# however they cannot be executed as tests because they depend on external +# resources (github repos and credentials). +- github.yaml +- github.tf.tmpl +- ghe.tf.tmpl +doc_hide: +# These tests depend on secrets stored in a separate project, so we prefer not +# to show them in the docs. +- github_connection.yaml +- ghe_connection.yaml +- ghe_complete_connection.yaml +- ghe_priv_connection.yaml +- ghe_priv_update_connection.yaml +- gitlab_connection.yaml +- gle_connection.yaml +- gle_old_connection.yaml +- gle_priv_connection.yaml +- gle_priv_update_connection.yaml diff --git a/tpgtools/overrides/cloudbuildv2/tpgtools_product.yaml b/tpgtools/overrides/cloudbuildv2/tpgtools_product.yaml new file mode 100644 index 000000000000..dd8f9eabb9de --- /dev/null +++ b/tpgtools/overrides/cloudbuildv2/tpgtools_product.yaml @@ -0,0 +1,9 @@ +## product level overrides + +- type: PRODUCT_DOCS_SECTION + details: + docssection: Cloud Build v2 + +- type: PRODUCT_BASE_PATH + details: + skip: true