engine.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  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 template
  14. import (
  15. "fmt"
  16. corev1 "k8s.io/api/core/v1"
  17. esapi "github.com/external-secrets/external-secrets/apis/externalsecrets/v1"
  18. v2 "github.com/external-secrets/external-secrets/pkg/template/v2"
  19. )
  20. type ExecFunc func(tpl, data map[string][]byte, scope esapi.TemplateScope, target esapi.TemplateTarget, secret *corev1.Secret) error
  21. func EngineForVersion(version esapi.TemplateEngineVersion) (ExecFunc, error) {
  22. // We want to leave this for new versions
  23. switch version { //nolint:gocritic
  24. case esapi.TemplateEngineV2:
  25. return v2.Execute, nil
  26. }
  27. return nil, fmt.Errorf("unsupported template engine version: %s", version)
  28. }