Merge pull request #4250 from xyz-li/app_store
Dynamically load helm app into app-store
This commit is contained in:
@@ -35,6 +35,8 @@ import (
|
||||
"sigs.k8s.io/controller-runtime/pkg/reconcile"
|
||||
"sigs.k8s.io/controller-runtime/pkg/source"
|
||||
|
||||
"kubesphere.io/kubesphere/pkg/constants"
|
||||
|
||||
"kubesphere.io/api/application/v1alpha1"
|
||||
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/openpitrix/helmrepoindex"
|
||||
@@ -42,9 +44,6 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// min sync period in seconds
|
||||
MinSyncPeriod = 180
|
||||
|
||||
MinRetryDuration = 60
|
||||
MaxRetryDuration = 600
|
||||
HelmRepoSyncStateLen = 10
|
||||
@@ -156,8 +155,8 @@ func (r *ReconcileHelmRepo) Reconcile(ctx context.Context, request reconcile.Req
|
||||
|
||||
copyInstance := instance.DeepCopy()
|
||||
|
||||
if copyInstance.Spec.SyncPeriod != 0 && copyInstance.Spec.SyncPeriod < MinSyncPeriod {
|
||||
copyInstance.Spec.SyncPeriod = MinSyncPeriod
|
||||
if copyInstance.Spec.SyncPeriod != 0 {
|
||||
copyInstance.Spec.SyncPeriod = int(math.Max(float64(copyInstance.Spec.SyncPeriod), constants.HelmRepoMinSyncPeriod))
|
||||
}
|
||||
|
||||
retryAfter := 0
|
||||
@@ -197,7 +196,7 @@ func (r *ReconcileHelmRepo) Reconcile(ctx context.Context, request reconcile.Req
|
||||
RequeueAfter: MinRetryDuration * time.Second,
|
||||
}, err
|
||||
} else {
|
||||
retryAfter = MinSyncPeriod
|
||||
retryAfter = constants.HelmRepoMinSyncPeriod
|
||||
if syncErr == nil {
|
||||
retryAfter = copyInstance.Spec.SyncPeriod
|
||||
}
|
||||
@@ -256,9 +255,7 @@ func needReSyncNow(instance *v1alpha1.HelmRepo) (syncNow bool, after int) {
|
||||
} else {
|
||||
period = instance.Spec.SyncPeriod
|
||||
if period != 0 {
|
||||
if period < MinSyncPeriod {
|
||||
period = MinSyncPeriod
|
||||
}
|
||||
period = int(math.Max(float64(instance.Spec.SyncPeriod), constants.HelmRepoMinSyncPeriod))
|
||||
if now.After(state.SyncTime.Add(time.Duration(period) * time.Second)) {
|
||||
return true, 0
|
||||
}
|
||||
@@ -296,7 +293,7 @@ func (r *ReconcileHelmRepo) syncRepo(instance *v1alpha1.HelmRepo) error {
|
||||
}
|
||||
|
||||
// 2. merge new index with old index which is stored in crd
|
||||
savedIndex := helmrepoindex.MergeRepoIndex(index, existsSavedIndex)
|
||||
savedIndex := helmrepoindex.MergeRepoIndex(instance, index, existsSavedIndex)
|
||||
|
||||
// 3. save index in crd
|
||||
data, err := savedIndex.Bytes()
|
||||
|
||||
Reference in New Issue
Block a user