Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions src/api/v1/createWorkloadCatalog.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/middleware/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { OpenApiRequestExt } from 'src/otomi-models'
import { default as OtomiStack, rootPath } from 'src/otomi-stack'
import { API_NAMESPACE, cleanEnv, EDITOR_INACTIVITY_TIMEOUT } from 'src/validators'
import { v4 as uuidv4 } from 'uuid'
import { getSanitizedErrorMessage } from '../utils'
import { setApiStatusInConfigMap } from '../k8s-operations'
import { getSanitizedErrorMessage } from '../utils'

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

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

// Block all write operations when the API is locked (git migration completed)
if (readOnlyStack?.locked) throw new ApiLockedError()
Expand Down
24 changes: 0 additions & 24 deletions src/openapi/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2358,30 +2358,6 @@ paths:
type: object
error:
type: string
'/v1/createWorkloadCatalog':
post:
operationId: createWorkloadCatalog
x-eov-operation-handler: v1/createWorkloadCatalog
x-aclSchema: Workload
description: Create workload catalog from a repository
requestBody:
content:
application/json:
schema:
type: object
description: Workload catalog object that contains updated values
required: true
responses:
'400':
$ref: '#/components/responses/BadRequest'
'404':
$ref: '#/components/responses/NotFound'
'200':
description: Successfully updated a team workload catalog
content:
application/json:
schema:
type: object

'/v1/teams/{teamId}/workloads':
parameters:
Expand Down
46 changes: 4 additions & 42 deletions src/otomi-stack.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CoreV1Api, KubeConfig, User as k8sUser, V1ObjectReference } from '@kubernetes/client-node'
import { CoreV1Api, User as k8sUser, KubeConfig, V1ObjectReference } from '@kubernetes/client-node'
import Debug from 'debug'

import { getRegions, ObjectStorageKeyRegions, Region, ResourcePage } from '@linode/api-v4'
Expand Down Expand Up @@ -99,6 +99,8 @@ import {
EDITOR_INACTIVITY_TIMEOUT,
GIT_BRANCH,
GIT_EMAIL,
GIT_INIT_MAX_RETRIES,
GIT_INIT_RETRY_INTERVAL_MS,
GIT_LOCAL_PATH,
GIT_PASSWORD,
GIT_REPO_URL,
Expand All @@ -111,8 +113,6 @@ import {
PREINSTALLED_EXCLUDED_APPS,
TOOLS_HOST,
VERSIONS,
GIT_INIT_MAX_RETRIES,
GIT_INIT_RETRY_INTERVAL_MS,
} from 'src/validators'
import { v4 as uuidv4 } from 'uuid'
import { parse as parseYaml, stringify as stringifyYaml } from 'yaml'
Expand Down Expand Up @@ -163,14 +163,7 @@ import {
userSecretDataToUser,
} from './utils/userUtils'
import { defineClusterId, ObjectStorageClient } from './utils/wizardUtils'
import {
fetchChartYaml,
fetchWorkloadCatalog,
isInteralGiteaURL,
NewHelmChartValues,
sparseCloneChart,
validateGitUrl,
} from './utils/workloadUtils'
import { fetchChartYaml, fetchWorkloadCatalog, isInteralGiteaURL, validateGitUrl } from './utils/workloadUtils'

interface ExcludedApp extends App {
managed: boolean
Expand Down Expand Up @@ -2015,37 +2008,6 @@ export default class OtomiStack {
return await fetchChartYaml(url)
}

async createWorkloadCatalog(body: NewHelmChartValues): Promise<boolean> {
const { gitRepositoryUrl, chartTargetDirName, chartIcon, allowTeams } = body

const uuid = uuidv4()
const localHelmChartsDir = `/tmp/otomi/charts/${uuid}`
const helmChartCatalogUrl = env.HELM_CHART_CATALOG
const { user, email } = this.git
const { cluster } = await this.getSettings(['cluster'])

try {
await sparseCloneChart(
gitRepositoryUrl,
localHelmChartsDir,
helmChartCatalogUrl,
user,
email,
chartTargetDirName,
chartIcon,
allowTeams,
cluster?.domainSuffix,
)
return true
} catch (error) {
debug('Error adding new Helm chart to catalog')
return false
} finally {
// Clean up: if the temporary directory exists, remove it.
if (existsSync(localHelmChartsDir)) rmSync(localHelmChartsDir, { recursive: true, force: true })
}
}

getTeamWorkloads(teamId: string): Workload[] {
return this.getTeamAplWorkloads(teamId).map(
(workload) => omit(getV1ObjectFromApl(workload), ['values']) as Workload,
Expand Down
Loading