Skip to content

Commit

Permalink
chore: clean up HCP Vault Secrets OpenAPI work post-launch (#2153)
Browse files Browse the repository at this point in the history
* chore: lift up api-docs utils to lib

* refactor: clean up PageConfig for new template

* chore: clean up now-unused flag
  • Loading branch information
zchsh authored Sep 6, 2023
1 parent 0ef1075 commit 9b3dcf5
Show file tree
Hide file tree
Showing 19 changed files with 151 additions and 227 deletions.
3 changes: 1 addition & 2 deletions config/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
},
"flags": {
"enable_datadog": true,
"enable_io_beta_cta": true,
"enable_hcp_vault_secrets_api_docs_revision": false
"enable_io_beta_cta": true
}
}
3 changes: 0 additions & 3 deletions config/development.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,5 @@
},
"learn": {
"max_static_paths": 1
},
"flags": {
"enable_hcp_vault_secrets_api_docs_revision": true
}
}
3 changes: 0 additions & 3 deletions config/preview.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@
"extends": "base",
"io_sites": {
"max_static_paths": 10
},
"flags": {
"enable_hcp_vault_secrets_api_docs_revision": true
}
}
3 changes: 0 additions & 3 deletions config/production.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,5 @@
"idp_url": "https://auth.idp.hashicorp.com"
},
"product_slugs_with_integrations": ["vault", "waypoint", "nomad", "packer"]
},
"flags": {
"enable_hcp_vault_secrets_api_docs_revision": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

import path from 'path'
import { fetchFileTreeFromGithub } from './fetch-file-tree-from-github'
import type { FileTreeEntry, GithubDir } from './fetch-file-tree-from-github'
import { fetchGithubFileTree } from 'lib/fetch-github-file-tree'
import type { FileTreeEntry, GithubDir } from 'lib/fetch-github-file-tree'

/**
* Given the details of a remote directory on GitHub,
Expand All @@ -20,7 +20,7 @@ import type { FileTreeEntry, GithubDir } from './fetch-file-tree-from-github'
export async function getJsonFilesFromGithubDir(
githubDir: GithubDir
): Promise<FileTreeEntry[]> {
const gitTree = await fetchFileTreeFromGithub(githubDir, { recursive: true })
const gitTree = await fetchGithubFileTree(githubDir, { recursive: true })
// Filter the data.tree for .json files
const jsonFiles = gitTree.filter((entry: FileTreeEntry) => {
// .json files will be blobs, filter out non-blobs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

import path from 'path'
import { getJsonFilesFromGithubDir } from './fetch-json-files-from-github-dir'
// Types
import type { FileTreeEntry, GithubDir } from './fetch-file-tree-from-github'
import type { ApiDocsVersionData } from '../../types'
import { sortDateVersionData } from '../sort-date-version-data'
// Types
import type { FileTreeEntry, GithubDir } from '../../fetch-github-file-tree'
import type { ApiDocsVersionData } from '../types'

/**
* Extract a `versionId` from a cloud API docs spec file path.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: MPL-2.0
*/

import { ApiDocsVersionData } from '../types'
import { ApiDocsVersionData } from './types'
import { sortDateVersionData } from './sort-date-version-data'

/**
Expand Down
8 changes: 8 additions & 0 deletions src/lib/api-docs/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/

export { fetchCloudApiVersionData } from './fetch-cloud-api-version-data'
export { findLatestStableVersion } from './find-latest-stable-version'
export { sortDateVersionData } from './sort-date-version-data'
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: MPL-2.0
*/

import { ApiDocsVersionData } from '../types'
import { ApiDocsVersionData } from './types'

/**
* Sort version data in descending order.
Expand Down
13 changes: 13 additions & 0 deletions src/lib/api-docs/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { GithubFile } from 'lib/fetch-github-file'

/**
* A type to describe versioned API docs source files.
*/
export interface ApiDocsVersionData {
// A unique id for this version, used to construct URL paths for example
versionId: string
// The release stage of this version of the API docs
releaseStage?: string // typically 'stable' | 'preview'
// The schema file we'll load and render into the page for this version
targetFile: GithubFile | string
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { Octokit } from '@octokit/core'
import { buildQueryStringSuffix } from './build-query-string-suffix'
import { buildQueryStringSuffix } from './api-docs/fetch-cloud-api-version-data/build-query-string-suffix'

/**
* Initialize octokit.
Expand Down Expand Up @@ -40,7 +40,7 @@ export interface FileTreeEntry {
* If the remote directory cannot be successfully fetched, or the resulting
* response does not contain a file tree, this function throws an error.
*/
export async function fetchFileTreeFromGithub(
export async function fetchGithubFileTree(
githubDir: GithubDir,
options: { recursive?: boolean } = {}
): Promise<FileTreeEntry[]> {
Expand Down
3 changes: 2 additions & 1 deletion src/pages/hcp/api-docs/packer/[[...page]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* SPDX-License-Identifier: MPL-2.0
*/

// Global
import { fetchCloudApiVersionData } from 'lib/api-docs'
// View
import ApiDocsView from 'views/api-docs-view'
import {
Expand All @@ -11,7 +13,6 @@ import {
ApiDocsParams,
} from 'views/api-docs-view/server'
import { buildApiDocsBreadcrumbs } from 'views/api-docs-view/server/get-api-docs-static-props/utils'
import { fetchCloudApiVersionData } from 'views/api-docs-view/utils'
// Components
import {
PathTruncationAside,
Expand Down
Loading

1 comment on commit 9b3dcf5

@vercel
Copy link

@vercel vercel bot commented on 9b3dcf5 Sep 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.