-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fix for k8s dict parsing #411
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
import tempfile | ||
import unittest | ||
import yaml | ||
import datetime | ||
|
||
class TestCompiler(unittest.TestCase): | ||
|
||
|
@@ -141,6 +142,21 @@ def test_basic_workflow(self): | |
shutil.rmtree(tmpdir) | ||
# print(tmpdir) | ||
|
||
def test_convert_k8s_obj_to_dic_accepts_dict(self): | ||
now = datetime.datetime.now() | ||
converted = compiler.Compiler()._convert_k8s_obj_to_dic({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The argument given to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
"ENV": "test", | ||
"number": 3, | ||
"list": [1,2,3], | ||
"time": now | ||
}) | ||
self.assertEqual(converted, { | ||
"ENV": "test", | ||
"number": 3, | ||
"list": [1,2,3], | ||
"time": now.isoformat() | ||
}) | ||
|
||
def test_composing_workflow(self): | ||
"""Test compiling a simple workflow, and a bigger one composed from the simple one.""" | ||
|
||
|
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.
Is this a style change? This function is copied directly from the official Kubernetes client library.
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 is the bug. I hit this issue because I tried to pass a dict into
op.add_env_variable
. Line 541 accessesiteritems
but it was only defined in a conditional branch so it threw an "object accessed before assignment" error.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.
Another fix here may be to throw a ValueError if the env_variable isn't a k8s object, but It would be nice to be able to pass in a dict without having to use the k8s wrapper. Regardless, this is definitely a bug.