cnabio / cnab-spec

Cloud Native Application Bundle Specification
https://cnab.io
Other
958 stars 99 forks source link

Pass credentials and parameters to a dependency #424

Open carolynvs opened 2 years ago

carolynvs commented 2 years ago

When a bundle has a dependency, that dependency will also have its own parameters and credentials. How should the parent bundle decide which credentials and parameters to give to a dependency?

Here's one thought. I'm using yaml but this would all be defined in the custom dependencies section in bundle.json. In the example below, the parent bundle would pass its admin-kubeconfig credential to the mysql bundle's kubeconfig credential.

dependencies:
  requires:
    - name: mysql
       reference: getporter/mysql:v0.1.1
       credentials:
         kubeconfig:
           credential: admin-kubeconfig # pass the admin-kubeconfig credential to the kubeconfig credential
       parameters:
         databaseName:
           value: "wordpress" # hard code passing wordpress as the database name
         databaseUser:
           parameter: username # pass the username parameter to the databaseUser parameter

The example above demonstrates how a parent can pass its own parameters and credentials to the dependency. Another scenario is that the output from one dependency needs to be passed to another as a parameter/credential.

dependencies:
  requires:
    - name: mysql
       reference: getporter/mysql:v0.1.1
    - name: wordpress
       reference: getporter/wordpress:v0.1.1
       parameters:
         mysqlConnStr:
           dependency: mysql
           output: connectionString
carolynvs commented 2 years ago

If a mapping is provided, but the bundle doesn't expose that parameter/credential (i.e. they aren't in the interface) then it is ignored by the runtime. If it is exposed, the runtime does a typcheck to make sure it can be mapped.