Skip to content

Commit 99c2040

Browse files
committed
[major] Use DynamicClient to install Tekton Resources
1 parent c6439a8 commit 99c2040

22 files changed

Lines changed: 1843 additions & 855 deletions

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[flake8]
22
# These rules are ignored
33
# - E501 line too long
4-
ignore = E501
4+
extend-ignore = E501 D
55
max-line-length = 120

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ kubectl.exe
1717
/build
1818
/.vscode
1919
/site
20+
/.bob/.bob-errors
21+
/.bob/notes

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
default_language_version:
22
python: python
33
repos:
4-
- repo: https://github.com/hhatto/autopep8
5-
rev: v2.3.2
4+
- repo: https://github.com/psf/black
5+
rev: 26.5.1
66
hooks:
7-
- id: autopep8
7+
- id: black
88
- repo: https://github.com/PyCQA/flake8
99
rev: 7.3.0
1010
hooks:

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
mas.devops
22
===============================================================================
3-
[![Code style: PEP8](https://img.shields.io/badge/code%20style-PEP--8-blue.svg)](https://peps.python.org/pep-0008/)
3+
[![Code Style: Black](https://img.shields.io/badge/Code%20Style-Black-000000.svg)](https://github.com/psf/black)
44
[![Flake8: checked](https://img.shields.io/badge/flake8-checked-blueviolet)](https://flake8.pycqa.org/en/latest/)
55
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/ibm-mas/python-devops/python-release.yml)
66
[![PyPI - Version](https://img.shields.io/pypi/v/mas.devops)](https://pypi.org/project/mas-devops)
@@ -31,7 +31,7 @@ installOpenShiftPipelines(dynamicClient)
3131

3232
# Create the pipelines namespace and install the MAS tekton definitions
3333
createNamespace(dynamicClient, pipelinesNamespace)
34-
updateTektonDefinitions(pipelinesNamespace, "/mascli/templates/ibm-mas-tekton.yaml")
34+
updateTektonDefinitions(dynamicClient, pipelinesNamespace, "/mascli/templates/ibm-mas-tekton.yaml")
3535

3636
# Launch the upgrade pipeline and print the URL to view the pipeline run
3737
pipelineURL = launchUpgradePipeline(self.dynamicClient, instanceId)
@@ -73,7 +73,7 @@ mas-devops-create-initial-users-for-saas \
7373
--manage-api-port 8443 \
7474
--coreapi-port 8444 \
7575
--admin-dashboard-port 8445
76-
76+
7777

7878
mas-devops-create-initial-users-for-saas \
7979
--mas-instance-id tgk01 \

docs/getting-started/quickstart.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ print("OpenShift Pipelines installed successfully")
5656
pipelinesNamespace = "mas-myinstance-pipelines"
5757
tektonYamlPath = "/path/to/ibm-mas-tekton.yaml"
5858

59-
updateTektonDefinitions(pipelinesNamespace, tektonYamlPath)
59+
updateTektonDefinitions(dynClient, pipelinesNamespace, tektonYamlPath)
6060
print("Tekton definitions updated successfully")
6161
```
6262

@@ -96,7 +96,7 @@ createNamespace(dynClient, pipelinesNamespace)
9696

9797
# Update Tekton definitions
9898
print("Updating Tekton definitions...")
99-
updateTektonDefinitions(pipelinesNamespace, tektonYamlPath)
99+
updateTektonDefinitions(dynClient, pipelinesNamespace, tektonYamlPath)
100100

101101
# Launch upgrade pipeline
102102
print("Launching upgrade pipeline...")

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ installOpenShiftPipelines(dynamicClient)
4545

4646
# Create the pipelines namespace and install the MAS tekton definitions
4747
createNamespace(dynamicClient, pipelinesNamespace)
48-
updateTektonDefinitions(pipelinesNamespace, "/mascli/templates/ibm-mas-tekton.yaml")
48+
updateTektonDefinitions(dynamicClient, pipelinesNamespace, "/mascli/templates/ibm-mas-tekton.yaml")
4949

5050
# Launch the upgrade pipeline and print the URL to view the pipeline run
5151
pipelineURL = launchUpgradePipeline(self.dynamicClient, instanceId)

src/mas/devops/aiservice.py

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010

1111
import logging
1212
from openshift.dynamic import DynamicClient
13-
from openshift.dynamic.exceptions import NotFoundError, ResourceNotFoundError, UnauthorizedError
13+
from openshift.dynamic.exceptions import (
14+
NotFoundError,
15+
ResourceNotFoundError,
16+
UnauthorizedError,
17+
)
1418

1519
from .ocp import listInstances
1620
from .olm import getSubscription
@@ -53,7 +57,9 @@ def verifyAiServiceInstance(dynClient: DynamicClient, instanceId: str) -> bool:
5357
or authorization fails.
5458
"""
5559
try:
56-
aiserviceAPI = dynClient.resources.get(api_version="aiservice.ibm.com/v1", kind="AIServiceApp")
60+
aiserviceAPI = dynClient.resources.get(
61+
api_version="aiservice.ibm.com/v1", kind="AIServiceApp"
62+
)
5763
aiserviceAPI.get(name=instanceId, namespace=f"aiservice-{instanceId}")
5864
return True
5965
except NotFoundError:
@@ -64,7 +70,9 @@ def verifyAiServiceInstance(dynClient: DynamicClient, instanceId: str) -> bool:
6470
print("RESOURCE NOT FOUND")
6571
return False
6672
except UnauthorizedError as e:
67-
logger.error(f"Error: Unable to verify AI Service instance due to failed authorization: {e}")
73+
logger.error(
74+
f"Error: Unable to verify AI Service instance due to failed authorization: {e}"
75+
)
6876
return False
6977

7078

@@ -85,7 +93,9 @@ def listAiServiceTenantInstances(dynClient: DynamicClient) -> list:
8593
return listInstances(dynClient, "aiservice.ibm.com/v1", "AIServiceTenant")
8694

8795

88-
def verifyAiServiceTenantInstance(dynClient: DynamicClient, instanceId: str, tenantId: str) -> bool:
96+
def verifyAiServiceTenantInstance(
97+
dynClient: DynamicClient, instanceId: str, tenantId: str
98+
) -> bool:
8999
"""
90100
Verify that a specific AI Service Tenant exists in the cluster.
91101
@@ -104,8 +114,13 @@ def verifyAiServiceTenantInstance(dynClient: DynamicClient, instanceId: str, ten
104114
or authorization fails.
105115
"""
106116
try:
107-
aiserviceTenantAPI = dynClient.resources.get(api_version="aiservice.ibm.com/v1", kind="AIServiceTenant")
108-
aiserviceTenantAPI.get(name=f"aiservice-{instanceId}-{tenantId}", namespace=f"aiservice-{instanceId}")
117+
aiserviceTenantAPI = dynClient.resources.get(
118+
api_version="aiservice.ibm.com/v1", kind="AIServiceTenant"
119+
)
120+
aiserviceTenantAPI.get(
121+
name=f"aiservice-{instanceId}-{tenantId}",
122+
namespace=f"aiservice-{instanceId}",
123+
)
109124
return True
110125
except NotFoundError:
111126
print("NOT FOUND")
@@ -115,7 +130,9 @@ def verifyAiServiceTenantInstance(dynClient: DynamicClient, instanceId: str, ten
115130
print("RESOURCE NOT FOUND")
116131
return False
117132
except UnauthorizedError as e:
118-
logger.error(f"Error: Unable to verify AI Service Tenant due to failed authorization: {e}")
133+
logger.error(
134+
f"Error: Unable to verify AI Service Tenant due to failed authorization: {e}"
135+
)
119136
return False
120137

121138

@@ -134,7 +151,9 @@ def getAiserviceChannel(dynClient: DynamicClient, instanceId: str) -> str | None
134151
str: The channel name (e.g., "v1.0", "stable") if the subscription exists,
135152
None if the subscription is not found.
136153
"""
137-
aiserviceSubscription = getSubscription(dynClient, f"aiservice-{instanceId}", "ibm-aiservice")
154+
aiserviceSubscription = getSubscription(
155+
dynClient, f"aiservice-{instanceId}", "ibm-aiservice"
156+
)
138157
if aiserviceSubscription is None:
139158
return None
140159
else:

0 commit comments

Comments
 (0)