You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guides/all/humanitec-integration.md
+76-41Lines changed: 76 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,9 +12,12 @@ import HumanitecResourceBlueprint from "/docs/guides/templates/humanitec/_humani
12
12
import HumanitecResourceGraphBlueprint from "/docs/guides/templates/humanitec/_humanitec_resource_graph_blueprint.mdx";
13
13
import HumanitecExporterCacheScript from "/docs/guides/templates/humanitec/_humanitec_exporter_cache.mdx";
14
14
import HumanitecExporterMainScript from "/docs/guides/templates/humanitec/_humanitec_exporter_main.mdx";
15
+
import HumanitecExporterConfig from "/docs/guides/templates/humanitec/_humanitec_exporter_config.mdx";
15
16
import HumanitecExporterRequirements from "/docs/guides/templates/humanitec/_humanitec_exporter_requirements.mdx";
16
17
import HumanitecExporterPortClient from "/docs/guides/templates/humanitec/_humanitec_exporter_port_client.mdx";
17
18
import HumanitecExporterHumanitecClient from "/docs/guides/templates/humanitec/_humanitec_exporter_humanitec_client.mdx";
19
+
import HumanitecExporterCircuitBreaker from "/docs/guides/templates/humanitec/_humanitec_exporter_circuit_breaker.mdx";
20
+
import HumanitecExporterRetryableHttpClient from "/docs/guides/templates/humanitec/_humanitec_exporter_retryable_http_client.mdx";
18
21
import HumanitecGroups from "/docs/guides/templates/humanitec/_humanitec_groups.mdx";
19
22
import HumanitecUsers from "/docs/guides/templates/humanitec/_humanitec_users.mdx";
20
23
import HumanitecPipelines from "/docs/guides/templates/humanitec/_humanitec_pipelines.mdx";
@@ -29,7 +32,7 @@ import HumanitecSharedValues from "/docs/guides/templates/humanitec/_humanitec_s
29
32
30
33
This guide demonstrates how to create a GitHub worklow integration to facilitate the ingestion of Humanitec applications, environments, workloads, resources, resource graphs, pipelines, deployment deltas, deployment sets, secret stores, shared values, value set versions, users, groups into your Port catalog on schedule.
@@ -52,38 +55,37 @@ As a first step, you need to create blueprint definitions in Port for the Humani
52
55
1. Go to the [Builder](https://app.getport.io/settings/data-model/data-model) page in your Port organization.
53
56
2. Click on the **+ Blueprint** button at the top of the page.
54
57
3. Click on `{...} Edit JSON` button at the top right corner.
55
-
4. Copyand paste the following blueprint JSON into the editor, repeating the process for each blueprint:
58
+
4. Copy, paste and save the following blueprints JSON into the editor, repeating the process for each blueprint:
56
59
57
-
<HumanitecApplicationBlueprint/>
60
+
<HumanitecApplicationBlueprint/>
58
61
59
-
<HumanitecEnvironmentBlueprint/>
62
+
<HumanitecEnvironmentBlueprint/>
60
63
61
-
<HumanitecWorkloadBlueprint/>
64
+
<HumanitecWorkloadBlueprint/>
62
65
63
-
<HumanitecResourceGraphBlueprint/>
66
+
<HumanitecResourceGraphBlueprint/>
64
67
65
-
<HumanitecResourceBlueprint/>
68
+
<HumanitecResourceBlueprint/>
66
69
67
-
<HumanitecSecretStores/>
70
+
<HumanitecSecretStores/>
68
71
69
-
<HumanitecSharedValues/>
72
+
<HumanitecSharedValues/>
70
73
71
-
<HumanitecValueSetVersions/>
74
+
<HumanitecValueSetVersions/>
72
75
73
-
<HumanitecDeploymentSets/>
76
+
<HumanitecDeploymentSets/>
74
77
75
-
<HumanitecPipelines/>
78
+
<HumanitecPipelines/>
76
79
77
-
<HumanitecDeploymentDeltas/>
80
+
<HumanitecDeploymentDeltas/>
78
81
79
-
<HumanitecUsers/>
82
+
<HumanitecUsers/>
80
83
81
-
<HumanitecGroups/>
84
+
<HumanitecGroups/>
82
85
83
-
84
-
:::tip Blueprint Properties
85
-
You may select the blueprints depending on what you want to track in your Humanitec account.
86
-
:::
86
+
:::tip Blueprint selection
87
+
You should select the blueprints depending on what you want to track in your Humanitec account.
88
+
:::
87
89
88
90
## Set up the integration
89
91
@@ -103,58 +105,90 @@ In your GitHub repository, [go to **Settings > Secrets**](https://docs.github.co
103
105
104
106
1. Create the following Python files in a folder named `integration` at the base directory of your GitHub repository:
105
107
-`main.py` - Orchestrates the synchronization of data from Humanitec to Port, ensuring that resource entities are accurately mirrored and updated on your Port catalog.
106
-
-`requirements.txt` - This file contains the dependencies or necessary external packages need to run the integration
107
108
109
+
Add the following code to the `main.py` file:
110
+
<details>
111
+
<summary><b>Main Executable Script (Click to expand)</b></summary>
108
112
113
+
<HumanitecExporterMainScript/>
109
114
110
-
<details>
111
-
<summary><b>Main Executable Script (Click to expand)</b></summary>
115
+
</details>
116
+
117
+
-`config.py` - Contains the configuration constants for the integration, including cache TTL, connection pooling, and other settings.
112
118
113
-
<HumanitecExporterMainScript/>
119
+
Add the following code to the `config.py` file:
120
+
<details>
121
+
<summary><b>Config (Click to expand)</b></summary>
114
122
115
-
</details>
123
+
<HumanitecExporterConfig/>
116
124
125
+
</details>
126
+
-`requirements.txt` - This file contains the dependencies or necessary external packages need to run the integration
117
127
118
-
<details>
119
-
<summary><b>Requirements (Click to expand)</b></summary>
128
+
Add the following code to the `requirements.txt` file:
129
+
<details>
130
+
<summary><b>Requirements (Click to expand)</b></summary>
120
131
121
-
<HumanitecExporterRequirements/>
132
+
<HumanitecExporterRequirements/>
122
133
123
-
</details>
134
+
</details>
124
135
125
136
126
137
2. Create the following Python files in a folder named `clients` at the base directory of the `integration` folder:
138
+
127
139
-`port_client.py` – Manages authentication and API requests to Port, facilitating the creation and updating of entities within Port's system.
140
+
141
+
Add the following code to the `port_client.py` file:
142
+
<details>
143
+
<summary><b>Port Client (Click to expand)</b></summary>
144
+
145
+
<HumanitecExporterPortClient/>
146
+
147
+
</details>
128
148
-`humanitec_client.py` – Handles API interactions with Humanitec, including retrieving data with caching mechanisms to optimize performance.
149
+
150
+
Add the following code to the `humanitec_client.py` file:
151
+
<details>
152
+
<summary><b>Humanitec Client (Click to expand)</b></summary>
153
+
154
+
<HumanitecExporterHumanitecClient/>
155
+
156
+
</details>
129
157
-`cache.py` - Provides an in-memory caching mechanism with thread-safe operations for setting, retrieving, and deleting cache entries asynchronously.
130
158
131
-
<details>
132
-
<summary><b>Port Client (Click to expand)</b></summary>
159
+
Add the following code to the `cache.py` file:
160
+
<details>
161
+
<summary><b>Cache (Click to expand)</b></summary>
162
+
163
+
<HumanitecExporterCacheScript/>
133
164
134
-
<HumanitecExporterPortClient/>
165
+
</details>
166
+
-`circuit_breaker.py` - Implements a circuit breaker pattern to handle transient failures in API calls, preventing cascading failures and improving the reliability of the integration.
135
167
136
-
</details>
168
+
Add the following code to the `circuit_breaker.py` file:
169
+
<details>
170
+
<summary><b>Circuit Breaker (Click to expand)</b></summary>
137
171
138
-
<details>
139
-
<summary><b>Humanitec Client (Click to expand)</b></summary>
172
+
<HumanitecExporterCircuitBreaker/>
140
173
141
-
<HumanitecExporterHumanitecClient/>
174
+
</details>
175
+
-`retryable_http_client.py` - Provides a retryable HTTP client with exponential backoff and jitter to handle failed API calls due to disonnected HTTP connections.
142
176
143
-
</details>
177
+
Add the following code to the `retryable_http_client.py` file:
178
+
<details>
179
+
<summary><b>Retryable HTTP Client (Click to expand)</b></summary>
144
180
181
+
<HumanitecExporterRetryableHttpClient/>
145
182
146
-
<details>
147
-
<summary><b>Cache (Click to expand)</b></summary>
183
+
</details>
148
184
149
-
<HumanitecExporterCacheScript/>
150
185
151
-
</details>
152
186
153
187
### Create the GitHub workflow
154
188
155
189
Create the file `.github/workflows/humanitec-exporter.yaml` in the `.github/workflows` folder of your repository.
156
190
157
-
:::tip Cron
191
+
:::tip Cron expression
158
192
Adjust the cron expression to fit your schedule. By default, the workflow is set to run at 2:00 AM every Monday ('0 2 * * 1').
159
193
:::
160
194
@@ -199,6 +233,7 @@ jobs:
199
233
200
234
</details>
201
235
236
+
## Conclusion
202
237
203
238
Done! Any change that happens to your application, environment, workloads, resources, resource graphs, pipelines, deployment deltas, deployment sets, secret stores, shared values, value set versions, users, groups in Humanitec will be synced to Port on the schedule interval defined in the GitHub workflow.
0 commit comments