Skip to content

Commit 729f8bc

Browse files
committed
fix: packgeInstall syncPeriod spec logic
Signed-off-by: imusmanmalik <[email protected]>
1 parent 8776976 commit 729f8bc

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

pkg/packageinstall/app.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ const (
3333
ExtFetchSecretNameAnnKeyFmt = "ext.packaging.carvel.dev/fetch-%d-secret-name"
3434
)
3535

36+
var (
37+
// Default syncPeriod value for App
38+
DefaultSyncPeriod = &metav1.Duration{Duration: time.Minute * 10}
39+
)
40+
3641
func NewApp(existingApp *v1alpha1.App, pkgInstall *pkgingv1alpha1.PackageInstall, pkgVersion datapkgingv1alpha1.Package, opts Opts) (*v1alpha1.App, error) {
3742
desiredApp := existingApp.DeepCopy()
3843

@@ -55,9 +60,11 @@ func NewApp(existingApp *v1alpha1.App, pkgInstall *pkgingv1alpha1.PackageInstall
5560
if pkgInstall.Spec.SyncPeriod == nil {
5661
if opts.DefaultSyncPeriod != 0 {
5762
desiredApp.Spec.SyncPeriod = &metav1.Duration{Duration: opts.DefaultSyncPeriod}
63+
} else {
64+
desiredApp.Spec.SyncPeriod = DefaultSyncPeriod
5865
}
5966
} else {
60-
desiredApp.Spec.SyncPeriod = &metav1.Duration{Duration: time.Minute * 10}
67+
desiredApp.Spec.SyncPeriod = pkgInstall.Spec.SyncPeriod
6168
}
6269
desiredApp.Spec.NoopDelete = pkgInstall.Spec.NoopDelete
6370
desiredApp.Spec.Paused = pkgInstall.Spec.Paused

pkg/packageinstall/app_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
)
1919

2020
// several tests below have no SyncPeriod set so they'll all use the same default.
21-
var defaultSyncPeriod metav1.Duration = metav1.Duration{10 * time.Minute}
21+
var defaultSyncPeriod = *packageinstall.DefaultSyncPeriod
2222

2323
func TestAppExtPathsFromSecretNameAnn(t *testing.T) {
2424
ipkg := &pkgingv1alpha1.PackageInstall{

0 commit comments

Comments
 (0)