#######################################################################################
# Copyright ETSI Contributors and Others.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#######################################################################################
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  name: {{ workflow_name }}
spec:
  arguments:
    parameters:
    # Fleet repo
    - name: git_fleet_url
      value: "{{ git_fleet_url }}"
    - name: fleet_destination_folder
      value: "/fleet/fleet-osm"
    - name: git_fleet_cred_secret
      value: fleet-repo
    # HelmRelease generation
    - name: helmrelease_name
      value: "jenkins"
    - name: chart_name
      value: "jenkins"
    - name: chart_version
      value: '13.4.x'
    - name: target_ns
      value: "jenkins"
    - name: create_ns
      value: "true"
    # Repo source generation
    - name: is_preexisting_repo
      value: "false"
    - name: helmrepo_name
      value: "bitnamicharts"
    - name: helmrepo_url
      value: oci://registry-1.docker.io/bitnamicharts
    - name: helmrepo_ns
      value: "jenkins"
    - name: helmrepo_secret_ref
      value: ""
    # HelmRelease inline values (if any)
    - name: inline_values
      # Install some Jenkins plugins:
      value: |
        plugins:
        - kubernetes:3852.v41ea_166a_ed1b_
        - workflow-aggregator:590.v6a_d052e5a_a_b_5
        - git:4.13.0
        - configuration-as-code:1569.vb_72405b_80249
        # overridePlugins: true
    # Secret reference and generation (if required)
    - name: is_preexisting_secret
      value: "false"
    - name: values_secret_name
      value: "mysecret"
    - name: secret_key
      value: "values.yaml"
    - name: age_public_key
      value: "age1s236gmpr7myjjyqfrl6hwz0npqjgxa9t6tjj46yq28j2c4nk653saqreav"
    - name: reference_secret_for_values
      value: "jenkins-credentials"
    - name: reference_key_for_values
      value: "creds"
    # ConfigMap reference and generation (if required)
    - name: is_preexisting_cm
      value: "false"
    - name: values_cm_name
      value: ""
    - name: cm_key
      value: "values.yaml"
    - name: cm_values
      value: ""
      # value: |
      #   cm-key1: cm-value1
      #   cm-key2: cm-value2
    # KSU rendering
    - name: ksu_name
      value: "jenkins"
    - name: profile_name
      value: "myakscluster01"
    - name: profile_type
      value: "applications"
    - name: project_name
      value: "osm_admin"
    # Debug/dry run?
    - name: debug
      value: "{{ workflow_debug }}"
    - name: dry_run
      value: "{{ workflow_dry_run }}"

  # Cleanup policy
  ttlStrategy:
    secondsAfterCompletion: 600  # Time to live after workflow is completed, replaces ttlSecondsAfterFinished
    secondsAfterSuccess: 600     # Time to live after workflow is successful
    secondsAfterFailure: 900     # Time to live after workflow fails

  workflowTemplateRef:
    name: full-update-ksu-generated-hr-wtf
