generator_interfaces.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.
  11. */
  12. package v1alpha1
  13. import (
  14. "context"
  15. apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
  16. "sigs.k8s.io/controller-runtime/pkg/client"
  17. )
  18. // +kubebuilder:object:root=false
  19. // +kubebuilder:object:generate:false
  20. // +k8s:deepcopy-gen:interfaces=nil
  21. // +k8s:deepcopy-gen=nil
  22. // Generator is the common interface for all generators that is actually used to generate whatever is needed.
  23. type Generator interface {
  24. // Generate creates a new secret or set of secrets.
  25. // The returned map is a mapping of secret names to their respective values.
  26. // The status is an optional field that can be used to store any generator-specific
  27. // state which can be used during the Cleanup phase.
  28. Generate(
  29. ctx context.Context,
  30. obj *apiextensions.JSON,
  31. kube client.Client,
  32. namespace string,
  33. ) (map[string][]byte, GeneratorProviderState, error)
  34. // Cleanup deletes any resources created during the Generate phase.
  35. // Cleanup is idempotent and should not return an error if the resources
  36. // have already been deleted.
  37. Cleanup(
  38. ctx context.Context,
  39. obj *apiextensions.JSON,
  40. status GeneratorProviderState,
  41. kube client.Client,
  42. namespace string,
  43. ) error
  44. }
  45. type GeneratorProviderState *apiextensions.JSON