Skip to content

Commit cb38cab

Browse files
Merge pull request #139 from cortexapps/staging #patch
Fix prometheus add
2 parents 05aa7b1 + 0efadfb commit cb38cab

File tree

6 files changed

+146
-160
lines changed

6 files changed

+146
-160
lines changed

.chglog/CHANGELOG.tpl.md

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

.chglog/config.yml

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

.github/workflows/publish.yml

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
with:
2929
ref: main
3030
fetch-depth: 0
31-
31+
3232
- name: Bump version and push tag
3333
uses: anothrNick/[email protected]
3434
env:
@@ -40,17 +40,19 @@ jobs:
4040
git config --global user.name "GitHub Actions"
4141
git config --global user.email "[email protected]"
4242
43-
- 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
4449
run: |
45-
curl -LO https://github.com/git-chglog/git-chglog/releases/download/v0.15.4/git-chglog_0.15.4_linux_386.tar.gz
46-
tar -xzf git-chglog_0.15.4_linux_386.tar.gz
47-
chmod +x git-chglog
48-
sudo mv git-chglog /usr/local/bin/
49-
git-chglog --version
50+
python -m pip install --upgrade pip
51+
pip install poetry git-changelog
5052
5153
- name: Generate HISTORY.md
5254
run: |
53-
git-chglog -o HISTORY.md
55+
git-changelog > HISTORY.md
5456
cat HISTORY.md
5557
5658
- name: Commit and Push
@@ -63,16 +65,6 @@ jobs:
6365
git push
6466
fi
6567
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:

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)