eso.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 addon
  13. import (
  14. "fmt"
  15. "os"
  16. // nolint
  17. . "github.com/onsi/ginkgo"
  18. // nolint
  19. . "github.com/onsi/gomega"
  20. // nolint
  21. "github.com/external-secrets/external-secrets/e2e/framework/util"
  22. )
  23. type ESO struct {
  24. Addon
  25. }
  26. func NewESO() *ESO {
  27. return &ESO{
  28. &HelmChart{
  29. Namespace: "default",
  30. ReleaseName: "eso",
  31. Chart: "/k8s/deploy/charts/external-secrets",
  32. Values: []string{"/k8s/eso.values.yaml"},
  33. },
  34. }
  35. }
  36. func (l *ESO) Install() error {
  37. By("Installing eso\n")
  38. err := l.Addon.Install()
  39. if err != nil {
  40. return err
  41. }
  42. By("afterInstall eso\n")
  43. err = l.afterInstall()
  44. if err != nil {
  45. return err
  46. }
  47. return nil
  48. }
  49. func (l *ESO) afterInstall() error {
  50. gcpProjectID := os.Getenv("GCP_PROJECT_ID")
  51. gcpGSAName := os.Getenv("GCP_GSA_NAME")
  52. gcpKSAName := os.Getenv("GCP_KSA_NAME")
  53. _, kubeClientSet, _ := util.NewConfig()
  54. annotations := make(map[string]string)
  55. annotations["iam.gke.io/gcp-service-account"] = fmt.Sprintf("%s@%s.iam.gserviceaccount.com", gcpGSAName, gcpProjectID)
  56. _, err := util.UpdateKubeSA(gcpKSAName, kubeClientSet, "default", annotations)
  57. Expect(err).NotTo(HaveOccurred())
  58. _, err = util.UpdateKubeSA("external-secrets-e2e", kubeClientSet, "default", annotations)
  59. Expect(err).NotTo(HaveOccurred())
  60. return nil
  61. }
  62. func NewScopedESO() *ESO {
  63. return &ESO{
  64. &HelmChart{
  65. Namespace: "default",
  66. ReleaseName: "eso-aws-sm",
  67. Chart: "/k8s/deploy/charts/external-secrets",
  68. Values: []string{"/k8s/eso.scoped.values.yaml"},
  69. },
  70. }
  71. }