-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from scality/config-runtime
ZENKO-2519 Customizable configuration at runtime
- Loading branch information
Showing
9 changed files
with
50 additions
and
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"api_endpoint": "http://127.0.0.1:5000" | ||
"apiEndpoint": "http://127.0.0.1:5000", | ||
"instanceId": "c4a88541-2a25-4896-a1f4-65dd7e88fab3" | ||
} |
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 |
---|---|---|
@@ -1,26 +1,30 @@ | ||
import Swagger from 'swagger-client'; | ||
|
||
function makePensieveClient(apiEndpoint, instanceId){ | ||
function makeApiClient(apiEndpoint, instanceId){ | ||
// NOTE: This is not production-ready. | ||
// It implements an authentication call based on a hardcoded OIDC token and an instance ID set in the `config.json` file. | ||
// This call returns a JWT token which allows the user to access "pensieve-api" resources that are permitted with that token. | ||
const request = { | ||
url: `${apiEndpoint}/api/v1/management/${instanceId}/token`, | ||
method: 'GET', | ||
headers: { 'X-Management-Authentication-Token': 'coco' }, | ||
headers: { 'X-Management-Authentication-Token': 'oidc.token' }, | ||
}; | ||
|
||
// TODO: use refreshToken API | ||
return Swagger.http(request) | ||
.then((res) => { | ||
return Swagger(apiEndpoint + '/swagger.json', | ||
{ authorizations: { 'public-api': res.body.token } }); | ||
}) | ||
.then(client => { | ||
client.spec.schemes = [apiEndpoint.split(':')[0]]; | ||
const pensieveClient = client.apis['ui-facing']; | ||
return pensieveClient; | ||
const apiClient = client.apis['ui-facing']; | ||
return apiClient; | ||
}) | ||
.catch(error => { | ||
throw new Error( | ||
`Unable to fetch OpenAPI descriptor: ${error.message || '(unknown reason)'}`); | ||
}); | ||
} | ||
|
||
export default makePensieveClient; | ||
export default makeApiClient; |
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
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