Skip to content

Commit

Permalink
Remove postFound function from hcoResourceHooks
Browse files Browse the repository at this point in the history
It was necessary for configreader role&rolebinding
in cdi hooks but we moved them to separate handlers
now. We don't need this function anymore.

Signed-off-by: Erkan Erol <eerol@redhat.com>
  • Loading branch information
Erkan Erol committed Jul 15, 2021
1 parent 0d09559 commit 3cc9a24
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 37 deletions.
11 changes: 2 additions & 9 deletions pkg/controller/operands/cdi.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ func getDefaultFeatureGates() []string {
return []string{HonorWaitForFirstConsumerGate}
}

func (h *cdiHooks) postFound(req *common.HcoRequest, exists runtime.Object) error { return nil }

func NewCDI(hc *hcov1beta1.HyperConverged, opts ...string) (*cdiv1beta1.CDI, error) {
uninstallStrategy := cdiv1beta1.CDIUninstallStrategyBlockUninstallIfWorkloadsExist

Expand Down Expand Up @@ -188,8 +186,7 @@ type storageConfigHooks struct{}
func (h storageConfigHooks) getFullCr(hc *hcov1beta1.HyperConverged) (client.Object, error) {
return NewKubeVirtStorageConfigForCR(hc, hc.Namespace), nil
}
func (h storageConfigHooks) getEmptyCr() client.Object { return &corev1.ConfigMap{} }
func (h storageConfigHooks) postFound(_ *common.HcoRequest, _ runtime.Object) error { return nil }
func (h storageConfigHooks) getEmptyCr() client.Object { return &corev1.ConfigMap{} }
func (h storageConfigHooks) getObjectMeta(cr runtime.Object) *metav1.ObjectMeta {
return &cr.(*corev1.ConfigMap).ObjectMeta
}
Expand Down Expand Up @@ -271,8 +268,7 @@ type configReaderRoleHooks struct{}
func (h configReaderRoleHooks) getFullCr(hc *hcov1beta1.HyperConverged) (client.Object, error) {
return NewConfigReaderRoleForCR(hc, hc.Namespace), nil
}
func (h configReaderRoleHooks) getEmptyCr() client.Object { return &rbacv1.Role{} }
func (h configReaderRoleHooks) postFound(_ *common.HcoRequest, _ runtime.Object) error { return nil }
func (h configReaderRoleHooks) getEmptyCr() client.Object { return &rbacv1.Role{} }
func (h configReaderRoleHooks) getObjectMeta(cr runtime.Object) *metav1.ObjectMeta {
return &cr.(*rbacv1.Role).ObjectMeta
}
Expand Down Expand Up @@ -342,9 +338,6 @@ func (h configReaderRoleBindingHooks) getFullCr(hc *hcov1beta1.HyperConverged) (
return NewConfigReaderRoleBindingForCR(hc, hc.Namespace), nil
}
func (h configReaderRoleBindingHooks) getEmptyCr() client.Object { return &rbacv1.RoleBinding{} }
func (h configReaderRoleBindingHooks) postFound(_ *common.HcoRequest, _ runtime.Object) error {
return nil
}
func (h configReaderRoleBindingHooks) getObjectMeta(cr runtime.Object) *metav1.ObjectMeta {
return &cr.(*rbacv1.RoleBinding).ObjectMeta
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/controller/operands/cliDownload.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ func (h cliDownloadHooks) getEmptyCr() client.Object {
return &consolev1.ConsoleCLIDownload{}
}

func (h cliDownloadHooks) postFound(_ *common.HcoRequest, _ runtime.Object) error { return nil }

func (h cliDownloadHooks) getObjectMeta(cr runtime.Object) *metav1.ObjectMeta {
return &cr.(*consolev1.ConsoleCLIDownload).ObjectMeta
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/controller/operands/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ func (h dashboardHooks) getEmptyCr() client.Object {
}
}

func (h dashboardHooks) postFound(_ *common.HcoRequest, _ runtime.Object) error { return nil }

func (h dashboardHooks) getObjectMeta(cr runtime.Object) *metav1.ObjectMeta {
return &cr.(*v1.ConfigMap).ObjectMeta
}
Expand Down
6 changes: 2 additions & 4 deletions pkg/controller/operands/kubevirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ func (h *kubevirtHooks) getFullCr(hc *hcov1beta1.HyperConverged) (client.Object,
return h.cache, nil
}

func (h kubevirtHooks) getEmptyCr() client.Object { return &kubevirtv1.KubeVirt{} }
func (h kubevirtHooks) postFound(*common.HcoRequest, runtime.Object) error { return nil }
func (h kubevirtHooks) getEmptyCr() client.Object { return &kubevirtv1.KubeVirt{} }
func (h kubevirtHooks) getConditions(cr runtime.Object) []metav1.Condition {
return translateKubeVirtConds(cr.(*kubevirtv1.KubeVirt).Status.Conditions)
}
Expand Down Expand Up @@ -477,8 +476,7 @@ type kvPriorityClassHooks struct{}
func (h kvPriorityClassHooks) getFullCr(hc *hcov1beta1.HyperConverged) (client.Object, error) {
return NewKubeVirtPriorityClass(hc), nil
}
func (h kvPriorityClassHooks) getEmptyCr() client.Object { return &schedulingv1.PriorityClass{} }
func (h kvPriorityClassHooks) postFound(_ *common.HcoRequest, _ runtime.Object) error { return nil }
func (h kvPriorityClassHooks) getEmptyCr() client.Object { return &schedulingv1.PriorityClass{} }
func (h kvPriorityClassHooks) getObjectMeta(cr runtime.Object) *metav1.ObjectMeta {
return &cr.(*schedulingv1.PriorityClass).ObjectMeta
}
Expand Down
7 changes: 2 additions & 5 deletions pkg/controller/operands/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ type metricsServiceHooks struct{}
func (h metricsServiceHooks) getFullCr(hc *hcov1beta1.HyperConverged) (client.Object, error) {
return NewMetricsService(hc, hc.Namespace), nil
}
func (h metricsServiceHooks) getEmptyCr() client.Object { return &corev1.Service{} }
func (h metricsServiceHooks) postFound(*common.HcoRequest, runtime.Object) error { return nil }
func (h metricsServiceHooks) getEmptyCr() client.Object { return &corev1.Service{} }
func (h metricsServiceHooks) getObjectMeta(cr runtime.Object) *metav1.ObjectMeta {
return &cr.(*corev1.Service).ObjectMeta
}
Expand Down Expand Up @@ -130,7 +129,6 @@ func (h metricsServiceMonitorHooks) getFullCr(hc *hcov1beta1.HyperConverged) (cl
func (h metricsServiceMonitorHooks) getEmptyCr() client.Object {
return &monitoringv1.ServiceMonitor{}
}
func (h metricsServiceMonitorHooks) postFound(*common.HcoRequest, runtime.Object) error { return nil }
func (h metricsServiceMonitorHooks) getObjectMeta(cr runtime.Object) *metav1.ObjectMeta {
return &cr.(*monitoringv1.ServiceMonitor).ObjectMeta
}
Expand Down Expand Up @@ -198,8 +196,7 @@ type prometheusRuleHooks struct{}
func (h prometheusRuleHooks) getFullCr(hc *hcov1beta1.HyperConverged) (client.Object, error) {
return NewPrometheusRule(hc, hc.Namespace), nil
}
func (h prometheusRuleHooks) getEmptyCr() client.Object { return &monitoringv1.PrometheusRule{} }
func (h prometheusRuleHooks) postFound(*common.HcoRequest, runtime.Object) error { return nil }
func (h prometheusRuleHooks) getEmptyCr() client.Object { return &monitoringv1.PrometheusRule{} }
func (h prometheusRuleHooks) getObjectMeta(cr runtime.Object) *metav1.ObjectMeta {
return &cr.(*monitoringv1.PrometheusRule).ObjectMeta
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/controller/operands/networkAddons.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ func (h *cnaHooks) getFullCr(hc *hcov1beta1.HyperConverged) (client.Object, erro
return h.cache, nil
}

func (h cnaHooks) getEmptyCr() client.Object { return &networkaddonsv1.NetworkAddonsConfig{} }
func (h cnaHooks) postFound(*common.HcoRequest, runtime.Object) error { return nil }
func (h cnaHooks) getEmptyCr() client.Object { return &networkaddonsv1.NetworkAddonsConfig{} }
func (h cnaHooks) getConditions(cr runtime.Object) []metav1.Condition {
return osConditionsToK8s(cr.(*networkaddonsv1.NetworkAddonsConfig).Status.Conditions)
}
Expand Down
6 changes: 0 additions & 6 deletions pkg/controller/operands/operand.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ type hcoResourceHooks interface {
// Generate an empty resource, to be used as the input of the client.Get method. After calling this method, it will
// contains the actual values in K8s.
getEmptyCr() client.Object
// an optional hook that is called just after getting the resource from K8s
postFound(*common.HcoRequest, runtime.Object) error
// check if there is a change between the required resource and the resource read from K8s, and update K8s accordingly.
updateCr(*common.HcoRequest, client.Client, runtime.Object, runtime.Object) (bool, bool, error)
// cast he specific resource to *metav1.ObjectMeta
Expand Down Expand Up @@ -102,10 +100,6 @@ func (h *genericOperand) ensure(req *common.HcoRequest) *EnsureResult {
func (h *genericOperand) handleExistingCr(req *common.HcoRequest, key client.ObjectKey, found client.Object, cr client.Object, res *EnsureResult) *EnsureResult {
req.Logger.Info(h.crType+" already exists", h.crType+".Namespace", key.Namespace, h.crType+".Name", key.Name)

if err := h.hooks.postFound(req, found); err != nil {
return res.Error(err)
}

h.doRemoveExistingOwners(req, found)

updated, overwritten, err := h.hooks.updateCr(req, h.Client, found, cr)
Expand Down
2 changes: 0 additions & 2 deletions pkg/controller/operands/quickStart.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ func (h qsHooks) getEmptyCr() client.Object {
}
}

func (h qsHooks) postFound(_ *common.HcoRequest, _ runtime.Object) error { return nil }

func (h qsHooks) getObjectMeta(cr runtime.Object) *metav1.ObjectMeta {
return &cr.(*consolev1.ConsoleQuickStart).ObjectMeta
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/controller/operands/ssp.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ func (h *sspHooks) getFullCr(hc *hcov1beta1.HyperConverged) (client.Object, erro
}
return h.cache, nil
}
func (h sspHooks) getEmptyCr() client.Object { return &sspv1beta1.SSP{} }
func (h sspHooks) postFound(*common.HcoRequest, runtime.Object) error { return nil }
func (h sspHooks) getEmptyCr() client.Object { return &sspv1beta1.SSP{} }
func (h sspHooks) getConditions(cr runtime.Object) []metav1.Condition {
return osConditionsToK8s(cr.(*sspv1beta1.SSP).Status.Conditions)
}
Expand Down
4 changes: 1 addition & 3 deletions pkg/controller/operands/vmImport.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ func (h *vmImportHooks) getFullCr(hc *hcov1beta1.HyperConverged) (client.Object,
}
return h.cache, nil
}
func (h vmImportHooks) getEmptyCr() client.Object { return &vmimportv1beta1.VMImportConfig{} }
func (h vmImportHooks) postFound(_ *common.HcoRequest, _ runtime.Object) error { return nil }
func (h vmImportHooks) getEmptyCr() client.Object { return &vmimportv1beta1.VMImportConfig{} }
func (h vmImportHooks) getConditions(cr runtime.Object) []metav1.Condition {
return osConditionsToK8s(cr.(*vmimportv1beta1.VMImportConfig).Status.Conditions)
}
Expand Down Expand Up @@ -122,7 +121,6 @@ func (h imsConfigHooks) getFullCr(hc *hcov1beta1.HyperConverged) (client.Object,
}
func (h imsConfigHooks) getEmptyCr() client.Object { return &corev1.ConfigMap{} }

func (h imsConfigHooks) postFound(_ *common.HcoRequest, _ runtime.Object) error { return nil }
func (h imsConfigHooks) getObjectMeta(cr runtime.Object) *metav1.ObjectMeta {
return &cr.(*corev1.ConfigMap).ObjectMeta
}
Expand Down

0 comments on commit 3cc9a24

Please sign in to comment.