Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding flag '--emit-trusted-host/no-emit-trusted-host' #353

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pipcompilemulti/features/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from .live_output import LiveOutput
from .extra_index_url import ExtraIndexUrl
from .build_isolation import BuildIsolation
from .emit_trusted_host import EmitTrustedHost


class FeaturesController:
Expand All @@ -46,6 +47,7 @@ def __init__(self):
self.live_output = LiveOutput()
self.extra_index_url = ExtraIndexUrl()
self.build_isolation = BuildIsolation()
self.emit_trusted_host = EmitTrustedHost()
self._features = [
self.annotate_index,
self.use_cache,
Expand All @@ -66,6 +68,7 @@ def __init__(self):
self.live_output,
self.extra_index_url,
self.build_isolation,
self.emit_trusted_host
]

def bind(self, command):
Expand All @@ -92,6 +95,7 @@ def pin_options(self, in_path):
options.extend(self.annotate_index.pin_options())
options.extend(self.extra_index_url.pin_options())
options.extend(self.build_isolation.pin_options())
options.extend(self.emit_trusted_host.pin_options())
return options

def compose_input_file_path(self, basename):
Expand Down
31 changes: 31 additions & 0 deletions pipcompilemulti/features/emit_trusted_host.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""
Add trusted host annotation
========================

This flag provides the ability to annotate the trusted host mimicking the logic of
the ``pip-compile`` ``--emit-trusted-host`` and ``--no-emit-trusted-host`` flag
by opting to add or not add the ``pip`` trusted host to the generated files.

.. code-block:: text

--emit-trusted-host / --no-emit-trusted-host Add trusted host to generated files (default true)

Note the default behavior is to add the trusted host, i.e., ``--emit-trusted-host``.
"""

from .base import ClickOption
from .forward import ForwardOption


class EmitTrustedHost(ForwardOption):
"""Optionally add the trusted host to the generated files."""

OPTION_NAME = 'emit_trusted_host'
CLICK_OPTION = ClickOption(
long_option='--emit-trusted-host/--no-emit-trusted-host',
is_flag=True,
default=True,
help_text="Add trusted host option to generated file"
)
enabled_pin_options = ['--emit-trusted-host']
disabled_pin_options = ['--no-emit-trusted-host']