vmware-tanzu / cartographer

Cartographer is a Supply Chain Choreographer.
https://cartographer.sh
Apache License 2.0
447 stars 64 forks source link

Support params specific to template option selected #974

Open xyloman opened 2 years ago

xyloman commented 2 years ago

Description of problem

Ability to have specific parameters passed to a template when selected via options:

Proposed solution

Update options selection of the templateRef for a resource to take option specific params.

Given a templateRef with options
When parameters need to flex based upon the selected template
Then parameters specific to the selected template will be provided

Example

  - name: image-provider
    templateRef:
      kind: ClusterImageTemplate
      options:
        - name: kpack-template
          selector:
            matchFields:
              - key: spec.params[?(@.name=="dockerfile")]
                operator: DoesNotExist
              - key: spec.image
                operator: DoesNotExist
           params:
              - name: clusterBuilder
                default: #@ data.values.cluster_builder
              - name: serviceAccount
                value: kpack-image-builder-service-account
              - name: registry
                value: myregistry2.com/myrepo
        - name: kaniko-template
          selector:
            matchFields:
              - key: spec.params[?(@.name=="dockerfile")]
                operator: Exists
              - key: spec.image
                operator: DoesNotExist
          params:
              - name: dockerfile
                default: ./Dockerfile
              - name: docker_build_context
                default: ./
              - name: docker_build_extra_args
                default: []
              - name: serviceAccount
                value: docker-image-builder-service-account
              - name: registry
                value: myregistry.com/myrepo
        - name: image-provider-template
          selector:
            matchFields:
              - key: spec.image
                operator: Exists
    sources:
    - resource: source-git
      name: source
github-actions[bot] commented 2 years ago

Hello @xyloman! Welcome to the Cartographer community and thank you for opening your first issue, we appreciate your contributions