Skip to content

Commit

Permalink
feat: Support loading manifest from artifacts for resource templates. F…
Browse files Browse the repository at this point in the history
…ixes #5878 (#8657)

* feat: Support loading manifest from artifacts for resource templates

Signed-off-by: book987 <book78987book@gmail.com>

* fix: lock down resource pods

Signed-off-by: book987 <book78987book@gmail.com>

* fix: resolve conlicts

Signed-off-by: book987 <book78987book@gmail.com>
  • Loading branch information
book987 authored Jun 17, 2022
1 parent 19eae92 commit 6106ac7
Show file tree
Hide file tree
Showing 31 changed files with 14,353 additions and 2,053 deletions.
16 changes: 16 additions & 0 deletions api/jsonschema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6091,6 +6091,18 @@
},
"type": "object"
},
"io.argoproj.workflow.v1alpha1.ManifestFrom": {
"properties": {
"artifact": {
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.Artifact",
"description": "Artifact contains the artifact to use"
}
},
"required": [
"artifact"
],
"type": "object"
},
"io.argoproj.workflow.v1alpha1.MemoizationStatus": {
"description": "MemoizationStatus is the status of this memoized node",
"properties": {
Expand Down Expand Up @@ -6690,6 +6702,10 @@
"description": "Manifest contains the kubernetes manifest",
"type": "string"
},
"manifestFrom": {
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.ManifestFrom",
"description": "ManifestFrom is the source for a single kubernetes manifest"
},
"mergeStrategy": {
"description": "MergeStrategy is the strategy used to merge a patch. It defaults to \"strategic\" Must be one of: strategic, merge, json",
"type": "string"
Expand Down
16 changes: 16 additions & 0 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -10532,6 +10532,18 @@
}
}
},
"io.argoproj.workflow.v1alpha1.ManifestFrom": {
"type": "object",
"required": [
"artifact"
],
"properties": {
"artifact": {
"description": "Artifact contains the artifact to use",
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.Artifact"
}
}
},
"io.argoproj.workflow.v1alpha1.MemoizationStatus": {
"description": "MemoizationStatus is the status of this memoized node",
"type": "object",
Expand Down Expand Up @@ -11135,6 +11147,10 @@
"description": "Manifest contains the kubernetes manifest",
"type": "string"
},
"manifestFrom": {
"description": "ManifestFrom is the source for a single kubernetes manifest",
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.ManifestFrom"
},
"mergeStrategy": {
"description": "MergeStrategy is the strategy used to merge a patch. It defaults to \"strategic\" Must be one of: strategic, merge, json",
"type": "string"
Expand Down
12 changes: 11 additions & 1 deletion cmd/argoexec/commands/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,18 @@ func execResource(ctx context.Context, action string) error {
wfExecutor.AddError(err)
return err
}
manifestPath := common.ExecutorResourceManifestPath
if wfExecutor.Template.Resource.ManifestFrom != nil {
targetArtName := wfExecutor.Template.Resource.ManifestFrom.Artifact.Name
for _, art := range wfExecutor.Template.Inputs.Artifacts {
if art.Name == targetArtName {
manifestPath = art.Path
break
}
}
}
resourceNamespace, resourceName, selfLink, err := wfExecutor.ExecResource(
action, common.ExecutorResourceManifestPath, wfExecutor.Template.Resource.Flags,
action, manifestPath, wfExecutor.Template.Resource.Flags,
)
if err != nil {
wfExecutor.AddError(err)
Expand Down
16 changes: 16 additions & 0 deletions docs/executor_swagger.md
Original file line number Diff line number Diff line change
Expand Up @@ -2292,6 +2292,21 @@ it always corresponds to the version of the main resource. | |



### <span id="manifest-from"></span> ManifestFrom






**Properties**

| Name | Type | Go type | Required | Default | Description | Example |
|------|------|---------|:--------:| ------- |-------------|---------|
| artifact | [Artifact](#artifact)| `Artifact` | | | | |



### <span id="memoize"></span> Memoize


Expand Down Expand Up @@ -3633,6 +3648,7 @@ flags: [
"--validate=false" # disable resource validation
] | |
| manifest | string| `string` | | | Manifest contains the kubernetes manifest | |
| manifestFrom | [ManifestFrom](#manifest-from)| `ManifestFrom` | | | | |
| mergeStrategy | string| `string` | | | MergeStrategy is the strategy used to merge a patch. It defaults to "strategic"
Must be one of: strategic, merge, json | |
| setOwnerReference | boolean| `bool` | | | SetOwnerReference sets the reference to the workflow on the OwnerReference of generated resource. | |
Expand Down
10 changes: 10 additions & 0 deletions docs/fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -2786,6 +2786,7 @@ ResourceTemplate is a template subtype to manipulate kubernetes resources
|`failureCondition`|`string`|FailureCondition is a label selector expression which describes the conditions of the k8s resource in which the step was considered failed|
|`flags`|`Array< string >`|Flags is a set of additional options passed to kubectl before submitting a resource I.e. to disable resource validation: flags: [ "--validate=false" # disable resource validation]|
|`manifest`|`string`|Manifest contains the kubernetes manifest|
|`manifestFrom`|[`ManifestFrom`](#manifestfrom)|ManifestFrom is the source for a single kubernetes manifest|
|`mergeStrategy`|`string`|MergeStrategy is the strategy used to merge a patch. It defaults to "strategic" Must be one of: strategic, merge, json|
|`setOwnerReference`|`boolean`|SetOwnerReference sets the reference to the workflow on the OwnerReference of generated resource.|
|`successCondition`|`string`|SuccessCondition is a label selector expression which describes the conditions of the k8s resource in which it is acceptable to proceed to the following step|
Expand Down Expand Up @@ -3902,6 +3903,15 @@ Cache is the configuration for the type of cache to be used
|:----------:|:----------:|---------------|
|`configMap`|[`ConfigMapKeySelector`](#configmapkeyselector)|ConfigMap sets a ConfigMap-based cache|

## ManifestFrom

_No description available_

### Fields
| Field Name | Field Type | Description |
|:----------:|:----------:|---------------|
|`artifact`|[`Artifact`](#artifact)|Artifact contains the artifact to use|

## ContinueOn

ContinueOn defines if a workflow should continue even if a task or step fails/errors. It can be specified if the workflow should continue when the pod errors, fails or both.
Expand Down
Loading

0 comments on commit 6106ac7

Please sign in to comment.