Skip to content

Commit 01cab20

Browse files
fix: remove createworkloadcatalog endpoint (#993)
* fix: remove createworkloadcatalog endpoint * fix: removed unnused endpoints * fix: removed unused interface * fix: reverted greedy cleanup --------- Co-authored-by: svcAPLBot <174728082+svcAPLBot@users.noreply.github.com>
1 parent fe80010 commit 01cab20

7 files changed

Lines changed: 113 additions & 697 deletions

File tree

src/api/v1/createWorkloadCatalog.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/api/v1/helmChartContent.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/middleware/session.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { OpenApiRequestExt } from 'src/otomi-models'
99
import { default as OtomiStack, rootPath } from 'src/otomi-stack'
1010
import { API_NAMESPACE, cleanEnv, EDITOR_INACTIVITY_TIMEOUT } from 'src/validators'
1111
import { v4 as uuidv4 } from 'uuid'
12-
import { getSanitizedErrorMessage } from '../utils'
1312
import { setApiStatusInConfigMap } from '../k8s-operations'
13+
import { getSanitizedErrorMessage } from '../utils'
1414

1515
const debug = Debug('otomi:session')
1616
const env = cleanEnv({
@@ -121,7 +121,7 @@ export function sessionMiddleware(server: http.Server): RequestHandler {
121121

122122
if (['post', 'put', 'delete'].includes(req.method.toLowerCase())) {
123123
// in the workloadCatalog endpoint(s), don't need to create a session
124-
if (req.path === '/v1/workloadCatalog' || req.path === '/v1/createWorkloadCatalog') return next()
124+
if (req.path === '/v1/workloadCatalog') return next()
125125

126126
// Block all write operations when the API is locked (git migration completed)
127127
if (readOnlyStack?.locked) throw new ApiLockedError()

src/openapi/api.yaml

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2331,58 +2331,6 @@ paths:
23312331
schema:
23322332
type: object
23332333

2334-
'/v1/helmChartContent':
2335-
get:
2336-
operationId: getHelmChartContent
2337-
x-eov-operation-handler: v1/helmChartContent
2338-
x-aclSchema: Workload
2339-
parameters:
2340-
- name: url
2341-
in: query
2342-
description: URL of the helm chart
2343-
schema:
2344-
type: string
2345-
responses:
2346-
'400':
2347-
$ref: '#/components/responses/BadRequest'
2348-
'404':
2349-
$ref: '#/components/responses/NotFound'
2350-
'200':
2351-
description: Successfully obtained helm chart content
2352-
content:
2353-
application/json:
2354-
schema:
2355-
type: object
2356-
properties:
2357-
values:
2358-
type: object
2359-
error:
2360-
type: string
2361-
'/v1/createWorkloadCatalog':
2362-
post:
2363-
operationId: createWorkloadCatalog
2364-
x-eov-operation-handler: v1/createWorkloadCatalog
2365-
x-aclSchema: Workload
2366-
description: Create workload catalog from a repository
2367-
requestBody:
2368-
content:
2369-
application/json:
2370-
schema:
2371-
type: object
2372-
description: Workload catalog object that contains updated values
2373-
required: true
2374-
responses:
2375-
'400':
2376-
$ref: '#/components/responses/BadRequest'
2377-
'404':
2378-
$ref: '#/components/responses/NotFound'
2379-
'200':
2380-
description: Successfully updated a team workload catalog
2381-
content:
2382-
application/json:
2383-
schema:
2384-
type: object
2385-
23862334
'/v1/teams/{teamId}/workloads':
23872335
parameters:
23882336
- $ref: '#/components/parameters/teamParams'

src/otomi-stack.ts

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CoreV1Api, KubeConfig, User as k8sUser, V1ObjectReference } from '@kubernetes/client-node'
1+
import { CoreV1Api, User as k8sUser, KubeConfig, V1ObjectReference } from '@kubernetes/client-node'
22
import Debug from 'debug'
33

44
import { getRegions, ObjectStorageKeyRegions, Region, ResourcePage } from '@linode/api-v4'
@@ -163,14 +163,7 @@ import {
163163
userSecretDataToUser,
164164
} from './utils/userUtils'
165165
import { defineClusterId, ObjectStorageClient } from './utils/wizardUtils'
166-
import {
167-
fetchChartYaml,
168-
fetchWorkloadCatalog,
169-
isInteralGiteaURL,
170-
NewHelmChartValues,
171-
sparseCloneChart,
172-
validateGitUrl,
173-
} from './utils/workloadUtils'
166+
import { fetchWorkloadCatalog, isInteralGiteaURL, validateGitUrl } from './utils/workloadUtils'
174167

175168
interface ExcludedApp extends App {
176169
managed: boolean
@@ -1952,41 +1945,6 @@ export default class OtomiStack {
19521945
}
19531946
}
19541947

1955-
async getHelmChartContent(url: string): Promise<any> {
1956-
return await fetchChartYaml(url)
1957-
}
1958-
1959-
async createWorkloadCatalog(body: NewHelmChartValues): Promise<boolean> {
1960-
const { gitRepositoryUrl, chartTargetDirName, chartIcon, allowTeams } = body
1961-
1962-
const uuid = uuidv4()
1963-
const localHelmChartsDir = `/tmp/otomi/charts/${uuid}`
1964-
const helmChartCatalogUrl = env.HELM_CHART_CATALOG
1965-
const { user, email } = this.git
1966-
const { cluster } = await this.getSettings(['cluster'])
1967-
1968-
try {
1969-
await sparseCloneChart(
1970-
gitRepositoryUrl,
1971-
localHelmChartsDir,
1972-
helmChartCatalogUrl,
1973-
user,
1974-
email,
1975-
chartTargetDirName,
1976-
chartIcon,
1977-
allowTeams,
1978-
cluster?.domainSuffix,
1979-
)
1980-
return true
1981-
} catch (error) {
1982-
debug('Error adding new Helm chart to catalog')
1983-
return false
1984-
} finally {
1985-
// Clean up: if the temporary directory exists, remove it.
1986-
if (existsSync(localHelmChartsDir)) rmSync(localHelmChartsDir, { recursive: true, force: true })
1987-
}
1988-
}
1989-
19901948
getTeamWorkloads(teamId: string): Workload[] {
19911949
return this.getTeamAplWorkloads(teamId).map(
19921950
(workload) => omit(getV1ObjectFromApl(workload), ['values']) as Workload,

0 commit comments

Comments
 (0)