Skip to content

Commit

Permalink
gitignore + init copypasterhino
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas.bechstein committed Feb 16, 2017
0 parents commit 352ea59
Show file tree
Hide file tree
Showing 9 changed files with 293 additions and 0 deletions.
135 changes: 135 additions & 0 deletions .gitignore
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
3 changes: 3 additions & 0 deletions opt/resource/check
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

python3 /opt/resource/check.py $@
31 changes: 31 additions & 0 deletions opt/resource/check.py
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.
16 changes: 16 additions & 0 deletions opt/resource/concourse_common/common.py
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)
32 changes: 32 additions & 0 deletions opt/resource/concourse_common/common_tests.py
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()
3 changes: 3 additions & 0 deletions opt/resource/in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

python3 /opt/resource/input.py $@
3 changes: 3 additions & 0 deletions opt/resource/out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

python3 /opt/resource/out.py $@
70 changes: 70 additions & 0 deletions opt/resource/schemas.py
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"
]
}

0 comments on commit 352ea59

Please sign in to comment.