Skip to content

Commit

Permalink
FIX Linting problems
Browse files Browse the repository at this point in the history
  • Loading branch information
angelbarrera92 committed Apr 26, 2021
1 parent c9fcef4 commit d01dc6c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions k8spin_common/k8spin_common/resources/space.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def ensure_space_resources(organization: k8spin_common.Organization, tenant: k8s
ensure_space_network_policies(
organization=organization, tenant=tenant, space_name=space_name)


@kubernetes_api
def ensure_space_namespace(api, organization: k8spin_common.Organization, tenant: k8spin_common.Tenant, space_name: str):
space_namespace_name = space_namespacename_generator(
Expand Down Expand Up @@ -83,6 +84,7 @@ def ensure_space_limit_range(api, organization: k8spin_common.Organization, tena
space_limit_range = ensure(space_limit_range, space)
return space_limit_range


@kubernetes_api
def ensure_space_network_policies(api, organization: k8spin_common.Organization, tenant: k8spin_common.Tenant, space_name: str):
space = get_space(space_name, tenant.name, organization.name)
Expand All @@ -99,6 +101,7 @@ def ensure_space_network_policies(api, organization: k8spin_common.Organization,
space_network_policy = ensure(space_network_policy, space)
return space_network_policy


@kubernetes_api
def ensure_space_role_bindings(api, organization: k8spin_common.Organization, tenant: k8spin_common.Tenant, space_name: str):
space = get_space(space_name=space_name, tenant_name=tenant.name,
Expand All @@ -119,8 +122,10 @@ def ensure_space_role_bindings(api, organization: k8spin_common.Organization, te
target_kind = "User"
targets = role.get('users', list())
for target in targets:
target_namespace = target.split(":")[0] if target_kind == "ServiceAccount" else None
target = target.split(":")[1] if target_kind == "ServiceAccount" else target
target_namespace = target.split(
":")[0] if target_kind == "ServiceAccount" else None
target = target.split(
":")[1] if target_kind == "ServiceAccount" else target
rolebinding_name = f"{space_name}-{name}-{target_kind.lower()}-{target.lower()}"
labels = {
"k8spin.cloud/type": "role",
Expand Down
6 changes: 3 additions & 3 deletions k8spin_webhook/mutator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import jsonpatch
from flask import Blueprint, jsonify, request
from k8spin_common.resources import tenant, space
from k8spin_common.resources import space, tenant
from loguru import logger

blueprint = Blueprint("mutator", __name__, url_prefix="/mutator")
Expand Down Expand Up @@ -66,6 +66,7 @@ def space_mutator():
def pod_mutator():
request_info = request.get_json()
try:
# pylint: disable=E1120
parent_space = space.get_space_from_namespace(
space_namespace_name=request_info["request"]["namespace"])
except KeyError: # Not a k8spin managed namespace
Expand All @@ -77,5 +78,4 @@ def pod_mutator():
"value": parent_space.runtime
}])
return mutator_response(True, "", patch)
else:
return jsonify({"response": {"allowed": True}})
return jsonify({"response": {"allowed": True}})

0 comments on commit d01dc6c

Please sign in to comment.