@@ -31,7 +31,6 @@ import (
31
31
"sigs.k8s.io/cluster-api/cmd/clusterctl/client/repository"
32
32
ctrl "sigs.k8s.io/controller-runtime"
33
33
"sigs.k8s.io/controller-runtime/pkg/client"
34
- "sigs.k8s.io/controller-runtime/pkg/reconcile"
35
34
36
35
operatorv1 "sigs.k8s.io/cluster-api-operator/api/v1alpha2"
37
36
"sigs.k8s.io/cluster-api-operator/util"
@@ -47,14 +46,14 @@ const (
47
46
)
48
47
49
48
// downloadManifests downloads CAPI manifests from a url.
50
- func (p * phaseReconciler ) downloadManifests (ctx context.Context ) (reconcile. Result , error ) {
49
+ func (p * PhaseReconciler ) downloadManifests (ctx context.Context ) (* Result , error ) {
51
50
log := ctrl .LoggerFrom (ctx )
52
51
53
52
// Return immediately if a custom config map is used instead of a url.
54
53
if p .provider .GetSpec ().FetchConfig != nil && p .provider .GetSpec ().FetchConfig .Selector != nil {
55
54
log .V (5 ).Info ("Custom config map is used, skip downloading provider manifests" )
56
55
57
- return reconcile. Result {}, nil
56
+ return & Result {}, nil
58
57
}
59
58
60
59
// Check if manifests are already downloaded and stored in a configmap
@@ -64,13 +63,13 @@ func (p *phaseReconciler) downloadManifests(ctx context.Context) (reconcile.Resu
64
63
65
64
exists , err := p .checkConfigMapExists (ctx , labelSelector , p .provider .GetNamespace ())
66
65
if err != nil {
67
- return reconcile. Result {}, wrapPhaseError (err , "failed to check that config map with manifests exists" , operatorv1 .ProviderInstalledCondition )
66
+ return & Result {}, wrapPhaseError (err , "failed to check that config map with manifests exists" , operatorv1 .ProviderInstalledCondition )
68
67
}
69
68
70
69
if exists {
71
70
log .V (5 ).Info ("Config map with downloaded manifests already exists, skip downloading provider manifests" )
72
71
73
- return reconcile. Result {}, nil
72
+ return & Result {}, nil
74
73
}
75
74
76
75
log .Info ("Downloading provider manifests" )
@@ -80,7 +79,7 @@ func (p *phaseReconciler) downloadManifests(ctx context.Context) (reconcile.Resu
80
79
if err != nil {
81
80
err = fmt .Errorf ("failed to create repo from provider url for provider %q: %w" , p .provider .GetName (), err )
82
81
83
- return reconcile. Result {}, wrapPhaseError (err , operatorv1 .ComponentsFetchErrorReason , operatorv1 .ProviderInstalledCondition )
82
+ return & Result {}, wrapPhaseError (err , operatorv1 .ComponentsFetchErrorReason , operatorv1 .ProviderInstalledCondition )
84
83
}
85
84
}
86
85
@@ -100,26 +99,26 @@ func (p *phaseReconciler) downloadManifests(ctx context.Context) (reconcile.Resu
100
99
if p .provider .GetSpec ().FetchConfig != nil && p .provider .GetSpec ().FetchConfig .OCI != "" {
101
100
configMap , err = OCIConfigMap (ctx , p .provider , OCIAuthentication (p .configClient .Variables ()))
102
101
if err != nil {
103
- return reconcile. Result {}, wrapPhaseError (err , operatorv1 .ComponentsFetchErrorReason , operatorv1 .ProviderInstalledCondition )
102
+ return & Result {}, wrapPhaseError (err , operatorv1 .ComponentsFetchErrorReason , operatorv1 .ProviderInstalledCondition )
104
103
}
105
104
} else {
106
105
configMap , err = RepositoryConfigMap (ctx , p .provider , p .repo )
107
106
if err != nil {
108
107
err = fmt .Errorf ("failed to create config map for provider %q: %w" , p .provider .GetName (), err )
109
108
110
- return reconcile. Result {}, wrapPhaseError (err , operatorv1 .ComponentsFetchErrorReason , operatorv1 .ProviderInstalledCondition )
109
+ return & Result {}, wrapPhaseError (err , operatorv1 .ComponentsFetchErrorReason , operatorv1 .ProviderInstalledCondition )
111
110
}
112
111
}
113
112
114
113
if err := p .ctrlClient .Create (ctx , configMap ); client .IgnoreAlreadyExists (err ) != nil {
115
- return reconcile. Result {}, wrapPhaseError (err , operatorv1 .ComponentsFetchErrorReason , operatorv1 .ProviderInstalledCondition )
114
+ return & Result {}, wrapPhaseError (err , operatorv1 .ComponentsFetchErrorReason , operatorv1 .ProviderInstalledCondition )
116
115
}
117
116
118
- return reconcile. Result {}, nil
117
+ return & Result {}, nil
119
118
}
120
119
121
120
// checkConfigMapExists checks if a config map exists in Kubernetes with the given LabelSelector.
122
- func (p * phaseReconciler ) checkConfigMapExists (ctx context.Context , labelSelector metav1.LabelSelector , namespace string ) (bool , error ) {
121
+ func (p * PhaseReconciler ) checkConfigMapExists (ctx context.Context , labelSelector metav1.LabelSelector , namespace string ) (bool , error ) {
123
122
labelSet := labels .Set (labelSelector .MatchLabels )
124
123
listOpts := []client.ListOption {
125
124
client.MatchingLabelsSelector {Selector : labels .SelectorFromSet (labelSet )},
@@ -140,7 +139,7 @@ func (p *phaseReconciler) checkConfigMapExists(ctx context.Context, labelSelecto
140
139
}
141
140
142
141
// prepareConfigMapLabels returns labels that identify a config map with downloaded manifests.
143
- func (p * phaseReconciler ) prepareConfigMapLabels () map [string ]string {
142
+ func (p * PhaseReconciler ) prepareConfigMapLabels () map [string ]string {
144
143
return ProviderLabels (p .provider )
145
144
}
146
145
0 commit comments