Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ jobs:
# the publish workflow runs..
- name: Install git-chglog
run: |
GIT_CHGLOG_VERSION="0.15.4"
curl -LO https://github.com/git-chglog/git-chglog/releases/download/v${GIT_CHGLOG_VERSION}/git-chglog_linux_amd64.tar.gz
tar -xzf git-chglog_linux_amd64.tar.gz
curl -LO https://github.com/git-chglog/git-chglog/releases/download/v0.15.4/git-chglog_0.15.4_linux_386.tar.gz
tar -xzf git-chglog_0.15.4_linux_386.tar.gz
chmod +x git-chglog
sudo mv git-chglog /usr/local/bin/
git-chglog --version
Expand Down
40 changes: 19 additions & 21 deletions cortexapps_cli/commands/integrations_commands/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,64 +35,62 @@ def add(
# remove any data elements that are None - can only be is_default
data = {k: v for k, v in data.items() if v is not None}

r = client.post("api/v1/github/configuration", data=data)
r = client.post("api/v1/github/configurations/app", data=data)
print_json(data=r)

@app.command()
def add_multiple(
def delete(
ctx: typer.Context,
file_input: Annotated[typer.FileText, typer.Option("--file", "-f", help="JSON file containing configurations; can be passed as stdin with -, example: -f-")] = None,
alias: str = typer.Option(..., "--alias", "-a", help="The alias of the configuration"),
):
"""
Add multiple configurations
Delete a configuration
"""

client = ctx.obj["client"]

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

r = client.put("api/v1/aws/configurations", data=data)
r = client.delete("api/v1/github/configurations/app/" + alias)
print_json(data=r)

@app.command()
def delete(
def delete_all(
ctx: typer.Context,
alias: str = typer.Option(..., "--alias", "-a", help="The alias of the configuration"),
):
"""
Delete a configuration
Delete all configurations
"""

client = ctx.obj["client"]

r = client.delete("api/v1/github/configuration/" + alias)
r = client.delete("api/v1/github/configurations")
print_json(data=r)

@app.command()
def delete_all(
def get(
ctx: typer.Context,
alias: str = typer.Option(..., "--alias", "-a", help="The alias of the configuration"),
):
"""
Delete all configurations
Get a single app configuration
"""

client = ctx.obj["client"]

r = client.delete("api/v1/github/configurations")
r = client.get("api/v1/github/configurations/app/" + alias)
print_json(data=r)

@app.command()
def get(
def get_personal(
ctx: typer.Context,
alias: str = typer.Option(..., "--alias", "-a", help="The alias of the configuration"),
):
"""
Get a configuration
Get a personal configuration
"""

client = ctx.obj["client"]

r = client.get("api/v1/github/configuration/" + alias)
r = client.get("api/v1/github/configurations/personal/" + alias)
print_json(data=r)

@app.command()
Expand Down Expand Up @@ -129,7 +127,7 @@ def update(
is_default: bool = typer.Option(False, "--is-default", "-i", help="If this is the default configuration"),
):
"""
Update a configuration
Update a single app configuration
"""

client = ctx.obj["client"]
Expand All @@ -139,7 +137,7 @@ def update(
"isDefault": is_default
}

r = client.put("api/v1/github/configuration/" + alias, data=data)
r = client.put("api/v1/github/configurations/app/" + alias, data=data)
print_json(data=r)

@app.command()
Expand All @@ -153,7 +151,7 @@ def validate(

client = ctx.obj["client"]

r = client.post("api/v1/github/configurations/validate" + alias)
r = client.post("api/v1/github/configurations/validate/" + alias)
print_json(data=r)

@app.command()
Expand All @@ -166,7 +164,7 @@ def validate_all(

client = ctx.obj["client"]

r = client.post("api/v1/github/configurations")
r = client.post("api/v1/github/configurations/validate")
print_json(data=r)

@app.command()
Expand Down
23 changes: 11 additions & 12 deletions tests/test_integrations_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,12 @@ def _dummy_file(tmp_path):

@responses.activate
def test_integrations_github_add():
responses.add(responses.POST, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configuration", json={}, status=200)
responses.add(responses.POST, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations/app", json={}, status=200)
cli(["integrations", "github", "add", "-a", "myAlias", "-h", "my.host.com", "--api-key", "123456", "-i"])

@responses.activate
def test_integrations_github_add_multiple(tmp_path):
f = _dummy_file(tmp_path)
responses.add(responses.POST, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations", json={}, status=200)
cli(["integrations", "github", "add-multiple", "-f", str(f)])

@responses.activate
def test_integrations_github_delete():
responses.add(responses.DELETE, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configuration/test", status=200)
responses.add(responses.DELETE, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations/app/test", status=200)
cli(["integrations", "github", "delete", "-a", "test"])

@responses.activate
Expand All @@ -30,7 +24,7 @@ def test_integrations_github_delete_all():

@responses.activate
def test_integrations_github_get():
responses.add(responses.GET, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configuration/test", json={}, status=200)
responses.add(responses.GET, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configuration/app/test", json={}, status=200)
cli(["integrations", "github", "get", "-a", "test"])

@responses.activate
Expand All @@ -45,17 +39,17 @@ def test_integrations_github_get_default():

@responses.activate
def test_integrations_github_update():
responses.add(responses.PUT, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configuration/test", json={}, status=200)
responses.add(responses.PUT, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations/app/test", json={}, status=200)
cli(["integrations", "github", "update", "-a", "test", "-i"])

@responses.activate
def test_integrations_github_validate():
responses.add(responses.POST, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configuration/validate/test", json={}, status=200)
responses.add(responses.POST, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations/validate/test", json={}, status=200)
cli(["integrations", "github", "validate", "-a", "test"])

@responses.activate
def test_integrations_github_validate_all():
responses.add(responses.POST, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configuration/validate", json={}, status=200)
responses.add(responses.POST, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations/validate", json={}, status=200)
cli(["integrations", "github", "validate-all"])

@responses.activate
Expand All @@ -68,6 +62,11 @@ def test_integrations_github_update_personal():
responses.add(responses.PUT, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations/personal/test", json={}, status=200)
cli(["integrations", "github", "update-personal", "-a", "test", "-i"])

@responses.activate
def test_integrations_github_get_personal():
responses.add(responses.GET, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations/personal/test", json={}, status=200)
cli(["integrations", "github", "get", "-a", "test"])

@responses.activate
def test_integrations_github_delete_personal():
responses.add(responses.DELETE, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations/personal/test", status=200)
Expand Down