Skip to content

Commit

Permalink
re-use license-file and config-values inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig O'Donnell committed Feb 27, 2024
1 parent 623d3e4 commit 332e629
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 29 deletions.
12 changes: 3 additions & 9 deletions kots-install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,10 @@ inputs:
description: 'Shared password to use when deploying the admin console. If not specified, a random password is generated.'
required: false
license-file:
description: 'A license.yaml to use. This should be the contents of the license file, not the path to the file. If not specified, a license-file-path must be provided.'
required: false
license-file-path:
description: 'The path to the license file to use.'
required: false
description: 'A license.yaml to use. This can be a path to a file or the contents of the file.'
required: true
config-values:
description: 'The config values to use. This should be the contents of the config values file, not the path to the file.'
required: false
config-values-path:
description: 'The path to the config values file to use.'
description: 'The config values to use. This can be a path to a file or the contents of the file.'
required: false
namespace:
description: 'The namespace to install the application to'
Expand Down
34 changes: 14 additions & 20 deletions kots-install/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,26 @@ import * as fs from 'fs';

async function run() {

const licenseFileInput = core.getInput('license-file')
let licenseFilePath = '';
if (core.getInput('license-file')) {
// Write the license
if (fs.existsSync(licenseFileInput)) {
licenseFilePath = licenseFileInput;
} else {
const {path: licensePath} = await file({postfix: '.yaml'});
fs.writeFileSync(licensePath, core.getInput('license-file'));
fs.writeFileSync(licensePath, licenseFileInput);
licenseFilePath = licensePath;
} else {
// Fall back to the license file path
licenseFilePath = core.getInput('license-file-path');
}

// License file is required for an automated install
if (!licenseFilePath) {
core.setFailed('No license file provided. Please provide a license-file or a license-file-path.');
return;
}

const configValuesInput = core.getInput('config-values')
let valuesFilePath = '';
if (core.getInput('config-values')) {
// Write the values if any
const {path: valuesPath} = await file({postfix: '.yaml'});
fs.writeFileSync(valuesPath, core.getInput('config-values'));
valuesFilePath = valuesPath;
} else {
// Fall back to the values file path
valuesFilePath = core.getInput('config-values-path');
if (configValuesInput) {
if (fs.existsSync(configValuesInput)) {
valuesFilePath = configValuesInput;
} else {
const {path: valuesPath} = await file({postfix: '.yaml'});
fs.writeFileSync(valuesPath, core.getInput('config-values'));
valuesFilePath = valuesPath;
}
}


Expand Down

0 comments on commit 332e629

Please sign in to comment.