diff --git a/src/api/v2/git.ts b/src/api/v2/git.ts index 593c7a13..8ac1a873 100644 --- a/src/api/v2/git.ts +++ b/src/api/v2/git.ts @@ -5,6 +5,18 @@ import { OpenApiRequestExt } from 'src/otomi-models' const debug = Debug('otomi:api:v2:git') +/** + * GET /v2/git + * Returns the configured external Git settings. + */ +export const getGitSettings = async (req: OpenApiRequestExt, res: Response): Promise => { + debug('getGitSettings') + + const gitSettings = await req.otomi.getGitSettings() + + res.json(gitSettings) +} + /** * PUT /v2/git * Migrate the values repository to a new git remote. diff --git a/src/openapi/api.yaml b/src/openapi/api.yaml index c5586e9e..055fdda9 100644 --- a/src/openapi/api.yaml +++ b/src/openapi/api.yaml @@ -2032,6 +2032,31 @@ paths: description: Successfully edited app values. /v2/git: + get: + operationId: getGitSettings + x-eov-operation-handler: v2/git + summary: Get Git settings + description: Get the current Git configuration. + x-aclSchema: AplGit + responses: + '200': + description: Current Git settings + content: + application/json: + schema: + $ref: '#/components/schemas/AplGit' + '401': + description: Unauthorized + '403': + $ref: '#/components/responses/Forbidden' + '500': + description: Internal Server Error + '503': + description: Service Unavailable (API locked or not ready) + content: + application/json: + schema: + $ref: '#/components/schemas/OtomiStackError' put: operationId: migrateGit x-eov-operation-handler: v2/git diff --git a/src/openapi/git.yaml b/src/openapi/git.yaml index 11be6674..bf3680dd 100644 --- a/src/openapi/git.yaml +++ b/src/openapi/git.yaml @@ -2,8 +2,10 @@ AplGit: x-acl: platformAdmin: - update-any - teamAdmin: [] - teamMember: [] + teamAdmin: + - read-any + teamMember: + - read-any type: object additionalProperties: false properties: diff --git a/src/openapi/settingsinfo.yaml b/src/openapi/settingsinfo.yaml index 43479813..610e80c7 100644 --- a/src/openapi/settingsinfo.yaml +++ b/src/openapi/settingsinfo.yaml @@ -59,6 +59,16 @@ SettingsInfo: branch: type: string description: The branch to use in the Git repository. + username: + type: string + description: The username used to authenticate with the Git repository. + password: + type: string + description: The password or personal access token used to authenticate with the Git repository. + email: + type: string + description: The email address used for Git commit author information. + format: email ingressClassNames: description: Ingress class names that are used by the cluster. items: diff --git a/src/otomi-stack.ts b/src/otomi-stack.ts index a19627ae..7a24e19c 100644 --- a/src/otomi-stack.ts +++ b/src/otomi-stack.ts @@ -372,6 +372,9 @@ export default class OtomiStack { 'aiEnabled', 'git.repoUrl', 'git.branch', + 'git.username', + 'git.password', + 'git.email', ]) if (otomiInfo.git?.repoUrl?.includes('gitea-http.gitea.svc.cluster.local')) { otomiInfo.git.repoUrl = `https://gitea.${settings.cluster?.domainSuffix}/otomi/values` @@ -660,6 +663,25 @@ export default class OtomiStack { await this.commitAndPushMigration({ ...params, filePath, aplObject, sealedSecretRecord }) } + async getGitSettings(): Promise<{ + repoUrl?: string + branch?: string + username?: string + password?: string + email?: string + }> { + const settingsInfo = await this.getSettingsInfo() + const git = settingsInfo.otomi?.git + + return { + repoUrl: git?.repoUrl, + branch: git?.branch, + username: git?.username, + password: git?.password, + email: git?.email, + } + } + private async persistOtomiSettings( updatedOtomi: Record, ): Promise<{ filePath: string; aplObject: AplObject }> {