Skip to content

Commit 83e9a95

Browse files
authored
Add detect tool for unlinked tmpl (#13802)
1 parent 6158b93 commit 83e9a95

File tree

6 files changed

+1264
-0
lines changed

6 files changed

+1264
-0
lines changed

.github/workflows/unit-test-mmv1.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,32 @@ jobs:
4242
if [[ -n "$tmpls" ]]; then
4343
go run main.go version-guard --file-list $tmpls
4444
fi
45+
unused-template-check:
46+
runs-on: ubuntu-22.04
47+
steps:
48+
- name: Checkout Repository
49+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.2
50+
with:
51+
path: repo
52+
fetch-depth: 0
53+
- name: Merge base branch
54+
id: pull_request
55+
run: |
56+
cd repo
57+
git config user.name "modular-magician"
58+
git config user.email "[email protected]"
59+
git fetch origin ${{ github.base_ref }} # Fetch the base branch
60+
git merge --no-ff origin/${{ github.base_ref }} # Merge with the base branch
61+
- name: Check new product templates are linked
62+
id: new_templates
63+
run: |
64+
cd repo/tools/template-check
65+
newtmplfiles=$(git diff --name-only --diff-filter=A origin/${{ github.base_ref }} HEAD -- ../../mmv1 | grep .tmpl | sed 's=^=../../=g')
66+
if [ ! -z "$newtmplfiles" ]; then
67+
newtmplfiles=${newtmplfiles//$'\n'/,}
68+
echo $newtmplfiles
69+
go run main.go unused-tmpl --file-list $newtmplfiles
70+
fi
4571
lint-yaml:
4672
runs-on: ubuntu-22.04
4773
steps:

tools/template-check/cmd/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func newRootCmd() (*cobra.Command, *rootOptions, error) {
2222
SilenceErrors: true,
2323
}
2424
cmd.AddCommand(newversionGuardCmd(o))
25+
cmd.AddCommand(newUnusedTmplCmd(o))
2526
return cmd, o, nil
2627
}
2728

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Copyright 2024 Google Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
---
15+
name: 'AppEngineService'
16+
description: |
17+
Only used to generate IAM resources
18+
# This resource is only used to generate IAM resources. They do not correspond to real
19+
# GCP resources, and should not be used to generate anything other than IAM support.
20+
exclude_resource: true
21+
docs:
22+
id_format: 'projects/{{project}}/iap_web/appengine-{{appId}}/services/{{service}}'
23+
base_url: 'projects/{{project}}/iap_web/appengine-{{appId}}/services/{{service}}'
24+
self_link: 'projects/{{project}}/iap_web/appengine-{{appId}}/services/{{service}}'
25+
import_format:
26+
- 'projects/{{project}}/iap_web/appengine-{{appId}}/services/{{service}}'
27+
- '{{service}}'
28+
timeouts:
29+
insert_minutes: 20
30+
update_minutes: 20
31+
delete_minutes: 20
32+
iam_policy:
33+
method_name_separator: ':'
34+
parent_resource_type: 'google_app_engine_standard_app_version'
35+
fetch_iam_policy_verb: 'POST'
36+
allowed_iam_role: 'roles/iap.httpsResourceAccessor'
37+
parent_resource_attribute: 'service'
38+
test_project_name: 'tf-test'
39+
iam_conditions_request_type: 'REQUEST_BODY'
40+
example_config_body: 'templates/terraform/iam/example_config_body/app_engine_service.tf.tmpl'
41+
custom_code:
42+
exclude_tgc: true
43+
examples:
44+
- name: 'iap_app_engine_service'
45+
primary_resource_id: 'version'
46+
primary_resource_name: 'context["project_id"], "default"'
47+
test_env_vars:
48+
org_id: 'ORG_ID'
49+
billing_account: 'BILLING_ACCT'
50+
# https://github.com/hashicorp/terraform-provider-google/issues/18936
51+
exclude_test: true
52+
parameters:
53+
properties:
54+
- name: 'appId'
55+
type: String
56+
description: Id of the App Engine application.
57+
required: true
58+
- name: 'service'
59+
type: String
60+
description: Service id of the App Engine application
61+
required: true

0 commit comments

Comments
 (0)