domino-cli 2.0.1__tar.gz → 2.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. {domino_cli-2.0.1 → domino_cli-2.2.0}/PKG-INFO +39 -14
  2. {domino_cli-2.0.1 → domino_cli-2.2.0}/README.md +37 -12
  3. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/__init__.py +1 -1
  4. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/ApplicationContext.py +4 -3
  5. domino_cli-2.2.0/domino_cli/core/cli/CLI.py +31 -0
  6. domino_cli-2.2.0/domino_cli/core/cli/Logging.py +68 -0
  7. domino_cli-2.2.0/domino_cli/core/cli/RuntimeHelper.py +64 -0
  8. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/client/DominoClient.py +2 -1
  9. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/command/AbstractLifecycleCommand.py +2 -1
  10. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/command/AuthCommand.py +2 -1
  11. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/command/DeployApplicationCommand.py +2 -1
  12. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/command/ExitCommand.py +3 -2
  13. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/command/HelpCommand.py +3 -1
  14. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/command/WizardCommand.py +2 -1
  15. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/domain/OAuthConfig.py +3 -1
  16. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/AuthenticationService.py +18 -7
  17. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/CommandProcessor.py +2 -1
  18. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/ConfigurationWizardService.py +6 -2
  19. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/DominoService.py +10 -6
  20. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/SessionContextHolder.py +7 -1
  21. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/auth/AuthUtils.py +4 -2
  22. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/CoordinatorConfigWizard.py +6 -1
  23. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/InstallerWizard.py +8 -2
  24. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/installer/DockerPlatformComponentInstaller.py +6 -2
  25. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/installer/PlatformComponentInstaller.py +7 -5
  26. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/mapping/CommonAgentConfigWizardDataMapping.py +2 -2
  27. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/mapping/CoordinatorConfigWizardDataMapping.py +5 -2
  28. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/mapping/InstallerWizardDataMapping.py +4 -1
  29. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/render/WizardResultConsoleRenderer.py +4 -1
  30. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/render/WizardResultFileRenderer.py +3 -1
  31. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/step/BaseWizardStep.py +2 -1
  32. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/step/KeyValuePairAnswerWizardStep.py +4 -2
  33. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/step/MultiAnswerWizardStep.py +2 -1
  34. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/step/OptionSelectorWizardStep.py +2 -1
  35. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/transformer/CoordinatorConfigWizardResultTransformer.py +5 -1
  36. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/transformer/DockerAgentConfigWizardResultTransformer.py +5 -1
  37. domino_cli-2.0.1/domino_cli/core/cli/CLI.py +0 -23
  38. {domino_cli-2.0.1 → domino_cli-2.2.0}/.gitignore +0 -0
  39. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/__main__.py +0 -0
  40. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/__init__.py +0 -0
  41. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/cli/__init__.py +0 -0
  42. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/client/OAuthAuthorizationClient.py +0 -0
  43. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/client/__init__.py +0 -0
  44. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/command/AbstractCommand.py +0 -0
  45. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/command/InfoCommand.py +0 -0
  46. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/command/RestartApplicationCommand.py +0 -0
  47. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/command/StartApplicationCommand.py +0 -0
  48. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/command/StopApplicationCommand.py +0 -0
  49. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/command/__init__.py +0 -0
  50. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/domain/AuthMode.py +0 -0
  51. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/domain/AuthRequest.py +0 -0
  52. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/domain/CommandDescriptor.py +0 -0
  53. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/domain/DominoCommand.py +0 -0
  54. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/domain/DominoRequest.py +0 -0
  55. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/domain/HTTPMethod.py +0 -0
  56. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/domain/SessionContext.py +0 -0
  57. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/domain/__init__.py +0 -0
  58. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/__init__.py +0 -0
  59. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/auth/AbstractAuthHandler.py +0 -0
  60. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/auth/DirectAuthHandler.py +0 -0
  61. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/auth/OAuthAuthHandler.py +0 -0
  62. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/auth/__init__.py +0 -0
  63. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/utility/BCryptUtil.py +0 -0
  64. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/utility/__init__.py +0 -0
  65. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/AbstractAgentConfigWizard.py +0 -0
  66. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/AbstractWizard.py +0 -0
  67. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/BinaryExecutableAgentConfigWizard.py +0 -0
  68. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/DeploymentConfigWizard.py +0 -0
  69. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/DockerAgentConfigWizard.py +0 -0
  70. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/__init__.py +0 -0
  71. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/installer/BinaryExecutablePlatformComponentInstaller.py +0 -0
  72. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/installer/DockerVersionResolver.py +0 -0
  73. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/installer/GitHubReleaseVersionResolver.py +0 -0
  74. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/installer/__init__.py +0 -0
  75. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/mapping/BinaryExecutableAgentConfigWizardDataMapping.py +0 -0
  76. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/mapping/DeploymentConfigWizardDataMapping.py +0 -0
  77. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/mapping/DockerAgentConfigWizardDataMapping.py +0 -0
  78. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/mapping/WizardDataMappingBaseEnum.py +0 -0
  79. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/mapping/__init__.py +0 -0
  80. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/render/__init__.py +0 -0
  81. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/step/WizardStep.py +0 -0
  82. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/step/__init__.py +0 -0
  83. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/transformer/AbstractWizardResultTransformer.py +0 -0
  84. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/transformer/BinaryExecutableAgentConfigWizardResultTransformer.py +0 -0
  85. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/transformer/DeploymentConfigWizardResultTransformer.py +0 -0
  86. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/service/wizard/transformer/__init__.py +0 -0
  87. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/util/ArrayStream.py +0 -0
  88. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/core/util/__init__.py +0 -0
  89. {domino_cli-2.0.1 → domino_cli-2.2.0}/domino_cli/installer_config.py +0 -0
  90. {domino_cli-2.0.1 → domino_cli-2.2.0}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: domino-cli
3
- Version: 2.0.1
3
+ Version: 2.2.0
4
4
  Summary: Domino Platform CLI tool, providing utilities to install, configure and control your Domino Platform insfrastructure
5
5
  Project-URL: Maintainer's website, https://psprog.hu
6
6
  Classifier: Development Status :: 5 - Production/Stable
@@ -33,18 +33,20 @@ also generate configuration files for each Domino Platform components, as well a
33
33
 
34
34
  The tool can be configured via the following environment variables:
35
35
 
36
- | Environment variable | Mandatory? | Description |
37
- |----------------------------|---------------|-----------------------------------------------------------------------------------------------|
38
- | DOMINO_BASE_URL | Yes | URL of Domino instance to be controlled, e.g. http://localhost:8080/domino |
39
- | DOMINO_CLI_USERNAME | No | Optional predefined username for accessing Domino |
40
- | DOMINO_CLI_PASSWORD | No | Optional predefined password for accessing Domino |
41
- | DOMINO_CLI_DEBUG_MODE | No | Optional debug switch. Currently its only effect is echoing the parsed command |
42
- | DOMINO_DEFAULT_AUTH_MODE | No | Changes how Domino CLI acquires the access token for Domino. Defaults to direct mode (legacy) |
43
- | DOMINO_OAUTH_TOKEN_URL | In OAuth mode | OAuth 2.0 compliant authorization server address, including the token request endpoint path |
44
- | DOMINO_OAUTH_CLIENT_ID | In OAuth mode | OAuth 2.0 Client ID of Domino CLI |
45
- | DOMINO_OAUTH_CLIENT_SECRET | In OAuth mode | OAuth 2.0 Client Secret of Domino CLI |
46
- | DOMINO_OAUTH_SCOPE | In OAuth mode | OAuth 2.0 access token scope |
47
- | DOMINO_OAUTH_AUDIENCE | No | OAuth 2.0 audience of Domino |
36
+ | Environment variable | Mandatory? | Description |
37
+ |--------------------------------|---------------|------------------------------------------------------------------------------------------------------------------|
38
+ | DOMINO_BASE_URL | Yes | URL of Domino instance to be controlled, e.g. http://localhost:8080/domino |
39
+ | DOMINO_CLI_USERNAME | No | Optional predefined username for accessing Domino |
40
+ | DOMINO_CLI_PASSWORD | No | Optional predefined password for accessing Domino |
41
+ | DOMINO_CLI_PREAUTHORIZED_TOKEN | No | (For CI/CD mode) Passes an already generated access token - see further information in [CI/CD mode](#cicd-mode)) |
42
+ | DOMINO_CLI_DEBUG_MODE | No | Optional debug switch. Currently its only effect is echoing the parsed command |
43
+ | DOMINO_CLI_DISABLE_COLORS | No | Optional switch to disable terminal colors. |
44
+ | DOMINO_DEFAULT_AUTH_MODE | No | Changes how Domino CLI acquires the access token for Domino. Defaults to direct mode (legacy) |
45
+ | DOMINO_OAUTH_TOKEN_URL | In OAuth mode | OAuth 2.0 compliant authorization server address, including the token request endpoint path |
46
+ | DOMINO_OAUTH_CLIENT_ID | In OAuth mode | OAuth 2.0 Client ID of Domino CLI |
47
+ | DOMINO_OAUTH_CLIENT_SECRET | In OAuth mode | OAuth 2.0 Client Secret of Domino CLI |
48
+ | DOMINO_OAUTH_SCOPE | In OAuth mode | OAuth 2.0 access token scope |
49
+ | DOMINO_OAUTH_AUDIENCE | No | OAuth 2.0 audience of Domino |
48
50
 
49
51
  ## Installation
50
52
 
@@ -85,6 +87,29 @@ After this step, you can start Domino CLI:
85
87
  domino-cli
86
88
  ```
87
89
 
90
+ ### CI/CD mode
91
+
92
+ Domino CLI now supports execution in so-called CI/CD mode, which is a simplified execution mode, primarily to be used on
93
+ CI/CD environments, usually within a deployment script. There are a few things to note here:
94
+ * To execute Domino CLI in CI/CD mode, pass the `--cicd` switch as the first command line parameter, then the command
95
+ you wish to execute, e.g. like this:
96
+ ```bash
97
+ domino-cli --cicd deploy your_app latest
98
+ ```
99
+ * Interactive terminal is not available in CI/CD mode, you may only execute a single command at a time, then Domino CLI
100
+ immediately quits with `exit 0` status code, or `exit 1` in case of any error.
101
+ * This also means, you can't open an authorized session. Instead, you may call the `auth --generate-token` command and
102
+ set the result (the generated access token) as the `DOMINO_CLI_PREAUTHORIZED_TOKEN` environment variable, e.g. as follows:
103
+ ```bash
104
+ export DOMINO_CLI_PREAUTHORIZED_TOKEN="$(domino-cli --cicd auth --generate-token)"
105
+ # the token in DOMINO_CLI_PREAUTHORIZED_TOKEN will be used by Domino CLI to authorize any further operations
106
+ domino-cli --cicd deploy your_app latest
107
+ domino-cli --cicd start your_app
108
+ ```
109
+ * Please note, that without the interactive terminal, any operation that depends on user input, is not available,
110
+ including the configuration wizards, and manual authentication (you need to define the necessary parameters as
111
+ environment variables, as described above in the [Configuration section](#configuration))
112
+
88
113
  ## Usage
89
114
  After successfully starting up Domino CLI you should see its prompt (`Domino CLI >`) along with some start-up messages.
90
115
  Now it's time to start playing around with the commands - the supported ones are the following:
@@ -15,18 +15,20 @@ also generate configuration files for each Domino Platform components, as well a
15
15
 
16
16
  The tool can be configured via the following environment variables:
17
17
 
18
- | Environment variable | Mandatory? | Description |
19
- |----------------------------|---------------|-----------------------------------------------------------------------------------------------|
20
- | DOMINO_BASE_URL | Yes | URL of Domino instance to be controlled, e.g. http://localhost:8080/domino |
21
- | DOMINO_CLI_USERNAME | No | Optional predefined username for accessing Domino |
22
- | DOMINO_CLI_PASSWORD | No | Optional predefined password for accessing Domino |
23
- | DOMINO_CLI_DEBUG_MODE | No | Optional debug switch. Currently its only effect is echoing the parsed command |
24
- | DOMINO_DEFAULT_AUTH_MODE | No | Changes how Domino CLI acquires the access token for Domino. Defaults to direct mode (legacy) |
25
- | DOMINO_OAUTH_TOKEN_URL | In OAuth mode | OAuth 2.0 compliant authorization server address, including the token request endpoint path |
26
- | DOMINO_OAUTH_CLIENT_ID | In OAuth mode | OAuth 2.0 Client ID of Domino CLI |
27
- | DOMINO_OAUTH_CLIENT_SECRET | In OAuth mode | OAuth 2.0 Client Secret of Domino CLI |
28
- | DOMINO_OAUTH_SCOPE | In OAuth mode | OAuth 2.0 access token scope |
29
- | DOMINO_OAUTH_AUDIENCE | No | OAuth 2.0 audience of Domino |
18
+ | Environment variable | Mandatory? | Description |
19
+ |--------------------------------|---------------|------------------------------------------------------------------------------------------------------------------|
20
+ | DOMINO_BASE_URL | Yes | URL of Domino instance to be controlled, e.g. http://localhost:8080/domino |
21
+ | DOMINO_CLI_USERNAME | No | Optional predefined username for accessing Domino |
22
+ | DOMINO_CLI_PASSWORD | No | Optional predefined password for accessing Domino |
23
+ | DOMINO_CLI_PREAUTHORIZED_TOKEN | No | (For CI/CD mode) Passes an already generated access token - see further information in [CI/CD mode](#cicd-mode)) |
24
+ | DOMINO_CLI_DEBUG_MODE | No | Optional debug switch. Currently its only effect is echoing the parsed command |
25
+ | DOMINO_CLI_DISABLE_COLORS | No | Optional switch to disable terminal colors. |
26
+ | DOMINO_DEFAULT_AUTH_MODE | No | Changes how Domino CLI acquires the access token for Domino. Defaults to direct mode (legacy) |
27
+ | DOMINO_OAUTH_TOKEN_URL | In OAuth mode | OAuth 2.0 compliant authorization server address, including the token request endpoint path |
28
+ | DOMINO_OAUTH_CLIENT_ID | In OAuth mode | OAuth 2.0 Client ID of Domino CLI |
29
+ | DOMINO_OAUTH_CLIENT_SECRET | In OAuth mode | OAuth 2.0 Client Secret of Domino CLI |
30
+ | DOMINO_OAUTH_SCOPE | In OAuth mode | OAuth 2.0 access token scope |
31
+ | DOMINO_OAUTH_AUDIENCE | No | OAuth 2.0 audience of Domino |
30
32
 
31
33
  ## Installation
32
34
 
@@ -67,6 +69,29 @@ After this step, you can start Domino CLI:
67
69
  domino-cli
68
70
  ```
69
71
 
72
+ ### CI/CD mode
73
+
74
+ Domino CLI now supports execution in so-called CI/CD mode, which is a simplified execution mode, primarily to be used on
75
+ CI/CD environments, usually within a deployment script. There are a few things to note here:
76
+ * To execute Domino CLI in CI/CD mode, pass the `--cicd` switch as the first command line parameter, then the command
77
+ you wish to execute, e.g. like this:
78
+ ```bash
79
+ domino-cli --cicd deploy your_app latest
80
+ ```
81
+ * Interactive terminal is not available in CI/CD mode, you may only execute a single command at a time, then Domino CLI
82
+ immediately quits with `exit 0` status code, or `exit 1` in case of any error.
83
+ * This also means, you can't open an authorized session. Instead, you may call the `auth --generate-token` command and
84
+ set the result (the generated access token) as the `DOMINO_CLI_PREAUTHORIZED_TOKEN` environment variable, e.g. as follows:
85
+ ```bash
86
+ export DOMINO_CLI_PREAUTHORIZED_TOKEN="$(domino-cli --cicd auth --generate-token)"
87
+ # the token in DOMINO_CLI_PREAUTHORIZED_TOKEN will be used by Domino CLI to authorize any further operations
88
+ domino-cli --cicd deploy your_app latest
89
+ domino-cli --cicd start your_app
90
+ ```
91
+ * Please note, that without the interactive terminal, any operation that depends on user input, is not available,
92
+ including the configuration wizards, and manual authentication (you need to define the necessary parameters as
93
+ environment variables, as described above in the [Configuration section](#configuration))
94
+
70
95
  ## Usage
71
96
  After successfully starting up Domino CLI you should see its prompt (`Domino CLI >`) along with some start-up messages.
72
97
  Now it's time to start playing around with the commands - the supported ones are the following:
@@ -2,7 +2,7 @@
2
2
  domino_cli.py :: Main entry point for Domino CLI application.
3
3
  """
4
4
 
5
- __version__ = "2.0.1"
5
+ __version__ = "2.2.0"
6
6
 
7
7
  import os
8
8
 
@@ -1,6 +1,7 @@
1
1
  import os
2
2
 
3
3
  from domino_cli.core.cli.CLI import CLI
4
+ from domino_cli.core.cli.Logging import info
4
5
  from domino_cli.core.client.DominoClient import DominoClient
5
6
  from domino_cli.core.client.OAuthAuthorizationClient import OAuthAuthorizationClient
6
7
  from domino_cli.core.command.AuthCommand import AuthCommand
@@ -50,7 +51,7 @@ class ApplicationContext:
50
51
  @staticmethod
51
52
  def init_cli(version: str) -> CLI:
52
53
 
53
- print("Initializing Domino CLI...")
54
+ info("Initializing Domino CLI...")
54
55
 
55
56
  # configuration properties
56
57
  _domino_base_url = ApplicationContext._assert_config_value("DOMINO_BASE_URL")
@@ -129,8 +130,8 @@ class ApplicationContext:
129
130
 
130
131
  _cli = CLI(_command_processor)
131
132
 
132
- print(f"Domino CLI v{version} initialized.")
133
- print("-" * 30)
133
+ info(f"Domino CLI v{version} initialized")
134
+ info("-" * 30)
134
135
 
135
136
  return _cli
136
137
 
@@ -0,0 +1,31 @@
1
+ from domino_cli.core.cli.Logging import TerminalColor, get_color
2
+ from domino_cli.core.cli.RuntimeHelper import RuntimeHelper
3
+ from domino_cli.core.domain.CommandDescriptor import CommandDescriptor
4
+ from domino_cli.core.service.CommandProcessor import CommandProcessor
5
+
6
+ _PROMPT = f"\n{get_color(TerminalColor.BLUE)}Domino CLI > {get_color(TerminalColor.NORMAL)}"
7
+
8
+
9
+ class CLI:
10
+ """
11
+ Command line interface (CLI) executor.
12
+ """
13
+ def __init__(self, command_processor: CommandProcessor):
14
+ self._command_processor = command_processor
15
+
16
+ def run_loop(self) -> None:
17
+ """
18
+ Executes a single command (passed from the command line) in CI/CD mode, otherwise runs CLI command execution
19
+ loop until an exit command terminates it.
20
+ """
21
+ if RuntimeHelper.is_cicd_mode():
22
+ command = CommandDescriptor(RuntimeHelper.get_cicd_command_line())
23
+ self._command_processor.execute_command(command)
24
+ return
25
+
26
+ while True:
27
+ command = CommandDescriptor(RuntimeHelper.input_wrapper(lambda: input(_PROMPT)))
28
+ continue_loop = self._command_processor.execute_command(command)
29
+
30
+ if not continue_loop:
31
+ break
@@ -0,0 +1,68 @@
1
+ import os
2
+ import string
3
+ import sys
4
+ from enum import Enum
5
+
6
+ from domino_cli.core.cli.RuntimeHelper import RuntimeHelper
7
+
8
+
9
+ class TerminalColor(Enum):
10
+ GREEN = "\033[92m"
11
+ YELLOW = "\033[93m"
12
+ RED = "\033[91m"
13
+ BLUE = "\033[94m"
14
+ NORMAL = "\033[0m"
15
+
16
+
17
+ class LogLevel(Enum):
18
+ INFO = "info"
19
+ WARNING = "warn"
20
+ ERROR = "error"
21
+
22
+ _terminal_color_mapping: dict[LogLevel, TerminalColor] = {
23
+ LogLevel.INFO: TerminalColor.GREEN,
24
+ LogLevel.WARNING: TerminalColor.YELLOW,
25
+ LogLevel.ERROR: TerminalColor.RED,
26
+ }
27
+
28
+
29
+ def info(message: string) -> None:
30
+ """
31
+ Logs the given message on info level. Ignores logging in CI/CD mode.
32
+
33
+ :param message: message to log
34
+ """
35
+ _log(LogLevel.INFO, message, False)
36
+
37
+ def warning(message: string) -> None:
38
+ """
39
+ Logs the given message on warn level. Ignores logging in CI/CD mode.
40
+
41
+ :param message: message to log
42
+ """
43
+ _log(LogLevel.WARNING, message, False)
44
+
45
+ def error(message: string) -> None:
46
+ """
47
+ Logs the given message on error level. Logs the given message even in CI/CD mode.
48
+
49
+ :param message: message to log
50
+ """
51
+ _log(LogLevel.ERROR, message, True)
52
+
53
+ def get_color(color: TerminalColor) -> str:
54
+ """
55
+ Returns the terminal color code assigned to the given TerminalColor, if using terminal colors is enabled. Otherwise,
56
+ returns an empty string.
57
+
58
+ :param color: TerminalColor enum constant
59
+ :return: color code or empty string
60
+ """
61
+ return "" \
62
+ if os.getenv("DOMINO_CLI_DISABLE_COLORS") is not None or "unittest" in sys.modules \
63
+ else color.value
64
+
65
+ def _log(log_level: LogLevel, message: string, force: bool = False) -> None:
66
+
67
+ if not RuntimeHelper.is_cicd_mode() or force:
68
+ print(f"[{get_color(_terminal_color_mapping[log_level])}{log_level.value:5}{get_color(TerminalColor.NORMAL)}] {message}")
@@ -0,0 +1,64 @@
1
+ import sys
2
+
3
+
4
+ class RuntimeHelper:
5
+ """
6
+ Runtime helper utilities.
7
+ """
8
+
9
+ _cicd_mode = len(sys.argv) > 1 and sys.argv[1] == "--cicd"
10
+
11
+ @classmethod
12
+ def is_cicd_mode(cls) -> bool:
13
+ """
14
+ Checks if the CLI was executed in CI/CD mode. CI/CD mode only allows executing a single command, defined
15
+ directly in the command line. The same commands and parameterization should be used as before, but in order to
16
+ run the CLI in CI/CD mode, the first parameter should be "--cicd". E.g. domino-cli --cicd deploy app 1.0.0.
17
+ For further information, see the relevant section of the documentation in README.md.
18
+
19
+ :return: true if CI/CD mode is enabled, false otherwise.
20
+ """
21
+ return cls._cicd_mode
22
+
23
+ @classmethod
24
+ def get_cicd_command_line(cls) -> str:
25
+ """
26
+ Returns the CI/CD command line, without the --cicd flag itself, only if the CLI is running in CI/CD mode.
27
+ Otherwise, it returns None.
28
+
29
+ :return: CI/CD command line without --cicd flag
30
+ """
31
+ return " ".join(sys.argv[2:]) \
32
+ if cls._cicd_mode \
33
+ else None
34
+
35
+ @classmethod
36
+ def input_wrapper(cls, input_call: lambda: str) -> str:
37
+ """
38
+ Checks if the CLI is running in CI/CD mode before executing an input call. If so, immediately quits, otherwise
39
+ executes the input call.
40
+
41
+ :param input_call: input call to be executed
42
+ :return: result of the input call
43
+ """
44
+ cls.unsupported_in_cicd_mode()
45
+
46
+ return input_call()
47
+
48
+ @classmethod
49
+ def exit_with_error_in_cicd_mode(cls) -> None:
50
+ """
51
+ Closes the CLI application with exit status 1 in CI/CD mode. Can be used to terminate the CLI on exception.
52
+ """
53
+ if cls._cicd_mode:
54
+ exit(1)
55
+
56
+ @classmethod
57
+ def unsupported_in_cicd_mode(cls) -> None:
58
+ """
59
+ Closes the CLI application with exit status 1 in CI/CD mode. Can be used to terminate the CLI when an
60
+ unsupported operation is executed in CI/CD mode.
61
+ """
62
+ if cls._cicd_mode:
63
+ print("[error] This operation is not supported in CI/CD mode")
64
+ exit(1)
@@ -3,6 +3,7 @@ import urllib.parse
3
3
  import requests
4
4
  from requests import Response
5
5
 
6
+ from domino_cli.core.cli.Logging import info
6
7
  from domino_cli.core.domain.DominoRequest import DominoRequest
7
8
  from domino_cli.core.service.SessionContextHolder import SessionContextHolder
8
9
 
@@ -15,7 +16,7 @@ class DominoClient:
15
16
  self._domino_base_url = domino_base_url
16
17
  self._session_context_holder = session_context_holder
17
18
 
18
- print("Domino CLI is configured to communicate with Domino on {0}".format(domino_base_url))
19
+ info("Domino CLI is configured to communicate with Domino on {0}".format(domino_base_url))
19
20
 
20
21
  def send_command(self, domino_request: DominoRequest) -> Response:
21
22
  """
@@ -1,3 +1,4 @@
1
+ from domino_cli.core.cli.Logging import warning
1
2
  from domino_cli.core.command.AbstractCommand import AbstractCommand
2
3
  from domino_cli.core.domain.CommandDescriptor import CommandDescriptor
3
4
  from domino_cli.core.domain.DominoCommand import DominoCommand
@@ -21,6 +22,6 @@ class AbstractLifecycleCommand(AbstractCommand):
21
22
  :param command_descriptor: CommandDescriptor object containing the command arguments
22
23
  """
23
24
  if not len(command_descriptor.arguments) == 1:
24
- print("Application name required")
25
+ warning("Application name required")
25
26
  else:
26
27
  self._domino_service.execute_lifecycle_command(self._domino_command, command_descriptor.arguments[0])
@@ -1,3 +1,4 @@
1
+ from domino_cli.core.cli.Logging import warning
1
2
  from domino_cli.core.command.AbstractCommand import AbstractCommand
2
3
  from domino_cli.core.domain.CommandDescriptor import CommandDescriptor
3
4
  from domino_cli.core.service.AuthenticationService import AuthenticationService
@@ -42,5 +43,5 @@ class AuthCommand(AbstractCommand):
42
43
 
43
44
  @staticmethod
44
45
  def _show_help():
45
- print("Auth command requires operation flag of: --encrypt-password | --generate-token | --open-session "
46
+ warning("Auth command requires operation flag of: --encrypt-password | --generate-token | --open-session "
46
47
  "| --set-mode direct|oauth")
@@ -1,3 +1,4 @@
1
+ from domino_cli.core.cli.Logging import warning
1
2
  from domino_cli.core.command.AbstractCommand import AbstractCommand
2
3
  from domino_cli.core.domain.CommandDescriptor import CommandDescriptor
3
4
  from domino_cli.core.domain.DominoCommand import DominoCommand
@@ -25,7 +26,7 @@ class DeployApplicationCommand(AbstractCommand):
25
26
  :param command_descriptor: CommandDescriptor object containing the command arguments
26
27
  """
27
28
  if not len(command_descriptor.arguments) == 2:
28
- print("Application name and 'latest' keyword or explicit version is required")
29
+ warning("Application name and 'latest' keyword or explicit version is required")
29
30
  else:
30
31
  application: str = command_descriptor.arguments[0]
31
32
  version: str = command_descriptor.arguments[1]
@@ -1,5 +1,6 @@
1
- from domino_cli.core.domain.CommandDescriptor import CommandDescriptor
1
+ from domino_cli.core.cli.Logging import info
2
2
  from domino_cli.core.command.AbstractCommand import AbstractCommand
3
+ from domino_cli.core.domain.CommandDescriptor import CommandDescriptor
3
4
 
4
5
  _COMMAND_NAME = "exit"
5
6
 
@@ -13,4 +14,4 @@ class ExitCommand(AbstractCommand):
13
14
  super().__init__(_COMMAND_NAME)
14
15
 
15
16
  def execute_command(self, command_descriptor: CommandDescriptor) -> None:
16
- print("Bye!")
17
+ info("Bye!")
@@ -1,5 +1,6 @@
1
- from domino_cli.core.domain.CommandDescriptor import CommandDescriptor
1
+ from domino_cli.core.cli.RuntimeHelper import RuntimeHelper
2
2
  from domino_cli.core.command.AbstractCommand import AbstractCommand
3
+ from domino_cli.core.domain.CommandDescriptor import CommandDescriptor
3
4
 
4
5
  _COMMAND_NAME = "help"
5
6
  _HELP_CONTENT = """
@@ -30,3 +31,4 @@ class HelpCommand(AbstractCommand):
30
31
 
31
32
  def execute_command(self, command_descriptor: CommandDescriptor) -> None:
32
33
  [print(line, end="") for line in self._help_text]
34
+ RuntimeHelper.exit_with_error_in_cicd_mode()
@@ -1,3 +1,4 @@
1
+ from domino_cli.core.cli.Logging import warning
1
2
  from domino_cli.core.command.AbstractCommand import AbstractCommand
2
3
  from domino_cli.core.domain.CommandDescriptor import CommandDescriptor
3
4
  from domino_cli.core.service.ConfigurationWizardService import ConfigurationWizardService
@@ -21,7 +22,7 @@ class WizardCommand(AbstractCommand):
21
22
  :param command_descriptor: CommandDescriptor object containing the command arguments
22
23
  """
23
24
  if not len(command_descriptor.arguments) == 1:
24
- print("Wizard name required")
25
+ warning("Wizard name required")
25
26
  self._configuration_wizard_service.show_available_wizards()
26
27
  else:
27
28
  self._configuration_wizard_service.run_wizard(command_descriptor.arguments[0])
@@ -1,5 +1,7 @@
1
1
  import os
2
2
 
3
+ from domino_cli.core.cli.Logging import warning
4
+
3
5
  _OAUTH_TOKEN_URL = "DOMINO_OAUTH_TOKEN_URL"
4
6
  _OAUTH_CLIENT_ID = "DOMINO_OAUTH_CLIENT_ID"
5
7
  _OAUTH_CLIENT_SECRET = "DOMINO_OAUTH_CLIENT_SECRET"
@@ -38,7 +40,7 @@ class OAuthConfig:
38
40
  present: bool = True
39
41
  if OAuthConfig._get_parameter(parameter) is None:
40
42
  present = False
41
- print(f"Parameter {parameter} is missing")
43
+ warning(f"Parameter {parameter} is missing")
42
44
 
43
45
  return present
44
46
 
@@ -1,5 +1,7 @@
1
1
  from typing import List, Dict
2
2
 
3
+ from domino_cli.core.cli.Logging import info, error
4
+ from domino_cli.core.cli.RuntimeHelper import RuntimeHelper
3
5
  from domino_cli.core.domain.AuthMode import AuthMode
4
6
  from domino_cli.core.domain.SessionContext import SessionContext
5
7
  from domino_cli.core.service.SessionContextHolder import SessionContextHolder
@@ -18,15 +20,16 @@ class AuthenticationService:
18
20
  self._session_context_holder: SessionContextHolder = session_context_holder
19
21
  self._auth_handler_dict: Dict[AuthMode, AbstractAuthHandler] = self._init_handler_map(auth_handlers)
20
22
 
21
- print(f"Domino authentication mode is set to {self._auth_mode.name}. Use 'auth --set-mode' command to change")
23
+ info(f"Domino authentication mode is set to {self._auth_mode.name}. Use 'auth --set-mode' command to change")
22
24
 
23
25
  def encrypt_password(self) -> None:
24
26
  """
25
27
  Utility to encrypt a password with BCrypt for usage in Domino (as service user password).
26
28
  """
29
+ RuntimeHelper.unsupported_in_cicd_mode()
27
30
  encrypted_password: str = encrypt(AuthUtils.input_password())
28
31
 
29
- print("Encrypted password: {0}".format(encrypted_password))
32
+ info("Encrypted password: {0}".format(encrypted_password))
30
33
 
31
34
  def generate_token(self) -> None:
32
35
  """
@@ -35,22 +38,29 @@ class AuthenticationService:
35
38
  try:
36
39
  session_context: SessionContext = self._request_token()
37
40
 
38
- print("Generated auth token: {0}".format(session_context.authentication_token))
41
+ if RuntimeHelper.is_cicd_mode():
42
+ print(session_context.authentication_token)
43
+ else:
44
+ info("Generated auth token: {0}".format(session_context.authentication_token))
45
+
39
46
  except Exception as exc:
40
- print("Failed to generate token - reason: {0}".format(str(exc)))
47
+ error("Failed to generate token - reason: {0}".format(str(exc)))
48
+ RuntimeHelper.exit_with_error_in_cicd_mode()
41
49
 
42
50
  def open_session(self) -> None:
43
51
  """
44
52
  Opens an authenticated session for Domino CLI.
45
53
  This step is required before executing any lifecycle command, otherwise Domino rejects every request.
46
54
  """
55
+ RuntimeHelper.unsupported_in_cicd_mode()
47
56
  try:
48
57
  session_context: SessionContext = self._request_token()
49
58
  self._session_context_holder.update(session_context)
50
59
 
51
- print("Session is open")
60
+ info("Session is open")
52
61
  except Exception as exc:
53
- print("Failed to open session - reason: {0}".format(str(exc)))
62
+ error("Failed to open session - reason: {0}".format(str(exc)))
63
+ RuntimeHelper.exit_with_error_in_cicd_mode()
54
64
 
55
65
  def set_mode(self, new_mode: str) -> None:
56
66
  """
@@ -59,10 +69,11 @@ class AuthenticationService:
59
69
 
60
70
  :param new_mode: authentication mode to change to
61
71
  """
72
+ RuntimeHelper.unsupported_in_cicd_mode()
62
73
  try:
63
74
  self._auth_mode = AuthMode.by_value(new_mode)
64
75
  except KeyError:
65
- print(f"Failed to change authentication mode, invalid mode defined: {new_mode}")
76
+ error(f"Failed to change authentication mode, invalid mode defined: {new_mode}")
66
77
 
67
78
  def _request_token(self) -> SessionContext:
68
79
 
@@ -1,6 +1,7 @@
1
1
  import os
2
2
  from typing import List
3
3
 
4
+ from domino_cli.core.cli.Logging import info
4
5
  from domino_cli.core.command.AbstractCommand import AbstractCommand
5
6
  from domino_cli.core.command.ExitCommand import ExitCommand
6
7
  from domino_cli.core.domain.CommandDescriptor import CommandDescriptor
@@ -27,7 +28,7 @@ class CommandProcessor:
27
28
  """
28
29
 
29
30
  if _DEBUG_MODE:
30
- print("Command to be executed: {0}".format(command_descriptor))
31
+ info("Command to be executed: {0}".format(command_descriptor))
31
32
 
32
33
  command_iterator = filter(lambda command: command.is_applicable(command_descriptor), self._registered_commands)
33
34
  selected_command = next(command_iterator, self._default_command)
@@ -1,5 +1,7 @@
1
1
  from typing import List, Dict
2
2
 
3
+ from domino_cli.core.cli.Logging import warning, info
4
+ from domino_cli.core.cli.RuntimeHelper import RuntimeHelper
3
5
  from domino_cli.core.service.wizard.AbstractWizard import AbstractWizard
4
6
 
5
7
  _WIZARD_HELP_TEXT_LINE = "{}\n[{:>15}]: {}"
@@ -17,7 +19,8 @@ class ConfigurationWizardService:
17
19
  """
18
20
  Prints the name and the description of the available wizards.
19
21
  """
20
- print("Available wizards:{0}".format(self._available_wizards_help))
22
+ RuntimeHelper.unsupported_in_cicd_mode()
23
+ info("Available wizards:{0}".format(self._available_wizards_help))
21
24
 
22
25
  def run_wizard(self, wizard_name: str) -> None:
23
26
  """
@@ -25,8 +28,9 @@ class ConfigurationWizardService:
25
28
 
26
29
  :param wizard_name: name of the wizard to be executed
27
30
  """
31
+ RuntimeHelper.unsupported_in_cicd_mode()
28
32
  if wizard_name not in self._wizards.keys():
29
- print("Unknown wizard '{0}'".format(wizard_name))
33
+ warning("Unknown wizard '{0}'".format(wizard_name))
30
34
  self.show_available_wizards()
31
35
  else:
32
36
  wizard: AbstractWizard = self._wizards.get(wizard_name)
@@ -1,5 +1,7 @@
1
1
  from requests import Response
2
2
 
3
+ from domino_cli.core.cli.Logging import info, error
4
+ from domino_cli.core.cli.RuntimeHelper import RuntimeHelper
3
5
  from domino_cli.core.client.DominoClient import DominoClient
4
6
  from domino_cli.core.domain.DominoCommand import DominoCommand
5
7
  from domino_cli.core.domain.DominoCommand import DominoRequestDescriptor
@@ -25,21 +27,23 @@ class DominoService:
25
27
  formatted_path = domino_request_descriptor.path_template.format(application, version)
26
28
  domino_request = DominoRequest(domino_request_descriptor.method, formatted_path, authenticated=True)
27
29
 
28
- print("Sending {0} command for application {1} via Domino".format(domino_command.name, application))
30
+ info("Sending {0} command for application {1} via Domino".format(domino_command.name, application))
29
31
 
30
32
  try:
31
33
  response: Response = self._domino_client.send_command(domino_request)
32
34
 
33
35
  if DominoService._is_successful(response):
34
- print("Command {0} successfully executed on application {1}".format(domino_command.name, application))
36
+ info("Command {0} successfully executed on application {1}".format(domino_command.name, application))
35
37
  else:
36
- print("Failed to execute command {0} on application {1} - Domino responded with {2}"
38
+ error("Failed to execute command {0} on application {1} - Domino responded with {2}"
37
39
  .format(domino_command.name, application, response.status_code))
40
+ RuntimeHelper.exit_with_error_in_cicd_mode()
38
41
 
39
42
  DominoService._render_response(response)
40
43
 
41
44
  except Exception as exc:
42
- print("Failed to execute HTTP request {0} - reason {1}".format(domino_request, str(exc)))
45
+ error("Failed to execute HTTP request {0} - reason {1}".format(domino_request, str(exc)))
46
+ RuntimeHelper.exit_with_error_in_cicd_mode()
43
47
 
44
48
  @staticmethod
45
49
  def _is_successful(response: Response) -> bool:
@@ -48,6 +52,6 @@ class DominoService:
48
52
  @staticmethod
49
53
  def _render_response(response: Response):
50
54
  response_dict = response.json()
51
- print(" --- Response details ---")
52
- [print("{:>10}: {}".format(field, response_dict[field])) for field in response_dict]
55
+ info(" --- Response details ---")
56
+ [info("{:>20}: {}".format(field, response_dict[field])) for field in response_dict]
53
57
  print()