apiVersion: xl/v2
kind: Blueprint
metadata:
  name: XL OP
  description: |
    This blueprint deploys DAI Deploy operator, DAI Release operator, and XL-k8s-foundation into an existing Kubernetes installation (local single-node Kubernetes, on-premises multi-node Kubernetes cluster, or Amazon EKS cluster).
  author: Digital.ai
  version: 1.0
spec:
  parameters:
    - name: ServerType
      type: Select
      prompt: "Product server you want to perform upgrade for"
      options:
        - label: Digital.ai Release
          value: daiRelease
        - label: Digital.ai Deploy
          value: daiDeploy
      saveInXlvals: true
      description: "Product server you want to perform upgrade for?"
    - name: RepositoryName
      type: Input
      saveInXlvals: true
      ignoreIfSkipped: true
      overrideDefault: true
      prompt: "Enter the repository name (eg: <repositoryName>/<imageName>:<tagName>)"
      default: xebialabs
      description: "Enter the image tag to use"
    - name: ImageNameDeploy
      type: Input
      saveInXlvals: true
      ignoreIfSkipped: true
      overrideDefault: true
      promptIf: !expr "ServerType == 'daiDeploy'"
      prompt: "Enter the image name (eg: <repositoryName>/<imageName>:<tagName>)"
      default: xl-deploy
      description: "Enter the image tag to use"
    - name: ImageNameRelease
      type: Input
      saveInXlvals: true
      ignoreIfSkipped: true
      overrideDefault: true
      promptIf: !expr "ServerType == 'daiRelease'"
      prompt: "Enter the image name (eg: <repositoryName>/<imageName>:<tagName>)"
      default: xl-release
      description: "Enter the image tag to use"
    - name: ImageTag
      type: Input
      saveInXlvals: true
      ignoreIfSkipped: true
      overrideDefault: true
      prompt: "Enter the image tag (eg: <repositoryName>/<imageName>:<tagName>)"
      default: 10.3.18
      description: "Enter the image tag to use"
    - name: UpgradeType
      type: Select
      prompt: "Select the type of upgrade you want."
      options:
        - label: Operator to Operator
          value: operatorToOperator
        - label: Helm to Operator
          value: helmToOperator
      saveInXlvals: true
      description: "Type of upgrade you want?"
    - name: OperatorImageDeployGeneric
      type: Input
      saveInXlvals: true
      ignoreIfSkipped: true
      overrideDefault: true
      prompt: "Enter the operator image to use (eg: <repositoryName>/<imageName>:<tagName>)"
      promptIf: !expr "ServerType == 'daiDeploy' && K8sSetup != 'Openshift'"
      default: xebialabs/deploy-operator:10.3.18
      description: "Enter the operator image to use"
    - name: OperatorImageDeployOpenshift
      type: Input
      saveInXlvals: true
      ignoreIfSkipped: true
      overrideDefault: true
      prompt: "Enter the operator image to use (eg: <repositoryName>/<imageName>:<tagName>)"
      promptIf: !expr "ServerType == 'daiDeploy' && K8sSetup == 'Openshift'"
      default: xebialabs/deploy-operator:10.3.18-openshift
      description: "Enter the operator image to use"
    - name: OperatorImageReleaseGeneric
      type: Input
      saveInXlvals: true
      ignoreIfSkipped: true
      overrideDefault: true
      prompt: "Enter the operator image to use (eg: <repositoryName>/<imageName>:<tagName>)"
      promptIf: !expr "ServerType == 'daiRelease' && K8sSetup != 'Openshift'"
      default: xebialabsunsupported/release-operator:10.3.18
      description: "Enter the operator image to use"
    - name: OperatorImageReleaseOpenshift
      type: Input
      saveInXlvals: true
      ignoreIfSkipped: true
      overrideDefault: true
      prompt: "Enter the operator image to use (eg: <repositoryName>/<imageName>:<tagName>)"
      promptIf: !expr "ServerType == 'daiRelease' && K8sSetup == 'Openshift'"
      default: xebialabsunsupported/release-operator:10.3.18-openshift
      description: "Enter the operator image to use"
    - name: CrName
      type: Input
      saveInXlvals: true
      promptIf: !expr "UpgradeType == 'operatorToOperator'"
      prompt: "Enter the name of custom resource."
      ignoreIfSkipped: true
      overrideDefault: true
      description: "The name of your custom resource"
    - name: CrdName
      type: Input
      saveInXlvals: true
      promptIf: !expr "UpgradeType == 'operatorToOperator'"
      prompt: "Enter the name of custom resource definition."
      ignoreIfSkipped: true
      overrideDefault: true
      description: "The name of your custom resource definition."
    - name: ReleaseName
      type: Input
      saveInXlvals: true
      promptIf: !expr "UpgradeType == 'helmToOperator'"
      prompt: "Enter the helm release name."
      ignoreIfSkipped: true
      overrideDefault: true
      description: "The name of your custom resource definition."
  files:
    # k8s-foundation
    - path: xebialabs/xl-k8s-foundation.yaml.tmpl
    # files to write if server to deploy is Deploy and kubernetes setup is docker desktop
    - path: xebialabs/dai-deploy/template-generic/cluster-role-digital-proxy-role.yaml
      writeIf: !expr "ServerType == 'daiDeploy' && K8sSetup != 'Openshift'"
    - path: xebialabs/dai-deploy/template-generic/cluster-role-manager-role.yaml
      writeIf: !expr "ServerType == 'daiDeploy' && K8sSetup != 'Openshift'"
    - path: xebialabs/dai-deploy/template-generic/cluster-role-metrics-reader.yaml
      writeIf: !expr "ServerType == 'daiDeploy' && K8sSetup != 'Openshift'"
    - path: xebialabs/dai-deploy/template-generic/controller-manager-metrics-service.yaml
      writeIf: !expr "ServerType == 'daiDeploy' && K8sSetup != 'Openshift'"
    - path: xebialabs/dai-deploy/template-generic/custom-resource-definition.yaml
      writeIf: !expr "ServerType == 'daiDeploy' && K8sSetup != 'Openshift'"
    - path: xebialabs/dai-deploy/template-generic/leader-election-role.yaml
      writeIf: !expr "ServerType == 'daiDeploy' && K8sSetup != 'Openshift'"
    - path: xebialabs/dai-deploy/template-generic/leader-election-rolebinding.yaml
      writeIf: !expr "ServerType == 'daiDeploy' && K8sSetup != 'Openshift'"
    - path: xebialabs/dai-deploy/template-generic/manager-rolebinding.yaml.tmpl
      writeIf: !expr "ServerType == 'daiDeploy' && K8sSetup != 'Openshift'"
    - path: xebialabs/dai-deploy/template-generic/proxy-rolebinding.yaml.tmpl
      writeIf: !expr "ServerType == 'daiDeploy' && K8sSetup != 'Openshift'"
    - path: xebialabs/dai-deploy/template-generic/deployment.yaml.tmpl
      writeIf: !expr "ServerType == 'daiDeploy' && K8sSetup != 'Openshift'"
    - path: xebialabs/dai-deploy-operator.yaml.tmpl
      writeIf: !expr "ServerType == 'daiDeploy' && K8sSetup != 'Openshift'"
    # files to write if server to deploy is Release and kubernetes environment is docker desktop
    - path: xebialabs/dai-release/template-generic/cluster-role-digital-proxy-role.yaml
      writeIf: !expr "ServerType == 'daiRelease' && K8sSetup != 'Openshift'"
    - path: xebialabs/dai-release/template-generic/cluster-role-manager-role.yaml
      writeIf: !expr "ServerType == 'daiRelease' && K8sSetup != 'Openshift'"
    - path: xebialabs/dai-release/template-generic/cluster-role-metrics-reader.yaml
      writeIf: !expr "ServerType == 'daiRelease' && K8sSetup != 'Openshift'"
    - path: xebialabs/dai-release/template-generic/controller-manager-metrics-service.yaml
      writeIf: !expr "ServerType == 'daiRelease' && K8sSetup != 'Openshift'"
    - path: xebialabs/dai-release/template-generic/custom-resource-definition.yaml
      writeIf: !expr "ServerType == 'daiRelease' && K8sSetup != 'Openshift'"
    - path: xebialabs/dai-release/template-generic/leader-election-role.yaml
      writeIf: !expr "ServerType == 'daiRelease' && K8sSetup != 'Openshift'"
    - path: xebialabs/dai-release/template-generic/leader-election-rolebinding.yaml
      writeIf: !expr "ServerType == 'daiRelease' && K8sSetup != 'Openshift'"
    - path: xebialabs/dai-release/template-generic/manager-rolebinding.yaml.tmpl
      writeIf: !expr "ServerType == 'daiRelease' && K8sSetup != 'Openshift'"
    - path: xebialabs/dai-release/template-generic/proxy-rolebinding.yaml.tmpl
      writeIf: !expr "ServerType == 'daiRelease' && K8sSetup != 'Openshift'"
    - path: xebialabs/dai-release-operator.yaml.tmpl
      writeIf: !expr "ServerType == 'daiRelease' && K8sSetup != 'Openshift'"
    - path: xebialabs/dai-release/template-generic/deployment.yaml.tmpl
      writeIf: !expr "ServerType == 'daiRelease' && K8sSetup != 'Openshift'"
    # files to write if server to deploy is Deploy and kubernetes setup is openshift
    - path: xebialabs/dai-deploy/template-openshift/cluster-role-digital-proxy-role.yaml
      writeIf: !expr "ServerType == 'daiDeploy' && K8sSetup == 'Openshift'"
    - path: xebialabs/dai-deploy/template-openshift/cluster-role-manager-role.yaml
      writeIf: !expr "ServerType == 'daiDeploy' && K8sSetup == 'Openshift'"
    - path: xebialabs/dai-deploy/template-openshift/cluster-role-metrics-reader.yaml
      writeIf: !expr "ServerType == 'daiDeploy' && K8sSetup == 'Openshift'"
    - path: xebialabs/dai-deploy/template-openshift/controller-manager-metrics-service.yaml
      writeIf: !expr "ServerType == 'daiDeploy' && K8sSetup == 'Openshift'"
    - path: xebialabs/dai-deploy/template-openshift/custom-resource-definition.yaml
      writeIf: !expr "ServerType == 'daiDeploy' && K8sSetup == 'Openshift'"
    - path: xebialabs/dai-deploy/template-openshift/leader-election-role.yaml
      writeIf: !expr "ServerType == 'daiDeploy' && K8sSetup == 'Openshift'"
    - path: xebialabs/dai-deploy/template-openshift/leader-election-rolebinding.yaml
      writeIf: !expr "ServerType == 'daiDeploy' && K8sSetup == 'Openshift'"
    - path: xebialabs/dai-deploy/template-openshift/manager-rolebinding.yaml.tmpl
      writeIf: !expr "ServerType == 'daiDeploy' && K8sSetup == 'Openshift'"
    - path: xebialabs/dai-deploy/template-openshift/proxy-rolebinding.yaml.tmpl
      writeIf: !expr "ServerType == 'daiDeploy' && K8sSetup == 'Openshift'"
    - path: xebialabs/dai-deploy/template-openshift/deployment.yaml.tmpl
      writeIf: !expr "ServerType == 'daiDeploy' && K8sSetup == 'Openshift'"
    - path: xebialabs/dai-deploy-operator.yaml.tmpl
      writeIf: !expr "ServerType == 'daiDeploy' && K8sSetup == 'Openshift'"
    # files to write if server to deploy is Release and kubernetes environment is openshift
    - path: xebialabs/dai-release/template-openshift/cluster-role-digital-proxy-role.yaml
      writeIf: !expr "ServerType == 'daiRelease' && K8sSetup == 'Openshift'"
    - path: xebialabs/dai-release/template-openshift/cluster-role-manager-role.yaml
      writeIf: !expr "ServerType == 'daiRelease' && K8sSetup == 'Openshift'"
    - path: xebialabs/dai-release/template-openshift/cluster-role-metrics-reader.yaml
      writeIf: !expr "ServerType == 'daiRelease' && K8sSetup == 'Openshift'"
    - path: xebialabs/dai-release/template-openshift/controller-manager-metrics-service.yaml
      writeIf: !expr "ServerType == 'daiRelease' && K8sSetup == 'Openshift'"
    - path: xebialabs/dai-release/template-openshift/custom-resource-definition.yaml
      writeIf: !expr "ServerType == 'daiRelease' && K8sSetup == 'Openshift'"
    - path: xebialabs/dai-release/template-openshift/leader-election-role.yaml
      writeIf: !expr "ServerType == 'daiRelease' && K8sSetup == 'Openshift'"
    - path: xebialabs/dai-release/template-openshift/leader-election-rolebinding.yaml
      writeIf: !expr "ServerType == 'daiRelease' && K8sSetup == 'Openshift'"
    - path: xebialabs/dai-release/template-openshift/manager-rolebinding.yaml.tmpl
      writeIf: !expr "ServerType == 'daiRelease' && K8sSetup == 'Openshift'"
    - path: xebialabs/dai-release/template-openshift/proxy-rolebinding.yaml.tmpl
      writeIf: !expr "ServerType == 'daiRelease' && K8sSetup == 'Openshift'"
    - path: xebialabs/dai-release-operator.yaml.tmpl
      writeIf: !expr "ServerType == 'daiRelease' && K8sSetup == 'Openshift'"
    - path: xebialabs/dai-release/template-openshift/deployment.yaml.tmpl
      writeIf: !expr "ServerType == 'daiRelease' && K8sSetup == 'Openshift'"
    - path: xebialabs/common.yaml.tmpl
    - path: xebialabs/deployments.yaml.tmpl
    - path: generated_answers.yaml.tmpl
    - path: xebialabs.yaml.tmpl
