Read And Write Config In Pipeline
After you read the Connect Helm Repository and the Connect Image Registry guides, you learned to manage the config via CLI and UI. In this guide, we will introduce how to read and write the config in the Pipeline or Workflow.
Why do we need to manage the config in the Pipeline?
There are many scenarios, such as:
- Deploy a DB application and write the connector info to the config and share it with other applications.
- Read the shared config to deploy the application.
- Base the config to orchestrate the Pipeline and Workflow.
The Step Type References
All steps are suitable for the Workflow and Pipeline.
Create and read config without the template
In the workflow, if we only want to share the config content and can not need to check the content validity, we could create the config without the template.
kind: Application
apiVersion: core.oam.dev/v1beta1
metadata:
name: create-config
namespace: "config-e2e-test"
spec:
components: []
workflow:
steps:
- name: write-config
type: create-config
properties:
name: test
config:
key1: value1
key2: 2
key3: true
key4:
key5: value5
---
kind: Application
apiVersion: core.oam.dev/v1beta1
metadata:
name: read-config
namespace: "config-e2e-test"
spec:
components: []
workflow:
steps:
- name: read-config
type: read-config
properties:
name: test
outputs:
- name: read-config
valueFrom: output.config
How the steps work with Config resources
Since v1.12, the steps work with Config resources and still read configs created by v1.11:
-
create-configcreates aConfigin the Application's namespace, or thenamespaceyou give. The Application owns it: it is updated when the step runs again and deleted with the Application. The step waits until the Config isAvailablefor the latest change, and fails with the controller's reason if the Config goes toError. For example, the step's message in the Application's status when a Secret of that name already exists:failed function call error for deploy: config my-team/db: secret my-team/db already exists and is not owned by this Config -
If a v1.11 config of the same name exists,
create-configadopts it in place, unless another Application manages it, which is refused. -
read-configandlist-configreturn Config resources and v1.11 configs, each config once.read-configwaits for a Config that is notAvailableyet, and fails on one inError. -
A sensitive config can be written, but never read:
read-configfails withthe config is sensitive. See Sensitive templates. -
delete-configdeletes the Config. To delete a Config another Application created, delete it through that Application; otherwise that Application creates it again the next time it reconciles. -
A template from another namespace may be used only as the Scope rules allow. The step checks the Application's user when the
AuthenticateApplicationfeature gate is on; with it off, it may use only a template in the Application's namespace or a system template.