Skip to content

Commit 2d33b75

Browse files
committed
feat: use new sealedsecrets
1 parent d383a7f commit 2d33b75

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

src/git.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -382,10 +382,6 @@ export class Git {
382382
return this.git.revparse('HEAD')
383383
}
384384

385-
async commitAndEncrypt(editor: string): Promise<void> {
386-
await this.commit(editor)
387-
}
388-
389385
async pushWithRetry(): Promise<void> {
390386
try {
391387
const retries = env.GIT_PUSH_RETRIES
@@ -417,7 +413,7 @@ export class Git {
417413
async save(editor: string): Promise<void> {
418414
// we are in a unique developer branch, so we can pull, push, and merge
419415
// with the remote root, which might have been modified by another developer
420-
await this.commitAndEncrypt(editor)
416+
await this.commit(editor)
421417
await this.pushWithRetry()
422418
}
423419
}

src/otomi-stack.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -708,8 +708,17 @@ export default class OtomiStack {
708708
}): Promise<void> {
709709
const { otomi } = await this.getSettings()
710710
const updatedOtomi = buildUpdatedOtomiSettings(otomi, params)
711+
712+
// Encrypt the password into the otomi-secrets SealedSecret and strip it from the settings YAML
713+
const sealedSecretRecord = await this.extractAndStoreSettingsSecrets('otomi', { otomi: updatedOtomi })
714+
const valuesSchema = await getValuesSchema()
715+
const subSchema = valuesSchema.properties?.otomi
716+
if (subSchema) {
717+
removeSettingsSecrets(extractSecretPaths(subSchema), updatedOtomi)
718+
}
719+
711720
const { filePath, aplObject } = await this.persistOtomiSettings(updatedOtomi)
712-
await this.commitAndPushMigration({ ...params, filePath, aplObject })
721+
await this.commitAndPushMigration({ ...params, filePath, aplObject, sealedSecretRecord })
713722
}
714723

715724
private async persistOtomiSettings(
@@ -730,11 +739,12 @@ export default class OtomiStack {
730739
remoteHasContent: boolean
731740
filePath: string
732741
aplObject: AplObject
742+
sealedSecretRecord?: AplRecord
733743
}): Promise<void> {
734-
const { repoUrl, branch, password, username, remoteHasContent, filePath, aplObject } = params
744+
const { repoUrl, branch, password, username, remoteHasContent, filePath, aplObject, sealedSecretRecord } = params
735745
const rootStack = await getSessionStack()
736746
try {
737-
await this.git.commitAndEncrypt(this.editor!)
747+
await this.git.commit(this.editor!)
738748
if (!remoteHasContent) {
739749
// Remote is empty: push so the new remote has the config pointing to itself
740750
await this.git.pushToNewRemote(repoUrl, branch, password, username)
@@ -743,6 +753,9 @@ export default class OtomiStack {
743753
await this.git.pushWithRetry()
744754
await rootStack.git.git.pull()
745755
rootStack.fileStore.set(filePath, aplObject)
756+
if (sealedSecretRecord) {
757+
rootStack.fileStore.set(sealedSecretRecord.filePath, sealedSecretRecord.content)
758+
}
746759
debug(`Updated root stack values with ${this.sessionId} migration changes`)
747760
} catch (e) {
748761
e.message = getSanitizedErrorMessage(e)

0 commit comments

Comments
 (0)