-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from ficap/glbc
Preparations for glbc tests
- Loading branch information
Showing
5 changed files
with
112 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
"""Kubernetes Ingress object""" | ||
from typing import Any, Dict, List, Optional, TYPE_CHECKING | ||
|
||
from testsuite.objects import LifecycleObject | ||
from testsuite.openshift.objects import OpenShiftObject | ||
|
||
if TYPE_CHECKING: | ||
# pylint: disable=cyclic-import | ||
from testsuite.openshift.client import OpenShiftClient | ||
|
||
|
||
class Ingress(OpenShiftObject, LifecycleObject): | ||
"""Represents Kubernetes Ingress object""" | ||
|
||
@classmethod | ||
def create_instance(cls, openshift: 'OpenShiftClient', name, rules: Optional[List[Dict[str, Any]]] = None, | ||
tls: Optional[List[Dict[str, Any]]] = None): | ||
"""Creates base instance""" | ||
if rules is None: | ||
rules = [] | ||
|
||
if tls is None: | ||
tls = [] | ||
|
||
model: Dict[str, Any] = { | ||
"apiVersion": "networking.k8s.io/v1", | ||
"kind": "Ingress", | ||
"metadata": { | ||
"name": name, | ||
"namespace": openshift.project | ||
}, | ||
"spec": { | ||
"rules": rules, | ||
"tls": tls | ||
} | ||
} | ||
|
||
with openshift.context: | ||
return cls(model) | ||
|
||
@classmethod | ||
def create_service_ingress(cls, openshift: 'OpenShiftClient', name, service_name, port_number=80, path="/", | ||
path_type="Prefix", host=None): | ||
""" | ||
Creates Ingress instance for service without tls configured | ||
""" | ||
rule = { | ||
"http": { | ||
"paths": [ | ||
{ | ||
"backend": { | ||
"service": { | ||
"name": service_name, | ||
"port": { | ||
"number": port_number | ||
} | ||
} | ||
}, | ||
"path": path, | ||
"pathType": path_type | ||
}, | ||
] | ||
} | ||
} | ||
|
||
if host is not None: | ||
rule["host"] = host | ||
|
||
return cls.create_instance(openshift, name, rules=[rule]) | ||
|
||
@property | ||
def rules(self): | ||
"""Returns rules defined in the ingress""" | ||
return self.model.spec.rules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters