2222
2323from jinja2 import Environment , FileSystemLoader
2424
25- from .ocp import getConsoleURL , waitForCRD , waitForDeployment
25+ from .ocp import getConsoleURL , waitForCRD , waitForDeployment , crdExists
2626
2727logger = logging .getLogger (__name__ )
2828
@@ -36,25 +36,26 @@ def installOpenShiftPipelines(dynClient: DynamicClient) -> bool:
3636
3737 # Create the Operator Subscription
3838 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" )
5859
5960 except NotFoundError :
6061 logger .warning ("Error: Couldn't find package manifest for Red Hat Openshift Pipelines Operator" )
0 commit comments