Skip to content

Commit 2de972c

Browse files
committed
Update to source-controller v1.0.0-rc.1
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
1 parent bba569c commit 2de972c

File tree

5 files changed

+22
-21
lines changed

5 files changed

+22
-21
lines changed

config/default/kustomization.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ apiVersion: kustomize.config.k8s.io/v1beta1
22
kind: Kustomization
33
namespace: helm-system
44
resources:
5-
- https://github.com/fluxcd/source-controller/releases/download/v0.36.1/source-controller.crds.yaml
6-
- https://github.com/fluxcd/source-controller/releases/download/v0.36.1/source-controller.deployment.yaml
5+
- https://github.com/fluxcd/source-controller/releases/download/v1.0.0-rc.1/source-controller.crds.yaml
6+
- https://github.com/fluxcd/source-controller/releases/download/v1.0.0-rc.1/source-controller.deployment.yaml
77
- ../crd
88
- ../rbac
99
- ../manager

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/fluxcd/pkg/apis/meta v1.0.0
1313
github.com/fluxcd/pkg/runtime v0.35.0
1414
github.com/fluxcd/pkg/ssa v0.27.0
15-
github.com/fluxcd/source-controller/api v0.36.1
15+
github.com/fluxcd/source-controller/api v1.0.0-rc.1
1616
github.com/go-logr/logr v1.2.4
1717
github.com/google/go-cmp v0.5.9
1818
github.com/hashicorp/go-retryablehttp v0.7.2

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ github.com/fluxcd/pkg/runtime v0.35.0 h1:9PYLcul8qdfLYQArcYpHe/QuMqyhAGGFN9F7uY/
181181
github.com/fluxcd/pkg/runtime v0.35.0/go.mod h1:sAaSTH8RHj3Y99xj0AtAndDTe5cv0DP4enyLV62EO78=
182182
github.com/fluxcd/pkg/ssa v0.27.0 h1:BJnWDy3xDtYD2U+sVZPkoh6PfnQKoXsklO0pzojU8XU=
183183
github.com/fluxcd/pkg/ssa v0.27.0/go.mod h1:fxvmVf4FxodJi5lTglMcL8JsF6hfJLG99C56/CgchH0=
184-
github.com/fluxcd/source-controller/api v0.36.1 h1:/ul69kJNEwrFG1Cwk2P/GwgraIxOETCL+tP+zMtxTu8=
185-
github.com/fluxcd/source-controller/api v0.36.1/go.mod h1:GktZmd5Dfxo84vPFBdLDl0bBtiJRODfd47uugK0romU=
184+
github.com/fluxcd/source-controller/api v1.0.0-rc.1 h1:MZaP5utClMG95Aw/AVu1l05WEfmpEw/RIlCLnkCQl14=
185+
github.com/fluxcd/source-controller/api v1.0.0-rc.1/go.mod h1:CvGNdS8g/MqwpERUK6aJp4lndsrm+JBzGpoyyZ4u0c8=
186186
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
187187
github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps=
188188
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=

internal/controllers/helmrelease_controller_chart.go

+16-15
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@ import (
4040
"k8s.io/apimachinery/pkg/types"
4141
ctrl "sigs.k8s.io/controller-runtime"
4242

43-
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
43+
sourcev1 "github.com/fluxcd/source-controller/api/v1"
44+
sourcev1b2 "github.com/fluxcd/source-controller/api/v1beta2"
4445

4546
v2 "github.com/fluxcd/helm-controller/api/v2beta1"
4647
)
4748

48-
func (r *HelmReleaseReconciler) reconcileChart(ctx context.Context, hr *v2.HelmRelease) (*sourcev1.HelmChart, error) {
49+
func (r *HelmReleaseReconciler) reconcileChart(ctx context.Context, hr *v2.HelmRelease) (*sourcev1b2.HelmChart, error) {
4950
chartName := types.NamespacedName{
5051
Namespace: hr.Spec.Chart.GetNamespace(hr.Namespace),
5152
Name: hr.GetHelmChartName(),
@@ -67,7 +68,7 @@ func (r *HelmReleaseReconciler) reconcileChart(ctx context.Context, hr *v2.HelmR
6768
}
6869

6970
// Continue with the reconciliation of the current template.
70-
var helmChart sourcev1.HelmChart
71+
var helmChart sourcev1b2.HelmChart
7172
err := r.Client.Get(ctx, chartName, &helmChart)
7273
if err != nil && !apierrors.IsNotFound(err) {
7374
return nil, err
@@ -81,7 +82,7 @@ func (r *HelmReleaseReconciler) reconcileChart(ctx context.Context, hr *v2.HelmR
8182
hr.Status.HelmChart = chartName.String()
8283
return hc, nil
8384
case helmChartRequiresUpdate(hr, &helmChart):
84-
ctrl.LoggerFrom(ctx).Info("chart diverged from template", strings.ToLower(sourcev1.HelmChartKind), chartName.String())
85+
ctrl.LoggerFrom(ctx).Info("chart diverged from template", strings.ToLower(sourcev1b2.HelmChartKind), chartName.String())
8586
helmChart.Spec = hc.Spec
8687
helmChart.Labels = hc.Labels
8788
helmChart.Annotations = hc.Annotations
@@ -97,9 +98,9 @@ func (r *HelmReleaseReconciler) reconcileChart(ctx context.Context, hr *v2.HelmR
9798
// getHelmChart retrieves the v1beta2.HelmChart for the given
9899
// v2beta1.HelmRelease using the name that is advertised in the status
99100
// object. It returns the v1beta2.HelmChart, or an error.
100-
func (r *HelmReleaseReconciler) getHelmChart(ctx context.Context, hr *v2.HelmRelease) (*sourcev1.HelmChart, error) {
101+
func (r *HelmReleaseReconciler) getHelmChart(ctx context.Context, hr *v2.HelmRelease) (*sourcev1b2.HelmChart, error) {
101102
namespace, name := hr.Status.GetHelmChart()
102-
hc := &sourcev1.HelmChart{}
103+
hc := &sourcev1b2.HelmChart{}
103104
if err := r.Client.Get(ctx, types.NamespacedName{Namespace: namespace, Name: name}, hc); err != nil {
104105
return nil, err
105106
}
@@ -109,7 +110,7 @@ func (r *HelmReleaseReconciler) getHelmChart(ctx context.Context, hr *v2.HelmRel
109110
// loadHelmChart attempts to download the artifact from the provided source,
110111
// loads it into a chart.Chart, and removes the downloaded artifact.
111112
// It returns the loaded chart.Chart on success, or an error.
112-
func (r *HelmReleaseReconciler) loadHelmChart(source *sourcev1.HelmChart) (*chart.Chart, error) {
113+
func (r *HelmReleaseReconciler) loadHelmChart(source *sourcev1b2.HelmChart) (*chart.Chart, error) {
113114
f, err := os.CreateTemp("", fmt.Sprintf("%s-%s-*.tgz", source.GetNamespace(), source.GetName()))
114115
if err != nil {
115116
return nil, err
@@ -174,7 +175,7 @@ func (r *HelmReleaseReconciler) deleteHelmChart(ctx context.Context, hr *v2.Helm
174175
if hr.Status.HelmChart == "" {
175176
return nil
176177
}
177-
var hc sourcev1.HelmChart
178+
var hc sourcev1b2.HelmChart
178179
chartNS, chartName := hr.Status.GetHelmChart()
179180
err := r.Client.Get(ctx, types.NamespacedName{Namespace: chartNS, Name: chartName}, &hc)
180181
if err != nil {
@@ -196,19 +197,19 @@ func (r *HelmReleaseReconciler) deleteHelmChart(ctx context.Context, hr *v2.Helm
196197

197198
// buildHelmChartFromTemplate builds a v1beta2.HelmChart from the
198199
// v2beta1.HelmChartTemplate of the given v2beta1.HelmRelease.
199-
func buildHelmChartFromTemplate(hr *v2.HelmRelease) *sourcev1.HelmChart {
200+
func buildHelmChartFromTemplate(hr *v2.HelmRelease) *sourcev1b2.HelmChart {
200201
template := hr.Spec.Chart
201-
return &sourcev1.HelmChart{
202+
return &sourcev1b2.HelmChart{
202203
ObjectMeta: metav1.ObjectMeta{
203204
Name: hr.GetHelmChartName(),
204205
Namespace: hr.Spec.Chart.GetNamespace(hr.Namespace),
205206
Labels: hr.Spec.Chart.ObjectMeta.Labels,
206207
Annotations: hr.Spec.Chart.ObjectMeta.Annotations,
207208
},
208-
Spec: sourcev1.HelmChartSpec{
209+
Spec: sourcev1b2.HelmChartSpec{
209210
Chart: template.Spec.Chart,
210211
Version: template.Spec.Version,
211-
SourceRef: sourcev1.LocalHelmChartSourceReference{
212+
SourceRef: sourcev1b2.LocalHelmChartSourceReference{
212213
Name: template.Spec.SourceRef.Name,
213214
Kind: template.Spec.SourceRef.Kind,
214215
},
@@ -224,7 +225,7 @@ func buildHelmChartFromTemplate(hr *v2.HelmRelease) *sourcev1.HelmChart {
224225
// helmChartRequiresUpdate compares the v2beta1.HelmChartTemplate of the
225226
// v2beta1.HelmRelease to the given v1beta2.HelmChart to determine if an
226227
// update is required.
227-
func helmChartRequiresUpdate(hr *v2.HelmRelease, chart *sourcev1.HelmChart) bool {
228+
func helmChartRequiresUpdate(hr *v2.HelmRelease, chart *sourcev1b2.HelmChart) bool {
228229
template := hr.Spec.Chart
229230
switch {
230231
case template.Spec.Chart != chart.Spec.Chart:
@@ -257,12 +258,12 @@ func helmChartRequiresUpdate(hr *v2.HelmRelease, chart *sourcev1.HelmChart) bool
257258
}
258259

259260
// templateVerificationToSourceVerification converts the HelmChartTemplateVerification to the OCIRepositoryVerification.
260-
func templateVerificationToSourceVerification(template *v2.HelmChartTemplateVerification) *sourcev1.OCIRepositoryVerification {
261+
func templateVerificationToSourceVerification(template *v2.HelmChartTemplateVerification) *sourcev1b2.OCIRepositoryVerification {
261262
if template == nil {
262263
return nil
263264
}
264265

265-
return &sourcev1.OCIRepositoryVerification{
266+
return &sourcev1b2.OCIRepositoryVerification{
266267
Provider: template.Provider,
267268
SecretRef: template.SecretRef,
268269
}

internal/controllers/source_predicate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"sigs.k8s.io/controller-runtime/pkg/event"
2121
"sigs.k8s.io/controller-runtime/pkg/predicate"
2222

23-
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
23+
sourcev1 "github.com/fluxcd/source-controller/api/v1"
2424
)
2525

2626
type SourceRevisionChangePredicate struct {

0 commit comments

Comments
 (0)