@itentialopensource/adapter-git 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +6 -0
- package/.eslintrc.js +18 -0
- package/.gitlab/.gitkeep +0 -0
- package/.gitlab/issue_templates/.gitkeep +0 -0
- package/.gitlab/issue_templates/Default.md +17 -0
- package/.gitlab/issue_templates/bugReportTemplate.md +76 -0
- package/.gitlab/issue_templates/featureRequestTemplate.md +14 -0
- package/.jshintrc +3 -0
- package/CHANGELOG.md +9 -0
- package/CODE_OF_CONDUCT.md +48 -0
- package/CONTRIBUTING.md +172 -0
- package/LICENSE +201 -0
- package/README.md +231 -0
- package/adapter.js +562 -0
- package/error.json +178 -0
- package/package.json +70 -0
- package/pronghorn.json +239 -0
- package/propertiesSchema.json +53 -0
- package/refs?service=git-upload-pack +0 -0
- package/sampleProperties.json +18 -0
- package/test/integration/adapterTestIntegration.js +318 -0
- package/test/unit/adapterTestUnit.js +629 -0
- package/utils/artifactize.js +146 -0
- package/utils/packModificationScript.js +35 -0
- package/utils/pre-commit.sh +27 -0
- package/utils/setup.js +33 -0
- package/utils/testRunner.js +298 -0
package/README.md
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# Git Adapter
|
|
2
|
+
|
|
3
|
+
This adapter is used to perform Git operations without needing to install Git on the machine. It can be used with a variety of Git services, including GitHub, GitLab, and Bitbucket. This ReadMe file is intended to provide information on this adapter.
|
|
4
|
+
|
|
5
|
+
Itential provides information on all of its product adapters in the Customer Knowledge Base. Information in the [Customer Knowledge Base](https://itential.atlassian.net/servicedesk/customer/portals) is consistently maintained and goes through documentation reviews. As a result, it should be the first place to go for information.
|
|
6
|
+
|
|
7
|
+
For custom built adapters, it is a starting point to understand what you have built, provide the information for you to be able to update the adapter, and assist you with deploying the adapter into IAP.
|
|
8
|
+
|
|
9
|
+
## Versioning
|
|
10
|
+
|
|
11
|
+
Itential Product and opensource adapters utilize SemVer for versioning. The current version of the adapter can be found in the `package.json` file or viewed in the IAP GUI on the System page. All Itential opensource adapters can be found in the <a href="https://gitlab.com/itentialopensource/adapters" target="_blank">Itential OpenSource Repository</a>.
|
|
12
|
+
|
|
13
|
+
Any release prior to 1.0.0 is a pre-release. Initial builds of adapters are generally set up as pre-releases as there is often work that needs to be done to configure the adapter and make sure the authentication process to Bitbucket_server works appropriately.
|
|
14
|
+
|
|
15
|
+
Release notes can be viewed in CHANGELOG.md or in the <a href="https://itential.atlassian.net/servicedesk/customer/portals" target="_blank">Customer Knowledge Base</a> for Itential adapters.
|
|
16
|
+
|
|
17
|
+
## Supported IAP Versions
|
|
18
|
+
|
|
19
|
+
Itential Product adapters are built for particular versions of IAP and packaged with the versions they work with.
|
|
20
|
+
|
|
21
|
+
Itential opensource adapter as well as custom adapters built with the Itential Adapter Builder work acoss many releases of IAP. As a result, it is not often necessary to modify an adapter when upgrading IAP. If IAP has changes that impact the pronghorn.json, like adding a new required section, this will most likely require changes to all adapters when upgrading IAP.
|
|
22
|
+
|
|
23
|
+
Many of the scripts that come with all adapters built using the Itential Adapter Builder do have some dependencies on IAP or the IAP database schema and so it is possible these scripts could stop working in different versions of IAP. If you notify Itential of any issues, the Adapter Team will attempt to fix the scripts for newer releases of IAP.
|
|
24
|
+
|
|
25
|
+
## Getting Started
|
|
26
|
+
|
|
27
|
+
These instructions will help you get a copy of the project on your local machine for development and testing. Reading this section is also helpful for deployments as it provides you with pertinent information on prerequisites and properties.
|
|
28
|
+
|
|
29
|
+
### Helpful Background Information
|
|
30
|
+
|
|
31
|
+
There is adapter documentation available on the Itential Developer Site <a href="https://www.itential.com/automation-platform/integrations/adapters-resources/" target="_blank">HERE</a>. This documentation includes information and examples that are helpful for:
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
Authentication
|
|
35
|
+
Properties
|
|
36
|
+
Code Files
|
|
37
|
+
Action Files
|
|
38
|
+
Schema Files
|
|
39
|
+
Mock Data Files
|
|
40
|
+
Linting and Testing
|
|
41
|
+
Troubleshooting
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Others will be added over time.
|
|
45
|
+
Want to build a new adapter? Use the <a href="https://adapters.itential.io" target="_blank">Itential Adapter Builder</a>
|
|
46
|
+
|
|
47
|
+
### Prerequisites
|
|
48
|
+
|
|
49
|
+
The following is a list of required packages for installation on the system the adapter will run on:
|
|
50
|
+
|
|
51
|
+
```text
|
|
52
|
+
Node.js
|
|
53
|
+
npm
|
|
54
|
+
Git
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The following list of packages are required for Itential opensource adapters or custom adapters that have been built utilizing the Itential Adapter Builder. You can install these packages by running npm install inside the adapter directory.
|
|
58
|
+
|
|
59
|
+
<table border="1" class="bordered-table">
|
|
60
|
+
<tr>
|
|
61
|
+
<th bgcolor="lightgrey" style="padding:15px"><span style="font-size:12.0pt">Package</span></th>
|
|
62
|
+
<th bgcolor="lightgrey" style="padding:15px"><span style="font-size:12.0pt">Description</span></th>
|
|
63
|
+
</tr>
|
|
64
|
+
<tr>
|
|
65
|
+
<td style="padding:15px">@itentialopensource/adapter-utils</td>
|
|
66
|
+
<td style="padding:15px">Runtime library classes for all adapters; includes request handling, connection, authentication throttling, and translation.</td>
|
|
67
|
+
</tr>
|
|
68
|
+
<tr>
|
|
69
|
+
<td style="padding:15px">fs-extra</td>
|
|
70
|
+
<td style="padding:15px">Utilized by the node scripts that are included with the adapter; helps to build and extend the functionality.</td>
|
|
71
|
+
</tr>
|
|
72
|
+
<tr>
|
|
73
|
+
<td style="padding:15px">mocha</td>
|
|
74
|
+
<td style="padding:15px">Testing library that is utilized by some of the node scripts that are included with the adapter.</td>
|
|
75
|
+
</tr>
|
|
76
|
+
<tr>
|
|
77
|
+
<td style="padding:15px">mocha-param</td>
|
|
78
|
+
<td style="padding:15px">Testing library that is utilized by some of the node scripts that are included with the adapter.</td>
|
|
79
|
+
</tr>
|
|
80
|
+
<tr>
|
|
81
|
+
<td style="padding:15px">readline-sync</td>
|
|
82
|
+
<td style="padding:15px">Utilized by the node script that comes with the adapter; helps to test unit and integration functionality.</td>
|
|
83
|
+
</tr>
|
|
84
|
+
</table>
|
|
85
|
+
<br>
|
|
86
|
+
|
|
87
|
+
If you are developing and testing a custom adapter, or have testing capabilities on an Itential opensource adapter, you will need to install these packages as well.
|
|
88
|
+
|
|
89
|
+
```text
|
|
90
|
+
chai
|
|
91
|
+
eslint
|
|
92
|
+
eslint-config-airbnb-base
|
|
93
|
+
eslint-plugin-import
|
|
94
|
+
eslint-plugin-json
|
|
95
|
+
package-json-validator
|
|
96
|
+
testdouble
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Specific Prerequisites
|
|
100
|
+
|
|
101
|
+
At the current time the Git adapter does not utilize the adapter utilities as it makes use of the following library instead.
|
|
102
|
+
|
|
103
|
+
<table border="1" class="bordered-table">
|
|
104
|
+
<tr>
|
|
105
|
+
<th bgcolor="lightgrey" style="padding:15px"><span style="font-size:12.0pt">Package</span></th>
|
|
106
|
+
<th bgcolor="lightgrey" style="padding:15px"><span style="font-size:12.0pt">Description</span></th>
|
|
107
|
+
</tr>
|
|
108
|
+
<tr>
|
|
109
|
+
<td style="padding:15px">isomorphic-git</td>
|
|
110
|
+
<td style="padding:15px">Javascript implementation of Git</td>
|
|
111
|
+
</tr>
|
|
112
|
+
</table>
|
|
113
|
+
<br>
|
|
114
|
+
|
|
115
|
+
### How to Install
|
|
116
|
+
|
|
117
|
+
1. Set up the name space location in your IAP node_modules.
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
cd /opt/pronghorn/current/node_modules (* could be in a different place)
|
|
121
|
+
if the @itentialopensource directory does not exist, create it:
|
|
122
|
+
mkdir @itentialopensource
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
2. Clone/unzip/tar the adapter into your IAP environment.
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
cd \@itentialopensource
|
|
129
|
+
git clone git@gitlab.com:\@itentialopensource/adapters/adapter-git
|
|
130
|
+
or
|
|
131
|
+
unzip adapter-gitr.zip
|
|
132
|
+
or
|
|
133
|
+
tar -xvf adapter-git.tar
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
3. Run the adapter install script.
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
cd adapter-git
|
|
140
|
+
npm run adapter:install
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
4. Restart IAP
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
systemctl restart pronghorn
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
5. Change the adapter service instance configuration (host, port, credentials, etc) in IAP Admin Essentials GUI
|
|
150
|
+
|
|
151
|
+
npm run adapter:install can be dependent on where the adapter is installed and on the version of IAP so it is subject to fail. If this happens you can replace step 3-5 above with these:
|
|
152
|
+
|
|
153
|
+
3. Install adapter dependencies and check the adapter.
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
cd adapter-git
|
|
157
|
+
npm run install
|
|
158
|
+
npm run lint:errors
|
|
159
|
+
npm run test
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
4. Restart IAP
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
systemctl restart pronghorn
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
5. Create an adapter service instance configuration in IAP Admin Essentials GUI
|
|
169
|
+
|
|
170
|
+
6. Copy the properties from the sampleProperties.json and paste them into the service instance configuration in the inner/second properties field.
|
|
171
|
+
|
|
172
|
+
7. Change the adapter service instance configuration (host, port, credentials, etc) in IAP Admin Essentials GUI
|
|
173
|
+
|
|
174
|
+
#### Unit Testing
|
|
175
|
+
|
|
176
|
+
Unit Testing includes testing basic adapter functionality as well as error conditions that are triggered in the adapter prior to any integration. There are two ways to run unit tests. The prefered method is to use the testRunner script; however, both methods are provided here.
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
node utils/testRunner --unit
|
|
180
|
+
|
|
181
|
+
npm run test:unit
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
To add new unit tests, edit the `test/unit/adapterTestUnit.js` file. The tests that are already in this file should provide guidance for adding additional tests.
|
|
185
|
+
|
|
186
|
+
### Integration Testing - Standalone
|
|
187
|
+
|
|
188
|
+
Standalone Integration Testing requires mock data to be provided with the entities. If this data is not provided, standalone integration testing will fail. When the adapter is set to run in stub mode (setting the stub property to true), the adapter will run through its code up to the point of making the request. It will then retrieve the mock data and return that as if it had received that data as the response from Git. It will then translate the data so that the adapter can return the expected response to the rest of the Itential software. Standalone is the default integration test.
|
|
189
|
+
|
|
190
|
+
Similar to unit testing, there are two ways to run integration tests. Using the testRunner script is better because it prevents you from having to edit the test script; it will also resets information after testing is complete so that credentials are not saved in the file.
|
|
191
|
+
|
|
192
|
+
```json
|
|
193
|
+
node utils/testRunner
|
|
194
|
+
answer no at the first prompt
|
|
195
|
+
|
|
196
|
+
npm run test:integration
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
To add new integration tests, edit the `test/integration/adapterTestIntegration.js` file. The tests that are already in this file should provide guidance for adding additional tests.
|
|
200
|
+
|
|
201
|
+
### Integration Testing
|
|
202
|
+
|
|
203
|
+
Integration Testing requires connectivity to a Git service. By using the testRunner script it prevents you from having to edit the integration test. It also resets the integration test after the test is complete so that credentials are not saved in the file.
|
|
204
|
+
|
|
205
|
+
> **Note**: These tests have been written as a best effort to make them work in most environments. However, the Adapter Builder often does not have the necessary information that is required to set up valid integration tests. For example, the order of the requests can be very important and data is often required for `creates` and `updates`. Hence, integration tests may have to be enhanced before they will work (integrate) with Git. Even after tests have been set up properly, it is possible there are environmental constraints that could result in test failures. Some examples of possible environmental issues are customizations that have been made within Git which change order dependencies or required data.
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
node utils/testRunner
|
|
209
|
+
answer yes at the first prompt
|
|
210
|
+
answer all other questions on connectivity and credentials
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Test should also be written to clean up after themselves. However, it is important to understand that in some cases this may not be possible. In addition, whenever exceptions occur, test execution may be stopped, which will prevent cleanup actions from running. It is recommended that tests be utilized in dev and test labs only.
|
|
214
|
+
|
|
215
|
+
> **Reminder**: Do not check in code with actual credentials to systems.
|
|
216
|
+
|
|
217
|
+
## Contributing to Git adapter
|
|
218
|
+
|
|
219
|
+
Please check out the [Contributing Guidelines](./CONTRIBUTING.md).
|
|
220
|
+
|
|
221
|
+
## License and Maintainers
|
|
222
|
+
|
|
223
|
+
```text
|
|
224
|
+
Itential Product Adapters are maintained by the Itential Product Team.
|
|
225
|
+
Itential OpenSource Adapters are maintained by the Itential Adapter Team and the community at large.
|
|
226
|
+
Custom Adapters are maintained by other sources.
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Product License
|
|
230
|
+
|
|
231
|
+
[Apache 2.0](./LICENSE)
|