provider.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. // nolint
  16. . "github.com/onsi/ginkgo/v2"
  17. // nolint
  18. . "github.com/onsi/gomega"
  19. metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
  20. "github.com/external-secrets/external-secrets-e2e/framework"
  21. esv1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1"
  22. )
  23. type templateProvider struct {
  24. framework *framework.Framework
  25. }
  26. func newProvider(f *framework.Framework) *templateProvider {
  27. prov := &templateProvider{
  28. framework: f,
  29. }
  30. BeforeEach(prov.BeforeEach)
  31. return prov
  32. }
  33. func (s *templateProvider) CreateSecret(key string, val framework.SecretEntry) {
  34. // noop: this provider implements static key/value pairs
  35. }
  36. func (s *templateProvider) DeleteSecret(key string) {
  37. // noop: this provider implements static key/value pairs
  38. }
  39. func (s *templateProvider) BeforeEach() {
  40. // Create a secret store - change these values to match YAML
  41. By("creating a secret store for credentials")
  42. secretStore := &esv1.SecretStore{
  43. ObjectMeta: metav1.ObjectMeta{
  44. Name: s.framework.Namespace.Name,
  45. Namespace: s.framework.Namespace.Name,
  46. },
  47. Spec: esv1.SecretStoreSpec{
  48. Provider: &esv1.SecretStoreProvider{
  49. Fake: &esv1.FakeProvider{
  50. Data: []esv1.FakeProviderData{
  51. {
  52. Key: "foo",
  53. Value: "bar",
  54. },
  55. {
  56. Key: "baz",
  57. Value: "bang",
  58. },
  59. {
  60. Key: "map",
  61. Value: `{"foo": "barmap", "bar": "bangmap"}`,
  62. },
  63. {
  64. Key: "json",
  65. Value: `{"foo":{"bar":"baz"}}`,
  66. },
  67. },
  68. },
  69. },
  70. },
  71. }
  72. err := s.framework.CRClient.Create(GinkgoT().Context(), secretStore)
  73. Expect(err).ToNot(HaveOccurred())
  74. }