File tree Expand file tree Collapse file tree 3 files changed +35
-10
lines changed
dify-helm-watchdog/src/app/api/v1/versions Expand file tree Collapse file tree 3 files changed +35
-10
lines changed Original file line number Diff line number Diff line change @@ -53,11 +53,6 @@ interface ImagesResponse {
5353 * description: Whether to include validation information alongside each image.
5454 * schema:
5555 * type: boolean
56- * - name: include_validation
57- * in: query
58- * description: Deprecated alias of includeValidation.
59- * schema:
60- * type: boolean
6156 * responses:
6257 * 200:
6358 * description: Image list in JSON or YAML.
@@ -74,10 +69,7 @@ export async function GET(
7469 const { version } = await params ;
7570 const url = new URL ( request . url ) ;
7671 const format = url . searchParams . get ( "format" ) || "json" ;
77- const includeValidationParam =
78- url . searchParams . get ( "includeValidation" ) ??
79- url . searchParams . get ( "include_validation" ) ;
80- const includeValidation = includeValidationParam === "true" ;
72+ const includeValidation = url . searchParams . get ( "includeValidation" ) === "true" ;
8173
8274 const cache = await loadCache ( ) ;
8375 if ( ! cache ) {
Original file line number Diff line number Diff line change @@ -18,6 +18,11 @@ export const runtime = "nodejs";
1818 * required: true
1919 * schema:
2020 * type: string
21+ * - name: isMissing
22+ * in: query
23+ * description: When true, only returns images with status "MISSING".
24+ * schema:
25+ * type: boolean
2126 * responses:
2227 * 200:
2328 * description: Validation payload in JSON format.
@@ -32,6 +37,8 @@ export async function GET(
3237) {
3338 try {
3439 const { version } = await params ;
40+ const url = new URL ( request . url ) ;
41+ const isMissing = url . searchParams . get ( "isMissing" ) === "true" ;
3542
3643 const cache = await loadCache ( ) ;
3744 if ( ! cache ) {
@@ -88,6 +95,12 @@ export async function GET(
8895 JSON . parse ( validationContent ) ,
8996 ) ;
9097
98+ if ( isMissing ) {
99+ validationData . images = validationData . images . filter (
100+ ( img ) => img . status === "MISSING" ,
101+ ) ;
102+ }
103+
91104 return createJsonResponse ( validationData , {
92105 request,
93106 headers : {
Original file line number Diff line number Diff line change @@ -11,9 +11,15 @@ export const runtime = "nodejs";
1111 * description: Returns convenience links to the most recent cached chart version and its related resources.
1212 * tags:
1313 * - Versions
14+ * parameters:
15+ * - name: versionOnly
16+ * in: query
17+ * description: When true, returns only the version string as plain text instead of the full JSON response.
18+ * schema:
19+ * type: boolean
1420 * responses:
1521 * 200:
16- * description: Metadata about the latest chart version.
22+ * description: Metadata about the latest chart version (JSON) or version string (plain text if versionOnly=true) .
1723 * 404:
1824 * description: No cached versions available.
1925 * 500:
@@ -38,6 +44,20 @@ export async function GET(request: Request) {
3844
3945 const latestVersion = cache . versions [ 0 ] ;
4046
47+ // Check for versionOnly parameter
48+ const url = new URL ( request . url ) ;
49+ const versionOnly = url . searchParams . get ( "versionOnly" ) === "true" ;
50+
51+ if ( versionOnly ) {
52+ return new Response ( latestVersion . version , {
53+ status : 200 ,
54+ headers : {
55+ "Content-Type" : "text/plain; charset=utf-8" ,
56+ "Cache-Control" : "public, s-maxage=1800, stale-while-revalidate=3600" ,
57+ } ,
58+ } ) ;
59+ }
60+
4161 const responseBody = {
4262 version : latestVersion . version ,
4363 appVersion : latestVersion . appVersion ?? null ,
You can’t perform that action at this time.
0 commit comments