Repository: GoogleCloudPlatform/k8s-config-connector
Pull request #4086: conductor: minor adjustment to the test file template
Author: login: jingyih
Labels: name: lgtm
name: approved
Created: 2025-03-19T00:55:25Z | Merged: 2025-03-19T04:55:47Z

 - Add copyright header.
 - Rename `locationID` to `location` which is more commonly used by resources.


Diff:
diff --git a/experiments/conductor/cmd/runner/controller_commands.go b/experiments/conductor/cmd/runner/controller_commands.go
index 775eb01f0b1..d2a4dda2489 100644
--- a/experiments/conductor/cmd/runner/controller_commands.go
+++ b/experiments/conductor/cmd/runner/controller_commands.go
@@ -21,6 +21,7 @@ import (
 	"os"
 	"path/filepath"
 	"strings"
+	"time"
 )
 
 // generateControllerClient creates a controller client for the branch
@@ -310,17 +311,34 @@ func createControllerTest(ctx context.Context, opts *RunnerOptions, branch Branc
 		return nil, nil, fmt.Errorf("failed to create test directory %s: %w", fullTestDir, err)
 	}
 
+	currentYear := time.Now().Year()
+	yamlCopyright := fmt.Sprintf(`# Copyright %d Google LLC
+#
+# 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.
+`, currentYear)
+
 	// Create create.yaml
-	createYaml := fmt.Sprintf(`apiVersion: %s/%s
+	createYaml := fmt.Sprintf(`%s
+apiVersion: %s/%s
 kind: %s
 metadata:
   name: %s-minimal-${uniqueId}
 spec:
   projectRef:
     external: ${projectId}
-  locationID: us-west2
+  location: us-central1
   description: "Initial description"
-`, crdGroup, crdVersion, branch.Kind, strings.ToLower(branch.Kind))
+`, yamlCopyright, crdGroup, crdVersion, branch.Kind, strings.ToLower(branch.Kind))
 
 	createYamlPath := filepath.Join(fullTestDir, "create.yaml")
 	if err := os.WriteFile(createYamlPath, []byte(createYaml), 0644); err != nil {
@@ -328,16 +346,17 @@ spec:
 	}
 
 	// Create update.yaml
-	updateYaml := fmt.Sprintf(`apiVersion: %s/%s
+	updateYaml := fmt.Sprintf(`%s
+apiVersion: %s/%s
 kind: %s
 metadata:
   name: %s-minimal-${uniqueId}
 spec:
   projectRef:
     external: ${projectId}
-  locationID: us-west2
+  location: us-central1
   description: "Updated description"
-`, crdGroup, crdVersion, branch.Kind, strings.ToLower(branch.Kind))
+`, yamlCopyright, crdGroup, crdVersion, branch.Kind, strings.ToLower(branch.Kind))
 
 	updateYamlPath := filepath.Join(fullTestDir, "update.yaml")
 	if err := os.WriteFile(updateYamlPath, []byte(updateYaml), 0644); err != nil {
diff --git a/experiments/conductor/cmd/runner/scripts/controller/04-create-test.sh b/experiments/conductor/cmd/runner/scripts/controller/04-create-test.sh
index 143e1e558cc..35072f47dad 100755
--- a/experiments/conductor/cmd/runner/scripts/controller/04-create-test.sh
+++ b/experiments/conductor/cmd/runner/scripts/controller/04-create-test.sh
@@ -43,6 +43,20 @@ TESTDIR=pkg/test/resourcefixture/testdata/basic/${SERVICE}/v1alpha1/${CRD_KIND,,
 mkdir -p ${TESTDIR}
 
 cat <<EOF > ${TESTDIR}/create.yaml
+# Copyright 2025 Google LLC
+#
+# 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.
+
 apiVersion: ${CRD_GROUP}/${CRD_VERSION}
 kind: ${CRD_KIND}
 metadata:
@@ -50,11 +64,25 @@ metadata:
 spec:
   projectRef:
     external: \${projectId}
-  locationID: us-west2
+  location: us-central1
   description: "Initial description"
 EOF
 
 cat <<EOF > ${TESTDIR}/update.yaml
+# Copyright 2025 Google LLC
+#
+# 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 a
+#
+#      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.
+
 apiVersion: ${CRD_GROUP}/${CRD_VERSION}
 kind: ${CRD_KIND}
 metadata:
@@ -62,7 +90,7 @@ metadata:
 spec:
   projectRef:
     external: \${projectId}
-  locationID: us-west2
+  location: us-central1
   description: "Updated description"
 EOF
 


Reviews:
user: login: barney-s
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-19T02:30:29Z
user: login: jingyih
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-19T03:15:01Z
user: login: barney-s
state: APPROVED
author_association: COLLABORATOR
submitted_at: 2025-03-19T04:54:47Z

Review comments:
diff_hunk: @@ -310,34 +311,51 @@ func createControllerTest(ctx context.Context, opts *RunnerOptions, branch Branc
 		return nil, nil, fmt.Errorf("failed to create test directory %s: %w", fullTestDir, err)
 	}
 
+	currentYear := time.Now().Year()
+	yamlCopyright := fmt.Sprintf(`# Copyright %d Google LLC
+#
+# 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.
+
+`, currentYear)
+
 	// Create create.yaml
-	createYaml := fmt.Sprintf(`apiVersion: %s/%s
+	createYaml := fmt.Sprintf(`%sapiVersion: %s/%s
path: experiments/conductor/cmd/runner/controller_commands.go
user: login: barney-s
body: more readable to: 
```
createYaml := fmt.Sprintf(`%s
apiVersion: %s/%s

```
created_at: 2025-03-19T02:30:09Z
author_association: COLLABORATOR
diff_hunk: @@ -310,34 +311,51 @@ func createControllerTest(ctx context.Context, opts *RunnerOptions, branch Branc
 		return nil, nil, fmt.Errorf("failed to create test directory %s: %w", fullTestDir, err)
 	}
 
+	currentYear := time.Now().Year()
+	yamlCopyright := fmt.Sprintf(`# Copyright %d Google LLC
+#
+# 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.
+
+`, currentYear)
+
 	// Create create.yaml
-	createYaml := fmt.Sprintf(`apiVersion: %s/%s
+	createYaml := fmt.Sprintf(`%sapiVersion: %s/%s
 kind: %s
 metadata:
   name: %s-minimal-${uniqueId}
 spec:
   projectRef:
     external: ${projectId}
-  locationID: us-west2
+  location: us-central1
   description: "Initial description"
-`, crdGroup, crdVersion, branch.Kind, strings.ToLower(branch.Kind))
+`, yamlCopyright, crdGroup, crdVersion, branch.Kind, strings.ToLower(branch.Kind))
 
 	createYamlPath := filepath.Join(fullTestDir, "create.yaml")
 	if err := os.WriteFile(createYamlPath, []byte(createYaml), 0644); err != nil {
 		return nil, nil, fmt.Errorf("failed to write create.yaml: %w", err)
 	}
 
 	// Create update.yaml
-	updateYaml := fmt.Sprintf(`apiVersion: %s/%s
+	updateYaml := fmt.Sprintf(`%sapiVersion: %s/%s
path: experiments/conductor/cmd/runner/controller_commands.go
user: login: barney-s
body: similar comment.
created_at: 2025-03-19T02:30:23Z
author_association: COLLABORATOR
diff_hunk: @@ -310,34 +311,51 @@ func createControllerTest(ctx context.Context, opts *RunnerOptions, branch Branc
 		return nil, nil, fmt.Errorf("failed to create test directory %s: %w", fullTestDir, err)
 	}
 
+	currentYear := time.Now().Year()
+	yamlCopyright := fmt.Sprintf(`# Copyright %d Google LLC
+#
+# 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.
+
+`, currentYear)
+
 	// Create create.yaml
-	createYaml := fmt.Sprintf(`apiVersion: %s/%s
+	createYaml := fmt.Sprintf(`%sapiVersion: %s/%s
path: experiments/conductor/cmd/runner/controller_commands.go
user: login: jingyih
body: Done. Thanks!
created_at: 2025-03-19T03:15:00Z
author_association: CONTRIBUTOR

PR comments:
user: login: barney-s
created_at: 2025-03-19T04:54:28Z
body: /lgtm
/approve
author_association: COLLABORATOR
user: login: google-oss-prow[bot]
created_at: 2025-03-19T04:54:57Z
body: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/GoogleCloudPlatform/k8s-config-connector/pull/4086#pullrequestreview-2696903914" title="Approved">barney-s</a>*

The full list of commands accepted by this bot can be found [here](https://oss.gprow.dev/command-help?repo=GoogleCloudPlatform%2Fk8s-config-connector).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[experiments/OWNERS](https://github.com/GoogleCloudPlatform/k8s-config-connector/blob/master/experiments/OWNERS)~~ [barney-s]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
author_association: CONTRIBUTOR