Update to source-controller v1.0.0-rc.1
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
This commit is contained in:
parent
bba569c1f9
commit
2de972cb8f
|
@ -2,8 +2,8 @@ apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
namespace: helm-system
|
namespace: helm-system
|
||||||
resources:
|
resources:
|
||||||
- https://github.com/fluxcd/source-controller/releases/download/v0.36.1/source-controller.crds.yaml
|
- https://github.com/fluxcd/source-controller/releases/download/v1.0.0-rc.1/source-controller.crds.yaml
|
||||||
- https://github.com/fluxcd/source-controller/releases/download/v0.36.1/source-controller.deployment.yaml
|
- https://github.com/fluxcd/source-controller/releases/download/v1.0.0-rc.1/source-controller.deployment.yaml
|
||||||
- ../crd
|
- ../crd
|
||||||
- ../rbac
|
- ../rbac
|
||||||
- ../manager
|
- ../manager
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -12,7 +12,7 @@ require (
|
||||||
github.com/fluxcd/pkg/apis/meta v1.0.0
|
github.com/fluxcd/pkg/apis/meta v1.0.0
|
||||||
github.com/fluxcd/pkg/runtime v0.35.0
|
github.com/fluxcd/pkg/runtime v0.35.0
|
||||||
github.com/fluxcd/pkg/ssa v0.27.0
|
github.com/fluxcd/pkg/ssa v0.27.0
|
||||||
github.com/fluxcd/source-controller/api v0.36.1
|
github.com/fluxcd/source-controller/api v1.0.0-rc.1
|
||||||
github.com/go-logr/logr v1.2.4
|
github.com/go-logr/logr v1.2.4
|
||||||
github.com/google/go-cmp v0.5.9
|
github.com/google/go-cmp v0.5.9
|
||||||
github.com/hashicorp/go-retryablehttp v0.7.2
|
github.com/hashicorp/go-retryablehttp v0.7.2
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -181,8 +181,8 @@ github.com/fluxcd/pkg/runtime v0.35.0 h1:9PYLcul8qdfLYQArcYpHe/QuMqyhAGGFN9F7uY/
|
||||||
github.com/fluxcd/pkg/runtime v0.35.0/go.mod h1:sAaSTH8RHj3Y99xj0AtAndDTe5cv0DP4enyLV62EO78=
|
github.com/fluxcd/pkg/runtime v0.35.0/go.mod h1:sAaSTH8RHj3Y99xj0AtAndDTe5cv0DP4enyLV62EO78=
|
||||||
github.com/fluxcd/pkg/ssa v0.27.0 h1:BJnWDy3xDtYD2U+sVZPkoh6PfnQKoXsklO0pzojU8XU=
|
github.com/fluxcd/pkg/ssa v0.27.0 h1:BJnWDy3xDtYD2U+sVZPkoh6PfnQKoXsklO0pzojU8XU=
|
||||||
github.com/fluxcd/pkg/ssa v0.27.0/go.mod h1:fxvmVf4FxodJi5lTglMcL8JsF6hfJLG99C56/CgchH0=
|
github.com/fluxcd/pkg/ssa v0.27.0/go.mod h1:fxvmVf4FxodJi5lTglMcL8JsF6hfJLG99C56/CgchH0=
|
||||||
github.com/fluxcd/source-controller/api v0.36.1 h1:/ul69kJNEwrFG1Cwk2P/GwgraIxOETCL+tP+zMtxTu8=
|
github.com/fluxcd/source-controller/api v1.0.0-rc.1 h1:MZaP5utClMG95Aw/AVu1l05WEfmpEw/RIlCLnkCQl14=
|
||||||
github.com/fluxcd/source-controller/api v0.36.1/go.mod h1:GktZmd5Dfxo84vPFBdLDl0bBtiJRODfd47uugK0romU=
|
github.com/fluxcd/source-controller/api v1.0.0-rc.1/go.mod h1:CvGNdS8g/MqwpERUK6aJp4lndsrm+JBzGpoyyZ4u0c8=
|
||||||
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
|
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
|
||||||
github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps=
|
github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps=
|
||||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
|
|
|
@ -40,12 +40,13 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
ctrl "sigs.k8s.io/controller-runtime"
|
ctrl "sigs.k8s.io/controller-runtime"
|
||||||
|
|
||||||
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
|
sourcev1 "github.com/fluxcd/source-controller/api/v1"
|
||||||
|
sourcev1b2 "github.com/fluxcd/source-controller/api/v1beta2"
|
||||||
|
|
||||||
v2 "github.com/fluxcd/helm-controller/api/v2beta1"
|
v2 "github.com/fluxcd/helm-controller/api/v2beta1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (r *HelmReleaseReconciler) reconcileChart(ctx context.Context, hr *v2.HelmRelease) (*sourcev1.HelmChart, error) {
|
func (r *HelmReleaseReconciler) reconcileChart(ctx context.Context, hr *v2.HelmRelease) (*sourcev1b2.HelmChart, error) {
|
||||||
chartName := types.NamespacedName{
|
chartName := types.NamespacedName{
|
||||||
Namespace: hr.Spec.Chart.GetNamespace(hr.Namespace),
|
Namespace: hr.Spec.Chart.GetNamespace(hr.Namespace),
|
||||||
Name: hr.GetHelmChartName(),
|
Name: hr.GetHelmChartName(),
|
||||||
|
@ -67,7 +68,7 @@ func (r *HelmReleaseReconciler) reconcileChart(ctx context.Context, hr *v2.HelmR
|
||||||
}
|
}
|
||||||
|
|
||||||
// Continue with the reconciliation of the current template.
|
// Continue with the reconciliation of the current template.
|
||||||
var helmChart sourcev1.HelmChart
|
var helmChart sourcev1b2.HelmChart
|
||||||
err := r.Client.Get(ctx, chartName, &helmChart)
|
err := r.Client.Get(ctx, chartName, &helmChart)
|
||||||
if err != nil && !apierrors.IsNotFound(err) {
|
if err != nil && !apierrors.IsNotFound(err) {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -81,7 +82,7 @@ func (r *HelmReleaseReconciler) reconcileChart(ctx context.Context, hr *v2.HelmR
|
||||||
hr.Status.HelmChart = chartName.String()
|
hr.Status.HelmChart = chartName.String()
|
||||||
return hc, nil
|
return hc, nil
|
||||||
case helmChartRequiresUpdate(hr, &helmChart):
|
case helmChartRequiresUpdate(hr, &helmChart):
|
||||||
ctrl.LoggerFrom(ctx).Info("chart diverged from template", strings.ToLower(sourcev1.HelmChartKind), chartName.String())
|
ctrl.LoggerFrom(ctx).Info("chart diverged from template", strings.ToLower(sourcev1b2.HelmChartKind), chartName.String())
|
||||||
helmChart.Spec = hc.Spec
|
helmChart.Spec = hc.Spec
|
||||||
helmChart.Labels = hc.Labels
|
helmChart.Labels = hc.Labels
|
||||||
helmChart.Annotations = hc.Annotations
|
helmChart.Annotations = hc.Annotations
|
||||||
|
@ -97,9 +98,9 @@ func (r *HelmReleaseReconciler) reconcileChart(ctx context.Context, hr *v2.HelmR
|
||||||
// getHelmChart retrieves the v1beta2.HelmChart for the given
|
// getHelmChart retrieves the v1beta2.HelmChart for the given
|
||||||
// v2beta1.HelmRelease using the name that is advertised in the status
|
// v2beta1.HelmRelease using the name that is advertised in the status
|
||||||
// object. It returns the v1beta2.HelmChart, or an error.
|
// object. It returns the v1beta2.HelmChart, or an error.
|
||||||
func (r *HelmReleaseReconciler) getHelmChart(ctx context.Context, hr *v2.HelmRelease) (*sourcev1.HelmChart, error) {
|
func (r *HelmReleaseReconciler) getHelmChart(ctx context.Context, hr *v2.HelmRelease) (*sourcev1b2.HelmChart, error) {
|
||||||
namespace, name := hr.Status.GetHelmChart()
|
namespace, name := hr.Status.GetHelmChart()
|
||||||
hc := &sourcev1.HelmChart{}
|
hc := &sourcev1b2.HelmChart{}
|
||||||
if err := r.Client.Get(ctx, types.NamespacedName{Namespace: namespace, Name: name}, hc); err != nil {
|
if err := r.Client.Get(ctx, types.NamespacedName{Namespace: namespace, Name: name}, hc); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -109,7 +110,7 @@ func (r *HelmReleaseReconciler) getHelmChart(ctx context.Context, hr *v2.HelmRel
|
||||||
// loadHelmChart attempts to download the artifact from the provided source,
|
// loadHelmChart attempts to download the artifact from the provided source,
|
||||||
// loads it into a chart.Chart, and removes the downloaded artifact.
|
// loads it into a chart.Chart, and removes the downloaded artifact.
|
||||||
// It returns the loaded chart.Chart on success, or an error.
|
// It returns the loaded chart.Chart on success, or an error.
|
||||||
func (r *HelmReleaseReconciler) loadHelmChart(source *sourcev1.HelmChart) (*chart.Chart, error) {
|
func (r *HelmReleaseReconciler) loadHelmChart(source *sourcev1b2.HelmChart) (*chart.Chart, error) {
|
||||||
f, err := os.CreateTemp("", fmt.Sprintf("%s-%s-*.tgz", source.GetNamespace(), source.GetName()))
|
f, err := os.CreateTemp("", fmt.Sprintf("%s-%s-*.tgz", source.GetNamespace(), source.GetName()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -174,7 +175,7 @@ func (r *HelmReleaseReconciler) deleteHelmChart(ctx context.Context, hr *v2.Helm
|
||||||
if hr.Status.HelmChart == "" {
|
if hr.Status.HelmChart == "" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
var hc sourcev1.HelmChart
|
var hc sourcev1b2.HelmChart
|
||||||
chartNS, chartName := hr.Status.GetHelmChart()
|
chartNS, chartName := hr.Status.GetHelmChart()
|
||||||
err := r.Client.Get(ctx, types.NamespacedName{Namespace: chartNS, Name: chartName}, &hc)
|
err := r.Client.Get(ctx, types.NamespacedName{Namespace: chartNS, Name: chartName}, &hc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -196,19 +197,19 @@ func (r *HelmReleaseReconciler) deleteHelmChart(ctx context.Context, hr *v2.Helm
|
||||||
|
|
||||||
// buildHelmChartFromTemplate builds a v1beta2.HelmChart from the
|
// buildHelmChartFromTemplate builds a v1beta2.HelmChart from the
|
||||||
// v2beta1.HelmChartTemplate of the given v2beta1.HelmRelease.
|
// v2beta1.HelmChartTemplate of the given v2beta1.HelmRelease.
|
||||||
func buildHelmChartFromTemplate(hr *v2.HelmRelease) *sourcev1.HelmChart {
|
func buildHelmChartFromTemplate(hr *v2.HelmRelease) *sourcev1b2.HelmChart {
|
||||||
template := hr.Spec.Chart
|
template := hr.Spec.Chart
|
||||||
return &sourcev1.HelmChart{
|
return &sourcev1b2.HelmChart{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: hr.GetHelmChartName(),
|
Name: hr.GetHelmChartName(),
|
||||||
Namespace: hr.Spec.Chart.GetNamespace(hr.Namespace),
|
Namespace: hr.Spec.Chart.GetNamespace(hr.Namespace),
|
||||||
Labels: hr.Spec.Chart.ObjectMeta.Labels,
|
Labels: hr.Spec.Chart.ObjectMeta.Labels,
|
||||||
Annotations: hr.Spec.Chart.ObjectMeta.Annotations,
|
Annotations: hr.Spec.Chart.ObjectMeta.Annotations,
|
||||||
},
|
},
|
||||||
Spec: sourcev1.HelmChartSpec{
|
Spec: sourcev1b2.HelmChartSpec{
|
||||||
Chart: template.Spec.Chart,
|
Chart: template.Spec.Chart,
|
||||||
Version: template.Spec.Version,
|
Version: template.Spec.Version,
|
||||||
SourceRef: sourcev1.LocalHelmChartSourceReference{
|
SourceRef: sourcev1b2.LocalHelmChartSourceReference{
|
||||||
Name: template.Spec.SourceRef.Name,
|
Name: template.Spec.SourceRef.Name,
|
||||||
Kind: template.Spec.SourceRef.Kind,
|
Kind: template.Spec.SourceRef.Kind,
|
||||||
},
|
},
|
||||||
|
@ -224,7 +225,7 @@ func buildHelmChartFromTemplate(hr *v2.HelmRelease) *sourcev1.HelmChart {
|
||||||
// helmChartRequiresUpdate compares the v2beta1.HelmChartTemplate of the
|
// helmChartRequiresUpdate compares the v2beta1.HelmChartTemplate of the
|
||||||
// v2beta1.HelmRelease to the given v1beta2.HelmChart to determine if an
|
// v2beta1.HelmRelease to the given v1beta2.HelmChart to determine if an
|
||||||
// update is required.
|
// update is required.
|
||||||
func helmChartRequiresUpdate(hr *v2.HelmRelease, chart *sourcev1.HelmChart) bool {
|
func helmChartRequiresUpdate(hr *v2.HelmRelease, chart *sourcev1b2.HelmChart) bool {
|
||||||
template := hr.Spec.Chart
|
template := hr.Spec.Chart
|
||||||
switch {
|
switch {
|
||||||
case template.Spec.Chart != chart.Spec.Chart:
|
case template.Spec.Chart != chart.Spec.Chart:
|
||||||
|
@ -257,12 +258,12 @@ func helmChartRequiresUpdate(hr *v2.HelmRelease, chart *sourcev1.HelmChart) bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// templateVerificationToSourceVerification converts the HelmChartTemplateVerification to the OCIRepositoryVerification.
|
// templateVerificationToSourceVerification converts the HelmChartTemplateVerification to the OCIRepositoryVerification.
|
||||||
func templateVerificationToSourceVerification(template *v2.HelmChartTemplateVerification) *sourcev1.OCIRepositoryVerification {
|
func templateVerificationToSourceVerification(template *v2.HelmChartTemplateVerification) *sourcev1b2.OCIRepositoryVerification {
|
||||||
if template == nil {
|
if template == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return &sourcev1.OCIRepositoryVerification{
|
return &sourcev1b2.OCIRepositoryVerification{
|
||||||
Provider: template.Provider,
|
Provider: template.Provider,
|
||||||
SecretRef: template.SecretRef,
|
SecretRef: template.SecretRef,
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"sigs.k8s.io/controller-runtime/pkg/event"
|
"sigs.k8s.io/controller-runtime/pkg/event"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/predicate"
|
"sigs.k8s.io/controller-runtime/pkg/predicate"
|
||||||
|
|
||||||
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
|
sourcev1 "github.com/fluxcd/source-controller/api/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SourceRevisionChangePredicate struct {
|
type SourceRevisionChangePredicate struct {
|
||||||
|
|
Loading…
Reference in New Issue