зеркало из https://github.com/Azure/orkestra.git
Changes for using action parameter of orkestra workflow executor (#230)
* Changes for using action parameter of orkestra workflow executor * Base64 encode reverse workflow helm release string * Resolved PR feedback * Rebased with the latest main * Changed action strings to lower-case. Removed ExecutorAction.String() method * 1) Updated executor image tag to v0.3.0 2) Rebased with the latest main Co-authored-by: Davut Karabay <davutk@microsoft.com>
This commit is contained in:
Родитель
9a1c2f7b19
Коммит
1344e26445
|
@ -21,6 +21,15 @@ import (
|
||||||
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// The set of executor actions which can be performed on a helmrelease object
|
||||||
|
Install ExecutorAction = "install"
|
||||||
|
Delete ExecutorAction = "delete"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ExecutorAction defines the set of executor actions which can be performed on a helmrelease object
|
||||||
|
type ExecutorAction string
|
||||||
|
|
||||||
type argo struct {
|
type argo struct {
|
||||||
scheme *runtime.Scheme
|
scheme *runtime.Scheme
|
||||||
cli client.Client
|
cli client.Client
|
||||||
|
@ -288,7 +297,7 @@ func (a *argo) generateReverseWorkflow(ctx context.Context, l logr.Logger, nodes
|
||||||
Parameters: []v1alpha12.Parameter{
|
Parameters: []v1alpha12.Parameter{
|
||||||
{
|
{
|
||||||
Name: HelmReleaseArg,
|
Name: HelmReleaseArg,
|
||||||
Value: utils.ToStrPtr(utils.HrToYaml(hr)),
|
Value: utils.ToStrPtr(base64.StdEncoding.EncodeToString([]byte(utils.HrToYaml(hr)))),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -306,7 +315,7 @@ func (a *argo) generateReverseWorkflow(ctx context.Context, l logr.Logger, nodes
|
||||||
|
|
||||||
updateWorkflowTemplates(a.rwf, entry)
|
updateWorkflowTemplates(a.rwf, entry)
|
||||||
|
|
||||||
updateWorkflowTemplates(a.rwf, defaultReverseExecutor())
|
updateWorkflowTemplates(a.rwf, defaultExecutor(HelmReleaseReverseExecutorName, Delete))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -344,7 +353,7 @@ func (a *argo) generateAppGroupTpls(ctx context.Context, g *v1alpha1.Application
|
||||||
|
|
||||||
// TODO: Add the executor template
|
// TODO: Add the executor template
|
||||||
// This should eventually be configurable
|
// This should eventually be configurable
|
||||||
updateWorkflowTemplates(a.wf, defaultExecutor())
|
updateWorkflowTemplates(a.wf, defaultExecutor(HelmReleaseExecutorName, Install))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -598,10 +607,10 @@ func updateWorkflowTemplates(wf *v1alpha12.Workflow, tpls ...v1alpha12.Template)
|
||||||
wf.Spec.Templates = append(wf.Spec.Templates, tpls...)
|
wf.Spec.Templates = append(wf.Spec.Templates, tpls...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultExecutor() v1alpha12.Template {
|
func defaultExecutor(tplName string, action ExecutorAction) v1alpha12.Template {
|
||||||
executorArgs := []string{"--spec", "{{inputs.parameters.helmrelease}}", "--timeout", "{{inputs.parameters.timeout}}", "--interval", "10s"}
|
executorArgs := []string{"--spec", "{{inputs.parameters.helmrelease}}", "--action", string(action), "--timeout", "{{inputs.parameters.timeout}}", "--interval", "10s"}
|
||||||
return v1alpha12.Template{
|
return v1alpha12.Template{
|
||||||
Name: HelmReleaseExecutorName,
|
Name: tplName,
|
||||||
ServiceAccountName: workflowServiceAccountName(),
|
ServiceAccountName: workflowServiceAccountName(),
|
||||||
Inputs: v1alpha12.Inputs{
|
Inputs: v1alpha12.Inputs{
|
||||||
Parameters: []v1alpha12.Parameter{
|
Parameters: []v1alpha12.Parameter{
|
||||||
|
@ -626,28 +635,6 @@ func defaultExecutor() v1alpha12.Template {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultReverseExecutor() v1alpha12.Template {
|
|
||||||
return v1alpha12.Template{
|
|
||||||
Name: HelmReleaseReverseExecutorName,
|
|
||||||
ServiceAccountName: workflowServiceAccountName(),
|
|
||||||
Inputs: v1alpha12.Inputs{
|
|
||||||
Parameters: []v1alpha12.Parameter{
|
|
||||||
{
|
|
||||||
Name: "helmrelease",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Executor: &v1alpha12.ExecutorConfig{
|
|
||||||
ServiceAccountName: workflowServiceAccountName(),
|
|
||||||
},
|
|
||||||
Resource: &v1alpha12.ResourceTemplate{
|
|
||||||
// SetOwnerReference: true,
|
|
||||||
Action: "delete",
|
|
||||||
Manifest: "{{inputs.parameters.helmrelease}}",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func generateSubchartHelmRelease(a v1alpha1.Application, appName, scName, version, repo, targetNS string, isStaged bool) (*fluxhelmv2beta1.HelmRelease, error) {
|
func generateSubchartHelmRelease(a v1alpha1.Application, appName, scName, version, repo, targetNS string, isStaged bool) (*fluxhelmv2beta1.HelmRelease, error) {
|
||||||
hr := &fluxhelmv2beta1.HelmRelease{
|
hr := &fluxhelmv2beta1.HelmRelease{
|
||||||
TypeMeta: v1.TypeMeta{
|
TypeMeta: v1.TypeMeta{
|
||||||
|
|
|
@ -15,7 +15,7 @@ const (
|
||||||
|
|
||||||
ExecutorName = "executor"
|
ExecutorName = "executor"
|
||||||
ExecutorImage = "azureorkestra/executor"
|
ExecutorImage = "azureorkestra/executor"
|
||||||
ExecutorImageTag = "v0.2.0"
|
ExecutorImageTag = "v0.3.0"
|
||||||
|
|
||||||
ChartMuseumName = "chartmuseum"
|
ChartMuseumName = "chartmuseum"
|
||||||
)
|
)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче