From 0cd47428eefc652cdacf47ac0649712551c68435 Mon Sep 17 00:00:00 2001 From: Yaeli Gimelshtein Date: Sun, 22 Dec 2024 02:56:35 -0800 Subject: [PATCH] [Core] Extend ocean new cli command (#1255) # Description fixed the flow of the ocean new command since it was not working properly by getting all data needed from the user and filling it out for him, and added debug file ## Type of change Please leave one option from the following and delete the rest: - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] Documentation (added/updated documentation)

All tests should be run against the port production environment(using a testing org).

### Core testing checklist - [ ] Integration able to create all default resources from scratch - [ ] Resync finishes successfully - [ ] Resync able to create entities - [ ] Resync able to update entities - [ ] Resync able to detect and delete entities - [ ] Scheduled resync able to abort existing resync and start a new one - [ ] Tested with at least 2 integrations from scratch - [ ] Tested with Kafka and Polling event listeners - [ ] Tested deletion of entities that don't pass the selector ### Integration testing checklist - [ ] Integration able to create all default resources from scratch - [ ] Resync able to create entities - [ ] Resync able to update entities - [ ] Resync able to detect and delete entities - [ ] Resync finishes successfully - [ ] If new resource kind is added or updated in the integration, add example raw data, mapping and expected result to the `examples` folder in the integration directory. - [ ] If resource kind is updated, run the integration with the example data and check if the expected result is achieved - [ ] If new resource kind is added or updated, validate that live-events for that resource are working as expected - [ ] Docs PR link [here](#) ### Preflight checklist - [ ] Handled rate limiting - [ ] Handled pagination - [ ] Implemented the code in async - [ ] Support Multi account ## Screenshots Include screenshots from your environment showing how the resources of the integration will look. ## API Documentation Provide links to the API documentation used for this integration. --------- Co-authored-by: Matan <51418643+matan84@users.noreply.github.com> --- .vscode/launch.json | 11 +++++++++ CHANGELOG.md | 6 +++++ .../docs/getting-started/getting-started.md | 23 ++++++++++++------- port_ocean/cli/commands/new.py | 11 ++++----- port_ocean/cli/cookiecutter/cookiecutter.json | 3 +++ .../.env.example | 8 +++++-- port_ocean/debug_cli.py | 5 ++++ pyproject.toml | 2 +- 8 files changed, 51 insertions(+), 18 deletions(-) create mode 100644 port_ocean/debug_cli.py diff --git a/.vscode/launch.json b/.vscode/launch.json index 9c29bec36b..ee22cd0a3d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -98,6 +98,17 @@ "python": "${workspaceFolder}/integrations/backstage/.venv/bin/python", "request": "launch", "type": "debugpy" + }, + { + "console": "integratedTerminal", + "cwd": "${workspaceFolder}/port_ocean/cli", + "justMyCode": true, + "name": "Run ocean new command", + "program": "${workspaceFolder}/port_ocean/debug_cli.py", + "python": "${workspaceFolder}/.venv/bin/python", + "request": "launch", + "type": "debugpy", + "args": ["new"] } ] } diff --git a/CHANGELOG.md b/CHANGELOG.md index 292aad97b6..3d745fb814 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.15.3 (2024-12-22) + +### Bug Fixes + +- Extended `Ocean new` cli command to fill out more information for the user and also fixed wrong output + ## 0.15.2 (2024-12-15) diff --git a/docs/framework-guides/docs/getting-started/getting-started.md b/docs/framework-guides/docs/getting-started/getting-started.md index e8d03355f0..d84960274b 100644 --- a/docs/framework-guides/docs/getting-started/getting-started.md +++ b/docs/framework-guides/docs/getting-started/getting-started.md @@ -44,18 +44,25 @@ $ straw@hat.com release_date [2023-08-06]: $ 2023-08-06 +is_private_integration [y/n] (y): +$ n -🌊 Ahoy, Captain! Your project is ready to set sail into the vast ocean of possibilities! -Here are your next steps: +port_client_id (you can find it using: https://docs.getport.io/build-your-software-catalog/custom-integration/api/#find-your-port-credentials): +$ + +port_client_secret (you can find it using: https://docs.getport.io/build-your-software-catalog/custom-integration/api/#find-your-port-credentials): +$ -⚓️ Install necessary packages: Run make install to install all required packages for your project. -▶️ cd ./my_integration && make install && . .venv/bin/activate +is_us_region [y/n] (n): +$ y -⚓️ Set sail with Ocean: Run ocean sail to run the project using Ocean. -▶️ ocean sail ./my_integration +🌊 Ahoy, Captain! Your project is ready to set sail into the vast ocean of possibilities! +Here are your next steps: -⚓️ Smooth sailing with Make: Alternatively, you can run make run to launch your project using Make. -▶️ make run ./my_integration +⚓️ Install necessary packages: Run cd ./my_integration && make install && . .venv/bin/activate to install all required packages for your project. +⚓️ Copy example env file: Run cp .env.example .env and update your integration's configuration in the .env file. +⚓️ Set sail with Ocean: Run ocean sail to run the project using Ocean. +⚓️ Smooth sailing with Make: Alternatively, you can run make run ./my_integration to launch your project using Make. ```
diff --git a/port_ocean/cli/commands/new.py b/port_ocean/cli/commands/new.py index c8422a714f..0c39bdef87 100644 --- a/port_ocean/cli/commands/new.py +++ b/port_ocean/cli/commands/new.py @@ -77,18 +77,15 @@ def new(path: str, is_private_integration: bool) -> None: ) console.print("Here are your next steps:\n", style="bold") console.print( - "⚓️ Install necessary packages: Run [bold][blue]make install[/blue][/bold] to install all required packages for your project.\n" - f"▶️ [bold][blue]cd {path}/{name} && make install && . .venv/bin/activate[/blue][/bold]\n" + f"⚓️ Install necessary packages: Run [bold][blue]cd {path}/{name} && make install && . .venv/bin/activate[/blue][/bold] to install all required packages for your project." ) console.print( - f"⚓️ Copy example env file: Run [bold][blue]cp {path}/{name}.env.example {path}/{name}/.env [/blue][/bold] and set your port credentials in the created file.\n" + "⚓️ Copy example env file: Run [bold][blue]cp .env.example .env [/blue][/bold] and update your integration's configuration in the .env file." ) console.print( - "⚓️ Set sail with [blue]Ocean[/blue]: Run [bold][blue]ocean sail[/blue] [/bold] to run the project using Ocean.\n" - f"▶️ [bold][blue]ocean sail {path}/{name}[/blue][/bold] \n" + "⚓️ Set sail with [blue]Ocean[/blue]: Run [bold][blue]ocean sail[/blue][/bold] to run the project using Ocean." ) if not final_private_integration: console.print( - "⚓️ Smooth sailing with [blue]Make[/blue]: Alternatively, you can run [bold][blue]make run[/blue][/bold] to launch your project using Make. \n" - f"▶️ [bold][blue]make run {path}/{name}[/blue][/bold]" + f"⚓️ Smooth sailing with [blue]Make[/blue]: Alternatively, you can run [bold][blue]make run {path}/{name}[/blue][/bold] to launch your project using Make." ) diff --git a/port_ocean/cli/cookiecutter/cookiecutter.json b/port_ocean/cli/cookiecutter/cookiecutter.json index 7d15761a22..0cfd649ad9 100644 --- a/port_ocean/cli/cookiecutter/cookiecutter.json +++ b/port_ocean/cli/cookiecutter/cookiecutter.json @@ -6,6 +6,9 @@ "email": "Your address email ", "release_date": "{% now 'local' %}", "is_private_integration": true, + "port_client_id": "you can find it using: https://docs.getport.io/build-your-software-catalog/custom-integration/api/#find-your-port-credentials", + "port_client_secret": "you can find it using: https://docs.getport.io/build-your-software-catalog/custom-integration/api/#find-your-port-credentials", + "is_us_region": false, "_extensions": [ "jinja2_time.TimeExtension", "extensions.VersionExtension" diff --git a/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/.env.example b/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/.env.example index 263a38a9c0..37caa46948 100644 --- a/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/.env.example +++ b/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/.env.example @@ -1,2 +1,6 @@ -OCEAN__PORT__CLIENT_ID="" -OCEAN__PORT__CLIENT_SECRET="" +OCEAN__PORT__CLIENT_ID={{ cookiecutter.port_client_id }} +OCEAN__PORT__CLIENT_SECRET={{ cookiecutter.port_client_secret }} +OCEAN__INTEGRATION__IDENTIFIER={{ cookiecutter.integration_slug }} +OCEAN__PORT__BASE_URL={% if cookiecutter.is_us_region %}https://api.us.getport.io{% else %}https://api.getport.io{% endif %} +OCEAN__EVENT_LISTENER__TYPE=POLLING +OCEAN__INITIALIZE_PORT_RESOURCES=true diff --git a/port_ocean/debug_cli.py b/port_ocean/debug_cli.py new file mode 100644 index 0000000000..1f5a7c3072 --- /dev/null +++ b/port_ocean/debug_cli.py @@ -0,0 +1,5 @@ +from port_ocean.cli.commands.main import cli_start + + +if __name__ == "__main__": + cli_start() diff --git a/pyproject.toml b/pyproject.toml index e94fed2990..2a57a18ccc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "port-ocean" -version = "0.15.2" +version = "0.15.3" description = "Port Ocean is a CLI tool for managing your Port projects." readme = "README.md" homepage = "https://app.getport.io"