Skip to content

Commit

Permalink
fix(license-release): Allow empty arrays for never-release users, cus…
Browse files Browse the repository at this point in the history
…tom properties etc

Fixes #1287
  • Loading branch information
Göran Sander committed Oct 24, 2024
1 parent 71f5230 commit 03ac212
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,7 @@ src/config/butler-config.yaml
src/udp_client/udp-client.exe
src/config/production_empty_arrays.yaml
src/config/production_template_filledin.yaml
build.cjs
butler
sea-config.json
sea-prep.blob
1 change: 1 addition & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"program": "${workspaceFolder}/src/butler.js",
// "runtimeVersion": "20",
"runtimeVersion": "18",
// "runtimeVersion": "23",
"cwd": "${workspaceFolder}/src",
"env": {
"NODE_CONFIG_DIR": "${workspaceFolder}/src/config",
Expand Down
1 change: 0 additions & 1 deletion src/butler.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import/first */
// Add dependencies
import dgram from 'dgram';

Expand Down
5 changes: 3 additions & 2 deletions src/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class Settings {
program.parse(process.argv);
this.options = program.opts();

// Utility functions
this.checkFileExistsSync = Settings.checkFileExistsSync;
this.sleep = Settings.sleep;

Expand Down Expand Up @@ -274,7 +275,7 @@ class Settings {
this.logger.debug('CONFIG: API doc mode=off');
// Deep copy of headers object
const httpHeadersEngine = JSON.parse(JSON.stringify(this.config.get('Butler.configEngine.headers')));

// Engine config
this.configEngine = {
engineVersion: this.config.get('Butler.configEngine.engineVersion'),
Expand All @@ -289,7 +290,7 @@ class Settings {

// Deep copy of headers object
const httpHeadersQRS = JSON.parse(JSON.stringify(this.config.get('Butler.configQRS.headers')));

// QRS config
this.configQRS = {
authentication: this.config.get('Butler.configQRS.authentication'),
Expand Down
21 changes: 11 additions & 10 deletions src/lib/qseow/qliksense_license.js
Original file line number Diff line number Diff line change
Expand Up @@ -616,21 +616,22 @@ async function licenseReleaseAnalyzer(config, logger, qrsInstance) {
let doNotRelease = false;
let doNotReleaseReason = '';

// Check do-not-release user names
// eslint-disable-next-line no-restricted-syntax
for (const user of neverReleaseUsers) {
if (license.user.userDirectory === user.userDir && license.user.userId === user.userId) {
doNotRelease = true;
doNotReleaseReason = 'User is in the neverRelease.user list';
break;
// Check do-not-release user names if there are any
if (neverReleaseUsers?.length > 0) {
for (const user of neverReleaseUsers) {
if (license.user.userDirectory === user.userDir && license.user.userId === user.userId) {
doNotRelease = true;
doNotReleaseReason = 'User is in the neverRelease.user list';
break;
}
}
}

// Check do-not-release tags
// If...
// - the user is not already marked as doNotRelease=true and
// - the currentUser does not haven any neverReleaseTags set
if (!doNotRelease) {
if (!doNotRelease && currentUser.tags?.length > 0) {
// Check if the user has any of the neverReleaseTags set
// currentUser.tags is an array of tag objects. Each object has properties id and name
// eslint-disable-next-line no-restricted-syntax
Expand All @@ -653,7 +654,7 @@ async function licenseReleaseAnalyzer(config, logger, qrsInstance) {
// If...
// - the user is not already marked as doNotRelease=true and
// - the currentUser does not have any neverReleaseCustomProperties set
if (!doNotRelease) {
if (!doNotRelease && currentUser.customProperties?.length > 0) {
// currentUser.customProperties is an array of custom property objects.
// Each object looks like this:
// {
Expand Down Expand Up @@ -688,7 +689,7 @@ async function licenseReleaseAnalyzer(config, logger, qrsInstance) {
// If...
// - the user is not already marked as doNotRelease=true and
// - the currentUser does not have any neverReleaseUserDirectories set
if (!doNotRelease) {
if (!doNotRelease && neverReleaseUserDirectories?.length > 0) {
// eslint-disable-next-line no-restricted-syntax
for (const neverReleaseUserDir of neverReleaseUserDirectories) {
if (license.user.userDirectory === neverReleaseUserDir) {
Expand Down

0 comments on commit 03ac212

Please sign in to comment.