-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
218 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// eslint-disable-next-line camelcase | ||
const { build_info } = require( "inaturalistjs" ); | ||
const process = require( "process" ); | ||
const fetch = require( "node-fetch" ); | ||
const InaturalistAPI = require( "../../inaturalist_api" ); | ||
const util = require( "../../util" ); | ||
const config = require( "../../../config" ); | ||
|
||
const index = async req => { | ||
if ( !req.userSession || ( req.userSession && !req.userSession.isAdmin ) ) { | ||
throw util.httpError( 401, "Unauthorized" ); | ||
} | ||
// Get Rails Build Info | ||
// eslint-disable-next-line camelcase | ||
const railsBuildInfoJSON = await InaturalistAPI.iNatJSWrap( build_info.get, req ); | ||
// Get API Build Info | ||
const apiBuildInfoJSON = { | ||
git_branch: process.env.GIT_BRANCH || "", | ||
git_commit: process.env.GIT_COMMIT || "", | ||
image_tag: process.env.IMAGE_TAG || "", | ||
build_date: process.env.BUILD_DATE || "" | ||
}; | ||
// Get Vision Build Info | ||
let visionBuildInfoJSON = {}; | ||
try { | ||
const response = await fetch( `${config.imageProcesing.tensorappURL}/build_info` ); | ||
if ( !response.ok ) { | ||
throw util.httpError( 500, "Error" ); | ||
} | ||
visionBuildInfoJSON = await response.json( ); | ||
} catch ( error ) { | ||
throw util.httpError( 500, "Error" ); | ||
} | ||
// Application Build Info | ||
const appBuildInfoJSON = { | ||
rails: railsBuildInfoJSON, | ||
api: apiBuildInfoJSON, | ||
vision: visionBuildInfoJSON | ||
}; | ||
return appBuildInfoJSON; | ||
}; | ||
|
||
module.exports = { | ||
index | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const process = require( "process" ); | ||
const util = require( "../../util" ); | ||
|
||
const index = async req => { | ||
if ( !req.userSession || ( req.userSession && !req.userSession.isAdmin ) ) { | ||
throw util.httpError( 401, "Unauthorized" ); | ||
} | ||
const buildInfoJSON = { | ||
git_branch: process.env.GIT_BRANCH || "", | ||
git_commit: process.env.GIT_COMMIT || "", | ||
image_tag: process.env.IMAGE_TAG || "", | ||
build_date: process.env.BUILD_DATE || "" | ||
}; | ||
return buildInfoJSON; | ||
}; | ||
|
||
module.exports = { | ||
index | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const AppBuildInfoController = require( "../../../lib/controllers/v2/app_build_info_controller" ); | ||
|
||
module.exports = sendWrapper => { | ||
async function GET( req, res ) { | ||
const results = await AppBuildInfoController.index( req ); | ||
sendWrapper( req, res, null, results ); | ||
} | ||
|
||
GET.apiDoc = { | ||
tags: ["AppBuildInfo"], | ||
summary: "Display application build information", | ||
security: [{ | ||
userJwtRequired: [] | ||
}], | ||
responses: { | ||
200: { | ||
description: "Application build information", | ||
content: { | ||
"application/json": { | ||
schema: { | ||
$ref: "#/components/schemas/AppBuildInfo" | ||
} | ||
} | ||
} | ||
}, | ||
default: { | ||
$ref: "#/components/responses/Error" | ||
} | ||
}, | ||
"x-unpublished": true | ||
}; | ||
|
||
return { | ||
GET | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const BuildInfoController = require( "../../../lib/controllers/v2/build_info_controller" ); | ||
|
||
module.exports = sendWrapper => { | ||
async function GET( req, res ) { | ||
const results = await BuildInfoController.index( req ); | ||
sendWrapper( req, res, null, results ); | ||
} | ||
|
||
GET.apiDoc = { | ||
tags: ["BuildInfo"], | ||
summary: "Display build information", | ||
security: [{ | ||
userJwtRequired: [] | ||
}], | ||
responses: { | ||
200: { | ||
description: "Build information", | ||
content: { | ||
"application/json": { | ||
schema: { | ||
$ref: "#/components/schemas/BuildInfo" | ||
} | ||
} | ||
} | ||
}, | ||
default: { | ||
$ref: "#/components/responses/Error" | ||
} | ||
}, | ||
"x-unpublished": true | ||
}; | ||
|
||
return { | ||
GET | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const Joi = require( "joi" ); | ||
|
||
module.exports = Joi.object( ).keys( {} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const Joi = require( "joi" ); | ||
|
||
module.exports = Joi.object( ).keys( {} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const Joi = require( "joi" ); | ||
|
||
module.exports = Joi.object( ).keys( { | ||
rails: Joi.object( ).keys( { | ||
git_branch: Joi.string( ), | ||
git_commit: Joi.string( ), | ||
image_tag: Joi.string( ), | ||
build_date: Joi.string( ) | ||
} ), | ||
api: Joi.object( ).keys( { | ||
git_branch: Joi.string( ), | ||
git_commit: Joi.string( ), | ||
image_tag: Joi.string( ), | ||
build_date: Joi.string( ) | ||
} ), | ||
vision: Joi.object( ).keys( { | ||
git_branch: Joi.string( ), | ||
git_commit: Joi.string( ), | ||
image_tag: Joi.string( ), | ||
build_date: Joi.string( ) | ||
} ) | ||
} ).unknown( false ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const Joi = require( "joi" ); | ||
|
||
module.exports = Joi.object( ).keys( { | ||
git_branch: Joi.string( ), | ||
git_commit: Joi.string( ), | ||
image_tag: Joi.string( ), | ||
build_date: Joi.string( ) | ||
} ).unknown( false ); |