Skip to content

Commit

Permalink
Fix package comments
Browse files Browse the repository at this point in the history
  • Loading branch information
roivaz committed Oct 7, 2022
1 parent 8cc2579 commit 84e6a50
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 6 deletions.
5 changes: 4 additions & 1 deletion pkg/reconcilers/basereconciler/v2/resources/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,26 @@ import (

var _ basereconciler.Resource = ConfigMapTemplate{}

// ConfigMaps specifies a ConfigMap resource
// ConfigMapsTemplate has methods to generate and reconcile a ConfigMap
type ConfigMapTemplate struct {
Template func() *corev1.ConfigMap
IsEnabled bool
}

// Build returns a ConfigMap resource
func (cmt ConfigMapTemplate) Build(ctx context.Context, cl client.Client) (client.Object, []string, error) {

cm := cmt.Template()
cm.GetObjectKind().SetGroupVersionKind(corev1.SchemeGroupVersion.WithKind("ConfigMap"))
return cm.DeepCopy(), DefaultExcludedPaths, nil
}

// Enabled indicates if the resource should be present or not
func (cmt ConfigMapTemplate) Enabled() bool {
return cmt.IsEnabled
}

// ResourceReconciler implements a generic reconciler for ConfigMap resources
func (cmt ConfigMapTemplate) ResourceReconciler(ctx context.Context, cl client.Client, obj client.Object) error {
logger := log.FromContext(ctx, "ResourceReconciler", "ConfigMap")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,26 @@ import (

var _ basereconciler.Resource = ExternalSecretTemplate{}

// PodDisruptionBudget specifies a PodDisruptionBudget resource
// ExternalSecretTemplate has methods to generate and reconcile an ExternalSecret
type ExternalSecretTemplate struct {
Template func() *externalsecretsv1beta1.ExternalSecret
IsEnabled bool
}

// Build returns an ExternalSecret resource
func (est ExternalSecretTemplate) Build(ctx context.Context, cl client.Client) (client.Object, []string, error) {

es := est.Template()
es.GetObjectKind().SetGroupVersionKind(externalsecretsv1beta1.SchemeGroupVersion.WithKind(externalsecretsv1beta1.ExtSecretKind))
return es.DeepCopy(), DefaultExcludedPaths, nil
}

// Enabled indicates if the resource should be present or not
func (est ExternalSecretTemplate) Enabled() bool {
return est.IsEnabled
}

// ResourceReconciler implements a generic reconciler for ExternalSecret resources
func (est ExternalSecretTemplate) ResourceReconciler(ctx context.Context, cl client.Client, obj client.Object) error {
logger := log.FromContext(ctx, "ResourceReconciler", "ExternalSecret")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,26 @@ import (

var _ basereconciler.Resource = GrafanaDashboardTemplate{}

// GrafanaDashboard specifies a GrafanaDashboard resource
// GrafanaDashboardTemplate has methods to generate and reconcile a GrafanaDashboard
type GrafanaDashboardTemplate struct {
Template func() *grafanav1alpha1.GrafanaDashboard
IsEnabled bool
}

// Build returns a GrafanaDashboard resource
func (gdt GrafanaDashboardTemplate) Build(ctx context.Context, cl client.Client) (client.Object, []string, error) {

gd := gdt.Template()
gd.GetObjectKind().SetGroupVersionKind(grafanav1alpha1.GroupVersion.WithKind("GrafanaDashboard"))
return gd.DeepCopy(), DefaultExcludedPaths, nil
}

// Enabled indicates if the resource should be present or not
func (gdt GrafanaDashboardTemplate) Enabled() bool {
return gdt.IsEnabled
}

// ResourceReconciler implements a generic reconciler for GrafanaDashboard resources
func (gdt GrafanaDashboardTemplate) ResourceReconciler(ctx context.Context, cl client.Client, obj client.Object) error {
logger := log.FromContext(ctx, "ResourceReconciler", "GrafanaDashboard")

Expand Down
5 changes: 4 additions & 1 deletion pkg/reconcilers/basereconciler/v2/resources/hpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,26 @@ import (

var _ basereconciler.Resource = HorizontalPodAutoscalerTemplate{}

// HorizontalPodAutoscaler specifies a HorizontalPodAutoscaler resource
// HorizontalPodAutoscalerTemplate has methods to generate and reconcile a HorizontalPodAutoscaler
type HorizontalPodAutoscalerTemplate struct {
Template func() *autoscalingv2beta2.HorizontalPodAutoscaler
IsEnabled bool
}

// Build returns a HorizontalPodAutoscaler resource
func (hpat HorizontalPodAutoscalerTemplate) Build(ctx context.Context, cl client.Client) (client.Object, []string, error) {

hpa := hpat.Template()
hpa.GetObjectKind().SetGroupVersionKind(autoscalingv2beta2.SchemeGroupVersion.WithKind("HorizontalPodAutoscaler"))
return hpa.DeepCopy(), []string{}, nil
}

// Enabled indicates if the resource should be present or not
func (hpat HorizontalPodAutoscalerTemplate) Enabled() bool {
return hpat.IsEnabled
}

// ResourceReconciler implements a generic reconciler for HorizontalPodAutoscaler resources
func (hpat HorizontalPodAutoscalerTemplate) ResourceReconciler(ctx context.Context, cl client.Client, obj client.Object) error {
logger := log.FromContext(ctx, "ResourceReconciler", "HorizontalPodAutoscaler")

Expand Down
5 changes: 4 additions & 1 deletion pkg/reconcilers/basereconciler/v2/resources/pdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,26 @@ import (

var _ basereconciler.Resource = PodDisruptionBudgetTemplate{}

// PodDisruptionBudget specifies a PodDisruptionBudget resource
// PodDisruptionBudgetTemplate has methods to generate and reconcile a PodDisruptionBudget
type PodDisruptionBudgetTemplate struct {
Template func() *policyv1.PodDisruptionBudget
IsEnabled bool
}

// Build returns a PodDisruptionBudget resource
func (pdbt PodDisruptionBudgetTemplate) Build(ctx context.Context, cl client.Client) (client.Object, []string, error) {

pdb := pdbt.Template()
pdb.GetObjectKind().SetGroupVersionKind(policyv1.SchemeGroupVersion.WithKind("PodDisruptionBudget"))
return pdb.DeepCopy(), DefaultExcludedPaths, nil
}

// Enabled indicates if the resource should be present or not
func (pdbt PodDisruptionBudgetTemplate) Enabled() bool {
return pdbt.IsEnabled
}

// ResourceReconciler implements a generic reconciler for PodDisruptionBudget resources
func (pdbt PodDisruptionBudgetTemplate) ResourceReconciler(ctx context.Context, cl client.Client, obj client.Object) error {
logger := log.FromContext(ctx, "ResourceReconciler", "PodDisruptionBudget")

Expand Down
5 changes: 4 additions & 1 deletion pkg/reconcilers/basereconciler/v2/resources/pod_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,26 @@ import (

var _ basereconciler.Resource = PodMonitorTemplate{}

// PodDisruptionBudget specifies a PodDisruptionBudget resource
// PodMonitorTemplate has methods to generate and reconcile a PodMonitor
type PodMonitorTemplate struct {
Template func() *monitoringv1.PodMonitor
IsEnabled bool
}

// Build returns a PodMonitor resource
func (pmt PodMonitorTemplate) Build(ctx context.Context, cl client.Client) (client.Object, []string, error) {

pm := pmt.Template()
pm.GetObjectKind().SetGroupVersionKind(monitoringv1.SchemeGroupVersion.WithKind("PodMonitor"))
return pm.DeepCopy(), DefaultExcludedPaths, nil
}

// Enabled indicates if the resource should be present or not
func (pmt PodMonitorTemplate) Enabled() bool {
return pmt.IsEnabled
}

// ResourceReconciler implements a generic reconciler for PodMonitor resources
func (pmt PodMonitorTemplate) ResourceReconciler(ctx context.Context, cl client.Client, obj client.Object) error {
logger := log.FromContext(ctx, "ResourceReconciler", "PodMonitor")

Expand Down
4 changes: 4 additions & 0 deletions pkg/reconcilers/basereconciler/v2/resources/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ import (
var _ basereconciler.Resource = ServiceTemplate{}
var _ basereconciler.ResourceWithCustomReconciler = ServiceTemplate{}

// ServiceTemplate has methods to generate and reconcile a Service
type ServiceTemplate struct {
Template func() *corev1.Service
IsEnabled bool
}

// Build returns a Service resource
func (st ServiceTemplate) Build(ctx context.Context, cl client.Client) (client.Object, []string, error) {

svc := st.Template()
Expand All @@ -33,10 +35,12 @@ func (st ServiceTemplate) Build(ctx context.Context, cl client.Client) (client.O
return svc.DeepCopy(), serviceExcludes(svc), nil
}

// Enabled indicates if the resource should be present or not
func (dt ServiceTemplate) Enabled() bool {
return dt.IsEnabled
}

// ResourceReconciler implements a generic reconciler for Service resources
func (st ServiceTemplate) ResourceReconciler(ctx context.Context, cl client.Client, obj client.Object) error {
logger := log.FromContext(ctx, "ResourceReconciler", "Service")

Expand Down

0 comments on commit 84e6a50

Please sign in to comment.