Merge "Remove unused impacted
CLI command"
This commit is contained in:
commit
3222ac21de
@ -198,23 +198,6 @@ Example with validation:
|
||||
-e global=/opt/aic-clcp-manifests \
|
||||
collect <site_name> -s /workspace -x P004 --validate
|
||||
|
||||
Impacted
|
||||
--------
|
||||
|
||||
Find sites impacted by changed files.
|
||||
|
||||
**-i / --input**
|
||||
|
||||
List of impacted files.
|
||||
|
||||
**-o / --output**
|
||||
|
||||
Where to output.
|
||||
|
||||
::
|
||||
|
||||
./pegleg impacted -i <input_stream> -o <output_stream>
|
||||
|
||||
List
|
||||
----
|
||||
|
||||
|
@ -137,24 +137,6 @@ def collect(*, save_location, validate, exclude_lint, warn_lint, site_name):
|
||||
engine.site.collect(site_name, save_location)
|
||||
|
||||
|
||||
@site.command(help='Find sites impacted by changed files')
|
||||
@click.option(
|
||||
'-i',
|
||||
'--input',
|
||||
'input_stream',
|
||||
type=click.File(mode='r'),
|
||||
default=sys.stdin,
|
||||
help='List of impacted files')
|
||||
@click.option(
|
||||
'-o',
|
||||
'--output',
|
||||
'output_stream',
|
||||
type=click.File(mode='w'),
|
||||
default=sys.stdout)
|
||||
def impacted(*, input_stream, output_stream):
|
||||
engine.site.impacted(input_stream, output_stream)
|
||||
|
||||
|
||||
@site.command('list', help='List known sites')
|
||||
@click.option(
|
||||
'-o',
|
||||
|
@ -12,7 +12,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import collections
|
||||
import csv
|
||||
import json
|
||||
import logging
|
||||
@ -23,7 +22,7 @@ import yaml
|
||||
|
||||
from pegleg.engine import util
|
||||
|
||||
__all__ = ('collect', 'impacted', 'list_', 'show', 'render')
|
||||
__all__ = ('collect', 'list_', 'show', 'render')
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
@ -89,20 +88,6 @@ def collect(site_name, save_location):
|
||||
_collect_to_stdout(site_name)
|
||||
|
||||
|
||||
def impacted(input_stream, output_stream):
|
||||
mapping = _build_impact_mapping()
|
||||
impacted_sites = set()
|
||||
|
||||
for line in input_stream:
|
||||
line = line.strip()
|
||||
directory = util.files.directory_for(path=line)
|
||||
if directory is not None:
|
||||
impacted_sites.update(mapping[directory])
|
||||
|
||||
for site_name in sorted(impacted_sites):
|
||||
output_stream.write(site_name + '\n')
|
||||
|
||||
|
||||
def render(site_name, output_stream):
|
||||
documents = []
|
||||
for filename in util.definition.site_files(site_name):
|
||||
@ -148,14 +133,3 @@ def show(site_name, output_stream):
|
||||
data = util.definition.load_as_params(site_name)
|
||||
data['files'] = list(util.definition.site_files(site_name))
|
||||
json.dump(data, output_stream, indent=2, sort_keys=True)
|
||||
|
||||
|
||||
def _build_impact_mapping():
|
||||
mapping = collections.defaultdict(set)
|
||||
|
||||
for site_name in util.files.list_sites():
|
||||
params = util.definition.load_as_params(site_name)
|
||||
for directory in util.files.directories_for(**params):
|
||||
mapping[directory].add(site_name)
|
||||
|
||||
return mapping
|
||||
|
@ -56,6 +56,13 @@ def load(site, primary_repo_base=None):
|
||||
|
||||
def load_as_params(site_name, primary_repo_base=None):
|
||||
definition = load(site_name, primary_repo_base)
|
||||
# TODO(felipemonteiro): Currently we are filtering out "revision" from
|
||||
# the params that are returned by this function because it is no longer
|
||||
# supported. This is a workaround. As soon as the site definition repos
|
||||
# switch to real repository format, then we can drop that workaround.
|
||||
# Ideally, we should:
|
||||
# 1) validate the site-definition.yaml format using lint module
|
||||
# 2) extract only the required params here
|
||||
params = definition.get('data', {})
|
||||
params['site_name'] = site_name
|
||||
return params
|
||||
|
@ -25,6 +25,7 @@ no longer relevant and so the lint logic for this rule needs to be updated.
|
||||
For more information, see: https://storyboard.openstack.org/#!/story/2003762
|
||||
"""
|
||||
|
||||
|
||||
@mock.patch.object(lint, '_verify_deckhand_render', return_value=[])
|
||||
@mock.patch.object(lint, '_verify_no_unexpected_files', return_value=[])
|
||||
def test_lint_excludes_P001(*args):
|
||||
|
Loading…
x
Reference in New Issue
Block a user