argo-cd

Форк
0
/
repo-service.ts 
221 строка · 6.3 Кб
1
import * as models from '../models';
2
import requests from './requests';
3

4
export class RepositoriesService {
5
    public list(): Promise<models.Repository[]> {
6
        return requests
7
            .get(`/repositories`)
8
            .then(res => res.body as models.RepositoryList)
9
            .then(list => list.items || []);
10
    }
11

12
    public listNoCache(): Promise<models.Repository[]> {
13
        return requests
14
            .get(`/repositories?forceRefresh=true`)
15
            .then(res => res.body as models.RepositoryList)
16
            .then(list => list.items || []);
17
    }
18

19
    public createHTTPS({
20
        type,
21
        name,
22
        url,
23
        username,
24
        password,
25
        tlsClientCertData,
26
        tlsClientCertKey,
27
        insecure,
28
        enableLfs,
29
        proxy,
30
        project,
31
        forceHttpBasicAuth,
32
        enableOCI
33
    }: {
34
        type: string;
35
        name: string;
36
        url: string;
37
        username: string;
38
        password: string;
39
        tlsClientCertData: string;
40
        tlsClientCertKey: string;
41
        insecure: boolean;
42
        enableLfs: boolean;
43
        proxy: string;
44
        project?: string;
45
        forceHttpBasicAuth?: boolean;
46
        enableOCI: boolean;
47
    }): Promise<models.Repository> {
48
        return requests
49
            .post('/repositories')
50
            .send({type, name, repo: url, username, password, tlsClientCertData, tlsClientCertKey, insecure, enableLfs, proxy, project, forceHttpBasicAuth, enableOCI})
51
            .then(res => res.body as models.Repository);
52
    }
53

54
    public updateHTTPS({
55
        type,
56
        name,
57
        url,
58
        username,
59
        password,
60
        tlsClientCertData,
61
        tlsClientCertKey,
62
        insecure,
63
        enableLfs,
64
        proxy,
65
        project,
66
        forceHttpBasicAuth,
67
        enableOCI
68
    }: {
69
        type: string;
70
        name: string;
71
        url: string;
72
        username: string;
73
        password: string;
74
        tlsClientCertData: string;
75
        tlsClientCertKey: string;
76
        insecure: boolean;
77
        enableLfs: boolean;
78
        proxy: string;
79
        project?: string;
80
        forceHttpBasicAuth?: boolean;
81
        enableOCI: boolean;
82
    }): Promise<models.Repository> {
83
        return requests
84
            .put(`/repositories/${encodeURIComponent(url)}`)
85
            .send({type, name, repo: url, username, password, tlsClientCertData, tlsClientCertKey, insecure, enableLfs, proxy, project, forceHttpBasicAuth, enableOCI})
86
            .then(res => res.body as models.Repository);
87
    }
88

89
    public createSSH({
90
        type,
91
        name,
92
        url,
93
        sshPrivateKey,
94
        insecure,
95
        enableLfs,
96
        proxy,
97
        project
98
    }: {
99
        type: string;
100
        name: string;
101
        url: string;
102
        sshPrivateKey: string;
103
        insecure: boolean;
104
        enableLfs: boolean;
105
        proxy: string;
106
        project?: string;
107
    }): Promise<models.Repository> {
108
        return requests
109
            .post('/repositories')
110
            .send({type, name, repo: url, sshPrivateKey, insecure, enableLfs, proxy, project})
111
            .then(res => res.body as models.Repository);
112
    }
113

114
    public createGitHubApp({
115
        type,
116
        name,
117
        url,
118
        githubAppPrivateKey,
119
        githubAppId,
120
        githubAppInstallationId,
121
        githubAppEnterpriseBaseURL,
122
        tlsClientCertData,
123
        tlsClientCertKey,
124
        insecure,
125
        enableLfs,
126
        proxy,
127
        project
128
    }: {
129
        type: string;
130
        name: string;
131
        url: string;
132
        githubAppPrivateKey: string;
133
        githubAppId: bigint;
134
        githubAppInstallationId: bigint;
135
        githubAppEnterpriseBaseURL: string;
136
        tlsClientCertData: string;
137
        tlsClientCertKey: string;
138
        insecure: boolean;
139
        enableLfs: boolean;
140
        proxy: string;
141
        project?: string;
142
    }): Promise<models.Repository> {
143
        return requests
144
            .post('/repositories')
145
            .send({
146
                type,
147
                name,
148
                repo: url,
149
                githubAppPrivateKey,
150
                githubAppId,
151
                githubAppInstallationId,
152
                githubAppEnterpriseBaseURL,
153
                tlsClientCertData,
154
                tlsClientCertKey,
155
                insecure,
156
                enableLfs,
157
                proxy,
158
                project
159
            })
160
            .then(res => res.body as models.Repository);
161
    }
162

163
    public createGoogleCloudSource({
164
        type,
165
        name,
166
        url,
167
        gcpServiceAccountKey,
168
        proxy,
169
        project
170
    }: {
171
        type: string;
172
        name: string;
173
        url: string;
174
        gcpServiceAccountKey: string;
175
        proxy: string;
176
        project?: string;
177
    }): Promise<models.Repository> {
178
        return requests
179
            .post('/repositories')
180
            .send({
181
                type,
182
                name,
183
                repo: url,
184
                gcpServiceAccountKey,
185
                proxy,
186
                project
187
            })
188
            .then(res => res.body as models.Repository);
189
    }
190

191
    public delete(url: string): Promise<models.Repository> {
192
        return requests
193
            .delete(`/repositories/${encodeURIComponent(url)}`)
194
            .send()
195
            .then(res => res.body as models.Repository);
196
    }
197

198
    public async revisions(repo: string): Promise<models.RefsInfo> {
199
        return requests.get(`/repositories/${encodeURIComponent(repo)}/refs`).then(res => res.body as models.RefsInfo);
200
    }
201

202
    public apps(repo: string, revision: string, appName: string, appProject: string): Promise<models.AppInfo[]> {
203
        return requests
204
            .get(`/repositories/${encodeURIComponent(repo)}/apps`)
205
            .query({revision})
206
            .query({appName})
207
            .query({appProject})
208
            .then(res => (res.body.items as models.AppInfo[]) || []);
209
    }
210

211
    public charts(repo: string): Promise<models.HelmChart[]> {
212
        return requests.get(`/repositories/${encodeURIComponent(repo)}/helmcharts`).then(res => (res.body.items as models.HelmChart[]) || []);
213
    }
214

215
    public appDetails(source: models.ApplicationSource, appName: string, appProject: string): Promise<models.RepoAppDetails> {
216
        return requests
217
            .post(`/repositories/${encodeURIComponent(source.repoURL)}/appdetails`)
218
            .send({source, appName, appProject})
219
            .then(res => res.body as models.RepoAppDetails);
220
    }
221
}
222

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.