diff --git a/docs/records.md b/docs/records.md index 1bfc7fd..9b494cf 100644 --- a/docs/records.md +++ b/docs/records.md @@ -174,6 +174,6 @@ In the above example each name had a single record, but there are cases where a ### Record data -Each record type has a corresponding set of required data. The easiest way to determine what's required is probably to look at the record object in [`octodns/record.py`](/octodns/record.py). You may also utilize `octodns-validate` which will throw errors about what's missing when run. +Each record type has a corresponding set of required data. The easiest way to determine what's required is probably to look at the record object in [`octodns/record/__init__.py`](/octodns/record/__init__.py). You may also utilize `octodns-validate` which will throw errors about what's missing when run. `type` is required for all records. `ttl` is optional. When TTL is not specified the `YamlProvider`'s default will be used. In any situation where an array of `values` can be used you can opt to go with `value` as a single item if there's only one. diff --git a/octodns/record/__init__.py b/octodns/record/__init__.py index ff162df..dca6100 100644 --- a/octodns/record/__init__.py +++ b/octodns/record/__init__.py @@ -714,6 +714,8 @@ class _TargetValue(object): @classmethod def process(self, value): + if value: + return value.lower() return value diff --git a/script/bootstrap b/script/bootstrap index 7a82923..b9ba803 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -4,7 +4,7 @@ set -e -cd "$(dirname $0)"/.. +cd "$(dirname "$0")"/.. ROOT=$(pwd) if [ -z "$VENV_NAME" ]; then @@ -13,9 +13,9 @@ fi if [ ! -d "$VENV_NAME" ]; then if [ -z "$VENV_PYTHON" ]; then - VENV_PYTHON=`which python` + VENV_PYTHON=$(command -v python) fi - virtualenv --python=$VENV_PYTHON $VENV_NAME + virtualenv --python="$VENV_PYTHON" "$VENV_NAME" fi . "$VENV_NAME/bin/activate" diff --git a/script/coverage b/script/coverage index d38a41a..8552eba 100755 --- a/script/coverage +++ b/script/coverage @@ -26,11 +26,11 @@ export DYN_PASSWORD= export DYN_USERNAME= export GOOGLE_APPLICATION_CREDENTIALS= -coverage run --branch --source=octodns --omit=octodns/cmds/* `which nosetests` --with-xunit "$@" +coverage run --branch --source=octodns --omit=octodns/cmds/* "$(command -v nosetests)" --with-xunit "$@" coverage html coverage xml coverage report -coverage report | grep ^TOTAL| grep -qv 100% && { - echo "Incomplete code coverage" +coverage report | grep ^TOTAL | grep -qv 100% && { + echo "Incomplete code coverage" >&2 exit 1 } || echo "Code coverage 100%" diff --git a/script/release b/script/release index 3b64911..dd3e1b1 100755 --- a/script/release +++ b/script/release @@ -2,7 +2,7 @@ set -e -cd "$(dirname $0)"/.. +cd "$(dirname "$0")"/.. ROOT=$(pwd) if [ -z "$VENV_NAME" ]; then @@ -16,10 +16,10 @@ if [ ! -f "$ACTIVATE" ]; then fi . "$ACTIVATE" -VERSION=$(grep __VERSION__ $ROOT/octodns/__init__.py | sed -e "s/.* = '//" -e "s/'$//") +VERSION="$(grep __VERSION__ "$ROOT/octodns/__init__.py" | sed -e "s/.* = '//" -e "s/'$//")" -git tag -s v$VERSION -m "Release $VERSION" -git push origin v$VERSION +git tag -s "v$VERSION" -m "Release $VERSION" +git push origin "v$VERSION" echo "Tagged and pushed v$VERSION" python setup.py sdist twine upload dist/*$VERSION.tar.gz diff --git a/script/sdist b/script/sdist index f244363..1ab0949 100755 --- a/script/sdist +++ b/script/sdist @@ -3,13 +3,13 @@ set -e if ! git diff-index --quiet HEAD --; then - echo "Changes in local directory, commit or clear" + echo "Changes in local directory, commit or clear" >&2 exit 1 fi SHA=$(git rev-parse HEAD) python setup.py sdist -TARBALL=dist/octodns-$SHA.tar.gz -mv dist/octodns-0.*.tar.gz $TARBALL +TARBALL="dist/octodns-$SHA.tar.gz" +mv dist/octodns-0.*.tar.gz "$TARBALL" echo "Created $TARBALL" diff --git a/tests/test_octodns_record.py b/tests/test_octodns_record.py index 4171e80..53bc5e7 100644 --- a/tests/test_octodns_record.py +++ b/tests/test_octodns_record.py @@ -8,8 +8,8 @@ from __future__ import absolute_import, division, print_function, \ from unittest import TestCase from octodns.record import ARecord, AaaaRecord, AliasRecord, CaaRecord, \ - CnameRecord, Create, Delete, GeoValue, MxRecord, NaptrRecord, \ - NaptrValue, NsRecord, Record, SshfpRecord, SpfRecord, SrvRecord, \ + CnameRecord, Create, Delete, GeoValue, MxRecord, NaptrRecord, NaptrValue, \ + NsRecord, PtrRecord, Record, SshfpRecord, SpfRecord, SrvRecord, \ TxtRecord, Update, ValidationError, _Dynamic, _DynamicPool, _DynamicRule from octodns.zone import Zone @@ -27,6 +27,45 @@ class TestRecord(TestCase): }) self.assertEquals('mixedcase', record.name) + def test_alias_lowering_value(self): + upper_record = AliasRecord(self.zone, 'aliasUppwerValue', { + 'ttl': 30, + 'type': 'ALIAS', + 'value': 'GITHUB.COM', + }) + lower_record = AliasRecord(self.zone, 'aliasLowerValue', { + 'ttl': 30, + 'type': 'ALIAS', + 'value': 'github.com', + }) + self.assertEquals(upper_record.value, lower_record.value) + + def test_cname_lowering_value(self): + upper_record = CnameRecord(self.zone, 'CnameUppwerValue', { + 'ttl': 30, + 'type': 'CNAME', + 'value': 'GITHUB.COM', + }) + lower_record = CnameRecord(self.zone, 'CnameLowerValue', { + 'ttl': 30, + 'type': 'CNAME', + 'value': 'github.com', + }) + self.assertEquals(upper_record.value, lower_record.value) + + def test_ptr_lowering_value(self): + upper_record = PtrRecord(self.zone, 'PtrUppwerValue', { + 'ttl': 30, + 'type': 'PTR', + 'value': 'GITHUB.COM', + }) + lower_record = PtrRecord(self.zone, 'PtrLowerValue', { + 'ttl': 30, + 'type': 'PTR', + 'value': 'github.com', + }) + self.assertEquals(upper_record.value, lower_record.value) + def test_a_and_record(self): a_values = ['1.2.3.4', '2.2.3.4'] a_data = {'ttl': 30, 'values': a_values}