Skip to content

Commit

Permalink
Fix: refactor workflow custom definition doc (kubevela#1016)
Browse files Browse the repository at this point in the history
Signed-off-by: FogDong <[email protected]>

Signed-off-by: FogDong <[email protected]>
  • Loading branch information
FogDong authored Oct 25, 2022
1 parent d94a692 commit a657c8b
Show file tree
Hide file tree
Showing 6 changed files with 453 additions and 227 deletions.
30 changes: 6 additions & 24 deletions docs/platform-engineers/oam/x-definition.md
Original file line number Diff line number Diff line change
Expand Up @@ -514,30 +514,12 @@ Once the application is created, KubeVela will tag the created resources with a
| `trait.oam.dev/resource` | `outputs.\<resource type\>`in Trait |
| `app.oam.dev/appRevision` | Application Revision Name |

## Definition Runtime Context

In the Definition, some runtime context information can be obtained through the `context` variable. The specific list is as follows, where the scope indicates which module definitions the Context variable can be used in:

| Context Variable | Description | Scope |
| :------------------------------: | :-----------------------------------------------------------------------------------: | :----------------------------------------------------: |
| `context.appRevision` | The app version name corresponding to the current instance of the application | ComponentDefinition, TraitDefinition |
| `context.appRevisionNum` | The app version number corresponding to the current instance of the application. | ComponentDefinition, TraitDefinition |
| `context.appName` | The app name corresponding to the current instance of the application. | ComponentDefinition, TraitDefinition |
| `context.name` | component name in ComponentDefinition and TraitDefinition,policy in PolicyDefinition | ComponentDefinition, TraitDefinition, PolicyDefinition |
| `context.namespace` | The namespace of the current instance of the application | ComponentDefinition, TraitDefinition |
| `context.revision` | The version name of the current component instance | ComponentDefinition, TraitDefinition |
| `context.parameter` | The parameters of the current component instance, it can be obtained in the trait | TraitDefinition |
| `context.output` | Object structure after instantiation of current component | ComponentDefinition, TraitDefinition |
| `context.outputs.<resourceName>` | Structure after instantiation of current component and trait | ComponentDefinition, TraitDefinition |

At the same time, in the Workflow system, because the `context` has to act on the application level, it is very different from the above usage. We introduce it separately:

| Context Variable | Description | Scope |
| :-------------------: | :--------------------------------------------------------: | :--------------------: |
| `context.name` | The name of the current instance of the application | WorkflowStepDefinition |
| `context.namespace` | The namespace of the current instance of the application | WorkflowStepDefinition |
| `context.labels` | The labels of the current instance of the application | WorkflowStepDefinition |
| `context.annotations` | The annotations of the current instance of the application | WorkflowStepDefinition |
## Runtime Context Data in Definitions

In the Definitions, some runtime context information can be obtained through the `context` variable, please check out:

- [Context data in Component Definition](../components/custom-component#full-available-context-in-component)
- [Context data in Trait Definition](../traits/customize-trait#full-available-context-in-trait)
- [Context data in Workflow Sep Definition](../workflow/workflow#full-available-context-in-workflow-step)

Please note that all the Definition concepts introduced in this section only need to be understood by the platform administrator when they want to expand the functions of KubeVela. The end users will learn the schema of above definitions with visualized forms (or the JSON schema of parameters if they prefer) and reference them in application deployment plan. Please check the [Generate Forms from Definitions](../openapi-v3-json-schema) section about how this is achieved.
2 changes: 1 addition & 1 deletion docs/platform-engineers/traits/customize-trait.md
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ status:
> Please refer to [this doc](https://github.com/kubevela/kubevela/blob/master/vela-templates/definitions/internal/trait/gateway.cue) for more complete example.


## Full available `context` in Component
## Full available `context` in Trait


| Context Variable | Description | Type |
Expand Down
Loading

0 comments on commit a657c8b

Please sign in to comment.