Skip to content

Commit 96a9c78

Browse files
Et/ptfe removal and renaming to terraform enterprise (#2806)
* wip: updating and removal of ptfe where necessary * test: update ptfe-releases references to terraform-enterprise in tests Update all test files to use terraform-enterprise product slug - Fix test expectations to match new unified docs structure - Update test comments and examples to reflect current repository structure * test: fix product documentation menu test locator conflicts - bypass portal element blocking documentation menu hover - Add force: true to hover action to bypass nextjs-portal interference - Resolve strict mode violation where multiple "Documentation" buttons existed - Use more specific header-scoped locator to avoid sidebar button conflicts Fixes E2E test timeout caused by portal elements intercepting hover events on the Terraform documentation dropdown menu. * Update scripts/docs-content-link-rewrites/helpers/get-mdx-and-nav-data-directories-for-repo.ts Co-authored-by: Leah Bush <[email protected]> * Update scripts/list-open-prs-with-docs-changes.ts Co-authored-by: Leah Bush <[email protected]> --------- Co-authored-by: Leah Bush <[email protected]>
1 parent 958f349 commit 96a9c78

File tree

20 files changed

+64
-45
lines changed

20 files changed

+64
-45
lines changed

build-libs/__tests__/get-latest-content-sha-for-product.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ describe('getLatestContentShaForProduct', () => {
1717
expect(typeof latestSha).toBe('string')
1818
})
1919
}
20-
if (['hcp-docs', 'sentinel', 'ptfe-releases', 'hvd-docs'].includes(repo)) {
20+
if (
21+
['hcp-docs', 'sentinel', 'terraform-enterprise', 'hvd-docs'].includes(
22+
repo
23+
)
24+
) {
2125
console.log(`Skipping test for private repo "${repo}"`)
2226
} else {
2327
it(`fetches the latest SHA for the "${repo}" repo, then validates the SHA by fetching redirects`, async () => {

build-libs/__tests__/redirects.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ describe('getRedirectsFromContentRepo', () => {
258258
'terraform-docs-common',
259259
'test',
260260
{
261-
'flags.unified_docs_migrated_repos': ['terraform-docs-common']
261+
'flags.unified_docs_migrated_repos': ['terraform-docs-common'],
262262
}
263263
)
264264

@@ -270,10 +270,10 @@ describe('getRedirectsFromContentRepo', () => {
270270
const mockConsole = vi.spyOn(console, 'error').mockImplementation(() => {})
271271

272272
const redirects = await getRedirectsFromContentRepo(
273-
'ptfe-releases',
273+
'terraform-enterprise',
274274
'test',
275275
{
276-
'flags.unified_docs_migrated_repos': ['ptfe-releases']
276+
'flags.unified_docs_migrated_repos': ['terraform-enterprise'],
277277
}
278278
)
279279

build-libs/get-latest-content-sha-for-product.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ const KNOWN_LATEST_REF_ENDPOINTS = {
2424
'terraform-docs-common':
2525
'/api/content/terraform-docs-common/nav-data/latest/docs',
2626
'hcp-docs': '/api/content/hcp-docs/nav-data/latest/docs',
27-
'ptfe-releases': '/api/content/ptfe-releases/nav-data/latest/enterprise',
27+
'terraform-enterprise':
28+
'/api/content/terraform-enterprise/nav-data/latest/enterprise',
2829
sentinel: '/api/content/sentinel/nav-data/latest/sentinel',
2930
}
3031

build-libs/redirects.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,13 @@ async function getRedirectsFromContentRepo(repoName, redirectsPath, config) {
6464
* Load redirects from the unified docs repo if it's in the list of migrated repos.
6565
* Return early if there are not any redirects found for that specific repo.
6666
*/
67-
if (
68-
config['flags.unified_docs_migrated_repos'].includes(repoName)
69-
) {
70-
const headers = process.env.UDR_VERCEL_AUTH_BYPASS_TOKEN ? new Headers({
71-
'x-vercel-protection-bypass': process.env.UDR_VERCEL_AUTH_BYPASS_TOKEN,
72-
}) : new Headers()
67+
if (config['flags.unified_docs_migrated_repos'].includes(repoName)) {
68+
const headers = process.env.UDR_VERCEL_AUTH_BYPASS_TOKEN
69+
? new Headers({
70+
'x-vercel-protection-bypass':
71+
process.env.UDR_VERCEL_AUTH_BYPASS_TOKEN,
72+
})
73+
: new Headers()
7374

7475
const getUDRRedirects = await fetch(
7576
`${process.env.UNIFIED_DOCS_API}/api/content/${repoName}/redirects`,
@@ -85,12 +86,15 @@ async function getRedirectsFromContentRepo(repoName, redirectsPath, config) {
8586
return []
8687
}
8788

88-
const privateRepos = ['hcp-docs', 'ptfe-releases', 'sentinel', 'hvd-docs']
89+
const privateRepos = ['hcp-docs', 'sentinel', 'hvd-docs']
8990
/**
9091
* The UDR docker image does not have access to the github token necessary to
9192
* fetch redirects from private repos so we return an empty array for those redirects
9293
*/
93-
if (process.env.HASHI_ENV === 'unified-docs-sandbox' && privateRepos.includes(repoName)) {
94+
if (
95+
process.env.HASHI_ENV === 'unified-docs-sandbox' &&
96+
privateRepos.includes(repoName)
97+
) {
9498
return []
9599
}
96100

@@ -144,7 +148,6 @@ const PRODUCT_REDIRECT_ENTRIES = [
144148
{ repo: 'consul', path: 'website/redirects.js' },
145149
{ repo: 'terraform-docs-common', path: 'website/redirects.js' },
146150
{ repo: 'hcp-docs', path: '/redirects.js' }, // private repo
147-
{ repo: 'ptfe-releases', path: 'website/redirects.js' }, // private repo
148151
{ repo: 'sentinel', path: 'website/redirects.js' }, // private repo
149152
{ repo: 'hvd-docs', path: '/redirects.js' }, // private repo
150153
]
@@ -316,8 +319,6 @@ function filterInvalidRedirects(redirects, repoSlug) {
316319
/** @deprecated - terraform-website is now archived and redirects have been moved to `terraform-docs-common` */
317320
'terraform-website': 'terraform',
318321
'terraform-docs-common': 'terraform',
319-
// Note: `ptfe-releases` docs are rendered under `terraform/enterprise` URLs
320-
'ptfe-releases': 'terraform/enterprise',
321322
'cloud.hashicorp.com': 'hcp',
322323
'hcp-docs': 'hcp',
323324
'hvd-docs': 'validated-designs',

config/base.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"terraform",
4949
"terraform-docs-common",
5050
"vault",
51-
"ptfe-releases"
51+
"terraform-enterprise"
5252
]
5353
}
5454
}

config/development.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"terraform",
2222
"terraform-docs-common",
2323
"vault",
24-
"ptfe-releases"
24+
"terraform-enterprise"
2525
]
2626
}
2727
}

config/unified-docs-sandbox.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"terraform-plugin-testing",
1919
"terraform-docs-agents",
2020
"terraform-cdk",
21-
"ptfe-releases",
21+
"terraform-enterprise",
2222
"terraform-docs-common",
2323
"terraform",
2424
"vault"

scripts/docs-content-link-rewrites/helpers/get-mdx-and-nav-data-directories-for-repo.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,24 @@
99
* - navDataPrefix: the filename prefix for nav data JSON files
1010
*/
1111
const getMdxAndNavDataDirectoriesForRepo = (repo: string) => {
12+
// Legacy product slug mapping
13+
const normalizedRepo =
14+
repo === 'ptfe-releases' ? 'terraform-enterprise' : repo
15+
1216
// The default values that most repos use
1317
let mdxPrefix = 'website/content'
1418
let navDataPrefix = 'website/data'
1519

1620
// HCP and Terraform docs content repos use slightly different values
1721
// Note: cloud.hashicorp.com is being renamed to hcp-docs
18-
if (repo === 'cloud.hashicorp.com' || repo === 'hcp-docs') {
22+
if (
23+
normalizedRepo === 'cloud.hashicorp.com' ||
24+
normalizedRepo === 'hcp-docs' ||
25+
normalizedRepo === 'terraform-enterprise'
26+
) {
1927
mdxPrefix = 'content'
2028
navDataPrefix = 'data'
21-
} else if (repo.startsWith('terraform') || repo.startsWith('ptfe-releases')) {
29+
} else if (repo.startsWith('terraform')) {
2230
mdxPrefix = 'website/docs'
2331
}
2432

scripts/docs-content-link-rewrites/helpers/get-mdx-links-to-rewrite.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ const getMdxLinksToRewrite = async ({
5656
* property indicates that the content is regularly copied over from the
5757
* source, and thus should not be modified.
5858
*
59-
* Example file in the `ptfe-releases` repository:
60-
* https://github.com/hashicorp/ptfe-releases/blob/ba4dc2af20cc9d0f46247c919be8b2ed90d1e6f8/website/docs/enterprise/registry/index.mdx?plain=1#L6
61-
*/
59+
* Example file in the `terraform-enterprise` repository (formerly ptfe-releases):
60+
* https://github.com/hashicorp/web-unified-docs/blob/main/content/terraform-enterprise/... */
6261
const { data: frontmatter } = matter(fileContent)
6362
const isSourcedFromDifferentRepo =
6463
typeof frontmatter?.source === 'string' && frontmatter.source !== repo

scripts/list-open-prs-with-docs-changes.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,24 @@ import { Octokit } from '@octokit/rest'
1212
* - navDataPrefix: the filename prefix for nav data JSON files
1313
*/
1414
const getRelevantFileNamePrefixes = (repo: string) => {
15+
// Legacy product slug mapping
16+
const normalizedRepo =
17+
repo === 'ptfe-releases' ? 'terraform-enterprise' : repo
18+
1519
// The default values that most repos use
1620
let mdxPrefix = 'website/content'
1721
let navDataPrefix = 'website/data'
1822

1923
// HCP and Terraform docs content repos use slightly different values
2024
// Note: cloud.hashicorp.com is being renamed to hcp-docs
21-
if (repo === 'cloud.hashicorp.com' || repo === 'hcp-docs') {
25+
if (
26+
normalizedRepo === 'cloud.hashicorp.com' ||
27+
normalizedRepo === 'hcp-docs' ||
28+
normalizedRepo === 'terraform-enterprise'
29+
) {
2230
mdxPrefix = 'content'
2331
navDataPrefix = 'content'
24-
} else if (repo.startsWith('terraform') || repo.startsWith('ptfe-releases')) {
32+
} else if (normalizedRepo.startsWith('terraform')) {
2533
mdxPrefix = 'website/docs'
2634
}
2735

0 commit comments

Comments
 (0)