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 Terraform for Developer Connect #12391

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 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
478 changes: 327 additions & 151 deletions mmv1/products/developerconnect/Connection.yaml

Large diffs are not rendered by default.

182 changes: 98 additions & 84 deletions mmv1/products/developerconnect/GitRepositoryLink.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,124 +12,138 @@
# 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
Copy link
Member

@zli82016 zli82016 Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind moving the changes of this file to a separate PR? This PR is too large and difficult to review. It is easy to missing something during the code review.

Copy link
Author

@ihnarayanan ihnarayanan Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed all changes and associated test files. Kept file in PR to promote to GA so as to not break the provider.

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
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'
- name: cloneUri
type: String
description: "Identifier. Resource name of the repository, in the format\n`projects/*/locations/*/connections/*/gitRepositoryLinks/*`. "
min_version: 'beta'
output: true
- 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:
"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: 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
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
@@ -1,5 +1,4 @@
resource "google_developer_connect_connection" "{{$.PrimaryResourceId}}" {
provider = google-beta
location = "us-central1"
connection_id = "{{index $.Vars "connection_name"}}"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
resource "google_secret_manager_secret" "github-token-secret" {

provider = google-beta
secret_id = "github-token-secret"

replication {
Expand All @@ -10,7 +9,6 @@ resource "google_secret_manager_secret" "github-token-secret" {

resource "google_secret_manager_secret_version" "github-token-secret-version" {

provider = google-beta
secret = google_secret_manager_secret.github-token-secret.id
secret_data = file("my-github-token.txt")
}
Expand All @@ -25,14 +23,12 @@ data "google_iam_policy" "p4sa-secretAccessor" {

resource "google_secret_manager_secret_iam_policy" "policy" {

provider = google-beta
secret_id = google_secret_manager_secret.github-token-secret.secret_id
policy_data = data.google_iam_policy.p4sa-secretAccessor.policy_data
}

resource "google_developer_connect_connection" "my-connection" {

provider = google-beta
location = "us-central1"
connection_id = "my-connection"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
resource "google_developer_connect_connection" "{{$.PrimaryResourceId}}" {
location = "us-central1"
connection_id = "{{index $.Vars "connection_name"}}"

github_enterprise_config {
host_uri = "https://ghe.proctor-staging-test.com"
app_id = 864434
private_key_secret_version = "projects/devconnect-terraform-creds/secrets/tf-test-ghe-do-not-change-ghe-private-key-f522d2/versions/latest"
webhook_secret_secret_version = "projects/devconnect-terraform-creds/secrets/tf-test-ghe-do-not-change-ghe-webhook-secret-3c806f/versions/latest"
app_installation_id = 837537
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
resource "google_secret_manager_secret" "private-key-secret" {
secret_id = "ghe-pk-secret"

replication {
auto {}
}
}

resource "google_secret_manager_secret_version" "private-key-secret-version" {
secret = google_secret_manager_secret.private-key-secret.id
secret_data = file("private-key.pem")
}

resource "google_secret_manager_secret" "webhook-secret-secret" {
secret_id = "ghe-token-secret"

replication {
auto {}
}
}

resource "google_secret_manager_secret_version" "webhook-secret-secret-version" {
secret = google_secret_manager_secret.webhook-secret-secret.id
secret_data = "<webhook-secret-data>"
}

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-pk" {
secret_id = google_secret_manager_secret.private-key-secret.secret_id
policy_data = data.google_iam_policy.p4sa-secretAccessor.policy_data
}

resource "google_secret_manager_secret_iam_policy" "policy-whs" {
secret_id = google_secret_manager_secret.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"

github_enterprise_config {
host_uri = "https://ghe.com"
private_key_secret_version = google_secret_manager_secret_version.private-key-secret-version.id
webhook_secret_secret_version = google_secret_manager_secret_version.webhook-secret-secret-version.id
app_id = 100
app_installation_id = 123123
}

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

gitlab_config {
webhook_secret_secret_version = "projects/devconnect-terraform-creds/secrets/gitlab-webhook/versions/latest"

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

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