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

Change collection PS util import pattern #61307

Merged
merged 6 commits into from Aug 27, 2019

Conversation

jborean93
Copy link
Contributor

@jborean93 jborean93 commented Aug 26, 2019

SUMMARY

Change the way PowerShell and C# module utils inside a collection are referenced. This is a breaking change but is being done to unify import patterns between the Python, PowerShell, and C#. Collections are a tech preview in 2.8 so this should hopefully be in by 2.9 before the existing pattern is more solidified.

This PR also adds a way to specify a type accelerator inside a C# util to simplify the type name a bit more. This is optional and a suggestion to add to Ansible but can have consequences if 2 utils use the same accelerator.

This also requires some changes in ansible-test but waiting to see what @nitzmahone and @mattclay says before delving in there.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

PowerShell
Collections

@jborean93 jborean93 requested review from nitzmahone, bcoca and mattclay and removed request for bcoca August 26, 2019 09:34
@ansibot
Copy link
Contributor

ansibot commented Aug 26, 2019

@ansibot ansibot added affects_2.9 This issue/PR affects Ansible v2.9 core_review In order to be merged, this PR must follow the core review workflow. docs This issue/PR relates to or includes documentation. docsite This issue/PR relates to the documentation website. feature This issue/PR relates to a feature request. needs_triage Needs a first human triage before being processed. new_plugin This PR includes a new plugin. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests. windows Windows community needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Aug 26, 2019
Copy link
Member

@mattclay mattclay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. A few minor changes to comments requested.

As for the type accelerators feature, that should probably be in a separate PR so it can be handled independently of this change.

docs/docsite/rst/porting_guides/porting_guide_2.9.rst Outdated Show resolved Hide resolved
docs/docsite/rst/dev_guide/collections_tech_preview.rst Outdated Show resolved Hide resolved
@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Aug 26, 2019
Copy link
Member

@nitzmahone nitzmahone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good- one thing to consider:

As a developer quality-of-life thing, it might be good to split the "find the #AnsibleRequires lines" away from the "load the contents" (not necessarily for freeze either, but as a bugfix/enhancement after), so that a malformed requires statement can give an error instead of being silently ignored because the regex didn't find it. It'd also probably make the regexes a little more "bite-size" and easier to follow.

I definitely like the "less magic" approach here to what I originally did, and the type accelerator thing is a good way to make that feature more accessible to stop the madness on verbosity of static/type refs.

self._re_cs_module = [
# Reference C# module_util in another C# util
re.compile(to_bytes(r'(?i)^using\s((Ansible\..+)|'
r'(ansible_collections\.[\w.]+\.[\w.]+\.plugins\.module_utils\.[\w.]+));\s*$')),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why include the . in the character groups? [\w.] is the same as [.]- and allows lots of things we don't want...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original regex originally was \w.+\. which mean match 1 word char then allow any char until .. Happy to change this to be just \w+ to match [A-Za-z0-0_] but having the . in there before made me pause.

lib/ansible/executor/powershell/module_manifest.py Outdated Show resolved Hide resolved
@jborean93
Copy link
Contributor Author

As a developer quality-of-life thing, it might be good to split the "find the #AnsibleRequires lines" away from the "load the contents" (not necessarily for freeze either, but as a bugfix/enhancement after)

Sounds fair enough, I'll add a comment for future work.

I definitely like the "less magic" approach here to what I originally did, and the type accelerator thing is a good way to make that feature more accessible to stop the madness on verbosity of static/type refs.

I thought it was a good idea and potentially a nice way to mask a potentially namespace/class change of the builtin C# utils if we ever do that. My only misgiving is that it potentially allows someone to have a name conflict if they don't really use something unique.

@mattclay
Copy link
Member

CI failures are unrelated to changes.

@mattclay mattclay merged commit 66f52b7 into ansible:devel Aug 27, 2019
@jborean93 jborean93 deleted the ps-collection-util branch August 27, 2019 23:10
adharshsrivatsr pushed a commit to adharshsrivatsr/ansible that referenced this pull request Sep 3, 2019
* Change collection PS util import pattern

* Add changes for py2 compat

* fix up regex and doc errors

* fix up import analysis

* Sanity fix for 2.6 CI workers

* Get collection util path for coverage collection
anas-shami pushed a commit to anas-shami/ansible that referenced this pull request Sep 23, 2019
* Change collection PS util import pattern

* Add changes for py2 compat

* fix up regex and doc errors

* fix up import analysis

* Sanity fix for 2.6 CI workers

* Get collection util path for coverage collection
@ansible ansible locked and limited conversation to collaborators Oct 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.9 This issue/PR affects Ansible v2.9 docs This issue/PR relates to or includes documentation. docsite This issue/PR relates to the documentation website. feature This issue/PR relates to a feature request. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. new_plugin This PR includes a new plugin. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests. windows Windows community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants