All secrets handled as dynamic secrets now

pull/273/head
Frostebite 2021-06-06 21:36:31 +01:00
parent 587ccb4493
commit 017b95a445
3 changed files with 44 additions and 17 deletions

27
dist/index.js vendored
View File

@ -769,6 +769,26 @@ class Kubernetes {
EnvironmentVariable: 'GITHUB_TOKEN', EnvironmentVariable: 'GITHUB_TOKEN',
ParameterValue: this.buildParameters.githubToken, ParameterValue: this.buildParameters.githubToken,
}, },
{
ParameterKey: 'UNITY_LICENSE',
EnvironmentVariable: 'UNITY_LICENSE',
ParameterValue: process.env.UNITY_LICENSE || '',
},
{
ParameterKey: 'ANDROID_KEYSTORE_BASE64',
EnvironmentVariable: 'ANDROID_KEYSTORE_BASE64',
ParameterValue: this.buildParameters.androidKeystoreBase64,
},
{
ParameterKey: 'ANDROID_KEYSTORE_PASS',
EnvironmentVariable: 'ANDROID_KEYSTORE_PASS',
ParameterValue: this.buildParameters.androidKeystorePass,
},
{
ParameterKey: 'ANDROID_KEYALIAS_PASS',
EnvironmentVariable: 'ANDROID_KEYALIAS_PASS',
ParameterValue: this.buildParameters.androidKeyaliasPass,
},
]; ];
try { try {
// setup // setup
@ -794,12 +814,7 @@ class Kubernetes {
secret.metadata = { secret.metadata = {
name: this.secretName, name: this.secretName,
}; };
secret.data = { secret.data = {};
UNITY_LICENSE: base64.encode(process.env.UNITY_LICENSE),
ANDROID_KEYSTORE_BASE64: base64.encode(this.buildParameters.androidKeystoreBase64),
ANDROID_KEYSTORE_PASS: base64.encode(this.buildParameters.androidKeystorePass),
ANDROID_KEYALIAS_PASS: base64.encode(this.buildParameters.androidKeyaliasPass),
};
for (const buildSecret of secrets) { for (const buildSecret of secrets) {
secret.data[buildSecret.EnvironmentVariable] = base64.encode(buildSecret.ParameterValue); secret.data[buildSecret.EnvironmentVariable] = base64.encode(buildSecret.ParameterValue);
secret.data[`${buildSecret.EnvironmentVariable}_NAME`] = base64.encode(buildSecret.ParameterKey); secret.data[`${buildSecret.EnvironmentVariable}_NAME`] = base64.encode(buildSecret.ParameterKey);

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -50,12 +50,32 @@ class Kubernetes implements RemoteBuilderProviderInterface {
async run() { async run() {
core.info('Running Remote Builder on Kubernetes'); core.info('Running Remote Builder on Kubernetes');
const defaultSecretsArray = [ const defaultSecretsArray: RemoteBuilderSecret[] = [
{ {
ParameterKey: 'GithubToken', ParameterKey: 'GithubToken',
EnvironmentVariable: 'GITHUB_TOKEN', EnvironmentVariable: 'GITHUB_TOKEN',
ParameterValue: this.buildParameters.githubToken, ParameterValue: this.buildParameters.githubToken,
}, },
{
ParameterKey: 'UNITY_LICENSE',
EnvironmentVariable: 'UNITY_LICENSE',
ParameterValue: process.env.UNITY_LICENSE || '',
},
{
ParameterKey: 'ANDROID_KEYSTORE_BASE64',
EnvironmentVariable: 'ANDROID_KEYSTORE_BASE64',
ParameterValue: this.buildParameters.androidKeystoreBase64,
},
{
ParameterKey: 'ANDROID_KEYSTORE_PASS',
EnvironmentVariable: 'ANDROID_KEYSTORE_PASS',
ParameterValue: this.buildParameters.androidKeystorePass,
},
{
ParameterKey: 'ANDROID_KEYALIAS_PASS',
EnvironmentVariable: 'ANDROID_KEYALIAS_PASS',
ParameterValue: this.buildParameters.androidKeyaliasPass,
},
]; ];
try { try {
// setup // setup
@ -80,19 +100,11 @@ class Kubernetes implements RemoteBuilderProviderInterface {
secret.metadata = { secret.metadata = {
name: this.secretName, name: this.secretName,
}; };
secret.data = {};
secret.data = {
UNITY_LICENSE: base64.encode(process.env.UNITY_LICENSE),
ANDROID_KEYSTORE_BASE64: base64.encode(this.buildParameters.androidKeystoreBase64),
ANDROID_KEYSTORE_PASS: base64.encode(this.buildParameters.androidKeystorePass),
ANDROID_KEYALIAS_PASS: base64.encode(this.buildParameters.androidKeyaliasPass),
};
for (const buildSecret of secrets) { for (const buildSecret of secrets) {
secret.data[buildSecret.EnvironmentVariable] = base64.encode(buildSecret.ParameterValue); secret.data[buildSecret.EnvironmentVariable] = base64.encode(buildSecret.ParameterValue);
secret.data[`${buildSecret.EnvironmentVariable}_NAME`] = base64.encode(buildSecret.ParameterKey); secret.data[`${buildSecret.EnvironmentVariable}_NAME`] = base64.encode(buildSecret.ParameterKey);
} }
try { try {
await this.kubeClient.createNamespacedSecret(this.namespace, secret); await this.kubeClient.createNamespacedSecret(this.namespace, secret);
} catch (error) { } catch (error) {