Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand Developer Connect Terraform to include BBC and BBDC #12608

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
618 changes: 467 additions & 151 deletions mmv1/products/developerconnect/Connection.yaml

Large diffs are not rendered by default.

200 changes: 116 additions & 84 deletions mmv1/products/developerconnect/GitRepositoryLink.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,124 +12,156 @@
# limitations under the License.

---
name: 'GitRepositoryLink'
description: "A git repository link to a parent connection."
min_version: 'beta'
docs:
id_format: 'projects/{{project}}/locations/{{location}}/connections/{{parent_connection}}/gitRepositoryLinks/{{git_repository_link_id}}'
base_url: 'projects/{{project}}/locations/{{location}}/connections/{{parent_connection}}/gitRepositoryLinks'
self_link: 'projects/{{project}}/locations/{{location}}/connections/{{parent_connection}}/gitRepositoryLinks/{{git_repository_link_id}}'
create_url: 'projects/{{project}}/locations/{{location}}/connections/{{parent_connection}}/gitRepositoryLinks?gitRepositoryLinkId={{git_repository_link_id}}'
name: GitRepositoryLink
description: A git repository link to a parent connection.
base_url: projects/{{project}}/locations/{{location}}/connections/{{parent_connection}}/gitRepositoryLinks
immutable: true
self_link: projects/{{project}}/locations/{{location}}/connections/{{parent_connection}}/gitRepositoryLinks/{{git_repository_link_id}}
create_url: projects/{{project}}/locations/{{location}}/connections/{{parent_connection}}/gitRepositoryLinks?gitRepositoryLinkId={{git_repository_link_id}}
id_format: projects/{{project}}/locations/{{location}}/connections/{{parent_connection}}/gitRepositoryLinks/{{git_repository_link_id}}
import_format:
- 'projects/{{project}}/locations/{{location}}/connections/{{parent_connection}}/gitRepositoryLinks/{{git_repository_link_id}}'
timeouts:
insert_minutes: 20
update_minutes: 20
delete_minutes: 20
autogen_async: true
async:
actions: ['create', 'delete', 'update']
type: 'OpAsync'
operation:
base_url: '{{op_id}}'
result:
resource_inside_response: true
custom_code:
- projects/{{project}}/locations/{{location}}/connections/{{parent_connection}}/gitRepositoryLinks/{{git_repository_link_id}}
examples:
# These tests depend on secrets stored in a separate project, so we prefer not
# to show them in the docs.
- name: 'developer_connect_git_repository_link_github'
primary_resource_id: 'primary'
min_version: 'beta'
vars:
connection_name: 'my-connection'
git_repository_link_name: 'my-repository'
exclude_docs: true
- name: 'developer_connect_git_repository_link_github_doc'
min_version: 'beta'
exclude_test: true
- name: 'developer_connect_git_repository_link_github_enterprise'
primary_resource_id: 'primary'
vars:
connection_name: 'my-connection'
git_repository_link_name: 'my-repository'
exclude_docs: true
- name: 'developer_connect_git_repository_link_github_enterprise_doc'
exclude_test: true
- name: 'developer_connect_git_repository_link_gitlab'
primary_resource_id: 'my-connection'
primary_resource_name: 'fmt.Sprintf("tf-test-connection%s", context["random_suffix"])'
vars:
connection_name: 'tf-test-connection'
git_repository_link_name: 'my-repository'
exclude_docs: true
- name: 'developer_connect_git_repository_link_gitlab_doc'
exclude_test: true
- name: 'developer_connect_git_repository_link_gitlab_enterprise'
primary_resource_id: 'my-connection'
primary_resource_name: 'fmt.Sprintf("tf-test-connection%s", context["random_suffix"])'
vars:
connection_name: 'tf-test-connection'
git_repository_link_name: 'my-repository'
exclude_docs: true
- name: 'developer_connect_git_repository_link_gitlab_enterprise_doc'
exclude_test: true
- name: 'developer_connect_git_repository_link_bitbucket_cloud'
primary_resource_id: 'my-connection'
primary_resource_name: 'fmt.Sprintf("tf-test-connection%s", context["random_suffix"])'
vars:
connection_name: 'tf-test-connection'
git_repository_link_name: 'my-repository'
exclude_docs: true
- name: 'developer_connect_git_repository_link_bitbucket_cloud_doc'
exclude_test: true
- name: 'developer_connect_git_repository_link_bbdc'
primary_resource_id: 'my-connection'
primary_resource_name: 'fmt.Sprintf("tf-test-connection%s", context["random_suffix"])'
vars:
connection_name: 'tf-test-connection'
git_repository_link_name: 'my-repository'
exclude_docs: true
- name: 'developer_connect_git_repository_link_bitbucket_cloud_doc'
exclude_test: true
autogen_async: true
async:
operation:
timeouts:
insert_minutes: 20
update_minutes: 20
delete_minutes: 20
base_url: '{{op_id}}'
actions:
- create
- delete
- update
type: OpAsync
result:
resource_inside_response: true
error: {}
include_project: false
autogen_status: R2l0UmVwb3NpdG9yeUxpbms=
parameters:
- name: 'location'
- name: location
type: String
description:
"Resource ID segment making up resource `name`. It identifies the resource
within its parent collection as described in https://google.aip.dev/122. See documentation
for resource type `developerconnect.googleapis.com/GitRepositoryLink`. "
min_version: 'beta'
description: Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
immutable: true
url_param_only: true
required: true
immutable: true
- name: 'parent_connection'
- name: parent_connection
type: String
description:
"Resource ID segment making up resource `name`. It identifies the resource
within its parent collection as described in https://google.aip.dev/122. See documentation
for resource type `developerconnect.googleapis.com/GitRepositoryLink`. "
min_version: 'beta'
description: Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
immutable: true
url_param_only: true
required: true
immutable: true
- name: 'gitRepositoryLinkId'
- name: gitRepositoryLinkId
type: String
description:
"Required. The ID to use for the repository, which will become the
final component of\nthe repository's resource name. This ID should be unique in
the connection.\nAllows alphanumeric characters and any of -._~%!$&'()*+,;=@. "
min_version: 'beta'
description: |-
Required. The ID to use for the repository, which will become the final component of
the repository's resource name. This ID should be unique in the connection.
Allows alphanumeric characters and any of -._~%!$&'()*+,;=@.
immutable: true
url_param_only: true
required: true
immutable: true
properties:
- name: 'name'
type: String
description: "Identifier. Resource name of the repository, in the format\n`projects/*/locations/*/connections/*/gitRepositoryLinks/*`. "
min_version: 'beta'
output: true
- name: 'cloneUri'
- name: cloneUri
type: String
description: "Required. Git Clone URI. "
min_version: 'beta'
description: Required. Git Clone URI.
required: true
- name: 'createTime'
- name: labels
type: KeyValueLabels
description: Optional. Labels as key value pairs
- name: annotations
type: KeyValueAnnotations
description: Optional. Allows clients to store small amounts of arbitrary data.
- name: uid
type: String
description: "Output only. [Output only] Create timestamp "
min_version: 'beta'
description: Output only. A system-assigned unique identifier for a the GitRepositoryLink.
output: true
- name: 'updateTime'
- name: name
type: String
description: "Output only. [Output only] Update timestamp "
min_version: 'beta'
description: |-
Identifier. Resource name of the repository, in the format
`projects/*/locations/*/connections/*/gitRepositoryLinks/*`.
output: true
- name: 'deleteTime'
- name: updateTime
type: String
description: "Output only. [Output only] Delete timestamp "
min_version: 'beta'
description: Output only. [Output only] Update timestamp
output: true
- name: 'labels'
type: KeyValueLabels
description: "Optional. Labels as key value pairs "
min_version: 'beta'
- name: 'etag'
- name: deleteTime
type: String
description: Output only. [Output only] Delete timestamp
output: true
- name: etag
type: String
description:
"Optional. This checksum is computed by the server based on the value
of other\nfields, and may be sent on update and delete requests to ensure the\nclient
has an up-to-date value before proceeding. "
min_version: 'beta'
- name: 'reconciling'
description: |-
Optional. 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.
- name: reconciling
type: Boolean
description:
"Output only. Set to true when the connection is being set up or updated
in the\nbackground. "
min_version: 'beta'
description: |-
Output only. Set to true when the connection is being set up or updated in the
background.
output: true
- name: 'annotations'
type: KeyValueAnnotations
description: "Optional. Allows clients to store small amounts of arbitrary data. "
min_version: 'beta'
- name: 'uid'
- name: webhookId
type: String
description: Output only. External ID of the webhook created for the repository.
output: true
- name: createTime
type: String
description: "Output only. A system-assigned unique identifier for a the GitRepositoryLink. "
min_version: 'beta'
description: Output only. [Output only] Create timestamp
output: true
11 changes: 6 additions & 5 deletions mmv1/products/developerconnect/product.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
# limitations under the License.

---
name: 'DeveloperConnect'
display_name: 'Developer Connect'
versions:
- name: 'beta'
base_url: 'https://developerconnect.googleapis.com/v1/'
name: DeveloperConnect
display_name: Developer Connect
scopes:
- 'https://www.googleapis.com/auth/cloud-platform'
versions:
- base_url: 'https://developerconnect.googleapis.com/v1/'
name: ga
caibaseurl: ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
resource "google_developer_connect_connection" "{{$.PrimaryResourceId}}" {
location = "us-central1"
connection_id = "{{index $.Vars "connection_name"}}"

bitbucket_data_center_config {
host_uri = "https://bitbucket-us-central.gcb-test.com"

webhook_secret_secret_version = "projects/devconnect-terraform-creds/secrets/bbdc-webhook/versions/latest"

read_authorizer_credential {
user_token_secret_version = "projects/devconnect-terraform-creds/secrets/bbdc-read-token/versions/latest"
}

authorizer_credential {
user_token_secret_version = "projects/devconnect-terraform-creds/secrets/bbdc-auth-token/versions/latest"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
resource "google_secret_manager_secret" "bbdc-read-cred-secret" {
secret_id = "bbdc-read-cred"
replication {
auto {}
}
}

resource "google_secret_manager_secret_version" "bbdc-read-cred-secret-version" {
secret = google_secret_manager_secret.bbdc-read-cred-secret.id
secret_data = file("my-bbdc-read-cred.txt")
}

resource "google_secret_manager_secret" "bbdc-auth-cred-secret" {
secret_id = "bbdc-auth-cred"
replication {
auto {}
}
}

resource "google_secret_manager_secret_version" "bbdc-auth-cred-secret-version" {
secret = google_secret_manager_secret.bbdc-auth-cred-secret.id
secret_data = file("my-bbdc-auth-cred.txt")
}

resource "google_secret_manager_secret" "bbdc-webhook-secret-secret" {
secret_id = "bbdc-webhook-secret"
replication {
auto {}
}
}

resource "google_secret_manager_secret_version" "bbdc-webhook-secret-secret-version" {
secret = google_secret_manager_secret.bbdc-webhook-secret-secret.id
secret_data = file("my-bbdc-webhook-secret.txt")

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:[email protected]"]
}
}

resource "google_secret_manager_secret_iam_policy" "policy-rc" {
secret_id = google_secret_manager_secret.bbdc-read-cred-secret.secret_id
policy_data = data.google_iam_policy.p4sa-secretAccessor.policy_data
}

resource "google_secret_manager_secret_iam_policy" "policy-ac" {
secret_id = google_secret_manager_secret.bbdc-auth-cred-secret.secret_id
policy_data = data.google_iam_policy.p4sa-secretAccessor.policy_data
}

resource "google_secret_manager_secret_iam_policy" "policy-wh" {
secret_id = google_secret_manager_secret.bbdc-webhook-secret-secret.secret_id
policy_data = data.google_iam_policy.p4sa-secretAccessor.policy_data
}

resource "google_developer_connect_connection" "my-connection" {

location = "us-central1"
connection_id = "my-connection"

bitbucket_cloud_config {
host_uri = "https://bitbucket-test-server.com"

webhook_secret_secret_version = google_secret_manager_secret_version.bbdc-webhook-secret-secret-version.id

read_authorizer_credential {
user_token_secret_version = google_secret_manager_secret_version.bbdc-read-cred-secret-version.id
}

authorizer_credential {
user_token_secret_version = google_secret_manager_secret_version.bbdc-auth-cred-secret-version.id
}
}

depends_on = [
google_secret_manager_secret_iam_policy.policy-rc,
google_secret_manager_secret_iam_policy.policy-ac,
google_secret_manager_secret_iam_policy.policy-wh
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
resource "google_developer_connect_connection" "{{$.PrimaryResourceId}}" {
location = "us-central1"
connection_id = "{{index $.Vars "connection_name"}}"

bitbucket_cloud_config {
workspace = "proctor-test-dc"
webhook_secret_secret_version = "projects/devconnect-terraform-creds/secrets/bbc-webhook/versions/latest"

read_authorizer_credential {
user_token_secret_version = "projects/devconnect-terraform-creds/secrets/bbc-read-token/versions/latest"
}

authorizer_credential {
user_token_secret_version = "projects/devconnect-terraform-creds/secrets/bbc-auth-token/versions/latest"
}
}
}
Loading
Loading