Remove unused impacted
CLI command
This patch set removes the impacted CLI command for the following reasons: 1) it currently isn't being used by anyone or any automation 2) it's not clear how to use it 3) making it work with git diff or git show in order to determine changed files automatically is sleaker design but currently there is no use case for this command Associated engine code, CLI documentation and helper functionality only associated with this command are dropped. Change-Id: Ic09951e988b82a386d2a1a7b9ce9d77f78bd00d7
This commit is contained in:
parent
73fbf264ca
commit
40c12b417e
@ -168,23 +168,6 @@ Example with validation:
|
|||||||
-e global=/opt/aic-clcp-manifests \
|
-e global=/opt/aic-clcp-manifests \
|
||||||
collect <site_name> -s /workspace -x P004 --validate
|
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
|
List
|
||||||
----
|
----
|
||||||
|
|
||||||
|
@ -137,24 +137,6 @@ def collect(*, save_location, validate, exclude_lint, warn_lint, site_name):
|
|||||||
engine.site.collect(site_name, save_location)
|
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')
|
@site.command('list', help='List known sites')
|
||||||
@click.option(
|
@click.option(
|
||||||
'-o',
|
'-o',
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import collections
|
|
||||||
import csv
|
import csv
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
@ -23,7 +22,7 @@ import yaml
|
|||||||
|
|
||||||
from pegleg.engine import util
|
from pegleg.engine import util
|
||||||
|
|
||||||
__all__ = ('collect', 'impacted', 'list_', 'show', 'render')
|
__all__ = ('collect', 'list_', 'show', 'render')
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -89,20 +88,6 @@ def collect(site_name, save_location):
|
|||||||
_collect_to_stdout(site_name)
|
_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):
|
def render(site_name, output_stream):
|
||||||
documents = []
|
documents = []
|
||||||
for filename in util.definition.site_files(site_name):
|
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 = util.definition.load_as_params(site_name)
|
||||||
data['files'] = list(util.definition.site_files(site_name))
|
data['files'] = list(util.definition.site_files(site_name))
|
||||||
json.dump(data, output_stream, indent=2, sort_keys=True)
|
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):
|
def load_as_params(site_name, primary_repo_base=None):
|
||||||
definition = load(site_name, primary_repo_base)
|
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 = definition.get('data', {})
|
||||||
params['site_name'] = site_name
|
params['site_name'] = site_name
|
||||||
return params
|
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
|
For more information, see: https://storyboard.openstack.org/#!/story/2003762
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@mock.patch.object(lint, '_verify_deckhand_render', return_value=[])
|
@mock.patch.object(lint, '_verify_deckhand_render', return_value=[])
|
||||||
@mock.patch.object(lint, '_verify_no_unexpected_files', return_value=[])
|
@mock.patch.object(lint, '_verify_no_unexpected_files', return_value=[])
|
||||||
def test_lint_excludes_P001(*args):
|
def test_lint_excludes_P001(*args):
|
||||||
|
Loading…
Reference in New Issue
Block a user