Skip to content

Commit

Permalink
feat: add spec reconciliation
Browse files Browse the repository at this point in the history
  • Loading branch information
raelga committed Sep 13, 2023
1 parent 9c2d806 commit 316ecc7
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
37 changes: 37 additions & 0 deletions resources/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,43 @@ func (pt PipelineTemplate) ResourceReconciler(ctx context.Context, cl client.Cli
needsUpdate = true
}

/* Reconcile spec */

if instance.Spec.DisplayName != desired.Spec.DisplayName {
instance.Spec.DisplayName = desired.Spec.DisplayName
needsUpdate = true
}

if instance.Spec.Description != desired.Spec.Description {
instance.Spec.Description = desired.Spec.Description
needsUpdate = true
}

if !equality.Semantic.DeepEqual(instance.Spec.Params, desired.Spec.Params) {
instance.Spec.Params = desired.Spec.Params
needsUpdate = true
}

if !equality.Semantic.DeepEqual(instance.Spec.Tasks, desired.Spec.Tasks) {
instance.Spec.Tasks = desired.Spec.Tasks
needsUpdate = true
}

if !equality.Semantic.DeepEqual(instance.Spec.Workspaces, desired.Spec.Workspaces) {
instance.Spec.Workspaces = desired.Spec.Workspaces
needsUpdate = true
}

if !equality.Semantic.DeepEqual(instance.Spec.Results, desired.Spec.Results) {
instance.Spec.Results = desired.Spec.Results
needsUpdate = true
}

if !equality.Semantic.DeepEqual(instance.Spec.Finally, desired.Spec.Finally) {
instance.Spec.Finally = desired.Spec.Finally
needsUpdate = true
}

if needsUpdate {
err := cl.Update(ctx, instance)
if err != nil {
Expand Down
52 changes: 52 additions & 0 deletions resources/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,58 @@ func (tt TaskTemplate) ResourceReconciler(ctx context.Context, cl client.Client,
needsUpdate = true
}

/* Reconcile spec */

if instance.Spec.DisplayName != desired.Spec.DisplayName {
instance.Spec.DisplayName = desired.Spec.DisplayName
needsUpdate = true
}

if instance.Spec.Description != desired.Spec.Description {
instance.Spec.Description = desired.Spec.Description
needsUpdate = true
}

if !equality.Semantic.DeepEqual(instance.Spec.Params, desired.Spec.Params) {
instance.Spec.Params = desired.Spec.Params
needsUpdate = true
}

if !equality.Semantic.DeepEqual(instance.Spec.Steps, desired.Spec.Steps) {
instance.Spec.Steps = desired.Spec.Steps
needsUpdate = true
}

if !equality.Semantic.DeepEqual(instance.Spec.StepTemplate, desired.Spec.StepTemplate) {
instance.Spec.StepTemplate = desired.Spec.StepTemplate
needsUpdate = true
}

if !equality.Semantic.DeepEqual(instance.Spec.Volumes, desired.Spec.Volumes) {
instance.Spec.Volumes = desired.Spec.Volumes
needsUpdate = true
}

if !equality.Semantic.DeepEqual(instance.Spec.Sidecars, desired.Spec.Sidecars) {
instance.Spec.Sidecars = desired.Spec.Sidecars
needsUpdate = true
}

if !equality.Semantic.DeepEqual(instance.Spec.Workspaces, desired.Spec.Workspaces) {
instance.Spec.Workspaces = desired.Spec.Workspaces
needsUpdate = true
}

if !equality.Semantic.DeepEqual(instance.Spec.Volumes, desired.Spec.Volumes) {
instance.Spec.Volumes = desired.Spec.Volumes
needsUpdate = true
}

if !equality.Semantic.DeepEqual(instance.Spec.Results, desired.Spec.Results) {
instance.Spec.Results = desired.Spec.Results
needsUpdate = true
}

if needsUpdate {
err := cl.Update(ctx, instance)
if err != nil {
Expand Down

0 comments on commit 316ecc7

Please sign in to comment.