sphinx-confluence-relay 0.0.0__tar.gz
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.
- sphinx_confluence_relay-0.0.0/LICENSE +22 -0
- sphinx_confluence_relay-0.0.0/LICENSE-3RD-PARTY +115 -0
- sphinx_confluence_relay-0.0.0/PKG-INFO +290 -0
- sphinx_confluence_relay-0.0.0/README.md +264 -0
- sphinx_confluence_relay-0.0.0/pyproject.toml +44 -0
- sphinx_confluence_relay-0.0.0/sphinx-confluence-relay.toml.default +62 -0
- sphinx_confluence_relay-0.0.0/sphinx_confluence_relay/__init__.py +4 -0
- sphinx_confluence_relay-0.0.0/sphinx_confluence_relay/__main__.py +209 -0
- sphinx_confluence_relay-0.0.0/sphinx_confluence_relay/app.py +192 -0
- sphinx_confluence_relay-0.0.0/sphinx_confluence_relay/cache.py +73 -0
- sphinx_confluence_relay-0.0.0/sphinx_confluence_relay/defs.py +84 -0
- sphinx_confluence_relay-0.0.0/sphinx_confluence_relay/description.md +66 -0
- sphinx_confluence_relay-0.0.0/sphinx_confluence_relay/health.py +32 -0
- sphinx_confluence_relay-0.0.0/sphinx_confluence_relay/logger.py +54 -0
- sphinx_confluence_relay-0.0.0/sphinx_confluence_relay/main.py +10 -0
- sphinx_confluence_relay-0.0.0/sphinx_confluence_relay/maintenance.py +77 -0
- sphinx_confluence_relay-0.0.0/sphinx_confluence_relay/manifest.py +351 -0
- sphinx_confluence_relay-0.0.0/sphinx_confluence_relay/models.py +118 -0
- sphinx_confluence_relay-0.0.0/sphinx_confluence_relay/process.py +177 -0
- sphinx_confluence_relay-0.0.0/sphinx_confluence_relay/publish.py +938 -0
- sphinx_confluence_relay-0.0.0/sphinx_confluence_relay/py.typed +0 -0
- sphinx_confluence_relay-0.0.0/sphinx_confluence_relay/routes.py +319 -0
- sphinx_confluence_relay-0.0.0/sphinx_confluence_relay/settings.py +312 -0
- sphinx_confluence_relay-0.0.0/sphinx_confluence_relay/state.py +22 -0
- sphinx_confluence_relay-0.0.0/sphinx_confluence_relay/static/favicon.png +0 -0
- sphinx_confluence_relay-0.0.0/sphinx_confluence_relay/static/scr.css +13 -0
- sphinx_confluence_relay-0.0.0/sphinx_confluence_relay/static/vendor/swagger-ui-bundle.js +2 -0
- sphinx_confluence_relay-0.0.0/sphinx_confluence_relay/static/vendor/swagger-ui-bundle.js.LICENSE.txt +106 -0
- sphinx_confluence_relay-0.0.0/sphinx_confluence_relay/static/vendor/swagger-ui.css +3 -0
- sphinx_confluence_relay-0.0.0/sphinx_confluence_relay/swagger.py +40 -0
- sphinx_confluence_relay-0.0.0/sphinx_confluence_relay/token.py +73 -0
- sphinx_confluence_relay-0.0.0/sphinx_confluence_relay/validate.py +246 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright 2026 jdknight
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without modification,
|
|
4
|
+
are permitted provided that the following conditions are met:
|
|
5
|
+
|
|
6
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
7
|
+
list of conditions and the following disclaimer.
|
|
8
|
+
|
|
9
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
and/or other materials provided with the distribution.
|
|
12
|
+
|
|
13
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
14
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
15
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
16
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
17
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
18
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
19
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
20
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
21
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
22
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
Licenses for incorporated software
|
|
2
|
+
==================================
|
|
3
|
+
|
|
4
|
+
----------------------------------------------------------------------
|
|
5
|
+
|
|
6
|
+
Embedded Swagger UI Bundle
|
|
7
|
+
|
|
8
|
+
----------------------------------------------------------------------
|
|
9
|
+
|
|
10
|
+
/*!
|
|
11
|
+
Copyright (c) 2018 Jed Watson.
|
|
12
|
+
Licensed under the MIT License (MIT), see
|
|
13
|
+
http://jedwatson.github.io/classnames
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/*!
|
|
17
|
+
* @description Recursive object extending
|
|
18
|
+
* @author Viacheslav Lotsmanov <lotsmanov89@gmail.com>
|
|
19
|
+
* @license MIT
|
|
20
|
+
*
|
|
21
|
+
* The MIT License (MIT)
|
|
22
|
+
*
|
|
23
|
+
* Copyright (c) 2013-2018 Viacheslav Lotsmanov
|
|
24
|
+
*
|
|
25
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
26
|
+
* this software and associated documentation files (the "Software"), to deal in
|
|
27
|
+
* the Software without restriction, including without limitation the rights to
|
|
28
|
+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
29
|
+
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
30
|
+
* subject to the following conditions:
|
|
31
|
+
*
|
|
32
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
33
|
+
* copies or substantial portions of the Software.
|
|
34
|
+
*
|
|
35
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
36
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
37
|
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
38
|
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
39
|
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
40
|
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/*!
|
|
44
|
+
* The buffer module from node.js, for the browser.
|
|
45
|
+
*
|
|
46
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
47
|
+
* @license MIT
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
/*!
|
|
51
|
+
* https://github.com/Starcounter-Jack/JSON-Patch
|
|
52
|
+
* (c) 2017-2021 Joachim Wester
|
|
53
|
+
* MIT license
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
/*!
|
|
57
|
+
* https://github.com/Starcounter-Jack/JSON-Patch
|
|
58
|
+
* (c) 2017-2022 Joachim Wester
|
|
59
|
+
* MIT licensed
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
/*!
|
|
63
|
+
* repeat-string <https://github.com/jonschlinkert/repeat-string>
|
|
64
|
+
*
|
|
65
|
+
* Copyright (c) 2014-2015, Jon Schlinkert.
|
|
66
|
+
* Licensed under the MIT License.
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
/*! @license DOMPurify 3.4.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.0/LICENSE */
|
|
70
|
+
|
|
71
|
+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
72
|
+
|
|
73
|
+
/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */
|
|
74
|
+
|
|
75
|
+
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @license React
|
|
79
|
+
* react-dom.production.min.js
|
|
80
|
+
*
|
|
81
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
82
|
+
*
|
|
83
|
+
* This source code is licensed under the MIT license found in the
|
|
84
|
+
* LICENSE file in the root directory of this source tree.
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @license React
|
|
89
|
+
* react.production.min.js
|
|
90
|
+
*
|
|
91
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
92
|
+
*
|
|
93
|
+
* This source code is licensed under the MIT license found in the
|
|
94
|
+
* LICENSE file in the root directory of this source tree.
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* @license React
|
|
99
|
+
* scheduler.production.min.js
|
|
100
|
+
*
|
|
101
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
102
|
+
*
|
|
103
|
+
* This source code is licensed under the MIT license found in the
|
|
104
|
+
* LICENSE file in the root directory of this source tree.
|
|
105
|
+
*/
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @license React
|
|
109
|
+
* use-sync-external-store-with-selector.production.js
|
|
110
|
+
*
|
|
111
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
112
|
+
*
|
|
113
|
+
* This source code is licensed under the MIT license found in the
|
|
114
|
+
* LICENSE file in the root directory of this source tree.
|
|
115
|
+
*/
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sphinx-confluence-relay
|
|
3
|
+
Version: 0.0.0
|
|
4
|
+
Summary: Publish service for Confluence Sphinx Documentation Manifests
|
|
5
|
+
Requires-Python: >=3.11
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: Environment :: Web Environment
|
|
9
|
+
Classifier: Framework :: FastAPI
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Classifier: Topic :: Documentation
|
|
17
|
+
Classifier: Topic :: Documentation :: Sphinx
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
License-File: LICENSE-3RD-PARTY
|
|
20
|
+
Requires-Dist: apscheduler
|
|
21
|
+
Requires-Dist: fastapi[standard]
|
|
22
|
+
Requires-Dist: sqlmodel
|
|
23
|
+
Project-URL: Download, https://pypi.python.org/pypi/sphinx-confluence-relay
|
|
24
|
+
Project-URL: Source, https://github.com/jdknight/sphinx-confluence-relay
|
|
25
|
+
|
|
26
|
+
# Sphinx Confluence Relay
|
|
27
|
+
|
|
28
|
+
[](https://pypi.python.org/pypi/sphinx-confluence-relay)
|
|
29
|
+
[](https://github.com/jdknight/sphinx-confluence-relay/actions/workflows/build.yml)
|
|
30
|
+
|
|
31
|
+
## Overview
|
|
32
|
+
|
|
33
|
+
The project provides the ability to create a "relay" service that accepts
|
|
34
|
+
generated manifest files from
|
|
35
|
+
[Atlassian Confluence Builder for Sphinx][confluencebuilder] and publish
|
|
36
|
+
them to a pre-configured Confluence Data Center instance (Confluence Cloud
|
|
37
|
+
is not supported). Using such a service allows system administrators to setup
|
|
38
|
+
publish relaying where users do not need to expose their Confluence tokens.
|
|
39
|
+
|
|
40
|
+
## Requirements
|
|
41
|
+
|
|
42
|
+
* [Python][python] 3.11+
|
|
43
|
+
* [APScheduler][apscheduler]
|
|
44
|
+
* [FastAPI][fastapi]
|
|
45
|
+
* [SQLModel][sqlmodel]
|
|
46
|
+
|
|
47
|
+
# Usage
|
|
48
|
+
|
|
49
|
+
Users of a running service will publish using at least three key components:
|
|
50
|
+
|
|
51
|
+
- A [data-embedded manifest][confluence-manifest-data] generated from
|
|
52
|
+
Atlassian Confluence Builder for Sphinx.
|
|
53
|
+
- The key of a space to publish into.
|
|
54
|
+
- The parent page name/identifier to publish documentation under.
|
|
55
|
+
|
|
56
|
+
A publish event will take a manifest and upload all pages/attachments into
|
|
57
|
+
a given target space. After pages/attachments are uploaded, any legacy content
|
|
58
|
+
hosted on Confluence will be removed. Publication and removals are contained
|
|
59
|
+
to the descendants of the configured parent page. Requests that would require
|
|
60
|
+
moving pages in a space into the parent page's descendants will be ignored.
|
|
61
|
+
|
|
62
|
+
Publish events are queued. The service can accept multiple requests and will
|
|
63
|
+
process them in a first-in-first-out (FIFO) order. Pages/attachments are only
|
|
64
|
+
uploaded if required (i.e. changed).
|
|
65
|
+
|
|
66
|
+
Users may use the REST interface of a hosted service utilizing any common
|
|
67
|
+
tools (e.g. [curl][curl]). Alternatively, if this package is installed on a
|
|
68
|
+
client system, users may utilize the publish helper tool:
|
|
69
|
+
|
|
70
|
+
```none
|
|
71
|
+
sphinx-confluence-relay-publish --help
|
|
72
|
+
(or)
|
|
73
|
+
python -m sphinx_confluence_relay --help
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
For example:
|
|
77
|
+
|
|
78
|
+
```none
|
|
79
|
+
sphinx-confluence-relay-publish http://upload.wiki.example.com/ --space-key MYSPACE --parent-page Documentation
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
If a manifest file is not provided via the `--manifest` argument, the default
|
|
83
|
+
paths searched for will be:
|
|
84
|
+
|
|
85
|
+
```none
|
|
86
|
+
scb-manifest.json
|
|
87
|
+
(or)
|
|
88
|
+
_build/confluence/scb-manifest.json
|
|
89
|
+
(or)
|
|
90
|
+
_build/singleconfluence/scb-manifest.json
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
If a system administrator has configured authentication requirements, a token
|
|
94
|
+
can be passed a couple of ways. The utility accepts a token value from the
|
|
95
|
+
environment:
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
SPHINX_CONFLUENCE_RELAY_PUBLISH_TOKEN
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Passed in using the standard input stream with `--password-stdin`:
|
|
102
|
+
|
|
103
|
+
```none
|
|
104
|
+
cat ~/.token | sphinx-confluence-relay-publish ... --password-stdin
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Or passed in using the `--token` argument:
|
|
108
|
+
|
|
109
|
+
```none
|
|
110
|
+
sphinx-confluence-relay-publish ... --token <TOKEN>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
# Service Installation
|
|
114
|
+
|
|
115
|
+
## Configuration
|
|
116
|
+
|
|
117
|
+
The relay service relies on a TOML configuration file. A template of this
|
|
118
|
+
configuration can be found in the root of this repository:
|
|
119
|
+
|
|
120
|
+
```none
|
|
121
|
+
sphinx-confluence-relay.toml.default
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
A system administrator will typically prepare a `sphinx-confluence-relay.toml`
|
|
125
|
+
file on a host. sphinx-confluence-relay will search for configurations found
|
|
126
|
+
in the following paths:
|
|
127
|
+
|
|
128
|
+
```none
|
|
129
|
+
sphinx-confluence-relay.toml
|
|
130
|
+
(or)
|
|
131
|
+
/etc/sphinx-confluence-relay.toml (non-Windows)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
A bare minimum configuration required is the configuration of the Confluence
|
|
135
|
+
Data Center API URL and the token that will be used for REST interaction:
|
|
136
|
+
|
|
137
|
+
```toml
|
|
138
|
+
[sphinx-confluence-relay]
|
|
139
|
+
confluence-url = 'https://wiki.example.com/rest/api/'
|
|
140
|
+
confluence-token = ''
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
If a system administrator wishes to require tokens for publish requests,
|
|
144
|
+
they can register one or more tokens in a `publish-tokens` option:
|
|
145
|
+
|
|
146
|
+
```toml
|
|
147
|
+
publish-tokens = [
|
|
148
|
+
'SOME_TOKEN',
|
|
149
|
+
]
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
By default, all spaces the Confluence token can access could be published to.
|
|
153
|
+
If an environment is looking to restrict only publishing to specific pages,
|
|
154
|
+
individual spaces can be populated in a `spaces` option:
|
|
155
|
+
|
|
156
|
+
```toml
|
|
157
|
+
spaces = [
|
|
158
|
+
'MYSPACE',
|
|
159
|
+
]
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
For additional advanced options, refer to the template configuration.
|
|
163
|
+
|
|
164
|
+
## Manual Service Setup
|
|
165
|
+
|
|
166
|
+
System administrators may manually setup using the following instructions.
|
|
167
|
+
Adjusts paths to desired preferences.
|
|
168
|
+
|
|
169
|
+
Build a path to hold packages:
|
|
170
|
+
|
|
171
|
+
```none
|
|
172
|
+
mkdir /opt/sphinx-confluence-relay
|
|
173
|
+
cd /opt/sphinx-confluence-relay
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Create a virtual environment:
|
|
177
|
+
|
|
178
|
+
```none
|
|
179
|
+
python -m venv .venv
|
|
180
|
+
source .venv/bin/activate
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Install this service using [pip][pip]:
|
|
184
|
+
|
|
185
|
+
```none
|
|
186
|
+
pip install sphinx-confluence-relay
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Place the prepare configuration file in the local directory with the name:
|
|
190
|
+
|
|
191
|
+
```none
|
|
192
|
+
sphinx-confluence-relay.toml
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Run this service:
|
|
196
|
+
|
|
197
|
+
```none
|
|
198
|
+
uvicorn sphinx_confluence_relay.main:app --host 0.0.0.0 --port 8080
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Docker
|
|
202
|
+
|
|
203
|
+
This project supports multiple ways to use this utility inside a Docker
|
|
204
|
+
environment. A recommended choice is to use a pre-built image available
|
|
205
|
+
from GitHub's container registry.
|
|
206
|
+
|
|
207
|
+
### Pre-built image
|
|
208
|
+
|
|
209
|
+
A pre-built image can be acquired using the following command:
|
|
210
|
+
|
|
211
|
+
```none
|
|
212
|
+
docker pull ghcr.io/jdknight/sphinx-confluence-relay
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
On the host what will run Docker, copy the configuration file into this path:
|
|
216
|
+
|
|
217
|
+
```none
|
|
218
|
+
/etc/sphinx-confluence-relay.toml
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Ensure the path is available for holding a database of queued requests and
|
|
222
|
+
status information:
|
|
223
|
+
|
|
224
|
+
```none
|
|
225
|
+
/var/lib/sphinx-confluence-relay/
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
The container than can be run using the following command:
|
|
229
|
+
|
|
230
|
+
```none
|
|
231
|
+
docker run --name sphinx-confluence-relay --detach --restart unless-stopped \
|
|
232
|
+
-p 8080:8080 \
|
|
233
|
+
-v /etc/sphinx-confluence-relay.toml:/etc/sphinx-confluence-relay.toml:ro \
|
|
234
|
+
-v /var/lib/sphinx-confluence-relay/:/database.db \
|
|
235
|
+
ghcr.io/jdknight/sphinx-confluence-relay
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Self-built image
|
|
239
|
+
|
|
240
|
+
Users who wish to manage their own image can do so with the Docker
|
|
241
|
+
definitions found inside this repository. This can be done by cloning
|
|
242
|
+
this repository on the host wanting to run the container. A Docker
|
|
243
|
+
build can be run using:
|
|
244
|
+
|
|
245
|
+
```none
|
|
246
|
+
docker build -t ghcr.io/jdknight/sphinx-confluence-relay \
|
|
247
|
+
--detach -f docker/Dockerfile .
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Then running the same `docker run` call mentioned above.
|
|
251
|
+
|
|
252
|
+
### Self-managed Docker Compose
|
|
253
|
+
|
|
254
|
+
Users can also take advantage of the Docker compose definition. For a
|
|
255
|
+
working directory to hold Docker Compose content, ensure a settings file
|
|
256
|
+
is setup:
|
|
257
|
+
|
|
258
|
+
```none
|
|
259
|
+
sphinx-confluence-relay.toml
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
Next, load up the container using `docker compose`:
|
|
263
|
+
|
|
264
|
+
```none
|
|
265
|
+
docker compose build
|
|
266
|
+
docker compose up --detach
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Both Docker build calls will by default load a container with the
|
|
270
|
+
PyPI version of sphinx-confluence-relay. Users wanting to use the local
|
|
271
|
+
implementation in their container can do so by performing a Docker build
|
|
272
|
+
with the `--build-arg local` argument.
|
|
273
|
+
|
|
274
|
+
For example:
|
|
275
|
+
|
|
276
|
+
```none
|
|
277
|
+
docker compose build --build-arg BUILD_MODE=local
|
|
278
|
+
docker compose up --detach
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
[apscheduler]: https://apscheduler.readthedocs.io/
|
|
283
|
+
[confluence-manifest-data]: https://sphinxcontrib-confluencebuilder.readthedocs.io/configuration/#confval-confluence_manifest_data
|
|
284
|
+
[confluencebuilder]: https://sphinxcontrib-confluencebuilder.readthedocs.io/
|
|
285
|
+
[curl]: https://curl.se/
|
|
286
|
+
[fastapi]: https://fastapi.tiangolo.com/
|
|
287
|
+
[pip]: https://pip.pypa.io/
|
|
288
|
+
[python]: https://www.python.org/
|
|
289
|
+
[sqlmodel]: https://sqlmodel.tiangolo.com/
|
|
290
|
+
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
# Sphinx Confluence Relay
|
|
2
|
+
|
|
3
|
+
[](https://pypi.python.org/pypi/sphinx-confluence-relay)
|
|
4
|
+
[](https://github.com/jdknight/sphinx-confluence-relay/actions/workflows/build.yml)
|
|
5
|
+
|
|
6
|
+
## Overview
|
|
7
|
+
|
|
8
|
+
The project provides the ability to create a "relay" service that accepts
|
|
9
|
+
generated manifest files from
|
|
10
|
+
[Atlassian Confluence Builder for Sphinx][confluencebuilder] and publish
|
|
11
|
+
them to a pre-configured Confluence Data Center instance (Confluence Cloud
|
|
12
|
+
is not supported). Using such a service allows system administrators to setup
|
|
13
|
+
publish relaying where users do not need to expose their Confluence tokens.
|
|
14
|
+
|
|
15
|
+
## Requirements
|
|
16
|
+
|
|
17
|
+
* [Python][python] 3.11+
|
|
18
|
+
* [APScheduler][apscheduler]
|
|
19
|
+
* [FastAPI][fastapi]
|
|
20
|
+
* [SQLModel][sqlmodel]
|
|
21
|
+
|
|
22
|
+
# Usage
|
|
23
|
+
|
|
24
|
+
Users of a running service will publish using at least three key components:
|
|
25
|
+
|
|
26
|
+
- A [data-embedded manifest][confluence-manifest-data] generated from
|
|
27
|
+
Atlassian Confluence Builder for Sphinx.
|
|
28
|
+
- The key of a space to publish into.
|
|
29
|
+
- The parent page name/identifier to publish documentation under.
|
|
30
|
+
|
|
31
|
+
A publish event will take a manifest and upload all pages/attachments into
|
|
32
|
+
a given target space. After pages/attachments are uploaded, any legacy content
|
|
33
|
+
hosted on Confluence will be removed. Publication and removals are contained
|
|
34
|
+
to the descendants of the configured parent page. Requests that would require
|
|
35
|
+
moving pages in a space into the parent page's descendants will be ignored.
|
|
36
|
+
|
|
37
|
+
Publish events are queued. The service can accept multiple requests and will
|
|
38
|
+
process them in a first-in-first-out (FIFO) order. Pages/attachments are only
|
|
39
|
+
uploaded if required (i.e. changed).
|
|
40
|
+
|
|
41
|
+
Users may use the REST interface of a hosted service utilizing any common
|
|
42
|
+
tools (e.g. [curl][curl]). Alternatively, if this package is installed on a
|
|
43
|
+
client system, users may utilize the publish helper tool:
|
|
44
|
+
|
|
45
|
+
```none
|
|
46
|
+
sphinx-confluence-relay-publish --help
|
|
47
|
+
(or)
|
|
48
|
+
python -m sphinx_confluence_relay --help
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
For example:
|
|
52
|
+
|
|
53
|
+
```none
|
|
54
|
+
sphinx-confluence-relay-publish http://upload.wiki.example.com/ --space-key MYSPACE --parent-page Documentation
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
If a manifest file is not provided via the `--manifest` argument, the default
|
|
58
|
+
paths searched for will be:
|
|
59
|
+
|
|
60
|
+
```none
|
|
61
|
+
scb-manifest.json
|
|
62
|
+
(or)
|
|
63
|
+
_build/confluence/scb-manifest.json
|
|
64
|
+
(or)
|
|
65
|
+
_build/singleconfluence/scb-manifest.json
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
If a system administrator has configured authentication requirements, a token
|
|
69
|
+
can be passed a couple of ways. The utility accepts a token value from the
|
|
70
|
+
environment:
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
SPHINX_CONFLUENCE_RELAY_PUBLISH_TOKEN
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Passed in using the standard input stream with `--password-stdin`:
|
|
77
|
+
|
|
78
|
+
```none
|
|
79
|
+
cat ~/.token | sphinx-confluence-relay-publish ... --password-stdin
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Or passed in using the `--token` argument:
|
|
83
|
+
|
|
84
|
+
```none
|
|
85
|
+
sphinx-confluence-relay-publish ... --token <TOKEN>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
# Service Installation
|
|
89
|
+
|
|
90
|
+
## Configuration
|
|
91
|
+
|
|
92
|
+
The relay service relies on a TOML configuration file. A template of this
|
|
93
|
+
configuration can be found in the root of this repository:
|
|
94
|
+
|
|
95
|
+
```none
|
|
96
|
+
sphinx-confluence-relay.toml.default
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
A system administrator will typically prepare a `sphinx-confluence-relay.toml`
|
|
100
|
+
file on a host. sphinx-confluence-relay will search for configurations found
|
|
101
|
+
in the following paths:
|
|
102
|
+
|
|
103
|
+
```none
|
|
104
|
+
sphinx-confluence-relay.toml
|
|
105
|
+
(or)
|
|
106
|
+
/etc/sphinx-confluence-relay.toml (non-Windows)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
A bare minimum configuration required is the configuration of the Confluence
|
|
110
|
+
Data Center API URL and the token that will be used for REST interaction:
|
|
111
|
+
|
|
112
|
+
```toml
|
|
113
|
+
[sphinx-confluence-relay]
|
|
114
|
+
confluence-url = 'https://wiki.example.com/rest/api/'
|
|
115
|
+
confluence-token = ''
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
If a system administrator wishes to require tokens for publish requests,
|
|
119
|
+
they can register one or more tokens in a `publish-tokens` option:
|
|
120
|
+
|
|
121
|
+
```toml
|
|
122
|
+
publish-tokens = [
|
|
123
|
+
'SOME_TOKEN',
|
|
124
|
+
]
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
By default, all spaces the Confluence token can access could be published to.
|
|
128
|
+
If an environment is looking to restrict only publishing to specific pages,
|
|
129
|
+
individual spaces can be populated in a `spaces` option:
|
|
130
|
+
|
|
131
|
+
```toml
|
|
132
|
+
spaces = [
|
|
133
|
+
'MYSPACE',
|
|
134
|
+
]
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
For additional advanced options, refer to the template configuration.
|
|
138
|
+
|
|
139
|
+
## Manual Service Setup
|
|
140
|
+
|
|
141
|
+
System administrators may manually setup using the following instructions.
|
|
142
|
+
Adjusts paths to desired preferences.
|
|
143
|
+
|
|
144
|
+
Build a path to hold packages:
|
|
145
|
+
|
|
146
|
+
```none
|
|
147
|
+
mkdir /opt/sphinx-confluence-relay
|
|
148
|
+
cd /opt/sphinx-confluence-relay
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Create a virtual environment:
|
|
152
|
+
|
|
153
|
+
```none
|
|
154
|
+
python -m venv .venv
|
|
155
|
+
source .venv/bin/activate
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Install this service using [pip][pip]:
|
|
159
|
+
|
|
160
|
+
```none
|
|
161
|
+
pip install sphinx-confluence-relay
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Place the prepare configuration file in the local directory with the name:
|
|
165
|
+
|
|
166
|
+
```none
|
|
167
|
+
sphinx-confluence-relay.toml
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Run this service:
|
|
171
|
+
|
|
172
|
+
```none
|
|
173
|
+
uvicorn sphinx_confluence_relay.main:app --host 0.0.0.0 --port 8080
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Docker
|
|
177
|
+
|
|
178
|
+
This project supports multiple ways to use this utility inside a Docker
|
|
179
|
+
environment. A recommended choice is to use a pre-built image available
|
|
180
|
+
from GitHub's container registry.
|
|
181
|
+
|
|
182
|
+
### Pre-built image
|
|
183
|
+
|
|
184
|
+
A pre-built image can be acquired using the following command:
|
|
185
|
+
|
|
186
|
+
```none
|
|
187
|
+
docker pull ghcr.io/jdknight/sphinx-confluence-relay
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
On the host what will run Docker, copy the configuration file into this path:
|
|
191
|
+
|
|
192
|
+
```none
|
|
193
|
+
/etc/sphinx-confluence-relay.toml
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Ensure the path is available for holding a database of queued requests and
|
|
197
|
+
status information:
|
|
198
|
+
|
|
199
|
+
```none
|
|
200
|
+
/var/lib/sphinx-confluence-relay/
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
The container than can be run using the following command:
|
|
204
|
+
|
|
205
|
+
```none
|
|
206
|
+
docker run --name sphinx-confluence-relay --detach --restart unless-stopped \
|
|
207
|
+
-p 8080:8080 \
|
|
208
|
+
-v /etc/sphinx-confluence-relay.toml:/etc/sphinx-confluence-relay.toml:ro \
|
|
209
|
+
-v /var/lib/sphinx-confluence-relay/:/database.db \
|
|
210
|
+
ghcr.io/jdknight/sphinx-confluence-relay
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Self-built image
|
|
214
|
+
|
|
215
|
+
Users who wish to manage their own image can do so with the Docker
|
|
216
|
+
definitions found inside this repository. This can be done by cloning
|
|
217
|
+
this repository on the host wanting to run the container. A Docker
|
|
218
|
+
build can be run using:
|
|
219
|
+
|
|
220
|
+
```none
|
|
221
|
+
docker build -t ghcr.io/jdknight/sphinx-confluence-relay \
|
|
222
|
+
--detach -f docker/Dockerfile .
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Then running the same `docker run` call mentioned above.
|
|
226
|
+
|
|
227
|
+
### Self-managed Docker Compose
|
|
228
|
+
|
|
229
|
+
Users can also take advantage of the Docker compose definition. For a
|
|
230
|
+
working directory to hold Docker Compose content, ensure a settings file
|
|
231
|
+
is setup:
|
|
232
|
+
|
|
233
|
+
```none
|
|
234
|
+
sphinx-confluence-relay.toml
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Next, load up the container using `docker compose`:
|
|
238
|
+
|
|
239
|
+
```none
|
|
240
|
+
docker compose build
|
|
241
|
+
docker compose up --detach
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
Both Docker build calls will by default load a container with the
|
|
245
|
+
PyPI version of sphinx-confluence-relay. Users wanting to use the local
|
|
246
|
+
implementation in their container can do so by performing a Docker build
|
|
247
|
+
with the `--build-arg local` argument.
|
|
248
|
+
|
|
249
|
+
For example:
|
|
250
|
+
|
|
251
|
+
```none
|
|
252
|
+
docker compose build --build-arg BUILD_MODE=local
|
|
253
|
+
docker compose up --detach
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
[apscheduler]: https://apscheduler.readthedocs.io/
|
|
258
|
+
[confluence-manifest-data]: https://sphinxcontrib-confluencebuilder.readthedocs.io/configuration/#confval-confluence_manifest_data
|
|
259
|
+
[confluencebuilder]: https://sphinxcontrib-confluencebuilder.readthedocs.io/
|
|
260
|
+
[curl]: https://curl.se/
|
|
261
|
+
[fastapi]: https://fastapi.tiangolo.com/
|
|
262
|
+
[pip]: https://pip.pypa.io/
|
|
263
|
+
[python]: https://www.python.org/
|
|
264
|
+
[sqlmodel]: https://sqlmodel.tiangolo.com/
|