2026-04-30 14:01:55 -04:00
|
|
|
package cnpg
|
2026-04-30 13:18:59 -04:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"danicos.dev/daniel/go-kube/pkg/flux"
|
|
|
|
|
"danicos.dev/daniel/homelab/pkg/root"
|
2026-04-30 14:01:55 -04:00
|
|
|
|
2026-04-30 13:18:59 -04:00
|
|
|
helm "github.com/fluxcd/helm-controller/api/v2"
|
|
|
|
|
source "github.com/fluxcd/source-controller/api/v1"
|
|
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func HelmSource() source.HelmRepository {
|
|
|
|
|
spec := source.HelmRepositorySpec{
|
|
|
|
|
Interval: durHour(root.FLUX_HELM_MONITORING_INTERVAL),
|
|
|
|
|
URL: root.HELM_CLOUD_NATIVE_PG_URL,
|
|
|
|
|
}
|
|
|
|
|
return flux.NewFluxHelmRepositorySource(meta, spec)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func HelmRelease() helm.HelmRelease {
|
|
|
|
|
interval := durHour(12)
|
|
|
|
|
spec := helm.HelmReleaseSpec{
|
|
|
|
|
Interval: durMin(30),
|
|
|
|
|
Chart: &helm.HelmChartTemplate{
|
|
|
|
|
Spec: helm.HelmChartTemplateSpec{
|
2026-04-30 13:24:15 -04:00
|
|
|
Chart: root.HELM_CLOUD_NATIVE_PG_CHART,
|
|
|
|
|
Version: root.HELM_CLOUD_NATIVE_PG_CHART_VERSION,
|
2026-04-30 13:18:59 -04:00
|
|
|
Interval: &interval,
|
|
|
|
|
SourceRef: helm.CrossNamespaceObjectReference{
|
|
|
|
|
Kind: flux.MetaHelmRepository.Kind,
|
|
|
|
|
Name: meta.Meta().Name,
|
|
|
|
|
Namespace: Namespace.Name,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-04-30 14:35:35 -04:00
|
|
|
Install: &helm.Install{CRDs: helm.Create},
|
|
|
|
|
Upgrade: &helm.Upgrade{CRDs: helm.CreateReplace},
|
2026-04-30 13:18:59 -04:00
|
|
|
}
|
|
|
|
|
return flux.NewFluxHelmRelease(meta, spec)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func durHour(d int64) metav1.Duration {
|
|
|
|
|
return metav1.Duration{Duration: (time.Duration(d) * time.Hour)}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func durMin(d int64) metav1.Duration {
|
|
|
|
|
return metav1.Duration{Duration: (time.Duration(d) * time.Minute)}
|
|
|
|
|
}
|