@@ -2,12 +2,11 @@ import $RefParser, { JSONSchema } from '@apidevtools/json-schema-ref-parser'
22import cleanDeep , { CleanOptions } from 'clean-deep'
33import { createHash } from 'crypto'
44import fs , { existsSync , readFileSync } from 'fs'
5- import { readdir , readFile , writeFile } from 'fs/promises'
5+ import { readdir , readFile } from 'fs/promises'
66import { glob } from 'glob'
77import walk from 'ignore-walk'
88import { dump , load } from 'js-yaml'
99import { omit } from 'lodash'
10- import * as pathModule from 'path'
1110import { dirname , join , resolve } from 'path'
1211import { $ , ProcessOutput , within } from 'zx'
1312import { operatorEnv } from '../operator/validators'
@@ -207,25 +206,14 @@ export const getSchemaSecretsPaths = async (teams: string[]): Promise<string[]>
207206 return cleanSecretPaths
208207}
209208
210- async function ensureKeepFile ( keepFilePath : string , deps = { writeFile } ) : Promise < void > {
211- const dirPath = dirname ( keepFilePath )
212- if ( ! existsSync ( dirPath ) ) {
213- await $ `mkdir -p ${ dirname ( keepFilePath ) } `
214- }
215- if ( existsSync ( keepFilePath ) ) return
216- // create the .keep file
217- await deps . writeFile ( keepFilePath , '' )
218- }
219-
220- export function ensureManifestDirectories ( ) : void {
221- ; [ operatorEnv . GITOPS_MANIFESTS_NS_PATH , operatorEnv . GITOPS_MANIFESTS_GLOBAL_PATH ] . forEach ( ( p ) =>
222- ensureDirectoryWithGitkeepAsync ( pathModule . join ( env . ENV_DIR , p ) ) ,
223- )
209+ export async function ensureManifestDirectories ( ) : Promise < void > {
210+ await ensureDirectoryWithGitkeepAsync ( join ( env . ENV_DIR , operatorEnv . GITOPS_MANIFESTS_NS_RELATIVE_DIR_PATH ) )
211+ await ensureDirectoryWithGitkeepAsync ( join ( env . ENV_DIR , operatorEnv . GITOPS_GLOBAL_MANIFESTS_RELATIVE_PATH ) )
224212}
225213
226- async function ensureDirectoryWithGitkeepAsync ( dirPath : string , deps = { fs, path : pathModule } ) {
214+ async function ensureDirectoryWithGitkeepAsync ( dirPath : string , deps = { fs } ) {
227215 await deps . fs . promises . mkdir ( dirPath , { recursive : true } )
228- const gitkeepPath = deps . path . join ( dirPath , '.gitkeep' )
216+ const gitkeepPath = join ( dirPath , '.gitkeep' )
229217
230218 try {
231219 await deps . fs . promises . access ( gitkeepPath )
@@ -234,11 +222,7 @@ async function ensureDirectoryWithGitkeepAsync(dirPath: string, deps = { fs, pat
234222 }
235223}
236224
237- export async function ensureTeamGitOpsDirectories (
238- envDir : string ,
239- values : Record < string , any > ,
240- deps = { fs, path : pathModule , glob } ,
241- ) {
225+ export async function ensureTeamGitOpsDirectories ( envDir : string , values : Record < string , any > , deps = { fs, glob } ) {
242226 const dirs = await deps . glob ( `${ envDir } /env/teams/*` )
243227 const baseGitOpsDirs = [ 'sealedsecrets' , 'workloadValues' ]
244228 const aiGitOpsDirs = [ 'databases' , 'knowledgebases' , 'agents' ]
0 commit comments