Skip to content

Commit

Permalink
Merge pull request #353 from philblckwd/feature/add-emit-trusted-host…
Browse files Browse the repository at this point in the history
…-option

Adding flag '--emit-trusted-host/no-emit-trusted-host'
  • Loading branch information
peterdemin authored Nov 3, 2022
2 parents 10c5ef9 + 03aea36 commit 2941c64
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
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']

0 comments on commit 2941c64

Please sign in to comment.