Skip to content

Commit

Permalink
Merge pull request #2099 from yuwenma/stricter-check-projectnumber
Browse files Browse the repository at this point in the history
fix: replace mockresourcemanager generated Project number
  • Loading branch information
google-oss-prow[bot] authored Jun 22, 2024
2 parents 404ed0a + c092454 commit 93d018f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ status:
reason: UpToDate
status: "True"
type: Ready
number: "2727742225"
number: ${projectNumber}
observedGeneration: 3
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ status:
reason: UpToDate
status: "True"
type: Ready
number: "2713651918"
number: ${projectNumber}
observedGeneration: 3
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ status:
reason: UpToDate
status: "True"
type: Ready
number: "2589592254"
number: ${projectNumber}
observedGeneration: 3
8 changes: 8 additions & 0 deletions tests/e2e/normalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,20 @@ func normalizeKRMObject(u *unstructured.Unstructured, project testgcp.GCPProject
visitor.sortSlices.Insert(".spec.access")
visitor.sortSlices.Insert(".spec.nodeConfig.oauthScopes")

if u.GetKind() == "Project" {
// For some tests that talk to the Mock Resource Manager, the Project object's ProjectID and ProjectNumber are dynamcially generated.
// We do not want to overrride this with the default mocked Project "mock-project".
visitor.replacePaths[".status.number"] = "${projectNumber}"
}

visitor.stringTransforms = append(visitor.stringTransforms, func(path string, s string) string {
return strings.ReplaceAll(s, project.ProjectID, "${projectId}")
})

visitor.stringTransforms = append(visitor.stringTransforms, func(path string, s string) string {
return strings.ReplaceAll(s, fmt.Sprintf("%d", project.ProjectNumber), "${projectNumber}")
})

visitor.stringTransforms = append(visitor.stringTransforms, func(path string, s string) string {
return strings.ReplaceAll(s, uniqueID, "${uniqueId}")
})
Expand Down

0 comments on commit 93d018f

Please sign in to comment.