Skip to content

Commit

Permalink
feat: Add environment variables linked to all commands' options
Browse files Browse the repository at this point in the history
Implements #568
  • Loading branch information
mountaindude committed Nov 29, 2024
1 parent 49a49c3 commit e3e969b
Show file tree
Hide file tree
Showing 22 changed files with 1,537 additions and 610 deletions.
16 changes: 11 additions & 5 deletions src/lib/cli/qscloud-test-connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@ export function setupQscloudTestConnectionCommand(qsCloud) {
}
})
.addOption(
new Option('--log-level <level>', 'log level').choices(['error', 'warn', 'info', 'verbose', 'debug', 'silly']).default('info')
new Option('--log-level <level>', 'log level')
.choices(['error', 'warn', 'info', 'verbose', 'debug', 'silly'])
.default('info')
.env('CTRLQ_LOG_LEVEL')
)

.requiredOption('--tenant-host <host>', 'Host of Qlik Sense cloud tenant. Example: "tenant.eu.qlikcloud.com"')
.addOption(new Option('-a, --auth-type <type>', 'authentication type').choices(['apikey']).default('apikey'))
.requiredOption('--apikey <key>', 'API key used to access the Sense APIs');
.addOption(
new Option('--tenant-host <host>', 'Host of Qlik Sense cloud tenant. Example: "tenant.eu.qlikcloud.com"')
.makeOptionMandatory()
.env('CTRLQ_TENANT_HOST')
)
.addOption(new Option('-a, --auth-type <type>', 'authentication type').choices(['apikey']).default('apikey').env('CTRLQ_AUTH_TYPE'))
.addOption(new Option('--apikey <key>', 'API key used to access the Sense APIs').makeOptionMandatory().env('CTRLQ_API_KEY'));
}
136 changes: 94 additions & 42 deletions src/lib/cli/qseow-cp-user-activity-bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,60 +34,112 @@ export function setupQseowUserActivityCustomPropertyCommand(qseow) {
}
})
.addOption(
new Option('--log-level <level>', 'log level').choices(['error', 'warn', 'info', 'verbose', 'debug', 'silly']).default('info')
)
.requiredOption('--host <host>', 'Qlik Sense server IP/FQDN')
.option('--port <port>', 'Qlik Sense repository API port', '4242')
.requiredOption('--virtual-proxy <prefix>', 'Qlik Sense virtual proxy prefix', '')
.requiredOption(
'--secure <true|false>',
'https connection to Qlik Sense must use correct certificate. Invalid certificates will result in rejected/failed connection.',
true
)
.option('--auth-user-dir <directory>', 'user directory for user to connect with', 'Internal')
.option('--auth-user-id <userid>', 'user ID for user to connect with', 'sa_repository')

.addOption(new Option('-a, --auth-type <type>', 'authentication type').choices(['cert', 'jwt']).default('cert'))
.option('--auth-cert-file <file>', 'Qlik Sense certificate file (exported from QMC)', './cert/client.pem')
.option('--auth-cert-key-file <file>', 'Qlik Sense certificate key file (exported from QMC)', './cert/client_key.pem')
.option('--auth-root-cert-file <file>', 'Qlik Sense root certificate file (exported from QMC)', './cert/root.pem')
.option('--jwt <JWT>', 'JSON Web Token (JWT) to use for authenticating with Qlik Sense', '')

.option('--user-directory <name...>', 'name of user directories whose users will be updated with activity info', '')
new Option('--log-level <level>', 'log level')
.choices(['error', 'warn', 'info', 'verbose', 'debug', 'silly'])
.default('info')
.env('CTRLQ_LOG_LEVEL')
)
.addOption(new Option('--host <host>', 'Qlik Sense server IP/FQDN').makeOptionMandatory().env('CTRLQ_HOST'))
.addOption(new Option('--port <port>', 'Qlik Sense repository API port').default('4242').env('CTRLQ_PORT'))
.addOption(
new Option('--virtual-proxy <prefix>', 'Qlik Sense virtual proxy prefix')
.makeOptionMandatory()
.default('')
.env('CTRLQ_VIRTUAL_PROXY')
)
.addOption(
new Option(
'--secure <true|false>',
'https connection to Qlik Sense must use correct certificate. Invalid certificates will result in rejected/failed connection.'
)
.makeOptionMandatory()
.default(true)
.env('CTRLQ_SECURE')
)
.addOption(
new Option('--auth-user-dir <directory>', 'user directory for user to connect with').default('Internal').env('CTRLQ_USER_DIR')
)
.addOption(new Option('--auth-user-id <userid>', 'user ID for user to connect with').default('sa_repository').env('CTRLQ_USER_ID'))
.addOption(
new Option('-a, --auth-type <type>', 'authentication type').choices(['cert', 'jwt']).default('cert').env('CTRLQ_AUTH_TYPE')
)
.addOption(
new Option('--auth-cert-file <file>', 'Qlik Sense certificate file (exported from QMC)')
.default('./cert/client.pem')
.env('CTRLQ_CERT_FILE')
)
.addOption(
new Option('--auth-cert-key-file <file>', 'Qlik Sense certificate key file (exported from QMC)')
.default('./cert/client_key.pem')
.env('CTRLQ_CERT_KEY_FILE')
)
.addOption(
new Option('--auth-root-cert-file <file>', 'Qlik Sense root certificate file (exported from QMC)')
.default('./cert/root.pem')
.env('CTRLQ_ROOT_CERT_FILE')
)
.addOption(new Option('--jwt <JWT>', 'JSON Web Token (JWT) to use for authenticating with Qlik Sense').default('').env('CTRLQ_JWT'))
.addOption(
new Option('--user-directory <name...>', 'name of user directories whose users will be updated with activity info')
.default('')
.env('CTRLQ_USER_DIR')
)
.addOption(
new Option(
'--license-type <name...>',
'license type(s) to consider when calculating user activity. Default is all license types.'
)
.choices(['analyzer', 'analyzer-time', 'login', 'professional', 'user'])
.default(['analyzer', 'analyzer-time', 'login', 'professional', 'user'])
.env('CTRLQ_LICENSE_TYPE')
)

.requiredOption('--custom-property-name <name>', 'name of custom property that will hold user activity buckets')
.addOption(
new Option('--force', 'forcibly overwrite and replace custom property and its values if the custom property already exists')
new Option('--custom-property-name <name>', 'name of custom property that will hold user activity buckets')
.makeOptionMandatory()
.env('CTRLQ_CUSTOM_PROPERTY_NAME')
)
.addOption(
new Option(
'--force',
'forcibly overwrite and replace custom property and its values if the custom property already exists'
).env('CTRLQ_FORCE')
)
.option(
'--activity-buckets <buckets...>',
'custom property values/user activity buckets to be defined. A comma or space separated list of numbers, representing days since last login.',
['1', '7', '14', '30', '90', '180', '365']
.addOption(
new Option(
'--activity-buckets <buckets...>',
'custom property values/user activity buckets to be defined. A comma or space separated list of numbers, representing days since last login.'
)
.default(['1', '7', '14', '30', '90', '180', '365'])
.env('CTRLQ_ACTIVITY_BUCKETS')
)
.option(
'--update-batch-size <number of users>',
'number of users to update in each batch when writing user activity info back into Sense. Valid values are 1-25.',
parseUpdateBatchSize,
25
.addOption(
new Option(
'--update-batch-size <number of users>',
'number of users to update in each batch when writing user activity info back into Sense. Valid values are 1-25.'
)
.argParser(parseUpdateBatchSize)
.default(25)
.env('CTRLQ_UPDATE_BATCH_SIZE')
)
.option(
'--update-batch-sleep <seconds>',
'Wait this long before continuing after each batch of users has been updated in Sense. 0 = no wait.',
3
.addOption(
new Option(
'--update-batch-sleep <seconds>',
'Wait this long before continuing after each batch of users has been updated in Sense. 0 = no wait.'
)
.default(3)
.env('CTRLQ_UPDATE_BATCH_SLEEP')
)
.option(
'--update-user-sleep <milliseconds>',
'Wait this long after updating each user in the Qlik Sense repository. 0 = no wait.',
500
.addOption(
new Option(
'--update-user-sleep <milliseconds>',
'Wait this long after updating each user in the Qlik Sense repository. 0 = no wait.'
)
.default(500)
.env('CTRLQ_UPDATE_USER_SLEEP')
)

.option('--dry-run', 'do a dry run, i.e. do not create or update anything - just show what would be done');
.addOption(
new Option('--dry-run', 'do a dry run, i.e. do not create or update anything - just show what would be done').env(
'CTRLQ_DRY_RUN'
)
);
}
101 changes: 76 additions & 25 deletions src/lib/cli/qseow-delete-master-dimension.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,80 @@ export function setupQseowDeleteMasterDimensionCommand(qseow) {
deleteMasterDimension(options);
})
.addOption(
new Option('--log-level <level>', 'log level').choices(['error', 'warn', 'info', 'verbose', 'debug', 'silly']).default('info')
)
.requiredOption('--host <host>', 'Qlik Sense server IP/FQDN')
.option('--port <port>', 'Qlik Sense server engine port (usually 4747 for cert auth, 443 for jwt auth)', '4747')
.option('--schema-version <string>', 'Qlik Sense engine schema version', '12.612.0')
.requiredOption('--app-id <id>', 'Qlik Sense app ID')
.requiredOption('--virtual-proxy <prefix>', 'Qlik Sense virtual proxy prefix', '')
.requiredOption(
'--secure <true|false>',
'https connection to Qlik Sense must use correct certificate. Invalid certificates will result in rejected/failed connection.',
true
)
.requiredOption('--auth-user-dir <directory>', 'user directory for user to connect with')
.requiredOption('--auth-user-id <userid>', 'user ID for user to connect with')

.addOption(new Option('-a, --auth-type <type>', 'authentication type').choices(['cert', 'jwt']).default('cert'))
.option('--auth-cert-file <file>', 'Qlik Sense certificate file (exported from QMC)', './cert/client.pem')
.option('--auth-cert-key-file <file>', 'Qlik Sense certificate key file (exported from QMC)', './cert/client_key.pem')
.option('--auth-root-cert-file <file>', 'Qlik Sense root certificate file (exported from QMC)', './cert/root.pem')
.option('--auth-jwt <jwt>', 'JSON Web Token (JWT) to use for authentication with Qlik Sense server')

.addOption(new Option('--id-type <type>', 'type of identifier passed in the --master-item option').choices(['id', 'name']))
.option('--master-item <ids...>', 'names or IDs of master dimensions to be deleted. Multiple IDs should be space separated')
.option('--delete-all', 'delete all master dimensions')
.option('--dry-run', 'do a dry run, i.e. do not delete anything - just show what would be deleted');
new Option('--log-level <level>', 'log level')
.choices(['error', 'warn', 'info', 'verbose', 'debug', 'silly'])
.default('info')
.env('CTRLQ_LOG_LEVEL')
)
.addOption(new Option('--host <host>', 'Qlik Sense server IP/FQDN').makeOptionMandatory().env('CTRLQ_HOST'))
.addOption(
new Option('--port <port>', 'Qlik Sense server engine port (usually 4747 for cert auth, 443 for jwt auth)')
.default('4747')
.env('CTRLQ_PORT')
)
.addOption(
new Option('--schema-version <string>', 'Qlik Sense engine schema version').default('12.612.0').env('CTRLQ_SCHEMA_VERSION')
)
.addOption(new Option('--app-id <id>', 'Qlik Sense app ID').makeOptionMandatory().env('CTRLQ_APP_ID'))
.addOption(
new Option('--virtual-proxy <prefix>', 'Qlik Sense virtual proxy prefix')
.makeOptionMandatory()
.default('')
.env('CTRLQ_VIRTUAL_PROXY')
)
.addOption(
new Option(
'--secure <true|false>',
'https connection to Qlik Sense must use correct certificate. Invalid certificates will result in rejected/failed connection.'
)
.makeOptionMandatory()
.default(true)
.env('CTRLQ_SECURE')
)
.addOption(
new Option('--auth-user-dir <directory>', 'user directory for user to connect with')
.makeOptionMandatory()
.env('CTRLQ_AUTH_USER_DIR')
)
.addOption(
new Option('--auth-user-id <userid>', 'user ID for user to connect with').makeOptionMandatory().env('CTRLQ_AUTH_USER_ID')
)
.addOption(
new Option('-a, --auth-type <type>', 'authentication type').choices(['cert', 'jwt']).default('cert').env('CTRLQ_AUTH_TYPE')
)
.addOption(
new Option('--auth-cert-file <file>', 'Qlik Sense certificate file (exported from QMC)')
.default('./cert/client.pem')
.env('CTRLQ_AUTH_CERT_FILE')
)
.addOption(
new Option('--auth-cert-key-file <file>', 'Qlik Sense certificate key file (exported from QMC)')
.default('./cert/client_key.pem')
.env('CTRLQ_AUTH_CERT_KEY_FILE')
)
.addOption(
new Option('--auth-root-cert-file <file>', 'Qlik Sense root certificate file (exported from QMC)')
.default('./cert/root.pem')
.env('CTRLQ_AUTH_ROOT_CERT_FILE')
)
.addOption(
new Option('--auth-jwt <jwt>', 'JSON Web Token (JWT) to use for authentication with Qlik Sense server')
.default('')
.env('CTRLQ_AUTH_JWT')
)
.addOption(
new Option('--id-type <type>', 'type of identifier passed in the --master-item option')
.choices(['id', 'name'])
.env('CTRLQ_ID_TYPE')
)
.addOption(
new Option(
'--master-item <ids...>',
'names or IDs of master dimensions to be deleted. Multiple IDs should be space separated'
).env('CTRLQ_MASTER_ITEM')
)
.addOption(new Option('--delete-all', 'delete all master dimensions').env('CTRLQ_DELETE_ALL'))
.addOption(
new Option('--dry-run', 'do a dry run, i.e. do not delete anything - just show what would be deleted').env('CTRLQ_DRY_RUN')
);
}
Loading

0 comments on commit e3e969b

Please sign in to comment.