Ejemplo n.º 1
0
 def register_args(self, parser):
     parser.add_argument("source",
                         nargs="+",
                         help=dedent("""
         The source directory where configuration files will be merged from.
         When multiple sources directories are provided, start with the most general and end
         with the specific; later sources will override values from the earlier ones.
         Supports wildcards so a typical Unix ``conf.d/##-NAME`` directory structure works well."""
                                     )).completer = DirectoriesCompleter()
     parser.add_argument("--target",
                         "-t",
                         help=dedent("""
         Directory where the merged files will be stored.
         Typically either 'default' or 'local'""")
                         ).completer = DirectoriesCompleter()
     parser.add_argument("--dry-run",
                         "-D",
                         default=False,
                         action="store_true",
                         help=dedent("""
         Enable dry-run mode.
         Instead of writing to TARGET, preview changes as a 'diff'.
         If TARGET doesn't exist, then show the merged file."""))
     parser.add_argument(
         "--banner",
         "-b",
         default=
         " **** WARNING: This file is managed by 'ksconf combine', do "
         "not edit hand-edit this file! ****",
         help=
         "A banner or warning comment added to the top of the TARGET file. "
         "Used to discourage Splunk admins from editing an auto-generated "
         "file.")
Ejemplo n.º 2
0
 def register_args(self, parser):
     parser.add_argument("source",
                         nargs="+",
                         help=dedent("""
         The source directory where configuration files will be merged from.
         When multiple source directories are provided, start with the most general and end
         with the specific; later sources will override values from the earlier ones.
         Supports wildcards so a typical Unix ``conf.d/##-NAME`` directory structure works well."""
                                     )).completer = DirectoriesCompleter()
     parser.add_argument("--target",
                         "-t",
                         help=dedent("""
         Directory where the merged files will be stored.
         Typically either 'default' or 'local'""")
                         ).completer = DirectoriesCompleter()
     parser.add_argument("--dry-run",
                         "-D",
                         default=False,
                         action="store_true",
                         help=dedent("""
         Enable dry-run mode.
         Instead of writing to TARGET, preview changes as a 'diff'.
         If TARGET doesn't exist, then show the merged file."""))
     parser.add_argument(
         "--follow-symlink",
         "-l",
         action="store_true",
         default=False,
         help="Follow symbolic links pointing to directories.  "
         "Symlinks to files are followed.")
     parser.add_argument(
         "--banner",
         "-b",
         default=
         " **** WARNING: This file is managed by 'ksconf combine', do "
         "not edit hand-edit this file! ****",
         help=
         "A banner or warning comment added to the top of the TARGET file. "
         "Used to discourage Splunk admins from editing an auto-generated "
         "file.")
     parser.add_argument("--disable-marker",
                         action="store_true",
                         default=False,
                         help=dedent("""
         Prevents the creation of or checking for the '{}' marker file safety check.
         This file is typically used indicate that the destination folder is managed by ksconf.
         This option should be reserved for well-controlled batch processing scenarios.
         """.format(CONTROLLED_DIR_MARKER)))
Ejemplo n.º 3
0
 def register_args(self, parser):
     parser.add_argument(
         "path",
         metavar="PATH",
         nargs="+",
         type=str,
         help="Directory from which to load configuration files.  "
         "All .conf and .meta file are included recursively."
     ).completer = DirectoriesCompleter()
     parser.add_argument("--output",
                         "-o",
                         metavar="FILE",
                         type=FileType("w"),
                         default=self.stdout,
                         help=dedent("""\
         Save the snapshot to the named files.  If not provided, the snapshot is written to
         standard output.""")).completer = FilesCompleter(
                             allowednames=["*.json"])
     parser.add_argument(
         "--minimize",
         action="store_true",
         default=False,
         help=
         "Reduce the size of the JSON output by removing whitespace.  Reduces readability."
     )
Ejemplo n.º 4
0
 def register_args(self, parser):
     parser.add_argument("tarball", metavar="SPL",
                         help="The path to the archive to install."
                         ).completer = FilesCompleter(allowednames=allowed_extentions)
     parser.add_argument("--dest", metavar="DIR", default=".", help="""
         Set the destination path where the archive will be extracted.
         By default the current directory is used, but sane values include etc/apps,
         etc/deployment-apps, and so on.
         This could also be a git repository working tree where splunk apps are stored."""
                         ).completer = DirectoriesCompleter()
     parser.add_argument("--app-name", metavar="NAME", default=None, help="""
         The app name to use when expanding the archive.
         By default, the app name is taken from the archive as the top-level path included
         in the archive (by convention).
         Expanding archives that contain multiple (ITSI) or nested apps (NIX, ES)
         is not supported.)""")
     parser.add_argument("--default-dir", default="default", metavar="DIR", help="""
         Name of the directory where the default contents will be stored.
         This is a useful feature for apps that use a dynamic default directory
         that's created and managed by the 'combine' mode."""
                         ).completer = DirectoriesCompleter()
     parser.add_argument("--exclude", "-e", action="append", default=[], help="""
         Add a file pattern to exclude.  Splunk's psudo-glob patterns are supported here.
         '*' for any non-directory match,
         '...' for ANY (including directories),
         and '?' for a single character.""")
     parser.add_argument("--keep", "-k", action="append", default=[],
                         help="""
         Specify a pattern for files to preserve during an upgrade.
         Repeat this argument to keep multiple patterns.""")
     parser.add_argument("--allow-local", default=False, action="store_true", help="""
         Allow local/ and local.meta files to be extracted from the archive.
         Shipping local files is a Splunk app packaging violation so local files are blocked
         to prevent content from being overridden.""")
     parser.add_argument("--git-sanity-check",
                         choices=["off", "changed", "untracked", "ignored"],
                         default="untracked", help="""
         By default 'git status' is run on the destination folder to detect working tree or
         index modifications before the unarchive process starts, but this is configurable.
         Sanity check choices go from least restrictive to most thorough:
         Use 'off' to prevent any 'git status' safely checks.
         Use 'changed' to abort only upon local modifications to files tracked by git.
         Use 'untracked' (the default) to look for changed and untracked files before
         considering the tree clean.
         Use 'ignored' to enable the most intense safety check which will abort if local
         changes, untracked, or ignored files are found.
         NOTE:  Sanity checks are automatically disabled if the app is not in a git working
         tree, or git is not installed.""")
     parser.add_argument("--git-mode", default="stage",
                         choices=["nochange", "stage", "commit"], help="""
         Set the desired level of git integration.
         The default mode is 'stage', where new, updated, or removed files are automatically
         handled for you.
         If 'commit' mode is selected, then files are committed with an auto-generated
         commit message.
         To prevent any 'git add' or 'git rm' commands from being run, pick the
         'nochange' mode.
         Notes:  (1) The git mode is irrelevant if the app is not in a git working tree.
         (2) If a git commit is incorrect, simply roll it back with 'git reset' or fix
         it with a 'git commit --amend' before the changes are pushed anywhere else.
         (That's why you're using git in the first place, right?)""")
     parser.add_argument("--no-edit",
                         action="store_true", default=False, help="""
         Tell git to skip opening your editor.
         By default you will be prompted to review/edit the commit message.
         (Git Tip:  Delete the content of the message to abort the commit.)""")
     parser.add_argument("--git-commit-args", "-G", default=[], action="append")
Ejemplo n.º 5
0
    def register_args(self, parser):
        parser.add_argument(
            "tarball",
            metavar="SPL",
            help="The path to the archive to install."
        ).completer = FilesCompleter(allowednames=allowed_extentions)
        parser.add_argument("--dest",
                            metavar="DIR",
                            default=".",
                            help=dedent("""\
            Set the destination path where the archive will be extracted.
            By default, the current directory is used.  Sane values include: etc/apps,
            etc/deployment-apps, and so on.""")
                            ).completer = DirectoriesCompleter()
        parser.add_argument("--app-name",
                            metavar="NAME",
                            default=None,
                            help=dedent("""\
            The app name to use when expanding the archive.
            By default, the app name is taken from the archive as the top-level path included
            in the archive (by convention).
            """))
        parser.add_argument("--default-dir",
                            default="default",
                            metavar="DIR",
                            help=dedent("""\
            Name of the directory where the default contents will be stored.
            This is a useful feature for apps that use a dynamic default directory
            that's created and managed by the 'combine' mode.""")
                            ).completer = DirectoriesCompleter()
        parser.add_argument("--exclude",
                            "-e",
                            action="append",
                            default=[],
                            help=dedent("""\
            Add a file pattern to exclude from extraction.
            Splunk's pseudo-glob patterns are supported here.
            ``*`` for any non-directory match,
            ``...`` for ANY (including directories),
            and ``?`` for a single character."""))
        parser.add_argument("--keep",
                            "-k",
                            action="append",
                            default=[],
                            help=dedent("""\
            Specify a pattern for files to preserve during an upgrade.
            Repeat this argument to keep multiple patterns."""))
        parser.add_argument("--allow-local",
                            default=False,
                            action="store_true",
                            help=dedent("""\
            Allow local/* and local.meta files to be extracted from the archive.
            """))
        parser.add_argument("--git-sanity-check",
                            choices=["off", "changed", "untracked", "ignored"],
                            default="untracked",
                            help=dedent("""\
            By default, 'git status' is run on the destination folder to detect working tree or
            index modifications before the unarchive process start.

            Sanity check choices go from least restrictive to most thorough:

            'off' prevents all safety checks.
            'changed' aborts only upon local modifications to files tracked by git.
            'untracked' (the default) looks for changed and untracked files.
            'ignored' aborts is (any) local changes, untracked, or ignored files are found.
            """))
        parser.add_argument("--git-mode",
                            default="stage",
                            choices=["nochange", "stage", "commit"],
                            help=dedent("""\
            Set the desired level of git integration.
            The default mode is *stage*, where new, updated, or removed files are automatically
            handled for you.

            To prevent any ``git add`` or ``git rm`` commands from being run, pick the
            'nochange' mode.
            """))
        parser.add_argument("--no-edit",
                            action="store_true",
                            default=False,
                            help=dedent("""\
            Tell git to skip opening your editor on commit.
            By default, you will be prompted to review/edit the commit message.
            (Git Tip:  Delete the content of the default message to abort the commit.)"""
                                        ))
        parser.add_argument("--git-commit-args",
                            "-G",
                            default=[],
                            action="append",
                            help="Extra arguments to pass to 'git'")