22
22
23
23
from jinja2 import Environment , FileSystemLoader
24
24
25
- from .ocp import getConsoleURL , waitForCRD , waitForDeployment
25
+ from .ocp import getConsoleURL , waitForCRD , waitForDeployment , crdExists
26
26
27
27
logger = logging .getLogger (__name__ )
28
28
@@ -36,25 +36,26 @@ def installOpenShiftPipelines(dynClient: DynamicClient) -> bool:
36
36
37
37
# Create the Operator Subscription
38
38
try :
39
- manifest = packagemanifestAPI .get (name = "openshift-pipelines-operator-rh" , namespace = "openshift-marketplace" )
40
- defaultChannel = manifest .status .defaultChannel
41
- catalogSource = manifest .status .catalogSource
42
- catalogSourceNamespace = manifest .status .catalogSourceNamespace
43
-
44
- logger .info (f"OpenShift Pipelines Operator Details: { catalogSourceNamespace } /{ catalogSource } @{ defaultChannel } " )
45
-
46
- templateDir = path .join (path .abspath (path .dirname (__file__ )), "templates" )
47
- env = Environment (
48
- loader = FileSystemLoader (searchpath = templateDir )
49
- )
50
- template = env .get_template ("subscription.yml.j2" )
51
- renderedTemplate = template .render (
52
- pipelines_channel = defaultChannel ,
53
- pipelines_source = catalogSource ,
54
- pipelines_source_namespace = catalogSourceNamespace
55
- )
56
- subscription = yaml .safe_load (renderedTemplate )
57
- subscriptionsAPI .apply (body = subscription , namespace = "openshift-operators" )
39
+ if not crdExists (dynClient , "pipelines.tekton.dev" ):
40
+ manifest = packagemanifestAPI .get (name = "openshift-pipelines-operator-rh" , namespace = "openshift-marketplace" )
41
+ defaultChannel = manifest .status .defaultChannel
42
+ catalogSource = manifest .status .catalogSource
43
+ catalogSourceNamespace = manifest .status .catalogSourceNamespace
44
+
45
+ logger .info (f"OpenShift Pipelines Operator Details: { catalogSourceNamespace } /{ catalogSource } @{ defaultChannel } " )
46
+
47
+ templateDir = path .join (path .abspath (path .dirname (__file__ )), "templates" )
48
+ env = Environment (
49
+ loader = FileSystemLoader (searchpath = templateDir )
50
+ )
51
+ template = env .get_template ("subscription.yml.j2" )
52
+ renderedTemplate = template .render (
53
+ pipelines_channel = defaultChannel ,
54
+ pipelines_source = catalogSource ,
55
+ pipelines_source_namespace = catalogSourceNamespace
56
+ )
57
+ subscription = yaml .safe_load (renderedTemplate )
58
+ subscriptionsAPI .apply (body = subscription , namespace = "openshift-operators" )
58
59
59
60
except NotFoundError :
60
61
logger .warning ("Error: Couldn't find package manifest for Red Hat Openshift Pipelines Operator" )
0 commit comments