Skip to content

Commit

Permalink
Merge pull request #219 from alexander-demicev/addon
Browse files Browse the repository at this point in the history
✨ Add support for addon providers
  • Loading branch information
k8s-ci-robot authored Sep 5, 2023
2 parents 2a0586c + a3e346e commit 623b457
Show file tree
Hide file tree
Showing 20 changed files with 3,664 additions and 1 deletion.
59 changes: 59 additions & 0 deletions api/v1alpha2/addonprovider_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
Copyright 2023 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha2

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// AddonProviderSpec defines the desired state of AddonProvider.
type AddonProviderSpec struct {
ProviderSpec `json:",inline"`
}

// AddonProviderStatus defines the observed state of AddonProvider.
type AddonProviderStatus struct {
ProviderStatus `json:",inline"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="InstalledVersion",type="string",JSONPath=".status.installedVersion"
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status"
// +kubebuilder:storageversion

// AddonProvider is the Schema for the addonproviders API.
type AddonProvider struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec AddonProviderSpec `json:"spec,omitempty"`
Status AddonProviderStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// AddonProviderList contains a list of AddonProvider.
type AddonProviderList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []AddonProvider `json:"items"`
}

func init() {
SchemeBuilder.Register(&AddonProvider{}, &AddonProviderList{})
}
91 changes: 91 additions & 0 deletions api/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,16 @@ func setupReconcilers(mgr ctrl.Manager) {
setupLog.Error(err, "unable to create controller", "controller", "ControlPlaneProvider")
os.Exit(1)
}

if err := (&providercontroller.GenericProviderReconciler{
Provider: &operatorv1.AddonProvider{},
ProviderList: &operatorv1.AddonProviderList{},
Client: mgr.GetClient(),
Config: mgr.GetConfig(),
}).SetupWithManager(mgr, concurrency(concurrencyNumber)); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "AddonProvider")
os.Exit(1)
}
}

func setupWebhooks(mgr ctrl.Manager) {
Expand All @@ -245,6 +255,11 @@ func setupWebhooks(mgr ctrl.Manager) {
setupLog.Error(err, "unable to create webhook", "webhook", "InfrastructureProvider")
os.Exit(1)
}

if err := (&webhook.AddonProviderWebhook{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "AddonProvider")
os.Exit(1)
}
}

func concurrency(c int) controller.Options {
Expand Down
Loading

0 comments on commit 623b457

Please sign in to comment.