-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: command line args via yargs, docs
- added --config and --validate command line flags via yargs. These will allow custom user configurations with a default behaviour of loading from the current working dir and/or default settings. --validate uses JSON Schema to validate the config. - Remove old X.509 certificate and private key, which I assume was included previously to run git-proxy with TLS enabled via a demo. Can be re-added as needed but probably shouldn't be included in src (even if its for demo only). - bumped Nodejs workflow to 16.x - update docs to reflect new CLI args and additional details of running the app via npx - update test to reflect new config file setting
- Loading branch information
1 parent
fd7bc16
commit eef3f88
Showing
13 changed files
with
194 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ jobs: | |
|
||
strategy: | ||
matrix: | ||
node-version: [13.x] | ||
node-version: [16.x] | ||
mongodb-version: [4.4] | ||
|
||
steps: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,13 +48,42 @@ Git Proxy is built with a developer-first mindset. By presenting simple-to-follo | |
To install Git Proxy, use the [npm](https://www.npmjs.com/) package manager: | ||
|
||
```bash | ||
$ npm install @finos/git-proxy | ||
$ npm install -g @finos/git-proxy | ||
$ git-proxy | ||
``` | ||
|
||
To install a specific version of Git Proxy, append the version to the end of the `install` command: | ||
|
||
```bash | ||
$ npm install @finos/[email protected] | ||
$ npm install -g @finos/[email protected] | ||
``` | ||
|
||
You can also run directly using `npx`: | ||
|
||
```bash | ||
$ npx @finos/git-proxy | ||
``` | ||
|
||
## Configuration | ||
By default, git-proxy ships with a [default configuration](./proxy.config.json) for demonstration purposes. In most environments, this should be overridden by your user-specific values. | ||
|
||
To set your own values, create a `proxy.config.json` in the current working directory. This will be loaded when you execute `git-proxy` if present. | ||
|
||
If you wish to specify a different file location to use as configuration, use the `-c/--config` command-line argument: | ||
|
||
```bash | ||
$ git-proxy --config /etc/gitproxy/config.json | ||
# With npx | ||
$ npx -- git-proxy --config /etc/gitproxy/config.json | ||
``` | ||
|
||
### Validation | ||
To valid your configuration against the [included schema](config.schema.json), use the following included script: | ||
|
||
```bash | ||
$ git-proxy --validate | ||
# Check a custom file location | ||
$ git-proxy --validate --config /etc/gitproxy/config.json | ||
``` | ||
|
||
## Contributing | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"$id": "https://git-proxy.finos.org/config.schema.json", | ||
"title": "Git Proxy", | ||
"description": "Configuration file for modifying the behaviour of git-proxy", | ||
"type": "object", | ||
"properties": { | ||
"authorisedList": { | ||
"description": "List of repositories that are authorised to be pushed to through the proxy.", | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/$defs/authorisedRepo" | ||
} | ||
}, | ||
"sink": { | ||
"description": "List of database sources. The first source in the configuration with enabled=true will be used.", | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/$defs/database" | ||
} | ||
}, | ||
"authentication": { | ||
"description": "List of authentication sources. The first source in the configuration with enabled=true will be used.", | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/$defs/authentication" | ||
} | ||
}, | ||
"tempPassword": { | ||
"description": "Toggle the generation of temporary password for git-proxy admin user", | ||
"type": "object", | ||
"properties": { | ||
"sendEmail": { "type": "boolean" }, | ||
"emailConfig": { | ||
"description": "Generic object to configure nodemailer. For full type information, please see https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/nodemailer", | ||
"type": "object" | ||
} | ||
} | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"anyOf": [ | ||
{ "required": "authorisedList" }, | ||
{ "required": "sink" }, | ||
{ "required": "authentication" }, | ||
{ "required": "tempPassword" } | ||
], | ||
"$defs": { | ||
"authorisedRepo": { | ||
"type": "object", | ||
"properties": { | ||
"project": { "type": "string" }, | ||
"name": { "type": "string" }, | ||
"url": { "type": "string" } | ||
}, | ||
"required": [ "project", "name", "url" ] | ||
}, | ||
"database": { | ||
"type": "object", | ||
"properties": { | ||
"type": { "type": "string" }, | ||
"enabled": { "type": "boolean" }, | ||
"connectionString": { "type": "string" }, | ||
"options": { "type": "object" }, | ||
"params": { "type": "object" } | ||
}, | ||
"required": [ "type", "enabled" ] | ||
}, | ||
"authentication": { | ||
"type": "object", | ||
"properties": { | ||
"type": { "type": "string" }, | ||
"enabled": { "type": "boolean" }, | ||
"options": { "type": "object" } | ||
}, | ||
"required": [ "type", "enabled" ] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const path = require('path'); | ||
// eslint-disable-next-line prefer-const | ||
let configFile = undefined; | ||
|
||
module.exports = { | ||
get configFile() { | ||
return configFile | ||
? configFile | ||
: path.join(process.cwd(), 'proxy.config.json'); | ||
}, | ||
set configFile(file) { | ||
configFile = file; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ "authorisedList": [ { "project": "foo", "name": "bar", "url": "https://github.com/foo/bar.git" } ] } |