@@ -3,7 +3,6 @@ import $RefParser, { JSONSchema } from '@apidevtools/json-schema-ref-parser'
3
3
import express , { Request , Response } from 'express'
4
4
import { Server } from 'http'
5
5
import { bootstrapSops } from 'src/cmd/bootstrap'
6
- import { validateValues } from 'src/cmd/validate-values'
7
6
import { decrypt , encrypt } from 'src/common/crypt'
8
7
import { terminal } from 'src/common/debug'
9
8
import { hfValues } from './common/hf'
@@ -25,12 +24,13 @@ app.get('/', async (req: Request, res: Response): Promise<Response<any>> => {
25
24
26
25
type QueryParams = {
27
26
envDir : string
27
+ files ?: string [ ]
28
28
}
29
29
30
30
app . get ( '/init' , async ( req : Request , res : Response ) => {
31
31
const { envDir } = req . query as QueryParams
32
32
try {
33
- d . log ( 'Request to initialize values repo' )
33
+ d . log ( 'Request to initialize values repo on' , envDir )
34
34
await decrypt ( envDir )
35
35
res . status ( 200 ) . send ( 'ok' )
36
36
} catch ( error ) {
@@ -40,21 +40,20 @@ app.get('/init', async (req: Request, res: Response) => {
40
40
} )
41
41
42
42
app . get ( '/prepare' , async ( req : Request , res : Response ) => {
43
- const { envDir } = req . query as QueryParams
43
+ const { envDir, files } = req . query as QueryParams
44
44
try {
45
- d . log ( 'Request to prepare values repo' )
45
+ d . log ( 'Request to prepare values repo on' , envDir )
46
46
await bootstrapSops ( envDir )
47
47
await setValuesFile ( envDir )
48
48
// Encrypt ensures that a brand new secret file is encrypted in place
49
- await encrypt ( envDir )
49
+ await encrypt ( envDir , ... ( files ?? [ ] ) )
50
50
// Decrypt ensures that a brand new encrypted secret file is decrypted to the .dec file
51
- await decrypt ( envDir )
52
- await validateValues ( envDir )
51
+ await decrypt ( envDir , ...( files ?? [ ] ) )
53
52
res . status ( 200 ) . send ( 'ok' )
54
53
} catch ( error ) {
55
54
const err = `${ error } `
56
55
let status = 500
57
- d . error ( err )
56
+ d . error ( `Request to prepare values went wrong: ${ err } ` )
58
57
if ( err . includes ( 'Values validation FAILED' ) ) {
59
58
status = 422
60
59
}
0 commit comments