Skip to content

Commit 623b457

Browse files
authored
Merge pull request #219 from alexander-demicev/addon
✨ Add support for addon providers
2 parents 2a0586c + a3e346e commit 623b457

20 files changed

+3664
-1
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
Copyright 2023 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha2
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// AddonProviderSpec defines the desired state of AddonProvider.
24+
type AddonProviderSpec struct {
25+
ProviderSpec `json:",inline"`
26+
}
27+
28+
// AddonProviderStatus defines the observed state of AddonProvider.
29+
type AddonProviderStatus struct {
30+
ProviderStatus `json:",inline"`
31+
}
32+
33+
// +kubebuilder:object:root=true
34+
// +kubebuilder:subresource:status
35+
// +kubebuilder:printcolumn:name="InstalledVersion",type="string",JSONPath=".status.installedVersion"
36+
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status"
37+
// +kubebuilder:storageversion
38+
39+
// AddonProvider is the Schema for the addonproviders API.
40+
type AddonProvider struct {
41+
metav1.TypeMeta `json:",inline"`
42+
metav1.ObjectMeta `json:"metadata,omitempty"`
43+
44+
Spec AddonProviderSpec `json:"spec,omitempty"`
45+
Status AddonProviderStatus `json:"status,omitempty"`
46+
}
47+
48+
// +kubebuilder:object:root=true
49+
50+
// AddonProviderList contains a list of AddonProvider.
51+
type AddonProviderList struct {
52+
metav1.TypeMeta `json:",inline"`
53+
metav1.ListMeta `json:"metadata,omitempty"`
54+
Items []AddonProvider `json:"items"`
55+
}
56+
57+
func init() {
58+
SchemeBuilder.Register(&AddonProvider{}, &AddonProviderList{})
59+
}

api/v1alpha2/zz_generated.deepcopy.go

Lines changed: 91 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/main.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,16 @@ func setupReconcilers(mgr ctrl.Manager) {
223223
setupLog.Error(err, "unable to create controller", "controller", "ControlPlaneProvider")
224224
os.Exit(1)
225225
}
226+
227+
if err := (&providercontroller.GenericProviderReconciler{
228+
Provider: &operatorv1.AddonProvider{},
229+
ProviderList: &operatorv1.AddonProviderList{},
230+
Client: mgr.GetClient(),
231+
Config: mgr.GetConfig(),
232+
}).SetupWithManager(mgr, concurrency(concurrencyNumber)); err != nil {
233+
setupLog.Error(err, "unable to create controller", "controller", "AddonProvider")
234+
os.Exit(1)
235+
}
226236
}
227237

228238
func setupWebhooks(mgr ctrl.Manager) {
@@ -245,6 +255,11 @@ func setupWebhooks(mgr ctrl.Manager) {
245255
setupLog.Error(err, "unable to create webhook", "webhook", "InfrastructureProvider")
246256
os.Exit(1)
247257
}
258+
259+
if err := (&webhook.AddonProviderWebhook{}).SetupWebhookWithManager(mgr); err != nil {
260+
setupLog.Error(err, "unable to create webhook", "webhook", "AddonProvider")
261+
os.Exit(1)
262+
}
248263
}
249264

250265
func concurrency(c int) controller.Options {

0 commit comments

Comments
 (0)