Skip to content

Commit

Permalink
fix(devbox): CRD synchronisation
Browse files Browse the repository at this point in the history
  • Loading branch information
rangoo94 committed Nov 12, 2024
1 parent d499ce5 commit 21dae34
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/tcl/kubectl-testkube/devbox/devutils/crdsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ func (c *CRDSync) processTemplate(sourcePath string, template testworkflowsv1.Te
if !bytes.Equal(v1, v2) {
c.templates[i].Template = template
c.updates = append(c.updates, CRDSyncUpdate{Template: &template, Op: CRDSyncUpdateOpUpdate})
return nil
}
return nil
}
}
c.templates = append(c.templates, CRDSyncTemplate{SourcePath: sourcePath, Template: template})
Expand Down
20 changes: 16 additions & 4 deletions cmd/tcl/kubectl-testkube/devbox/devutils/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,14 @@ func (r *ossResourcesClient) CreateTestWorkflow(workflow testkube.TestWorkflow)
}

func (r *ossResourcesClient) UpdateTestWorkflow(workflow testkube.TestWorkflow) (result testkube.TestWorkflow, err error) {
workflow.Namespace = r.namespace
v, err := r.testWorkflows.Update(testworkflows.MapAPIToKube(&workflow))
prev, err := r.testWorkflows.Get(workflow.Name)
if err != nil {
return r.CreateTestWorkflow(workflow)
}
cr := testworkflows.MapAPIToKube(&workflow)
cr.Namespace = r.namespace
cr.ResourceVersion = prev.ResourceVersion
v, err := r.testWorkflows.Update(cr)
if err != nil {
return
}
Expand All @@ -72,8 +78,14 @@ func (r *ossResourcesClient) CreateTestWorkflowTemplate(template testkube.TestWo
}

func (r *ossResourcesClient) UpdateTestWorkflowTemplate(template testkube.TestWorkflowTemplate) (result testkube.TestWorkflowTemplate, err error) {
template.Namespace = r.namespace
v, err := r.testWorkflowTemplates.Update(testworkflows.MapTemplateAPIToKube(&template))
prev, err := r.testWorkflowTemplates.Get(template.Name)
if err != nil {
return r.CreateTestWorkflowTemplate(template)
}
cr := testworkflows.MapTemplateAPIToKube(&template)
cr.Namespace = r.namespace
cr.ResourceVersion = prev.ResourceVersion
v, err := r.testWorkflowTemplates.Update(cr)
if err != nil {
return
}
Expand Down

0 comments on commit 21dae34

Please sign in to comment.