Skip to content

Commit a5b7960

Browse files
feat: new v2 git get endpoint
1 parent 2abe381 commit a5b7960

5 files changed

Lines changed: 73 additions & 2 deletions

File tree

src/api/v2/git.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ import { OpenApiRequestExt } from 'src/otomi-models'
55

66
const debug = Debug('otomi:api:v2:git')
77

8+
/**
9+
* GET /v2/git
10+
* Returns the configured external Git settings.
11+
*/
12+
export const getGitSettings = async (req: OpenApiRequestExt, res: Response): Promise<void> => {
13+
debug('getGitSettings')
14+
15+
const gitSettings = await req.otomi.getGitSettings()
16+
17+
res.json(gitSettings)
18+
}
19+
820
/**
921
* PUT /v2/git
1022
* Migrate the values repository to a new git remote.

src/openapi/api.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2032,6 +2032,31 @@ paths:
20322032
description: Successfully edited app values.
20332033

20342034
/v2/git:
2035+
get:
2036+
operationId: getGitSettings
2037+
x-eov-operation-handler: v2/git
2038+
summary: Get Git settings
2039+
description: Get the current Git configuration.
2040+
x-aclSchema: AplGit
2041+
responses:
2042+
'200':
2043+
description: Current Git settings
2044+
content:
2045+
application/json:
2046+
schema:
2047+
$ref: '#/components/schemas/AplGit'
2048+
'401':
2049+
description: Unauthorized
2050+
'403':
2051+
$ref: '#/components/responses/Forbidden'
2052+
'500':
2053+
description: Internal Server Error
2054+
'503':
2055+
description: Service Unavailable (API locked or not ready)
2056+
content:
2057+
application/json:
2058+
schema:
2059+
$ref: '#/components/schemas/OtomiStackError'
20352060
put:
20362061
operationId: migrateGit
20372062
x-eov-operation-handler: v2/git

src/openapi/git.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ AplGit:
22
x-acl:
33
platformAdmin:
44
- update-any
5-
teamAdmin: []
6-
teamMember: []
5+
teamAdmin:
6+
- read-any
7+
teamMember:
8+
- read-any
79
type: object
810
additionalProperties: false
911
properties:

src/openapi/settingsinfo.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ SettingsInfo:
5959
branch:
6060
type: string
6161
description: The branch to use in the Git repository.
62+
username:
63+
type: string
64+
description: The username used to authenticate with the Git repository.
65+
password:
66+
type: string
67+
description: The password or personal access token used to authenticate with the Git repository.
68+
email:
69+
type: string
70+
description: The email address used for Git commit author information.
71+
format: email
6272
ingressClassNames:
6373
description: Ingress class names that are used by the cluster.
6474
items:

src/otomi-stack.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,9 @@ export default class OtomiStack {
372372
'aiEnabled',
373373
'git.repoUrl',
374374
'git.branch',
375+
'git.username',
376+
'git.password',
377+
'git.email',
375378
])
376379
if (otomiInfo.git?.repoUrl?.includes('gitea-http.gitea.svc.cluster.local')) {
377380
otomiInfo.git.repoUrl = `https://gitea.${settings.cluster?.domainSuffix}/otomi/values`
@@ -660,6 +663,25 @@ export default class OtomiStack {
660663
await this.commitAndPushMigration({ ...params, filePath, aplObject, sealedSecretRecord })
661664
}
662665

666+
async getGitSettings(): Promise<{
667+
repoUrl?: string
668+
branch?: string
669+
username?: string
670+
password?: string
671+
email?: string
672+
}> {
673+
const settingsInfo = await this.getSettingsInfo()
674+
const git = settingsInfo.otomi?.git
675+
676+
return {
677+
repoUrl: git?.repoUrl,
678+
branch: git?.branch,
679+
username: git?.username,
680+
password: git?.password,
681+
email: git?.email,
682+
}
683+
}
684+
663685
private async persistOtomiSettings(
664686
updatedOtomi: Record<string, any>,
665687
): Promise<{ filePath: string; aplObject: AplObject }> {

0 commit comments

Comments
 (0)