metadata:
  name: abapEnvironmentPushATCSystemConfig
  description: Create/Update ATC System Configuration
  longDescription: |
    This step is for creating/updating an [ATC](https://help.sap.com/products/BTP/65de2977205c403bbc107264b8eccf4b/657285a09f7148d894c27bb8e17827cf.html?version=Cloud) system configurationon on an SAP BTP, ABAP Environment system.
    Please provide either of the following options:

    * The host and credentials the SAP BTP, ABAP Environment system itself. The credentials must be configured for the Communication Scenario [SAP_COM_0763](https://help.sap.com/products/BTP/65de2977205c403bbc107264b8eccf4b/657285a09f7148d894c27bb8e17827cf.html?version=Cloud).
    * The Cloud Foundry parameters (API endpoint, organization, space), credentials, the service instance for the ABAP service and the service key for the Communication Scenario SAP_COM_0763.
    * Only provide one of those options with the respective credentials. If all values are provided, the direct communication (via host) has priority.

spec:
  inputs:
    secrets:
      - name: abapCredentialsId
        aliases:
          - name: cfCredentialsId
        description: Jenkins credentials ID containing user and password to authenticate to the SAP BTP, ABAP Environment system or the Cloud Foundry API
        type: jenkins
    params:
      - name: atcSystemConfigFilePath
        type: string
        description: Path to a JSON file with ATC System Configuration
        scope:
          - PARAMETERS
          - STAGES
          - STEPS
        mandatory: true
      - name: patchIfExisting
        type: bool
        description: In case an configuration under the given name already exists in the system. Should the step update/patch the existing ATC Systm Configuration from the provided ATC System Configuration file?
        scope:
          - PARAMETERS
          - STAGES
          - STEPS
        default: true
      - name: cfApiEndpoint
        type: string
        description: Cloud Foundry API endpoint
        scope:
          - PARAMETERS
          - STAGES
          - STEPS
          - GENERAL
        mandatory: false
        aliases:
          - name: cloudFoundry/apiEndpoint
      - name: cfOrg
        type: string
        description: CF org
        scope:
          - PARAMETERS
          - STAGES
          - STEPS
          - GENERAL
        mandatory: false
        aliases:
          - name: cloudFoundry/org
      - name: cfServiceInstance
        type: string
        description: Parameter of ServiceInstance Name to delete CloudFoundry Service
        scope:
          - PARAMETERS
          - STAGES
          - STEPS
          - GENERAL
        mandatory: false
        aliases:
          - name: cloudFoundry/serviceInstance
      - name: cfServiceKeyName
        type: string
        description: Parameter of CloudFoundry Service Key to be created
        scope:
          - PARAMETERS
          - STAGES
          - STEPS
          - GENERAL
        mandatory: false
        aliases:
          - name: cloudFoundry/serviceKey
          - name: cloudFoundry/serviceKeyName
          - name: cfServiceKey
      - name: cfSpace
        type: string
        description: CF Space
        scope:
          - PARAMETERS
          - STAGES
          - STEPS
          - GENERAL
        mandatory: false
        aliases:
          - name: cloudFoundry/space
      - name: username
        type: string
        description: User for either the Cloud Foundry API or the Communication Arrangement for SAP_COM_0763
        scope:
          - PARAMETERS
          - STAGES
          - STEPS
        mandatory: true
        secret: true
        resourceRef:
          - name: abapCredentialsId
            type: secret
            param: username
      - name: password
        type: string
        description: Password for either the Cloud Foundry API or the Communication Arrangement for SAP_COM_0763
        scope:
          - PARAMETERS
          - STAGES
          - STEPS
        mandatory: true
        secret: true
        resourceRef:
          - name: abapCredentialsId
            type: secret
            param: password
      - name: host
        type: string
        description: Specifies the host address of the SAP SAP BTP, ABAP Environment system
        scope:
          - PARAMETERS
          - STAGES
          - STEPS
          - GENERAL
        mandatory: false

  containers:
    - name: cf
      image: ppiper/cf-cli:7
