-
Notifications
You must be signed in to change notification settings - Fork 820
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: team provider migration (#5733)
* fix: using team provider for secrets
- Loading branch information
1 parent
f3df233
commit d18f795
Showing
31 changed files
with
767 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const SecretFileMode = 0o600; //file permissions for -rw------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { DeploymentSecrets } from '.'; | ||
import _ from 'lodash'; | ||
|
||
export const mergeDeploymentSecrets = (deploymentSecretsModifier: deploymentSecretMerge): DeploymentSecrets => { | ||
const { currentDeploymentSecrets, category, rootStackId, envName, resource, keyName, value } = deploymentSecretsModifier; | ||
const newDeploymentAppSecret = _.find(currentDeploymentSecrets.appSecrets, appSecret => appSecret.rootStackId === rootStackId) || { | ||
rootStackId, | ||
environments: {}, | ||
}; | ||
_.set(newDeploymentAppSecret, ['environments', envName, category, resource, keyName], value); | ||
return { | ||
appSecrets: [...currentDeploymentSecrets.appSecrets.filter(appSecret => appSecret.rootStackId !== rootStackId), newDeploymentAppSecret], | ||
}; | ||
}; | ||
|
||
export const removeFromDeploymentSecrets = (deploymentSecretsModifier: deploymentSecretsRemove): DeploymentSecrets => { | ||
const { currentDeploymentSecrets, category, rootStackId, envName, resource, keyName } = deploymentSecretsModifier; | ||
const secretsByAppId = _.find(currentDeploymentSecrets.appSecrets, secrets => secrets.rootStackId === rootStackId); | ||
if (secretsByAppId) { | ||
recursiveOmit(secretsByAppId.environments, [envName, category, resource, keyName]); | ||
if (Object.keys(secretsByAppId.environments).length === 0) { | ||
currentDeploymentSecrets.appSecrets = currentDeploymentSecrets.appSecrets.filter(r => r.rootStackId !== rootStackId); | ||
} | ||
} | ||
return currentDeploymentSecrets; | ||
}; | ||
const recursiveOmit = (obj: any, path: Array<string>): void => { | ||
if (path.length === 0) return; | ||
const currentKey = path[0]; | ||
if (path.length === 1 && !!obj[currentKey]) { | ||
delete obj[currentKey]; | ||
return; | ||
} | ||
recursiveOmit(obj[currentKey], path.slice(1)); | ||
|
||
if (obj[currentKey] && _.isEmpty(obj[currentKey])) { | ||
delete obj[currentKey]; | ||
} | ||
}; | ||
|
||
type deploymentSecretMerge = deploymentSecretsRemove & { value: string }; | ||
|
||
type deploymentSecretsRemove = { | ||
currentDeploymentSecrets: DeploymentSecrets; | ||
category: string; | ||
rootStackId: string; | ||
envName: string; | ||
resource: string; | ||
keyName: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.