Skip to content

Commit 1b8dd8e

Browse files
committed
Choco install refinement
1 parent f22a9ec commit 1b8dd8e

4 files changed

Lines changed: 45 additions & 25 deletions

File tree

cmd/openem-ingestor-app/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func main() {
7171
configFileReader := core.NewConfigReader()
7272
var err error
7373
if config, err = configFileReader.ReadConfig(core.DefaultConfigFileName()); err != nil {
74-
slog.Info("Reading config", "file", configFileReader.GetCurrentConfigFilePath())
74+
slog.Error("Reading config failed", "file", configFileReader.GetCurrentConfigFilePath(), "error", err)
7575
panic(fmt.Errorf("failed to read config file: %w", err))
7676
}
7777

configs/openem-ingestor-config-template.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ WebServer:
5151
Scopes:
5252
- email
5353
OIDC:
54-
IssuerURL: "${KEYCLOAK_HOST}/realms/awi"
54+
IssuerURL: "${KEYCLOAK_HOST}/realms/${KEYCLOAK_REALM}"
5555
JWT:
5656
UseJWKS: true
57-
JwksURL: "${KEYCLOAK_HOST}/realms/awi/protocol/openid-connect/certs"
57+
JwksURL: "${KEYCLOAK_HOST}/realms/${KEYCLOAK_REALM}/protocol/openid-connect/certs"
5858
JwksSignatureMethods:
5959
- RS256
6060
RBAC:

openem-ingestor.nuspec

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,22 @@
1212
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1313
<description>
1414
OpenEM Ingestor Package
15-
This package installs the ingestor as a windows network service. The config file is templated using the package parameters and saved
15+
This package installs the openem-ingestor. The config file is templated using the package parameters and saved
1616
at "$Env:ChocolateyInstall\lib\openem-ingestor-config.yaml", i.e. next to the binary. Any changes need to be done there.
17-
The service name "OpenEM-Ingestor" and needs to be stopped before making changes to the config file.
18-
19-
The service depends on https://github.com/mtkennerly/shawl. Install with winget:
20-
21-
`winget install --scope "machine" -e --id mtkennerly.shawl`
22-
23-
The log file can be found in the directory of the shawl executable; using powershell this can be found by `get-command shawl`.
2417

2518
#### Package Parameters
2619
The following package parameters can be set:
2720

21+
* `/Environment:` Deployment environement one of dev, qa, prod - example --params="'/Environment:dev'"
22+
* `/CollectionLocations:` List of collection location name and path - example --params="'/CollectionLocations:storage1:\\\\path\\to\\storage1;storage2:\\\\path\\to\\storage2'"
23+
24+
The parameter environment will set the following values that can be overridden:
25+
2826
* `/Scicat.Host:` - Scicat backend URL - defaults to: "https://dacat.psi.ch"
2927
* `/Frontend.Host:` - Scicat Frontend URL - defaults to "https://discovery.psi.ch"
3028
* `/Keycloak.Host` - Keycloak URL - defaults to "https://kc.psi.ch"
29+
* `/Keycloak.Realm` - Keycloak URL - defaults to "awi"
3130
* `/S3.Host:` - S3 host URL - defaults to "https://scopem-openem.ethz.ch"
32-
* `/CollectionLocations:` List of collection location name and path - example --params="'/CollectionLocations:storage1:\\\\path\\to\\storage1;storage2:\\\\path\\to\\storage2'"
3331

3432
To pass parameters, use `--params "''"` (e.g. `choco install openem-ingestor [other options] --params="'/ITEM:value /ITEM2:value2 /FLAG_BOOLEAN'"`).
3533
To have choco remember parameters on upgrade, be sure to set `choco feature enable -n=useRememberedArgumentsForUpgrades`.

tools/chocolateyInstall.ps1

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,54 @@ $ErrorActionPreference = 'Stop';
22

33
$package = Get-Package -Name 'Openem-Ingestor' -ErrorAction SilentlyContinue
44

5-
6-
75
if ($package) {
86
Write-Host "Package already installed. Uninstalling first."
97
choco uninstall openem-ingestor -y
108
}
119

12-
1310
$packageName = 'openem-ingestor'
1411

15-
1612
$pp = Get-PackageParameters
1713

18-
if (!$pp['Scicat.Host']) { $pp['Scicat.Host'] = 'https://dacat.psi.ch' }
19-
if (!$pp['Frontend.Host']) { $pp['Frontend.Host'] = 'https://discovery.psi.ch' }
20-
if (!$pp['Keycloak.Host']) { $pp['Keycloak.Host'] = 'https://kc.psi.ch' }
21-
if (!$pp['S3.Host']) { $pp['S3.Host'] = 'https://scopem-openem.ethz.ch' }
2214

23-
# Copy the executable
15+
if (!$pp['environment']) {
16+
Write-Error -Message "No environment specified (dev, qa, prod)"
17+
Exit -1
18+
}
19+
20+
$deployment_env = $pp['Environment']
2421

2522
# Define the string to find and the string to replace it with
2623
$parameters = @{};
27-
$parameters["SCICAT_HOST"] = $pp['Scicat.Host']
28-
$parameters["FRONTEND_HOST"] = $pp['Frontend.Host']
29-
$parameters["KEYCLOAK_HOST"] = $pp['Keycloak.Host']
30-
$parameters["S3_HOST"] = $pp['S3.Host']
24+
25+
if ($deployment_env -eq "dev"){
26+
$parameters["SCICAT_HOST"] = "https://scopem-openem2.ethz.ch/scicat/backend"
27+
$parameters["FRONTEND_HOST"] = "https://scopem-openem2.ethz.ch"
28+
$parameters["KEYCLOAK_HOST"] = "https://scopem-openem2.ethz.ch/keycloak"
29+
$parameters["KEYCLOAK_REALM"] = "facility"
30+
$parameters["S3_HOST"] = "https://scopem-openem2.ethz.ch"
31+
} elseif ($deployment_env -eq "qa") {
32+
$parameters["SCICAT_HOST"] = "https://dacat-qa.psi.ch"
33+
$parameters["FRONTEND_HOST"] = "https://discovery-qa.psi.ch"
34+
$parameters["KEYCLOAK_HOST"] = "https://kc.psi.ch"
35+
$parameters["KEYCLOAK_REALM"] = "awi"
36+
$parameters["S3_HOST"] = "https://scopem-openem.ethz.ch"
37+
} elseif ($deployment_env -eq "prod") {
38+
$parameters["SCICAT_HOST"] = "https://dacat.psi.ch"
39+
$parameters["FRONTEND_HOST"] = "https://discovery.psi.ch"
40+
$parameters["KEYCLOAK_HOST"] = "https://kc.psi.ch"
41+
$parameters["KEYCLOAK_REALM"] = "awi"
42+
$parameters["S3_HOST"] = "https://scopem-openem.ethz.ch"
43+
}else{
44+
Write-Error -Message "Unknown environment specified (allowed: dev, qa, prod)"
45+
Exit -1
46+
}
47+
48+
if ($pp['Scicat.Host']) { $parameters['SCICAT_HOST'] = $pp['Scicat.Host'] }
49+
if ($pp['Frontend.Host']) { $parameters['FRONTEND_HOST'] = $pp['Frontend.Host'] }
50+
if ($pp['Keycloak.Host']) { $parameters['KEYCLOAK_HOST'] = $pp['Keycloak.Host'] }
51+
if ($pp['Keycloak.Realm']) { $parameters['KEYCLOAK_REALM'] = $pp['Keycloak.Realm'] }
52+
if ($pp['S3.Host']) { $parameters['S3_HOST'] = $pp['S3.Host'] }
3153

3254
$locationPairs = $pp['CollectionLocations'] -split ';'
3355
for ($index = 0; $index -lt $locationPairs.Length; $index++) {

0 commit comments

Comments
 (0)