[Python-apps-commits] r14083 - in packages/bundlewrap/trunk (12 files)
highvoltage-guest at users.alioth.debian.org
highvoltage-guest at users.alioth.debian.org
Sat May 27 11:57:26 UTC 2017
Date: Saturday, May 27, 2017 @ 11:57:24
Author: highvoltage-guest
Revision: 14083
Update bundlewrap to 2.18.0
Modified:
packages/bundlewrap/trunk/CHANGELOG.md
packages/bundlewrap/trunk/bundlewrap/__init__.py
packages/bundlewrap/trunk/bundlewrap/items/__init__.py
packages/bundlewrap/trunk/bundlewrap/items/postgres_dbs.py
packages/bundlewrap/trunk/bundlewrap/items/users.py
packages/bundlewrap/trunk/bundlewrap/utils/statedict.py
packages/bundlewrap/trunk/bundlewrap/utils/text.py
packages/bundlewrap/trunk/debian/changelog
packages/bundlewrap/trunk/docs/content/items/postgres_db.md
packages/bundlewrap/trunk/docs/content/repo/bundles.md
packages/bundlewrap/trunk/setup.py
packages/bundlewrap/trunk/tests/integration/bw_test.py
Modified: packages/bundlewrap/trunk/CHANGELOG.md
===================================================================
--- packages/bundlewrap/trunk/CHANGELOG.md 2017-05-24 23:24:35 UTC (rev 14082)
+++ packages/bundlewrap/trunk/CHANGELOG.md 2017-05-27 11:57:24 UTC (rev 14083)
@@ -1,3 +1,13 @@
+# 2.18.0
+
+2017-05-22
+
+* added encoding and collation to postgres_db items
+* added the 'comment' attribute for all items
+* fixed group deletion
+* fixed accidental modification of lists in statedicts
+
+
# 2.17.1
2017-04-19
Modified: packages/bundlewrap/trunk/bundlewrap/__init__.py
===================================================================
--- packages/bundlewrap/trunk/bundlewrap/__init__.py 2017-05-24 23:24:35 UTC (rev 14082)
+++ packages/bundlewrap/trunk/bundlewrap/__init__.py 2017-05-27 11:57:24 UTC (rev 14083)
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-VERSION = (2, 17, 1)
+VERSION = (2, 18, 0)
VERSION_STRING = ".".join([str(v) for v in VERSION])
Modified: packages/bundlewrap/trunk/bundlewrap/items/__init__.py
===================================================================
--- packages/bundlewrap/trunk/bundlewrap/items/__init__.py 2017-05-24 23:24:35 UTC (rev 14082)
+++ packages/bundlewrap/trunk/bundlewrap/items/__init__.py 2017-05-27 11:57:24 UTC (rev 14083)
@@ -6,17 +6,20 @@
from __future__ import unicode_literals
from copy import copy
from datetime import datetime
+from inspect import cleandoc
from os.path import join
+from textwrap import TextWrapper
from bundlewrap.exceptions import BundleError, ItemDependencyError, FaultUnavailable
from bundlewrap.utils import cached_property
from bundlewrap.utils.statedict import diff_keys, diff_value, hash_statedict, validate_statedict
from bundlewrap.utils.text import force_text, mark_for_translation as _
-from bundlewrap.utils.text import blue, bold, wrap_question
+from bundlewrap.utils.text import blue, bold, italic, wrap_question
from bundlewrap.utils.ui import io
BUILTIN_ITEM_ATTRIBUTES = {
'cascade_skip': None,
+ 'comment': None,
'needed_by': [],
'needs': [],
'preceded_by': [],
@@ -30,7 +33,22 @@
'when_creating': {},
}
+wrapper = TextWrapper(
+ break_long_words=False,
+ break_on_hyphens=False,
+ expand_tabs=False,
+ replace_whitespace=False,
+)
+
+def format_comment(comment):
+ result = "\n\n"
+ for line in wrapper.wrap(cleandoc(comment)):
+ for inlineline in line.split("\n"):
+ result += "# {}\n".format(italic(inlineline))
+ return result
+
+
class ItemStatus(object):
"""
Holds information on a particular Item such as whether it needs
@@ -455,6 +473,8 @@
keys_to_fix,
)
question_text = self.ask(cdict, sdict, keys_to_fix)
+ if self.comment:
+ question_text += format_comment(self.comment)
question = wrap_question(
self.id,
question_text,
Modified: packages/bundlewrap/trunk/bundlewrap/items/postgres_dbs.py
===================================================================
--- packages/bundlewrap/trunk/bundlewrap/items/postgres_dbs.py 2017-05-24 23:24:35 UTC (rev 14082)
+++ packages/bundlewrap/trunk/bundlewrap/items/postgres_dbs.py 2017-05-27 11:57:24 UTC (rev 14083)
@@ -8,13 +8,30 @@
from bundlewrap.utils.text import force_text, mark_for_translation as _
-def create_db(node, name, owner):
- return node.run("sudo -u postgres createdb -wO {owner} {name}".format(
- name=name,
- owner=owner,
- ))
+def create_db(node, name, owner, when_creating):
+ template = None
+ cmd = "sudo -u postgres createdb -wO {} ".format(owner)
+ if when_creating.get('collation') is not None:
+ cmd += "--lc-collate={} ".format(when_creating['collation'])
+ template = "template0"
+ if when_creating.get('ctype') is not None:
+ cmd += "--lc-ctype={} ".format(when_creating['ctype'])
+ template = "template0"
+
+ if when_creating.get('encoding') is not None:
+ cmd += "--encoding={} ".format(when_creating['encoding'])
+ template = "template0"
+
+ if template is not None:
+ cmd += "--template={} ".format(template)
+
+ cmd += name
+
+ return node.run(cmd)
+
+
def drop_db(node, name):
return node.run("sudo -u postgres dropdb -w {}".format(quote(name)))
@@ -50,6 +67,11 @@
'owner': "postgres",
}
ITEM_TYPE_NAME = "postgres_db"
+ WHEN_CREATING_ATTRIBUTES = {
+ 'collation': None,
+ 'ctype': None,
+ 'encoding': None,
+ }
def __repr__(self):
return "<PostgresDB name:{}>".format(self.name)
@@ -64,7 +86,7 @@
if status.must_be_deleted:
drop_db(self.node, self.name)
elif status.must_be_created:
- create_db(self.node, self.name, self.attributes['owner'])
+ create_db(self.node, self.name, self.attributes['owner'], self.when_creating)
elif 'owner' in status.keys_to_fix:
set_owner(self.node, self.name, self.attributes['owner'])
else:
Modified: packages/bundlewrap/trunk/bundlewrap/items/users.py
===================================================================
--- packages/bundlewrap/trunk/bundlewrap/items/users.py 2017-05-24 23:24:35 UTC (rev 14082)
+++ packages/bundlewrap/trunk/bundlewrap/items/users.py 2017-05-27 11:57:24 UTC (rev 14083)
@@ -145,9 +145,16 @@
def get_auto_deps(self, items):
deps = []
+ groups = self.attributes['groups'] or []
for item in items:
if item.ITEM_TYPE_NAME == "group":
- if item.attributes['delete']:
+ if not (item.name in groups or (
+ self.attributes['gid'] in [item.attributes['gid'], item.name] and
+ self.attributes['gid'] is not None
+ )):
+ # we don't need to depend on this group
+ continue
+ elif item.attributes['delete']:
raise BundleError(_(
"{item1} (from bundle '{bundle1}') depends on item "
"{item2} (from bundle '{bundle2}') which is set to be deleted"
Modified: packages/bundlewrap/trunk/bundlewrap/utils/statedict.py
===================================================================
--- packages/bundlewrap/trunk/bundlewrap/utils/statedict.py 2017-05-24 23:24:35 UTC (rev 14082)
+++ packages/bundlewrap/trunk/bundlewrap/utils/statedict.py 2017-05-27 11:57:24 UTC (rev 14083)
@@ -60,7 +60,9 @@
if isinstance(value1, set):
value1 = sorted(value1)
value2 = sorted(value2)
- elif isinstance(value1, tuple):
+ else:
+ # convert tuples and create copies of lists before possibly
+ # appending stuff later on (see below)
value1 = list(value1)
value2 = list(value2)
# make sure that *if* we have lines, the last one will also end with
Modified: packages/bundlewrap/trunk/bundlewrap/utils/text.py
===================================================================
--- packages/bundlewrap/trunk/bundlewrap/utils/text.py 2017-05-24 23:24:35 UTC (rev 14082)
+++ packages/bundlewrap/trunk/bundlewrap/utils/text.py 2017-05-27 11:57:24 UTC (rev 14083)
@@ -47,6 +47,11 @@
@ansi_wrapper
+def italic(text):
+ return "\033[3m{}\033[0m".format(text)
+
+
+ at ansi_wrapper
def green(text):
return "\033[32m{}\033[0m".format(text)
Modified: packages/bundlewrap/trunk/debian/changelog
===================================================================
--- packages/bundlewrap/trunk/debian/changelog 2017-05-24 23:24:35 UTC (rev 14082)
+++ packages/bundlewrap/trunk/debian/changelog 2017-05-27 11:57:24 UTC (rev 14083)
@@ -1,8 +1,8 @@
-bundlewrap (2.17.1-1) experimental; urgency=medium
+bundlewrap (2.18.0-1) experimental; urgency=medium
* New upstream release
- -- Jonathan Carter <jcarter at linux.com> Wed, 03 May 2017 19:40:19 +0200
+ -- Jonathan Carter <jcarter at linux.com> Sat, 27 May 2017 13:45:15 +0200
bundlewrap (2.17.0-1) unstable; urgency=medium
Modified: packages/bundlewrap/trunk/docs/content/items/postgres_db.md
===================================================================
--- packages/bundlewrap/trunk/docs/content/items/postgres_db.md 2017-05-24 23:24:35 UTC (rev 14082)
+++ packages/bundlewrap/trunk/docs/content/items/postgres_db.md 2017-05-27 11:57:24 UTC (rev 14083)
@@ -5,6 +5,11 @@
postgres_dbs = {
"mydatabase": {
"owner": "me",
+ "when_creating": {
+ "encoding": "LATIN1",
+ "collation": "de_DE.ISO-8859-1",
+ "ctype": "de_DE.ISO-8859-1",
+ },
},
}
@@ -19,3 +24,9 @@
### owner
Name of the role which owns this database (defaults to `"postgres"`).
+
+### encoding, collation, and ctype
+
+By default, BundleWrap will only create a database using your default PostgreSQL template, which most likely is `template1`. This means it will use the same encoding and collation that `template1` uses. By specifying any of the attributes `encoding`, `collation`, or `ctype`, BundleWrap will instead create a new database from `template0`, thus allowing you to override said database attributes.
+
+These options are creation-time only.
Modified: packages/bundlewrap/trunk/docs/content/repo/bundles.md
===================================================================
--- packages/bundlewrap/trunk/docs/content/repo/bundles.md 2017-05-24 23:24:35 UTC (rev 14082)
+++ packages/bundlewrap/trunk/docs/content/repo/bundles.md 2017-05-27 11:57:24 UTC (rev 14083)
@@ -70,6 +70,12 @@
<br>
+### comment
+
+This is a string that will be displayed in interactive mode (`bw apply -i`) whenever the item is to be changed in any way. You can use it to warn users before they start disruptive actions.
+
+<br>
+
### error_on_missing_fault
This will simply skip an item instead of raising an error when a Fault used for an attribute on the item is unavailable. Faults are special objects used by `repo.vault` to [handle secrets](../guide/secrets.md). A Fault being unavailable can mean you're missing the secret key required to decrypt a secret you're trying to use as an item attribute value.
Modified: packages/bundlewrap/trunk/setup.py
===================================================================
--- packages/bundlewrap/trunk/setup.py 2017-05-24 23:24:35 UTC (rev 14082)
+++ packages/bundlewrap/trunk/setup.py 2017-05-27 11:57:24 UTC (rev 14083)
@@ -16,7 +16,7 @@
setup(
name="bundlewrap",
- version="2.17.1",
+ version="2.18.0",
description="Config management with Python",
long_description=(
"By allowing for easy and low-overhead config management, BundleWrap fills the gap between complex deployments using Chef or Puppet and old school system administration over SSH.\n"
Modified: packages/bundlewrap/trunk/tests/integration/bw_test.py
===================================================================
--- packages/bundlewrap/trunk/tests/integration/bw_test.py 2017-05-24 23:24:35 UTC (rev 14082)
+++ packages/bundlewrap/trunk/tests/integration/bw_test.py 2017-05-27 11:57:24 UTC (rev 14083)
@@ -491,3 +491,78 @@
assert run("bw test", path=str(tmpdir))[2] == 1
assert run("bw test group1", path=str(tmpdir))[2] == 1
assert run("bw test group2", path=str(tmpdir))[2] == 1
+
+
+def test_group_user_dep_deleted(tmpdir):
+ make_repo(
+ tmpdir,
+ nodes={
+ "node1": {
+ 'bundles': ["bundle1"],
+ },
+ },
+ bundles={
+ "bundle1": {
+ "users": {
+ "user1": {
+ 'groups': ["group1"],
+ },
+ },
+ "groups": {
+ "group1": {
+ 'delete': True,
+ },
+ },
+ },
+ },
+ )
+ assert run("bw test", path=str(tmpdir))[2] == 1
+
+
+def test_group_user_dep_ok(tmpdir):
+ # regression test for #341
+ make_repo(
+ tmpdir,
+ nodes={
+ "node1": {
+ 'bundles': ["bundle1"],
+ },
+ },
+ bundles={
+ "bundle1": {
+ "users": {
+ "user1": {},
+ },
+ "groups": {
+ "group1": {'delete': True},
+ },
+ },
+ },
+ )
+ assert run("bw test", path=str(tmpdir))[2] == 0
+
+
+def test_group_user_dep_deleted_gid(tmpdir):
+ make_repo(
+ tmpdir,
+ nodes={
+ "node1": {
+ 'bundles': ["bundle1"],
+ },
+ },
+ bundles={
+ "bundle1": {
+ "users": {
+ "user1": {
+ 'gid': "group1",
+ },
+ },
+ "groups": {
+ "group1": {
+ 'delete': True,
+ },
+ },
+ },
+ },
+ )
+ assert run("bw test", path=str(tmpdir))[2] == 1
More information about the Python-apps-commits
mailing list