Skip to content

Commit

Permalink
Removed potentially offensive terms
Browse files Browse the repository at this point in the history
- Replaced the terms 'whitelist' and 'blacklist' throughout the code and docs,
  where possible.  The CLI argument changed have not been part of any non-beta
  release so no one should be impacted by this.
  • Loading branch information
lowell80 committed Jun 19, 2020
1 parent 08536df commit 8cccae5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
12 changes: 6 additions & 6 deletions docs/source/dyn/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ ksconf package
.. code-block:: none
usage: ksconf package [-h] [-f SPL] [--app-name APP_NAME]
[--blacklist BLACKLIST] [--whitelist WHITELIST]
[--blocklist BLOCKLIST] [--allowlist ALLOWLIST]
[-I PATTERN] [-E PATTERN] [--follow-symlink]
[--set-version VERSION] [--set-build BUILD]
[--allow-local | --block-local | --merge-local]
Expand All @@ -225,15 +225,15 @@ ksconf package
--app-name APP_NAME Specify the top-level app folder name. If this is not
given, the app folder name is automatically extracted
from the basename of SOURCE.
--blacklist BLACKLIST, -b BLACKLIST
--blocklist BLOCKLIST, -b BLOCKLIST
Pattern for files/directories to exclude. Can be given
multiple times. You can load multiple exclusions from
disk by using 'file://path' which can be used with
'.gitignore' for example. (Default includes: '.git*',
'*.py[co]', '__pycache__', '.DS_Store')
--whitelist WHITELIST, -w WHITELIST
--allowlist ALLOWLIST, -w ALLOWLIST
Remove a pattern that was previously added to the
blacklist.
blocklist.
--follow-symlink, -l Follow symbolic links pointing to directories.
Symlinks to files are always followed.
--set-version VERSION
Expand Down Expand Up @@ -271,9 +271,9 @@ ksconf package
--hook-script COMMAND
Run the given command or script. This is run after all
layer have been combined, and local directory
handling, but before blacklist cleanup. Therefore if
handling, but before blocklist cleanup. Therefore if
this command produces any unwanted files they can be
removed with a '--blacklist' entry. This can be used
removed with a '--blocklist' entry. This can be used
to install python packages, for example.
Expand Down
48 changes: 24 additions & 24 deletions ksconf/commands/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ def combine(self, src, filters, layer_method="dir.d", allow_symlink=False):
if rc != 0:
raise ValueError("Issue calling 'combine' internally during app build....")

def blacklist(self, patterns):
# XXX: Rewrite -- Had to hack the layers to explicitly blacklist '.git' dir, because '*.git' wasn't working here. :=(
def blocklist(self, patterns):
# XXX: Rewrite -- Had to hack the layers to explicitly blocklist '.git' dir, because '*.git' wasn't working here. :=(

# For now we just delete files out the build directory. Not sophisticated, but it works
# Do we need relwalker here? relwalk
Expand Down Expand Up @@ -260,7 +260,7 @@ class PackageCmd(KsconfCmd):
#format = "manual"
maturity = "alpha"

default_blacklist = [
default_blocklist = [
".git*",
"*.py[co]",
"__pycache__",
Expand All @@ -284,19 +284,19 @@ def f(pattern):
help="Specify the top-level app folder name. "
"If this is not given, the app folder name is automatically "
"extracted from the basename of SOURCE.")
parser.add_argument("--blacklist", "-b",
parser.add_argument("--blocklist", "-b",
action="append",
default=self.default_blacklist,
default=self.default_blocklist,
help="Pattern for files/directories to exclude. "
"Can be given multiple times. You can load multiple exclusions "
"from disk by using ``file://path`` which can be used "
"with ``.gitignore`` for example. (Default includes: {})"
.format(", ".join("``{}``".format(i) for i in self.default_blacklist)))
.format(", ".join("``{}``".format(i) for i in self.default_blocklist)))

# XXX: This should be smarter; stacked like we support for layers -- where order matters.
parser.add_argument("--whitelist", "-w",
parser.add_argument("--allowlist", "-w",
action="append", default=[],
help="Remove a pattern that was previously added to the blacklist.")
help="Remove a pattern that was previously added to the blocklist.")

player = parser.add_argument_group("Layer filtering",
"If the app being packaged includes multiple layers, these arguments can be used to "
Expand Down Expand Up @@ -350,36 +350,36 @@ def f(pattern):
action="append", default=[],
help="Run the given command or script. "
"This is run after all layer have been combined, and local "
"directory handling, but before blacklist cleanup. "
"directory handling, but before blocklist cleanup. "
"Therefore if this command produces any unwanted files they can "
"be removed with a ``--blacklist`` entry. "
"be removed with a ``--blocklist`` entry. "
"This can be used to install python packages, for example.")

@staticmethod
def load_blacklist(path):
def load_blocklist(path):
with open(path) as stream:
for line in stream:
line = line.rstrip()
if line and not line.startswith("#"):
yield line

def pre_run(self, args):
if "local" in args.blacklist:
if "local" in args.blocklist:
self.stderr.write("Blacklisting 'local' is not supported. "
"Most likely you want '--block-local' instead.\n")
return EXIT_CODE_BAD_ARGS

blacklist = []
for pattern in args.blacklist:
blocklist = []
for pattern in args.blocklist:
if pattern.startswith("file://"):
blacklist_file = pattern[7:]
expanded = list(self.load_blacklist(blacklist_file))
self.stderr.write("Extended blacklist from {} with {:d} entries\n"
.format(blacklist_file, len(expanded)))
blacklist.extend(expanded)
blocklist_file = pattern[7:]
expanded = list(self.load_blocklist(blocklist_file))
self.stderr.write("Extended blocklist from {} with {:d} entries\n"
.format(blocklist_file, len(expanded)))
blocklist.extend(expanded)
else:
blacklist.append(pattern)
args.blacklist = [pattern for pattern in blacklist if pattern not in args.whitelist]
blocklist.append(pattern)
args.blocklist = [pattern for pattern in blocklist if pattern not in args.allowlist]

def run(self, args):
''' Create a Splunk app/add-on .spl file from a directory '''
Expand All @@ -406,9 +406,9 @@ def run(self, args):
for script in args.hook_script:
builder.run_hook_script(script)

if args.blacklist:
self.stderr.write("Applying blacklist: {!r}\n".format(args.blacklist))
builder.blacklist(args.blacklist)
if args.blocklist:
self.stderr.write("Applying blocklist: {!r}\n".format(args.blocklist))
builder.blocklist(args.blocklist)

if args.set_build or args.set_version:
builder.update_app_conf(version=args.set_version,
Expand Down

0 comments on commit 8cccae5

Please sign in to comment.