Skip to content

Commit

Permalink
Merge branch 'GoogleCloudPlatform:main' into acm-egress-resource
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelina612 authored Jan 7, 2025
2 parents 5c1e466 + c6cb3e6 commit dbf5f79
Show file tree
Hide file tree
Showing 52 changed files with 1,820 additions and 267 deletions.
1 change: 1 addition & 0 deletions .github/workflows/unit-test-tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ permissions: read-all
on:
pull_request:
paths:
- 'docs/**'
- 'tools/**'
- '.github/workflows/unit-test-tools.yml'

Expand Down
6 changes: 4 additions & 2 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ terraform build provider:
make tpgtools

mmv1:
# Chaining these with "&&" is critical so this will exit non-0 if the first
# command fails, since we're not forcing bash and errexit / pipefail here.
cd mmv1;\
if [ "$(VERSION)" = "ga" ]; then \
go run . --output $(OUTPUT_PATH) --version ga --no-docs $(mmv1_compile); \
go run . --output $(OUTPUT_PATH) --version beta --no-code $(mmv1_compile); \
go run . --output $(OUTPUT_PATH) --version ga --no-docs $(mmv1_compile) \
&& go run . --output $(OUTPUT_PATH) --version beta --no-code $(mmv1_compile); \
else \
go run . --output $(OUTPUT_PATH) --version $(VERSION) $(mmv1_compile); \
fi
Expand Down
9 changes: 9 additions & 0 deletions docs/content/code-review/review-pr.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ aliases:

This page provides guidelines for reviewing a Magic Modules pull request (PR).

## Special cases

The following types of PRs may require additional scrutiny and/or multiple reviewers.

- DCL to MMv1 migrations
- Adding multi-actor fields (fields whose values can be altered as a side effect of changes made to a different resource)

## Review

1. Read the PR description to understand the context and ensure the PR either
* is linked to a GitHub issue or an internal bug
* if not, check the [issue tracker](https://github.com/hashicorp/terraform-provider-google/issues) to see whether the feature has already been requested and add the issues in the description, if any.
Expand Down
1 change: 1 addition & 0 deletions docs/content/develop/add-resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ For more information about types of resources and the generation process overall
- Documentation: [`magic-modules/mmv1/third_party/terraform/website/docs/r`](https://github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/third_party/terraform/website/docs/r)
- Tests: Copy to the appropriate service folder inside [`magic-modules/mmv1/third_party/terraform/services`](https://github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/third_party/terraform/services), and remove `_generated` from the filename
- Sweepers: Put to the appropriate service folder inside [`magic-modules/mmv1/third_party/terraform/services`](https://github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/third_party/terraform/services), and add `_sweeper` suffix to the filename
- Metadata: Copy `*_meta.yaml` to the appropriate service folder inside [`magic-modules/mmv1/third_party/terraform/services`](https://github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/third_party/terraform/services), and remove `_generated` from the filename
4. Modify the Go code as needed.
- Replace all occurrences of `github.com/hashicorp/terraform-provider-google-beta/google-beta` with `github.com/hashicorp/terraform-provider-google/google`
- Remove the `Example` suffix from all test function names.
Expand Down
32 changes: 32 additions & 0 deletions docs/content/reference/metadata.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: "MMv1 metadata reference"
weight: 35
---

# MMv1 metadata reference

This page documents all properties for metadata. Metadata does not impact the provider itself, but is used by Google internally for coverage metrics.

## Required

### `resource`

The name of the Terraform resource e.g., "google_cloudfunctions2_function".

### `generation_type`

The generation method used to create the Terraform resource e.g., "mmv1", "dcl", "handwritten".

## Optional

### `api_service_name`

The base name of the API used for this resource e.g., "cloudfunctions.googleapis.com".

### `api_version`

The version of the API used for this resource e.g., "v2".

### `api_resource_type_kind`

The API "resource type kind" used for this resource e.g., "Function".
4 changes: 4 additions & 0 deletions mmv1/api/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,10 @@ type Resource struct {
// The compiler to generate the downstream files, for example "terraformgoogleconversion-codegen".
Compiler string `yaml:"-"`

// The API "resource type kind" used for this resource e.g., "Function".
// If this is not set, then :name is used instead, which is strongly
// preferred wherever possible. Its main purpose is for supporting
// fine-grained resources and legacy resources.
ApiResourceTypeKind string `yaml:"api_resource_type_kind,omitempty"`

ImportPath string `yaml:"-"`
Expand Down
9 changes: 9 additions & 0 deletions mmv1/api/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,15 @@ func (t Type) Lineage() string {
return fmt.Sprintf("%s.%s", t.ParentMetadata.Lineage(), google.Underscore(t.Name))
}

// Returns the lineage in snake case
func (t Type) LineageAsSnakeCase() string {
if t.ParentMetadata == nil {
return google.Underscore(t.Name)
}

return fmt.Sprintf("%s_%s", t.ParentMetadata.LineageAsSnakeCase(), google.Underscore(t.Name))
}

// Prints the access path of the field in the configration eg: metadata.0.labels
// The only intended purpose is to get the value of the labes field by calling d.Get().
func (t Type) TerraformLineage() string {
Expand Down
8 changes: 6 additions & 2 deletions mmv1/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,13 @@ func main() {
}

startTime := time.Now()
providerName := "default (terraform)"
if *forceProvider != "" {
providerName = *forceProvider
}
log.Printf("Generating MM output to '%s'", *outputPath)
log.Printf("Using %s version", *version)
log.Printf("Using %s provider", *forceProvider)
log.Printf("Building %s version", *version)
log.Printf("Building %s provider", providerName)

// Building compute takes a long time and can't be parallelized within the product
// so lets build it first
Expand Down
98 changes: 98 additions & 0 deletions mmv1/products/chronicle/DataAccessLabel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Copyright 2024 Google Inc.
# 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: DataAccessLabel
description: A DataAccessLabel is a label on events to define user access to data.
min_version: 'beta'
references:
guides:
'Introduction to data RBAC': 'https://cloud.google.com/chronicle/docs/onboard/onboard-datarbac'
api: 'https://cloud.google.com/chronicle/docs/reference/rest/v1alpha/projects.locations.instances.dataAccessLabels'
base_url: projects/{{project}}/locations/{{location}}/instances/{{instance}}/dataAccessLabels
self_link: projects/{{project}}/locations/{{location}}/instances/{{instance}}/dataAccessLabels/{{data_access_label_id}}
create_url: projects/{{project}}/locations/{{location}}/instances/{{instance}}/dataAccessLabels?dataAccessLabelId={{data_access_label_id}}
id_format: projects/{{project}}/locations/{{location}}/instances/{{instance}}/dataAccessLabels/{{data_access_label_id}}
import_format:
- projects/{{project}}/locations/{{location}}/instances/{{instance}}/dataAccessLabels/{{data_access_label_id}}
update_verb: PATCH
update_mask: true

examples:
- name: 'chronicle_dataaccesslabel_basic'
primary_resource_id: 'example'
min_version: 'beta'
vars:
data_access_label_id: label-id
description: label-description
test_env_vars:
chronicle_id: 'CHRONICLE_ID'

parameters:
- name: location
type: String
description: The location of the resource. This is the geographical region where the Chronicle instance resides, such as "us" or "europe-west2".
immutable: true
url_param_only: true
required: true
- name: instance
type: String
description: The unique identifier for the Chronicle instance, which is the same as the customer ID.
immutable: true
url_param_only: true
required: true
- name: dataAccessLabelId
type: String
description: |-
Required. The ID to use for the data access label, which will become the label's
display name and the final component of the label's resource name. It must
only contain ASCII lowercase letters, numbers, and dashes; it must begin
with a letter, and it must not exceed 1000 characters.
immutable: true
url_param_only: true
required: true
properties:
- name: author
type: String
description: Output only. The user who created the data access label.
output: true
- name: lastEditor
type: String
description: Output only. The user who last updated the data access label.
output: true
- name: description
type: String
description: Optional. A description of the data access label for a human reader.
- name: udmQuery
type: String
description: A UDM query over event data.
required: true
- name: name
type: String
description: |-
The unique resource name of the data access label. This unique identifier is generated using values provided for the URL parameters.
Format:
projects/{project}/locations/{location}/instances/{instance}/dataAccessLabels/{data_access_label_id}
output: true
- name: displayName
type: String
description: Output only. The short name displayed for the label as it appears on event data. This is same as data access label id.
output: true
- name: createTime
type: String
description: Output only. The time at which the data access label was created.
output: true
- name: updateTime
type: String
description: Output only. The time at which the data access label was last updated.
output: true
Loading

0 comments on commit dbf5f79

Please sign in to comment.