-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jonas.bechstein
committed
Feb 16, 2017
0 parents
commit 352ea59
Showing
9 changed files
with
293 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,135 @@ | ||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm | ||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 | ||
|
||
# User-specific stuff: | ||
.idea/**/workspace.xml | ||
.idea/**/tasks.xml | ||
|
||
# Sensitive or high-churn files: | ||
.idea/**/dataSources/ | ||
.idea/**/dataSources.ids | ||
.idea/**/dataSources.xml | ||
.idea/**/dataSources.local.xml | ||
.idea/**/sqlDataSources.xml | ||
.idea/**/dynamic.xml | ||
.idea/**/uiDesigner.xml | ||
|
||
# Gradle: | ||
.idea/**/gradle.xml | ||
.idea/**/libraries | ||
|
||
# Mongo Explorer plugin: | ||
.idea/**/mongoSettings.xml | ||
|
||
## File-based project format: | ||
*.iws | ||
|
||
## Plugin-specific files: | ||
|
||
# IntelliJ | ||
/out/ | ||
|
||
|
||
# mpeltonen/sbt-idea plugin | ||
.idea_modules/ | ||
|
||
# JIRA plugin | ||
atlassian-ide-plugin.xml | ||
|
||
# Crashlytics plugin (for Android Studio and IntelliJ) | ||
com_crashlytics_export_strings.xml | ||
crashlytics.properties | ||
crashlytics-build.properties | ||
fabric.properties | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*,cover | ||
.hypothesis/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# dotenv | ||
.env | ||
|
||
# virtualenv | ||
.venv | ||
venv/ | ||
ENV/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
|
||
# Rope project settings | ||
.ropeproject |
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,3 @@ | ||
#!/bin/sh | ||
|
||
python3 /opt/resource/check.py $@ |
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,31 @@ | ||
#! /usr/bin/env python3 | ||
from jsonschema import Draft4Validator | ||
|
||
import schemas | ||
from concourse_common import common | ||
|
||
|
||
def execute(): | ||
|
||
payload = common.get_payload() | ||
|
||
validation_result = validate(payload) | ||
if validation_result != 0: | ||
return validation_result | ||
|
||
return 0 | ||
|
||
|
||
def validate(payload): | ||
v = Draft4Validator(schemas.checkSchema) | ||
valid = True | ||
|
||
for error in sorted(v.iter_errors(payload), key=str): | ||
common.log(error.message) | ||
valid = False | ||
|
||
return 0 if valid else -1 | ||
|
||
|
||
if __name__ == '__main__': | ||
exit(execute()) |
Empty 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import json | ||
import sys | ||
import tempfile | ||
|
||
|
||
def get_payload(): | ||
payload = json.load(sys.stdin) | ||
_, fname = tempfile.mkstemp() | ||
log("Logging payload to {}".format(fname)) | ||
with open(fname, 'w') as fp: | ||
fp.write(json.dumps(payload)) | ||
log(payload) | ||
return payload | ||
|
||
def log(*args, **kwargs): | ||
print(*args, file=sys.stderr, **kwargs) |
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,32 @@ | ||
import sys | ||
import unittest | ||
from io import StringIO | ||
|
||
from concourse_common import common | ||
|
||
|
||
class CommonTest(unittest.TestCase): | ||
check_payload = ('{"source":{' | ||
'"bucket":"bucketName",' | ||
'"access_key":"apiKey123",' | ||
'"secret_access_key":"secretKey321",' | ||
'"region_name":"eu-west-1",' | ||
'"regexp":"directory_on_s3/release-(.*).tar.gz' | ||
'"},' | ||
'"version":{"version":"version-v1-dev"}}') | ||
|
||
def test_getPayload(self): | ||
put_stdin(self.check_payload) | ||
result = common.get_payload() | ||
self.assertEqual(result['source']['access_key'], "apiKey123") | ||
self.assertEqual(result['source']['secret_access_key'], "secretKey321") | ||
self.assertEqual(result['source']['region_name'], "eu-west-1") | ||
self.assertEqual(result['source']['regexp'], "directory_on_s3/release-(.*).tar.gz") | ||
self.assertEqual(result['version']['version'], "version-v1-dev") | ||
|
||
|
||
def put_stdin(content): | ||
sys.stdin = StringIO(content) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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,3 @@ | ||
#!/bin/sh | ||
|
||
python3 /opt/resource/input.py $@ |
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,3 @@ | ||
#!/bin/sh | ||
|
||
python3 /opt/resource/out.py $@ |
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,70 @@ | ||
checkSchema = { | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"type": "object", | ||
"properties": { | ||
"source": { | ||
"type": "object", | ||
"properties": { | ||
"preFix": { | ||
"type": "string" | ||
}, | ||
|
||
}, | ||
"required": [ | ||
"preFix" | ||
] | ||
}, | ||
"version": { | ||
"type": "object", | ||
"properties": { | ||
"version": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"version" | ||
] | ||
} | ||
}, | ||
"required": [ | ||
"source" | ||
] | ||
} | ||
|
||
outSchema = { | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"type": "object", | ||
"properties": { | ||
"source": { | ||
"type": "object", | ||
"properties": { | ||
"preFix": { | ||
"type": "string" | ||
}, | ||
|
||
}, | ||
"required": [ | ||
"preFix" | ||
] | ||
}, | ||
"names": { | ||
"type": "object", | ||
"properties": { | ||
"default": { | ||
"type": "string" | ||
}, | ||
"heroku": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"default", | ||
"heroku" | ||
] | ||
} | ||
}, | ||
"required": [ | ||
"source", | ||
"names" | ||
] | ||
} |