Skip to content

Commit 0efadfb

Browse files
Merge pull request #138 from cortexapps/136-prometheus-add-is-incorrect---does-not-include-tenant-and-password-parameters
136 prometheus add is incorrect does not include tenant and password parameters
2 parents 608339d + da344be commit 0efadfb

File tree

7 files changed

+165
-183
lines changed

7 files changed

+165
-183
lines changed

.chglog/CHANGELOG.tpl.md

Lines changed: 0 additions & 22 deletions
This file was deleted.

.chglog/config.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,31 @@ jobs:
2828
with:
2929
ref: main
3030
fetch-depth: 0
31+
32+
- name: Bump version and push tag
33+
uses: anothrNick/[email protected]
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
36+
WITH_V: false
3137

3238
- name: Set up Git
3339
run: |
3440
git config --global user.name "GitHub Actions"
3541
git config --global user.email "[email protected]"
3642
37-
- name: Install git-chglog
43+
- name: Set up Python 3.11
44+
uses: actions/setup-python@v5
45+
with:
46+
python-version: 3.11
47+
48+
- name: Install dependencies
3849
run: |
39-
curl -LO https://github.com/git-chglog/git-chglog/releases/download/v0.15.4/git-chglog_0.15.4_linux_386.tar.gz
40-
tar -xzf git-chglog_0.15.4_linux_386.tar.gz
41-
chmod +x git-chglog
42-
sudo mv git-chglog /usr/local/bin/
43-
git-chglog --version
50+
python -m pip install --upgrade pip
51+
pip install poetry git-changelog
4452
4553
- name: Generate HISTORY.md
4654
run: |
47-
git-chglog -o HISTORY.md
55+
git-changelog > HISTORY.md
4856
cat HISTORY.md
4957
5058
- name: Commit and Push
@@ -57,22 +65,6 @@ jobs:
5765
git push
5866
fi
5967
60-
- name: Bump version and push tag
61-
uses: anothrNick/[email protected]
62-
env:
63-
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
64-
WITH_V: false
65-
66-
- name: Set up Python 3.11
67-
uses: actions/setup-python@v5
68-
with:
69-
python-version: 3.11
70-
71-
- name: Install dependencies
72-
run: |
73-
python -m pip install --upgrade pip
74-
pip install poetry
75-
7668
- name: Git details about version
7769
id: git-details
7870
env:

README.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,20 @@ This recipe does the following:
439439
cortex catalog descriptor -y -t ${entity} | yq "with(.info.x-cortex-owners[]; select(.type | downcase == \"group\") | select(.provider == null) | .provider = \"${provider}\" )" | cortex catalog create -f-
440440
done
441441
442+
-----------------------------------------------------------------------------
443+
Export all workflows
444+
-----------------------------------------------------------------------------
445+
446+
This recipe creates YAML files for each Workflow. This may be helpful if you are considering enabling GitOps for Workflows and you want to export current Workflows as a starting point.
447+
448+
.. code:: bash
449+
450+
for workflow in `cortex workflows list --csv --no-headers --columns tag`
451+
do
452+
echo "workflow = $workflow"
453+
cortex workflows get --tag $workflow --yaml > $workflow.yaml
454+
done
455+
442456
-----------------------------------------------------------------------------
443457
Obfuscating a Cortex export
444458
-----------------------------------------------------------------------------

cortexapps_cli/commands/integrations_commands/prometheus.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
@app.command()
99
def add(
1010
ctx: typer.Context,
11-
alias: str = typer.Option(..., "--alias", "-a", help="Alias for this configuration"),
12-
api_key: str = typer.Option(..., "--api-key", "-api", help="API key"),
11+
alias: str = typer.Option(None, "--alias", "-a", help="Alias for this configuration"),
1312
host: str = typer.Option(None, "--host", "-h", help="Optional host name"),
13+
username: str = typer.Option(None, "--username", "-u", help="username"),
14+
password: str = typer.Option(None, "--password", "-p", help="password"),
15+
tenant_id: str = typer.Option(None, "--tenant", "-t", help="Optional tenant id"),
1416
is_default: bool = typer.Option(False, "--is-default", "-i", help="If this is the default configuration"),
1517
file_input: Annotated[typer.FileText, typer.Option("--file", "-f", help="JSON file containing configurations, if command line options not used; can be passed as stdin with -, example: -f-")] = None,
1618
):
@@ -21,19 +23,23 @@ def add(
2123
client = ctx.obj["client"]
2224

2325
if file_input:
24-
if alias or api_key or is_default or host:
25-
raise typer.BadParameter("When providing a custom event definition file, do not specify any other custom event attributes")
26+
if alias or host or username or password or tenant_id or is_default:
27+
raise typer.BadParameter("When providing a prometheus definition file, do not specify any other attributes")
2628
data = json.loads("".join([line for line in file_input]))
2729
else:
30+
2831
data = {
2932
"alias": alias,
30-
"apiKey": api_key,
3133
"host": host,
32-
"isDefault": is_default,
34+
"username": username,
35+
"password": password,
36+
"tenant_id": tenant_id,
37+
"is_default": is_default
3338
}
3439

35-
# remove any data elements that are None - can only be is_default
36-
data = {k: v for k, v in data.items() if v is not None}
40+
for k, v in data.items():
41+
if v is None:
42+
raise typer.BadParameter("Missing required parameter: " + k)
3743

3844
r = client.post("api/v1/prometheus/configuration", data=data)
3945
print_json(data=r)
@@ -51,7 +57,7 @@ def add_multiple(
5157

5258
data = json.loads("".join([line for line in file_input]))
5359

54-
r = client.put("api/v1/aws/configurations", data=data)
60+
r = client.put("api/v1/prometheus/configurations", data=data)
5561
print_json(data=r)
5662

5763
@app.command()

0 commit comments

Comments
 (0)