Skip to content

Commit

Permalink
feat: set jobRef on stack run (#201)
Browse files Browse the repository at this point in the history
* set jobRef on stack run

* fix linter
  • Loading branch information
zreigz authored May 29, 2024
1 parent f9f252f commit 98191e2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/open-policy-agent/gatekeeper/v3 v3.15.1
github.com/orcaman/concurrent-map/v2 v2.0.1
github.com/pkg/errors v0.9.1
github.com/pluralsh/console-client-go v0.5.9
github.com/pluralsh/console-client-go v0.5.10
github.com/pluralsh/controller-reconcile-helper v0.0.4
github.com/pluralsh/gophoenix v0.1.3-0.20231201014135-dff1b4309e34
github.com/pluralsh/polly v0.1.10
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -526,10 +526,8 @@ github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg=
github.com/pluralsh/console-client-go v0.5.8 h1:Qm7vS+gCbmWqy5i4saLPc5/SUZaW6RCzxWF+uxyPA+Y=
github.com/pluralsh/console-client-go v0.5.8/go.mod h1:eyCiLA44YbXiYyJh8303jk5JdPkt9McgCo5kBjk4lKo=
github.com/pluralsh/console-client-go v0.5.9 h1:r5YMD4dU2zWiDApWtqu45l/02X4RnsNeVEFzuuyehEA=
github.com/pluralsh/console-client-go v0.5.9/go.mod h1:eyCiLA44YbXiYyJh8303jk5JdPkt9McgCo5kBjk4lKo=
github.com/pluralsh/console-client-go v0.5.10 h1:2BnzzJ6w8bkDX/k55GaRykPTVOy66k/vojfhBAof5G8=
github.com/pluralsh/console-client-go v0.5.10/go.mod h1:eyCiLA44YbXiYyJh8303jk5JdPkt9McgCo5kBjk4lKo=
github.com/pluralsh/controller-reconcile-helper v0.0.4 h1:1o+7qYSyoeqKFjx+WgQTxDz4Q2VMpzprJIIKShxqG0E=
github.com/pluralsh/controller-reconcile-helper v0.0.4/go.mod h1:AfY0gtteD6veBjmB6jiRx/aR4yevEf6K0M13/pGan/s=
github.com/pluralsh/gophoenix v0.1.3-0.20231201014135-dff1b4309e34 h1:ab2PN+6if/Aq3/sJM0AVdy1SYuMAnq4g20VaKhTm/Bw=
Expand Down
11 changes: 11 additions & 0 deletions pkg/controller/stacks/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ func (r *StackReconciler) reconcileRunJob(ctx context.Context, run *console.Stac
logger.Error(err, "unable to create job")
return nil, err
}

if err := r.ConsoleClient.UpdateStackRun(run.ID, console.StackRunAttributes{
Status: run.Status,
JobRef: &console.NamespacedName{
Name: job.Name,
Namespace: job.Namespace,
},
}); err != nil {
return nil, err
}

return job, nil
}
return foundJob, nil
Expand Down
3 changes: 3 additions & 0 deletions pkg/controller/stacks/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ var _ = Describe("Reconciler", Ordered, func() {

fakeConsoleClient := mocks.NewClientMock(mocks.TestingT)
fakeConsoleClient.On("GetStackRun", mock.Anything).Return(stackRun, nil)
fakeConsoleClient.On("UpdateStackRun", mock.Anything, mock.Anything).Return(nil)

reconciler := stacks.NewStackReconciler(fakeConsoleClient, kClient, time.Minute, namespace, "", "")

Expand Down Expand Up @@ -153,6 +154,7 @@ var _ = Describe("Reconciler", Ordered, func() {

fakeConsoleClient := mocks.NewClientMock(mocks.TestingT)
fakeConsoleClient.On("GetStackRun", mock.Anything).Return(stackRun, nil)
fakeConsoleClient.On("UpdateStackRun", mock.Anything, mock.Anything).Return(nil)

reconciler := stacks.NewStackReconciler(fakeConsoleClient, kClient, time.Minute, namespace, "", "")

Expand Down Expand Up @@ -208,6 +210,7 @@ var _ = Describe("Reconciler", Ordered, func() {

fakeConsoleClient := mocks.NewClientMock(mocks.TestingT)
fakeConsoleClient.On("GetStackRun", mock.Anything).Return(stackRun, nil)
fakeConsoleClient.On("UpdateStackRun", mock.Anything, mock.Anything).Return(nil)

reconciler := stacks.NewStackReconciler(fakeConsoleClient, kClient, time.Minute, namespace, "", "")

Expand Down

0 comments on commit 98191e2

Please sign in to comment.