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

feat: add json_patch module for JSON patching #378

Conversation

particledecay
Copy link

@particledecay particledecay commented May 20, 2020

This module was originally being considered for inclusion in Ansible, but was ultimately rejected in favor of using collections instead. This is my attempt to get this into a community-maintained collection.

It's not clear how this collection is meant to be tested, so I didn't run any tests. However, this did pass testing previously in the Ansible PR. The one question mark for me would be in tests/integration/targets/json_patch/meta/main.yml... not sure if that dependency is even accessible this way anymore.

The original repo is here if you need additional info. There's a good README there.

Thanks!

@ansibullbot
Copy link
Collaborator

The test ansible-test sanity --test ansible-doc [explain] failed with the error:

Output on stderr from ansible-doc is considered an error.

Command "ansible-doc -t module community.general.json_patch" returned exit status 0.
>>> Standard Error
[WARNING]: module community.general.json_patch not found in:
/dev/null:/root/ansible/lib/ansible/modules

The test ansible-test sanity --test validate-modules [explain] failed with 2 errors:

plugins/modules/files/json_patch.py:0:0: doc-choices-do-not-match-spec: Argument 'create_type' in argument_spec defines choices as ([]) but documentation defines choices as (['object', 'array'])
plugins/modules/files/json_patch.py:0:0: parameter-list-no-elements: Argument 'operations' in argument_spec defines type as list but elements is not defined

click here for bot help

plugins/modules/files/json_patch.py Outdated Show resolved Hide resolved
plugins/modules/files/json_patch.py Outdated Show resolved Hide resolved
plugins/modules/files/json_patch.py Outdated Show resolved Hide resolved
plugins/modules/files/json_patch.py Outdated Show resolved Hide resolved
plugins/modules/files/json_patch.py Outdated Show resolved Hide resolved
plugins/modules/files/json_patch.py Outdated Show resolved Hide resolved
plugins/modules/files/json_patch.py Outdated Show resolved Hide resolved
plugins/modules/files/json_patch.py Outdated Show resolved Hide resolved
plugins/modules/files/json_patch.py Outdated Show resolved Hide resolved
@Andersson007
Copy link
Contributor

@particledecay thanks for the PR! I haven't looked at the code. will do it after mentioned stuff is fixed, thanks!

@ansibullbot ansibullbot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR and removed community_review labels May 22, 2020
@Andersson007
Copy link
Contributor

Andersson007 commented May 23, 2020

@particledecay

  1. First of all, please fix things from my last comment, then push.
    After that a part of sanity errors will disappear.

  2. Then fix the other errors (Shippable — Run 1627 status is FAILED. the detailes link, click on red failed tests and then 'Tests' tab to see what went wrong)

(ansible/third-party-check tests can be ignored)

@ansibullbot
Copy link
Collaborator

The test ansible-test sanity --test ansible-doc [explain] failed with the error:

Output on stderr from ansible-doc is considered an error.

Command "ansible-doc -t module community.general.json_patch" returned exit status 0.
>>> Standard Error
[WARNING]: module community.general.json_patch not found in:
/dev/null:/root/ansible/lib/ansible/modules

The test ansible-test sanity --test validate-modules [explain] failed with 16 errors:

plugins/modules/files/json_patch.py:0:0: deprecation-mismatch: "meta/routing.yml" and DOCUMENTATION.deprecation do not agree.
plugins/modules/files/json_patch.py:0:0: doc-choices-do-not-match-spec: Argument 'create_type' in argument_spec defines choices as (['object', 'array']) but documentation defines choices as ([])
plugins/modules/files/json_patch.py:0:0: doc-default-does-not-match-spec: Argument 'create_type' in argument_spec defines default as ('object') but documentation defines default as (None)
plugins/modules/files/json_patch.py:0:0: doc-elements-mismatch: Argument 'operations' in argument_spec specifies elements as ?,but elements is not documented
plugins/modules/files/json_patch.py:0:0: doc-required-mismatch: Argument 'operations' in argument_spec is required, but is not documented as being required
plugins/modules/files/json_patch.py:0:0: doc-required-mismatch: Argument 'src' in argument_spec is required, but is not documented as being required
plugins/modules/files/json_patch.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.operations.elements: not a valid value for dictionary value @ data['argument_spec']['operations']['elements']. Got '?'
plugins/modules/files/json_patch.py:0:0: parameter-type-not-in-doc: Argument 'backup' in argument_spec defines type as 'bool' but documentation doesn't define type
plugins/modules/files/json_patch.py:0:0: parameter-type-not-in-doc: Argument 'create' in argument_spec defines type as 'bool' but documentation doesn't define type
plugins/modules/files/json_patch.py:0:0: parameter-type-not-in-doc: Argument 'create_type' in argument_spec defines type as 'str' but documentation doesn't define type
plugins/modules/files/json_patch.py:0:0: parameter-type-not-in-doc: Argument 'dest' in argument_spec defines type as 'str' but documentation doesn't define type
plugins/modules/files/json_patch.py:0:0: parameter-type-not-in-doc: Argument 'operations' in argument_spec defines type as 'list' but documentation doesn't define type
plugins/modules/files/json_patch.py:0:0: parameter-type-not-in-doc: Argument 'pretty' in argument_spec defines type as 'bool' but documentation doesn't define type
plugins/modules/files/json_patch.py:0:0: parameter-type-not-in-doc: Argument 'src' in argument_spec defines type as 'str' but documentation doesn't define type
plugins/modules/files/json_patch.py:0:0: parameter-type-not-in-doc: Argument 'unsafe_writes' in argument_spec defines type as 'bool' but documentation doesn't define type
plugins/modules/files/json_patch.py:37:19: documentation-syntax-error: DOCUMENTATION is not valid YAML

The test ansible-test sanity --test yamllint [explain] failed with 2 errors:

plugins/modules/files/json_patch.py:25:19: unparsable-with-libyaml: None - mapping keys are not allowed in this context
plugins/modules/files/json_patch.py:37:19: error: DOCUMENTATION: syntax error: mapping keys are not allowed here (syntax)

click here for bot help

plugins/modules/files/json_patch.py Outdated Show resolved Hide resolved
plugins/modules/files/json_patch.py Outdated Show resolved Hide resolved
plugins/modules/files/json_patch.py Outdated Show resolved Hide resolved
plugins/modules/files/json_patch.py Outdated Show resolved Hide resolved
plugins/modules/files/json_patch.py Outdated Show resolved Hide resolved
plugins/modules/files/json_patch.py Outdated Show resolved Hide resolved
plugins/modules/files/json_patch.py Outdated Show resolved Hide resolved
@felixfontein
Copy link
Collaborator

@particledecay did you have a chance to look at @Andersson007's review comments? If you need help with something, please ask.

@ansibullbot ansibullbot added the stale_ci CI is older than 7 days, rerun before merging label Jun 15, 2020
@particledecay
Copy link
Author

@felixfontein no I didn't! Dang, I recently got flooded with GH notifications and must have accidentally marked this Done or something... Ok cool, I'll take a look at these. Thanks!

@ansibullbot ansibullbot removed the stale_ci CI is older than 7 days, rerun before merging label Jun 17, 2020
@ansibullbot
Copy link
Collaborator

The test ansible-test sanity --test ansible-doc [explain] failed with the error:

Output on stderr from ansible-doc is considered an error.

Command "ansible-doc -t module community.general.json_patch" returned exit status 0.
>>> Standard Error
[WARNING]: module community.general.json_patch not found in:
/dev/null:/root/ansible/lib/ansible/modules

click here for bot help

@felixfontein
Copy link
Collaborator

You need to create a (relative) symlink from plugins/modules/json_patch.py to files/json_patch.py.

@gundalow gundalow added the ci_verified Push fixes to PR branch to re-run CI label Jun 17, 2020
@particledecay
Copy link
Author

@felixfontein created.

@ansibullbot ansibullbot removed the ci_verified Push fixes to PR branch to re-run CI label Jun 17, 2020
plugins/modules/files/json_patch.py Outdated Show resolved Hide resolved
tests/unit/plugins/modules/files/test_json_patch.py Outdated Show resolved Hide resolved
plugins/modules/files/json_patch.py Show resolved Hide resolved
plugins/modules/files/json_patch.py Show resolved Hide resolved
@felixfontein felixfontein changed the base branch from master to main July 6, 2020 07:56
@ansibullbot ansibullbot added the stale_ci CI is older than 7 days, rerun before merging label Jul 6, 2020
@Andersson007 Andersson007 reopened this Oct 20, 2020
@Andersson007
Copy link
Contributor

@particledecay i close-reopened the pr to trigger the tests but then noticed that many of them failed. Could you fix them?

@ansibullbot ansibullbot added affects_1 unit tests/unit and removed stale_ci CI is older than 7 days, rerun before merging labels Oct 20, 2020
@felixfontein
Copy link
Collaborator

@particledecay are you still working on this?

needs_info

@ansibullbot ansibullbot added needs_info This issue requires further information. Please answer any outstanding questions needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html stale_ci CI is older than 7 days, rerun before merging labels Feb 26, 2021
@felixfontein
Copy link
Collaborator

Closing since there was no more reaction. @particledecay if you're interested again in working on this, please ping me. If someone else is interested in continuing this PR, please also write it here so we can coordinate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has_issue integration tests/integration module module needs_info This issue requires further information. Please answer any outstanding questions needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR new_contributor Help guide this first time contributor new_module New module new_plugin New plugin stale_ci CI is older than 7 days, rerun before merging tests tests unit tests/unit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants