mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-06 13:02:37 +00:00
Upgrade black version (#424)
Upgrade black version SUMMARY Move off of beta version of black and pin to current calendar year version. The only manual changes here are to tox.ini. Everything else is from running the new version of black. ISSUE TYPE COMPONENT NAME ADDITIONAL INFORMATION Reviewed-by: Abhijeet Kasurde <None>
This commit is contained in:
@@ -240,12 +240,12 @@ class Connection(ConnectionBase):
|
|||||||
# Translate verify_ssl to skip_verify_ssl, and output as string
|
# Translate verify_ssl to skip_verify_ssl, and output as string
|
||||||
skip_verify_ssl = not self.get_option(key)
|
skip_verify_ssl = not self.get_option(key)
|
||||||
local_cmd.append(
|
local_cmd.append(
|
||||||
u"{0}={1}".format(
|
"{0}={1}".format(
|
||||||
self.connection_options[key], str(skip_verify_ssl).lower()
|
self.connection_options[key], str(skip_verify_ssl).lower()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
censored_local_cmd.append(
|
censored_local_cmd.append(
|
||||||
u"{0}={1}".format(
|
"{0}={1}".format(
|
||||||
self.connection_options[key], str(skip_verify_ssl).lower()
|
self.connection_options[key], str(skip_verify_ssl).lower()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -262,12 +262,12 @@ class Connection(ConnectionBase):
|
|||||||
else:
|
else:
|
||||||
censored_local_cmd += [cmd_arg, self.get_option(key)]
|
censored_local_cmd += [cmd_arg, self.get_option(key)]
|
||||||
|
|
||||||
extra_args_name = u"{0}_extra_args".format(self.transport)
|
extra_args_name = "{0}_extra_args".format(self.transport)
|
||||||
if self.get_option(extra_args_name):
|
if self.get_option(extra_args_name):
|
||||||
local_cmd += self.get_option(extra_args_name).split(" ")
|
local_cmd += self.get_option(extra_args_name).split(" ")
|
||||||
censored_local_cmd += self.get_option(extra_args_name).split(" ")
|
censored_local_cmd += self.get_option(extra_args_name).split(" ")
|
||||||
|
|
||||||
pod = self.get_option(u"{0}_pod".format(self.transport))
|
pod = self.get_option("{0}_pod".format(self.transport))
|
||||||
if not pod:
|
if not pod:
|
||||||
pod = self._play_context.remote_addr
|
pod = self._play_context.remote_addr
|
||||||
# -i is needed to keep stdin open which allows pipelining to work
|
# -i is needed to keep stdin open which allows pipelining to work
|
||||||
@@ -275,7 +275,7 @@ class Connection(ConnectionBase):
|
|||||||
censored_local_cmd += ["exec", "-i", pod]
|
censored_local_cmd += ["exec", "-i", pod]
|
||||||
|
|
||||||
# if the pod has more than one container, then container is required
|
# if the pod has more than one container, then container is required
|
||||||
container_arg_name = u"{0}_container".format(self.transport)
|
container_arg_name = "{0}_container".format(self.transport)
|
||||||
if self.get_option(container_arg_name):
|
if self.get_option(container_arg_name):
|
||||||
local_cmd += ["-c", self.get_option(container_arg_name)]
|
local_cmd += ["-c", self.get_option(container_arg_name)]
|
||||||
censored_local_cmd += ["-c", self.get_option(container_arg_name)]
|
censored_local_cmd += ["-c", self.get_option(container_arg_name)]
|
||||||
@@ -290,7 +290,7 @@ class Connection(ConnectionBase):
|
|||||||
super(Connection, self)._connect()
|
super(Connection, self)._connect()
|
||||||
if not self._connected:
|
if not self._connected:
|
||||||
display.vvv(
|
display.vvv(
|
||||||
u"ESTABLISH {0} CONNECTION".format(self.transport),
|
"ESTABLISH {0} CONNECTION".format(self.transport),
|
||||||
host=self._play_context.remote_addr,
|
host=self._play_context.remote_addr,
|
||||||
)
|
)
|
||||||
self._connected = True
|
self._connected = True
|
||||||
|
|||||||
@@ -473,9 +473,11 @@ class K8sAnsibleMixin(object):
|
|||||||
if result_empty(result):
|
if result_empty(result):
|
||||||
res = dict(resources=[], api_found=True)
|
res = dict(resources=[], api_found=True)
|
||||||
if last_exception is not None:
|
if last_exception is not None:
|
||||||
res["msg"] = (
|
res[
|
||||||
"Exception '%s' raised while trying to get resource using %s"
|
"msg"
|
||||||
% (last_exception, params)
|
] = "Exception '%s' raised while trying to get resource using %s" % (
|
||||||
|
last_exception,
|
||||||
|
params,
|
||||||
)
|
)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|||||||
@@ -385,9 +385,11 @@ def check_pod(k8s_ansible_mixin, module):
|
|||||||
def _fail(exc):
|
def _fail(exc):
|
||||||
arg = {}
|
arg = {}
|
||||||
if hasattr(exc, "body"):
|
if hasattr(exc, "body"):
|
||||||
msg = "Namespace={0} Kind=Pod Name={1}: Failed requested object: {2}".format(
|
msg = (
|
||||||
|
"Namespace={0} Kind=Pod Name={1}: Failed requested object: {2}".format(
|
||||||
namespace, name, exc.body
|
namespace, name, exc.body
|
||||||
)
|
)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
msg = to_native(exc)
|
msg = to_native(exc)
|
||||||
for attr in ["status", "reason"]:
|
for attr in ["status", "reason"]:
|
||||||
|
|||||||
@@ -123,9 +123,15 @@ def main():
|
|||||||
state=dict(
|
state=dict(
|
||||||
type="str", default="present", choices=["present", "absent", "latest"]
|
type="str", default="present", choices=["present", "absent", "latest"]
|
||||||
),
|
),
|
||||||
plugin_path=dict(type="str",),
|
plugin_path=dict(
|
||||||
plugin_name=dict(type="str",),
|
type="str",
|
||||||
plugin_version=dict(type="str",),
|
),
|
||||||
|
plugin_name=dict(
|
||||||
|
type="str",
|
||||||
|
),
|
||||||
|
plugin_version=dict(
|
||||||
|
type="str",
|
||||||
|
),
|
||||||
# Helm options
|
# Helm options
|
||||||
context=dict(
|
context=dict(
|
||||||
type="str",
|
type="str",
|
||||||
|
|||||||
@@ -81,7 +81,9 @@ def main():
|
|||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
binary_path=dict(type="path"),
|
binary_path=dict(type="path"),
|
||||||
plugin_name=dict(type="str",),
|
plugin_name=dict(
|
||||||
|
type="str",
|
||||||
|
),
|
||||||
# Helm options
|
# Helm options
|
||||||
context=dict(
|
context=dict(
|
||||||
type="str",
|
type="str",
|
||||||
|
|||||||
@@ -228,7 +228,10 @@ def execute_module(module, k8s_ansible_mixin):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(argument_spec=argspec(), supports_check_mode=True,)
|
module = AnsibleModule(
|
||||||
|
argument_spec=argspec(),
|
||||||
|
supports_check_mode=True,
|
||||||
|
)
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.common import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.common import (
|
||||||
K8sAnsibleMixin,
|
K8sAnsibleMixin,
|
||||||
get_api_client,
|
get_api_client,
|
||||||
|
|||||||
@@ -164,7 +164,8 @@ SCALE_ARG_SPEC = {
|
|||||||
|
|
||||||
|
|
||||||
def execute_module(
|
def execute_module(
|
||||||
module, k8s_ansible_mixin,
|
module,
|
||||||
|
k8s_ansible_mixin,
|
||||||
):
|
):
|
||||||
k8s_ansible_mixin.set_resource_definitions(module)
|
k8s_ansible_mixin.set_resource_definitions(module)
|
||||||
|
|
||||||
|
|||||||
@@ -301,7 +301,10 @@ class K8sTaintAnsible:
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(argument_spec=argspec(), supports_check_mode=True,)
|
module = AnsibleModule(
|
||||||
|
argument_spec=argspec(),
|
||||||
|
supports_check_mode=True,
|
||||||
|
)
|
||||||
k8s_taint = K8sTaintAnsible(module)
|
k8s_taint = K8sTaintAnsible(module)
|
||||||
k8s_taint.execute_module()
|
k8s_taint.execute_module()
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,8 @@ from ansible.module_utils.basic import AnsibleModule
|
|||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
binary_path=dict(type="path"), version=dict(type="str", default="3.7.0"),
|
binary_path=dict(type="path"),
|
||||||
|
version=dict(type="str", default="3.7.0"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -324,27 +324,27 @@ tests = [
|
|||||||
# str type and everything else was mostly unicode type (don't ask me how)
|
# str type and everything else was mostly unicode type (don't ask me how)
|
||||||
dict(
|
dict(
|
||||||
last_applied={
|
last_applied={
|
||||||
u"kind": u"ConfigMap",
|
"kind": "ConfigMap",
|
||||||
u"data": {u"one": "1", "three": "3", "two": "2"},
|
"data": {"one": "1", "three": "3", "two": "2"},
|
||||||
u"apiVersion": u"v1",
|
"apiVersion": "v1",
|
||||||
u"metadata": {u"namespace": u"apply", u"name": u"apply-configmap"},
|
"metadata": {"namespace": "apply", "name": "apply-configmap"},
|
||||||
},
|
},
|
||||||
actual={
|
actual={
|
||||||
u"kind": u"ConfigMap",
|
"kind": "ConfigMap",
|
||||||
u"data": {u"one": "1", "three": "3", "two": "2"},
|
"data": {"one": "1", "three": "3", "two": "2"},
|
||||||
u"apiVersion": u"v1",
|
"apiVersion": "v1",
|
||||||
u"metadata": {
|
"metadata": {
|
||||||
u"namespace": u"apply",
|
"namespace": "apply",
|
||||||
u"name": u"apply-configmap",
|
"name": "apply-configmap",
|
||||||
u"resourceVersion": "1714994",
|
"resourceVersion": "1714994",
|
||||||
u"creationTimestamp": u"2019-08-17T05:08:05Z",
|
"creationTimestamp": "2019-08-17T05:08:05Z",
|
||||||
u"annotations": {},
|
"annotations": {},
|
||||||
u"selfLink": u"/api/v1/namespaces/apply/configmaps/apply-configmap",
|
"selfLink": "/api/v1/namespaces/apply/configmaps/apply-configmap",
|
||||||
u"uid": u"fed45fb0-c0ac-11e9-9d95-025000000001",
|
"uid": "fed45fb0-c0ac-11e9-9d95-025000000001",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
desired={
|
desired={
|
||||||
"kind": u"ConfigMap",
|
"kind": "ConfigMap",
|
||||||
"data": {"one": "1", "three": "3", "two": "2"},
|
"data": {"one": "1", "three": "3", "two": "2"},
|
||||||
"apiVersion": "v1",
|
"apiVersion": "v1",
|
||||||
"metadata": {"namespace": "apply", "name": "apply-configmap"},
|
"metadata": {"namespace": "apply", "name": "apply-configmap"},
|
||||||
@@ -355,7 +355,7 @@ tests = [
|
|||||||
# then apply the Deployment again. Should un-scale the Deployment
|
# then apply the Deployment again. Should un-scale the Deployment
|
||||||
dict(
|
dict(
|
||||||
last_applied={
|
last_applied={
|
||||||
"kind": u"Deployment",
|
"kind": "Deployment",
|
||||||
"spec": {
|
"spec": {
|
||||||
"replicas": 1,
|
"replicas": 1,
|
||||||
"template": {
|
"template": {
|
||||||
@@ -372,10 +372,10 @@ tests = [
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"metadata": {"namespace": "apply", "name": u"apply-deployment"},
|
"metadata": {"namespace": "apply", "name": "apply-deployment"},
|
||||||
},
|
},
|
||||||
actual={
|
actual={
|
||||||
"kind": u"Deployment",
|
"kind": "Deployment",
|
||||||
"spec": {
|
"spec": {
|
||||||
"replicas": 0,
|
"replicas": 0,
|
||||||
"template": {
|
"template": {
|
||||||
@@ -392,10 +392,10 @@ tests = [
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"metadata": {"namespace": "apply", "name": u"apply-deployment"},
|
"metadata": {"namespace": "apply", "name": "apply-deployment"},
|
||||||
},
|
},
|
||||||
desired={
|
desired={
|
||||||
"kind": u"Deployment",
|
"kind": "Deployment",
|
||||||
"spec": {
|
"spec": {
|
||||||
"replicas": 1,
|
"replicas": 1,
|
||||||
"template": {
|
"template": {
|
||||||
@@ -409,7 +409,7 @@ tests = [
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"metadata": {"namespace": "apply", "name": u"apply-deployment"},
|
"metadata": {"namespace": "apply", "name": "apply-deployment"},
|
||||||
},
|
},
|
||||||
expected={
|
expected={
|
||||||
"spec": {
|
"spec": {
|
||||||
|
|||||||
@@ -26,25 +26,49 @@ from ansible_collections.kubernetes.core.plugins.module_utils.hashes import (
|
|||||||
|
|
||||||
tests = [
|
tests = [
|
||||||
dict(
|
dict(
|
||||||
resource=dict(kind="ConfigMap", name="", data=dict(),),
|
resource=dict(
|
||||||
|
kind="ConfigMap",
|
||||||
|
name="",
|
||||||
|
data=dict(),
|
||||||
|
),
|
||||||
expected=b'{"data":{},"kind":"ConfigMap","name":""}',
|
expected=b'{"data":{},"kind":"ConfigMap","name":""}',
|
||||||
),
|
),
|
||||||
dict(
|
dict(
|
||||||
resource=dict(kind="ConfigMap", name="", data=dict(one=""),),
|
resource=dict(
|
||||||
|
kind="ConfigMap",
|
||||||
|
name="",
|
||||||
|
data=dict(one=""),
|
||||||
|
),
|
||||||
expected=b'{"data":{"one":""},"kind":"ConfigMap","name":""}',
|
expected=b'{"data":{"one":""},"kind":"ConfigMap","name":""}',
|
||||||
),
|
),
|
||||||
dict(
|
dict(
|
||||||
resource=dict(
|
resource=dict(
|
||||||
kind="ConfigMap", name="", data=dict(two="2", one="", three="3",),
|
kind="ConfigMap",
|
||||||
|
name="",
|
||||||
|
data=dict(
|
||||||
|
two="2",
|
||||||
|
one="",
|
||||||
|
three="3",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
expected=b'{"data":{"one":"","three":"3","two":"2"},"kind":"ConfigMap","name":""}',
|
expected=b'{"data":{"one":"","three":"3","two":"2"},"kind":"ConfigMap","name":""}',
|
||||||
),
|
),
|
||||||
dict(
|
dict(
|
||||||
resource=dict(kind="Secret", type="my-type", name="", data=dict(),),
|
resource=dict(
|
||||||
|
kind="Secret",
|
||||||
|
type="my-type",
|
||||||
|
name="",
|
||||||
|
data=dict(),
|
||||||
|
),
|
||||||
expected=b'{"data":{},"kind":"Secret","name":"","type":"my-type"}',
|
expected=b'{"data":{},"kind":"Secret","name":"","type":"my-type"}',
|
||||||
),
|
),
|
||||||
dict(
|
dict(
|
||||||
resource=dict(kind="Secret", type="my-type", name="", data=dict(one=""),),
|
resource=dict(
|
||||||
|
kind="Secret",
|
||||||
|
type="my-type",
|
||||||
|
name="",
|
||||||
|
data=dict(one=""),
|
||||||
|
),
|
||||||
expected=b'{"data":{"one":""},"kind":"Secret","name":"","type":"my-type"}',
|
expected=b'{"data":{"one":""},"kind":"Secret","name":"","type":"my-type"}',
|
||||||
),
|
),
|
||||||
dict(
|
dict(
|
||||||
@@ -52,7 +76,11 @@ tests = [
|
|||||||
kind="Secret",
|
kind="Secret",
|
||||||
type="my-type",
|
type="my-type",
|
||||||
name="",
|
name="",
|
||||||
data=dict(two="Mg==", one="", three="Mw==",),
|
data=dict(
|
||||||
|
two="Mg==",
|
||||||
|
one="",
|
||||||
|
three="Mw==",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
expected=b'{"data":{"one":"","three":"Mw==","two":"Mg=="},"kind":"Secret","name":"","type":"my-type"}',
|
expected=b'{"data":{"one":"","three":"Mw==","two":"Mg=="},"kind":"Secret","name":"","type":"my-type"}',
|
||||||
),
|
),
|
||||||
|
|||||||
4
tox.ini
4
tox.ini
@@ -21,7 +21,7 @@ commands = collection_prep_add_docs -p .
|
|||||||
|
|
||||||
[testenv:black]
|
[testenv:black]
|
||||||
deps =
|
deps =
|
||||||
black==19.10b0
|
black >= 22.0, < 23.0
|
||||||
|
|
||||||
commands =
|
commands =
|
||||||
black -v --check --diff {toxinidir}/plugins {toxinidir}/tests
|
black -v --check --diff {toxinidir}/plugins {toxinidir}/tests
|
||||||
@@ -30,7 +30,7 @@ commands =
|
|||||||
deps =
|
deps =
|
||||||
yamllint
|
yamllint
|
||||||
flake8
|
flake8
|
||||||
black==19.10b0
|
{[testenv:black]deps}
|
||||||
|
|
||||||
commands =
|
commands =
|
||||||
black -v --check --diff {toxinidir}/plugins {toxinidir}/tests
|
black -v --check --diff {toxinidir}/plugins {toxinidir}/tests
|
||||||
|
|||||||
Reference in New Issue
Block a user