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

DNM - Extend hidden_fields to allow more complicated field definitions #880

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

abikouo
Copy link
Contributor

@abikouo abikouo commented Feb 13, 2025

SUMMARY

Fixes corner case from #872

ISSUE TYPE
  • Feature Pull Request

Copy link

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.
Warning:
Error merging github.com/ansible-collections/kubernetes.core for 880,ac4781ddb8c94e5e9c9c0f8c6ca23c3519c4f20e

willthames and others added 7 commits February 13, 2025 16:39
This allows us to ignore e.g. the last-applied-configuration
annotation by specifying
`metadata.annotations[kubectl.kubernetes.io/last-applied-configuration]`
Needed to cope with multiple levels of bracketed keys

e.g. spec.template.spec[securityContext][runAsUser]

and implementing that lead to a much simpler version
that finds the first key and the rest, and deals with
just those two.

Added more tests to cover some of the new supported
cases.
Ensure test correctly captures that hidden fields should be hidden
in diffs too
example:
@yurnov ➜ /workspaces/kubernetes.core (hide-fields) $ flake8 plugins/
@yurnov ➜ /workspaces/kubernetes.core (hide-fields) $ black --diff plugins/
--- /workspaces/kubernetes.core/plugins/module_utils/k8s/service.py     2025-02-03 09:02:53.501654+00:00
+++ /workspaces/kubernetes.core/plugins/module_utils/k8s/service.py     2025-02-03 09:03:33.328340+00:00
@@ -653,14 +653,14 @@
     rbracket = hidden_field.find("]")
     dot = hidden_field.find(".")

     if lbracket == 0:
         # skip past right bracket and any following dot
-        rest = hidden_field[rbracket + 1:]
+        rest = hidden_field[rbracket + 1 :]
         if rest and rest[0] == ".":
             rest = rest[1:]
-        return (hidden_field[lbracket + 1: rbracket], rest)
+        return (hidden_field[lbracket + 1 : rbracket], rest)

     if lbracket != -1 and (dot == -1 or lbracket < dot):
         return (hidden_field[:lbracket], hidden_field[lbracket:])

     split = hidden_field.split(".", 1)
would reformat /workspaces/kubernetes.core/plugins/module_utils/k8s/service.py

All done! ✨ 🍰 ✨
1 file would be reformatted, 73 files would be left unchanged.
@yurnov ➜ /workspaces/kubernetes.core (hide-fields) $ black plugins/
reformatted /workspaces/kubernetes.core/plugins/module_utils/k8s/service.py

All done! ✨ 🍰 ✨
1 file reformatted, 73 files left unchanged.
@yurnov ➜ /workspaces/kubernetes.core (hide-fields) $ flake8 plugins/
plugins/module_utils/k8s/service.py:658:41: E203 whitespace before ':'
plugins/module_utils/k8s/service.py:661:42: E203 whitespace before ':'
@yurnov ➜ /workspaces/kubernetes.core (hide-fields) $
@abikouo abikouo force-pushed the ab_hidden_fields_20250213 branch from ac4781d to 28a8e38 Compare February 13, 2025 15:41
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants