Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Integration][Amplication] add initial version of Amplication integration #1354

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

itainathaniel
Copy link
Contributor

Description

What: This PR introduces an integration that imports Amplication templates, resources (services), and outdated version alerts into Port. The integration provides a seamless way to sync backend services and their metadata generated by Amplication into Port's service catalog. In addition, there's a self service action which creates an Amplication resource using a webhook.

Why: This integration was built to bridge the gap between backend service creation (Amplication) and infrastructure management (Port). By enabling automatic imports and alerts, it centralizes service metadata for better organization and visibility and saves time by automating manual data entry and tracking. By automating scaffolding using Amplication via Port, the developer can create consistent and standard boilerplate and foundation.

How: By using the catalog API endpoint, we imported the templates and resources. By using the outdatedVersionAlerts endpoint, we imported the alerts. By making relations between templates, resources and alerts, we can show everything in bright colours.

Type of change

Please leave one option from the following and delete the rest:

  • New Integration (non-breaking change which adds a new integration)

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

templates index with their resource_count
Screenshot 2025-01-26 at 17 09 44

template entity with its resources
Screenshot 2025-01-26 at 17 10 35

resource entity with its alerts
Screenshot 2025-01-26 at 17 11 48

Creating an Amplication service from template action
Screenshot 2025-01-26 at 17 08 04

API Documentation

Since we're using GraphQL, the API documentation can be found in our GraphQL Playground, in our sandbox server. We use two queries, catalog and outdatedVersionAlerts and you can find their docs in the DOCS button to the right side of the page.

Copy link
Contributor

@omby8888 omby8888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! please address those changes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for this file, we manage the image build from a singular Dockerfile under integrations/_infra

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for this file

"method": "POST",
"headers": {
"RUN_ID": "{{ .run.id }}",
"authorization": "Bearer {{ .secrets.amplication_token }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will not work, as .secrets.* is a context of Port organization's managed secrets rather than the integration's env params. as for now, this token ingestion needs to be done manually

Suggested change
"authorization": "Bearer {{ .secrets.amplication_token }}"
"authorization": "Bearer <YourAmplicationToken>"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@omby8888 I'm sorry, but I don't follow. I see an example to this comment in GitLab's integration:

"url": "https://gitlab.com/api/v4/projects/<YourGitlabProject>/ref/main/trigger/pipeline?token=<YourGitlabToken>"

but it means users which install Amplication's integration will have to go to the two self-service actions and add the token there, instead of going to the Manage secrets panel, like the suggestion in the Edit Action's Backend tab:

Configure the invocation payload

The following values ... You can reference secrets using {{ .secrets["secret-name"] }}

It actually work for us now with our sandbox, so this is why I'm confused.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, looks like when installing an integration, the token requested in spec.yaml (the field[s] with the sensitive: true value) are saved as secrets automatically, so I could access them with _<INTEGRATION_NAME>_<CONFIGURATION_SPEC_NAME>, right?

"method": "POST",
"headers": {
"RUN_ID": "{{ .run.id }}",
"authorization": "Bearer {{ .secrets.amplication_token }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

@@ -0,0 +1,57 @@
createMissingRelatedEntities: True

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove break line

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for this file

@@ -0,0 +1,113 @@
[tool.poetry]
name = "amplication"
version = "0.1.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make it beta for now please

Suggested change
version = "0.1.0"
version = "0.1.0-beta"

headers=await self.auth_headers,
)
response.raise_for_status()
return response.json()["data"]["catalog"]["data"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add safeguards here please

headers=await self.auth_headers,
)
response.raise_for_status()
return response.json()["data"]["outdatedVersionAlerts"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

headers=await self.auth_headers,
)
response.raise_for_status()
return response.json()["data"]["catalog"]["data"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

@itainathaniel
Copy link
Contributor Author

Thanks @omby8888 , I fixed most of the stuff you asked, the only open issue is the use of {{ .secrets }} in the actions.json file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants