generator_interfaces.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. Copyright © 2025 ESO Maintainer Team
  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. https://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 v1alpha1
  14. import (
  15. "context"
  16. apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
  17. "sigs.k8s.io/controller-runtime/pkg/client"
  18. )
  19. // +kubebuilder:object:root=false
  20. // +kubebuilder:object:generate:false
  21. // +k8s:deepcopy-gen:interfaces=nil
  22. // +k8s:deepcopy-gen=nil
  23. // Generator is the common interface for all generators that is actually used to generate whatever is needed.
  24. type Generator interface {
  25. // Generate creates a new secret or set of secrets.
  26. // The returned map is a mapping of secret names to their respective values.
  27. // The status is an optional field that can be used to store any generator-specific
  28. // state which can be used during the Cleanup phase.
  29. Generate(
  30. ctx context.Context,
  31. obj *apiextensions.JSON,
  32. kube client.Client,
  33. namespace string,
  34. ) (map[string][]byte, GeneratorProviderState, error)
  35. // Cleanup deletes any resources created during the Generate phase.
  36. // Cleanup is idempotent and should not return an error if the resources
  37. // have already been deleted.
  38. Cleanup(
  39. ctx context.Context,
  40. obj *apiextensions.JSON,
  41. status GeneratorProviderState,
  42. kube client.Client,
  43. namespace string,
  44. ) error
  45. }
  46. type GeneratorProviderState *apiextensions.JSON