-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c697056
commit 7ff5285
Showing
4 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package vshnforgejo | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
xfnproto "github.com/crossplane/function-sdk-go/proto/v1beta1" | ||
vshnv1 "github.com/vshn/appcat/v4/apis/vshn/v1" | ||
"github.com/vshn/appcat/v4/pkg/comp-functions/functions/common" | ||
"github.com/vshn/appcat/v4/pkg/comp-functions/functions/common/maintenance" | ||
"github.com/vshn/appcat/v4/pkg/comp-functions/runtime" | ||
) | ||
|
||
// AddMaintenanceJob will add a job to do the maintenance for the instance | ||
func AddMaintenanceJob(ctx context.Context, comp *vshnv1.VSHNForgejo, svc *runtime.ServiceRuntime) *xfnproto.Result { | ||
|
||
err := svc.GetObservedComposite(comp) | ||
if err != nil { | ||
return runtime.NewFatalResult(fmt.Errorf("can't get composite: %w", err)) | ||
} | ||
|
||
common.SetRandomSchedules(comp, comp) | ||
|
||
instanceNamespace := comp.GetInstanceNamespace() | ||
schedule := comp.GetFullMaintenanceSchedule() | ||
|
||
err = svc.SetDesiredCompositeStatus(comp) | ||
if err != nil { | ||
return runtime.NewFatalResult(fmt.Errorf("cannot update composite status: %w", err)) | ||
} | ||
|
||
return maintenance.New(comp, svc, schedule, instanceNamespace, comp.GetServiceName()). | ||
WithHelmBasedService(). | ||
Run(ctx) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters