neo4j.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. Copyright 2026 LocoStack.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package reconciler
  14. import (
  15. "context"
  16. "fmt"
  17. "github.com/LocoStack/loco-operator/api/v1alpha1"
  18. "k8s.io/apimachinery/pkg/runtime"
  19. "sigs.k8s.io/controller-runtime/pkg/client"
  20. )
  21. const (
  22. NEO4J_DEFAULT_STORAGE_SIZE = "1Gi"
  23. )
  24. type Neo4jReconciler struct {
  25. *DefaultComponentReconciler
  26. client client.Client
  27. scheme *runtime.Scheme
  28. stack *v1alpha1.Stack
  29. component *v1alpha1.Component
  30. }
  31. func NewNeo4jReconciler(client client.Client, scheme *runtime.Scheme, stack *v1alpha1.Stack, component *v1alpha1.Component) *Neo4jReconciler {
  32. return &Neo4jReconciler{
  33. DefaultComponentReconciler: NewDefaultComponentReconciler(client, scheme, stack, component),
  34. client: client,
  35. scheme: scheme,
  36. stack: stack,
  37. component: component,
  38. }
  39. }
  40. func (r *Neo4jReconciler) ReconcileComponent(ctx context.Context, tmpl *v1alpha1.Template, variables map[string]string) ([]client.Object, error) {
  41. if err := r.ReconcileStorage(ctx, "neo4j", NEO4J_DEFAULT_STORAGE_SIZE); err != nil {
  42. return nil, fmt.Errorf("reconciling neo4j persistent volume: %w", err)
  43. }
  44. if _, err := r.DefaultComponentReconciler.ReconcileComponent(ctx, tmpl, variables); err != nil {
  45. return nil, err
  46. }
  47. return nil, nil
  48. }