1- import { CoreV1Api , KubeConfig , User as k8sUser , V1ObjectReference } from '@kubernetes/client-node'
1+ import { CoreV1Api , User as k8sUser , KubeConfig , V1ObjectReference } from '@kubernetes/client-node'
22import Debug from 'debug'
33
44import { getRegions , ObjectStorageKeyRegions } from '@linode/api-v4'
@@ -17,9 +17,9 @@ import {
1717 PublicUrlExists ,
1818 ValidationError ,
1919} from 'src/error'
20- import getRepo , { getWorktreeRepo , Git } from 'src/git'
21- import { FileStore } from 'src/fileStore/file-store'
2220import { getSettingsFileMaps } from 'src/fileStore/file-map'
21+ import { FileStore } from 'src/fileStore/file-store'
22+ import getRepo , { getWorktreeRepo , Git } from 'src/git'
2323import { cleanSession , getSessionStack } from 'src/middleware'
2424import {
2525 AplAgentRequest ,
@@ -109,6 +109,7 @@ import { v4 as uuidv4 } from 'uuid'
109109import { parse as parseYaml , stringify as stringifyYaml } from 'yaml'
110110import { getAIModels } from './ai/aiModelHandler'
111111import { DatabaseCR } from './ai/DatabaseCR'
112+ import { getResourceFilePath , getSecretFilePath } from './fileStore/file-map'
112113import {
113114 apply ,
114115 checkPodExists ,
@@ -132,7 +133,6 @@ import { getSealedSecretsPEM, sealedSecretManifest } from './utils/sealedSecretU
132133import { getKeycloakUsers , isValidUsername } from './utils/userUtils'
133134import { ObjectStorageClient } from './utils/wizardUtils'
134135import { fetchChartYaml , fetchWorkloadCatalog , NewHelmChartValues , sparseCloneChart } from './utils/workloadUtils'
135- import { getResourceFilePath , getSecretFilePath } from './fileStore/file-map'
136136
137137interface ExcludedApp extends App {
138138 managed : boolean
@@ -616,15 +616,13 @@ export default class OtomiStack {
616616 const orig = this . getApp ( id )
617617 if ( orig && this . canToggleApp ( id ) ) {
618618 const filePath = getResourceFilePath ( 'AplApp' , id )
619- const aplApp = toPlatformObject ( 'AplApp' , id , {
620- ...orig ,
621- enabled,
622- values : { ...orig . values , enabled } ,
623- } )
624- this . fileStore . set ( filePath , aplApp )
625-
626- const app = { ...orig , enabled }
627- await this . saveAdminApp ( app )
619+ const aplApp = this . fileStore . get ( filePath )
620+ if ( ! aplApp ) {
621+ throw new NotExistError ( `App ${ id } not found` )
622+ }
623+ set ( aplApp , 'spec.enabled' , enabled )
624+
625+ await this . saveAppToggle ( aplApp )
628626 return { filePath, content : aplApp } as AplRecord
629627 }
630628 return undefined
@@ -2391,6 +2389,11 @@ export default class OtomiStack {
23912389
23922390 return { filePath, content : aplObject }
23932391 }
2392+ async saveAppToggle ( app : AplObject ) : Promise < void > {
2393+ const globalPaths = getSecretPaths ( )
2394+ const appSecretPaths = this . extractAppSecretPaths ( app . metadata . name , globalPaths )
2395+ await this . saveWithSecrets ( app , appSecretPaths )
2396+ }
23942397
23952398 async saveAdminApp ( app : App , secretPaths ?: string [ ] ) : Promise < void > {
23962399 const { id, enabled, values, rawValues } = app
0 commit comments