-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add Individual Resource Verification Override #67
Conversation
Signed-off-by: Michael Honaker <Michael.Honaker@ibm.com>
Signed-off-by: Michael Honaker <Michael.Honaker@ibm.com>
639a2e3
to
c324526
Compare
fd18435
to
b475934
Compare
Signed-off-by: Michael Honaker <Michael.Honaker@ibm.com>
@gabe-l-hart this is now readyto review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One debatable API breaking change and a couple of NITs. Thanks for adding all this!
oper8/verify_resources.py
Outdated
@@ -39,6 +45,7 @@ def verify_resource( | |||
# Use a predfined _SESSION_NAMESPACE default instead of None to differentiate between | |||
# nonnamespaced resources (which pass None) and those that use session.namespace | |||
namespace: Optional[str] = _SESSION_NAMESPACE, | |||
verify_function: RESOURCE_VERIFY_FUNCTION = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: This should be Optional[RESOURCE_VERIFY_FUNCTION]
. While you're at it, can you fix the other missing Optional[]
type hints on the below args?
oper8/dag/node.py
Outdated
|
||
def __init__(self, name: str, manifest: dict): | ||
def __init__(self, name: str, manifest: dict, verify_func: Callable = None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this use the full RESOURCE_VERIFY_FUNCTION
signature rather than just Callable
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circular references :( I wasn't able to figure out a way to import verify_resources
in the node dag.
oper8/dag/node.py
Outdated
@property | ||
def manifest(self) -> str: | ||
"""The resource manifest""" | ||
return self.get_data()[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. I wonder if having a Tuple
returned from get_data
is going to break anything. I think I might have at least one place where I've invoked get_data
directly, so this could be seen as an API breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
oper8/managed_object.py
Outdated
@@ -10,7 +11,7 @@ | |||
class ManagedObject: # pylint: disable=too-many-instance-attributes | |||
"""Basic struct to represent a managed kubernetes object""" | |||
|
|||
def __init__(self, definition): | |||
def __init__(self, definition, verify_function: Callable = None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question about Callable
here. Also, if you do change it, maybe throw a type hint on definition
too!
oper8/verify_resources.py
Outdated
@@ -282,3 +289,9 @@ def is_expected_reason() -> bool: | |||
return obj_reason == expected_reason | |||
|
|||
return is_expected_status() and is_expected_reason() | |||
return is_expected_status() and is_expected_reason() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happened here??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VS Code likes to autoformat things :( I think it removed a newline?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This diff shows six copies of the same return statement?
Signed-off-by: Michael Honaker <Michael.Honaker@ibm.com>
8726eca
to
f5ea182
Compare
Signed-off-by: Michael Honaker <Michael.Honaker@ibm.com>
Signed-off-by: Michael Honaker <Michael.Honaker@ibm.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
5f73d3a
to
4275ad8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more nit pick!
oper8/dag/node.py
Outdated
return self.get_data() | ||
|
||
@property | ||
def verify_function(self) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Crap, one more NIT: The return on this should be Callable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I will also fix the manifest section as well
Signed-off-by: Michael Honaker <Michael.Honaker@ibm.com>
Related Issue
Supports #66
Related PRs
This PR helps support #64
What this PR does / why we need it
This PR allows users to override
Special notes for your reviewer
If applicable**
What gif most accurately describes how I feel towards this PR?