Skip to content

Commit

Permalink
feat: add support for custom subdomains (#6)
Browse files Browse the repository at this point in the history
* feat: add support for custom subdomains
* chore: rename Prefix with more accurate Subdomain
  • Loading branch information
rangoo94 authored Aug 14, 2024
1 parent a7a3290 commit 970d643
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,12 @@ Besides common inputs, there are some different for kubectl and Pro connection.

### Pro and Enterprise

| Required | Name | Description |
|:--------:|----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ✓ | `organization` | The organization ID from Testkube Pro or Enterprise - it starts with `tkc_org`, you may find it i.e. in the dashboard's URL |
| ✓ | `environment` | The environment ID from Testkube Pro or Enterprise - it starts with `tkc_env`, you may find it i.e. in the dashboard's URL |
| ✓ | `token` | API token that has at least a permission to run specific test or test suite. You may read more about [**creating API token**](https://docs.testkube.io/testkube-pro/organization-management#api-tokens) in Testkube Pro or Enterprise |
| ✗ | `url` | URL of the Testkube Enterprise instance, if applicable |
| Required | Name | Description |
|:--------:|--------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ✓ | `organization` | The organization ID from Testkube Pro or Enterprise - it starts with `tkc_org`, you may find it i.e. in the dashboard's URL |
| ✓ | `environment` | The environment ID from Testkube Pro or Enterprise - it starts with `tkc_env`, you may find it i.e. in the dashboard's URL |
| ✓ | `token` | API token that has at least a permission to run specific test or test suite. You may read more about [**creating API token**](https://docs.testkube.io/testkube-pro/organization-management#api-tokens) in Testkube Pro or Enterprise |
| ✗ | `url` | URL of the Testkube Enterprise instance, if applicable |
| ✗ | `urlApiSubdomain` | API subdomain the Testkube Enterprise URL, if necessary |
| ✗ | `urlUiSubdomain` | Dashboard subdomain the Testkube Enterprise URL, if necessary |
| ✗ | `urlLogsSubdomain` | Logs Server subdomain the Testkube Enterprise URL, if necessary |
9 changes: 9 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ inputs:
description: "Testkube Cloud/Enterprise root domain, defaults to the Testkube Cloud (testkube.io)."
default: "testkube.io"
required: false
urlApiSubdomain:
description: "API URL subdomain before the Testkube Cloud/Enterprise root domain, if custom setup."
required: false
urlUiSubdomain:
description: "Dashboard URL subdomain before the Testkube Cloud/Enterprise root domain, if custom setup."
required: false
urlLogsSubdomain:
description: "Logs Server URL subdomain before the Testkube Cloud/Enterprise root domain, if custom setup."
required: false
organization:
description: "Organization ID in the Testkube Cloud/Enterprise."
required: false
Expand Down
6 changes: 6 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10683,6 +10683,9 @@ const params = {
channel: (0,_actions_core__WEBPACK_IMPORTED_MODULE_4__.getInput)("channel") || "stable",
namespace: (0,_actions_core__WEBPACK_IMPORTED_MODULE_4__.getInput)("namespace") || "testkube",
url: (0,_actions_core__WEBPACK_IMPORTED_MODULE_4__.getInput)("url") || "testkube.io",
urlApiSubdomain: (0,_actions_core__WEBPACK_IMPORTED_MODULE_4__.getInput)("urlApiSubdomain"),
urlUiSubdomain: (0,_actions_core__WEBPACK_IMPORTED_MODULE_4__.getInput)("urlUiSubdomain"),
urlLogsSubdomain: (0,_actions_core__WEBPACK_IMPORTED_MODULE_4__.getInput)("urlLogsSubdomain"),
organization: (0,_actions_core__WEBPACK_IMPORTED_MODULE_4__.getInput)("organization"),
environment: (0,_actions_core__WEBPACK_IMPORTED_MODULE_4__.getInput)("environment"),
token: (0,_actions_core__WEBPACK_IMPORTED_MODULE_4__.getInput)("token"),
Expand Down Expand Up @@ -10832,6 +10835,9 @@ const contextArgs = mode === "kubectl"
params.organization,
"--env-id",
params.environment,
...(params.urlApiSubdomain ? ["--api-prefix", params.urlApiSubdomain] : []),
...(params.urlUiSubdomain ? ["--ui-prefix", params.urlUiSubdomain] : []),
...(params.urlLogsSubdomain ? ["--logs-prefix", params.urlLogsSubdomain] : []),
];
process.exit((0,node_child_process__WEBPACK_IMPORTED_MODULE_0__.spawnSync)("testkube", ["set", "context", ...contextArgs], { stdio: "inherit" }).status || 0);

Expand Down
9 changes: 9 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ interface Params {
channel: string;
namespace?: string | null;
url: string;
urlApiSubdomain?: string | null;
urlUiSubdomain?: string | null;
urlLogsSubdomain?: string | null;
organization?: string | null;
environment?: string | null;
token?: string | null;
Expand All @@ -21,6 +24,9 @@ const params: Params = {
channel: getInput("channel") || "stable",
namespace: getInput("namespace") || "testkube",
url: getInput("url") || "testkube.io",
urlApiSubdomain: getInput("urlApiSubdomain"),
urlUiSubdomain: getInput("urlUiSubdomain"),
urlLogsSubdomain: getInput("urlLogsSubdomain"),
organization: getInput("organization"),
environment: getInput("environment"),
token: getInput("token"),
Expand Down Expand Up @@ -193,6 +199,9 @@ const contextArgs =
params.organization!,
"--env-id",
params.environment!,
...(params.urlApiSubdomain ? ["--api-prefix", params.urlApiSubdomain] : []),
...(params.urlUiSubdomain ? ["--ui-prefix", params.urlUiSubdomain] : []),
...(params.urlLogsSubdomain ? ["--logs-prefix", params.urlLogsSubdomain] : []),
];

process.exit(spawnSync("testkube", ["set", "context", ...contextArgs], { stdio: "inherit" }).status || 0);

0 comments on commit 970d643

Please sign in to comment.