register.go 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. "reflect"
  16. "k8s.io/apimachinery/pkg/runtime/schema"
  17. "sigs.k8s.io/controller-runtime/pkg/scheme"
  18. )
  19. // Package type metadata.
  20. const (
  21. Group = "generators.external-secrets.io"
  22. Version = "v1alpha1"
  23. )
  24. var (
  25. // SchemeGroupVersion is group version used to register these objects.
  26. SchemeGroupVersion = schema.GroupVersion{Group: Group, Version: Version}
  27. // SchemeBuilder is used to add go types to the GroupVersionKind scheme.
  28. SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}
  29. // AddToScheme adds the types in this group-version to the given scheme.
  30. AddToScheme = SchemeBuilder.AddToScheme
  31. )
  32. var (
  33. // ECRAuthorizationTokenKind is the kind name for ECRAuthorizationToken resource.
  34. ECRAuthorizationTokenKind = reflect.TypeOf(ECRAuthorizationToken{}).Name()
  35. // STSSessionTokenKind is the kind name for STSSessionToken resource.
  36. STSSessionTokenKind = reflect.TypeOf(STSSessionToken{}).Name()
  37. // GCRAccessTokenKind is the kind name for GCRAccessToken resource.
  38. GCRAccessTokenKind = reflect.TypeOf(GCRAccessToken{}).Name()
  39. // ACRAccessTokenKind is the kind name for ACRAccessToken resource.
  40. ACRAccessTokenKind = reflect.TypeOf(ACRAccessToken{}).Name()
  41. // PasswordKind is the kind name for Password resource.
  42. PasswordKind = reflect.TypeOf(Password{}).Name()
  43. // SSHKeyKind is the kind name for SSHKey resource.
  44. SSHKeyKind = reflect.TypeOf(SSHKey{}).Name()
  45. // WebhookKind is the kind name for Webhook resource.
  46. WebhookKind = reflect.TypeOf(Webhook{}).Name()
  47. // FakeKind is the kind name for Fake resource.
  48. FakeKind = reflect.TypeOf(Fake{}).Name()
  49. // VaultDynamicSecretKind is the kind name for VaultDynamicSecret resource.
  50. VaultDynamicSecretKind = reflect.TypeOf(VaultDynamicSecret{}).Name()
  51. // GithubAccessTokenKind is the kind name for GithubAccessToken resource.
  52. GithubAccessTokenKind = reflect.TypeOf(GithubAccessToken{}).Name()
  53. // QuayAccessTokenKind is the kind name for QuayAccessToken resource.
  54. QuayAccessTokenKind = reflect.TypeOf(QuayAccessToken{}).Name()
  55. // UUIDKind is the kind name for UUID resource.
  56. UUIDKind = reflect.TypeOf(UUID{}).Name()
  57. // GrafanaKind is the kind name for Grafana resource.
  58. GrafanaKind = reflect.TypeOf(Grafana{}).Name()
  59. // MFAKind is the kind name for MFA resource.
  60. MFAKind = reflect.TypeOf(MFA{}).Name()
  61. // ClusterGeneratorKind is the kind name for ClusterGenerator resource.
  62. ClusterGeneratorKind = reflect.TypeOf(ClusterGenerator{}).Name()
  63. // CloudsmithAccessTokenKind is the kind name for CloudsmithAccessToken resource.
  64. CloudsmithAccessTokenKind = reflect.TypeOf(CloudsmithAccessToken{}).Name()
  65. )
  66. func init() {
  67. SchemeBuilder.Register(&GeneratorState{}, &GeneratorStateList{})
  68. /*
  69. ===============================================================================
  70. NOTE: when adding support for new kinds of generators:
  71. 1. register the struct types in `SchemeBuilder` (right below this note)
  72. 2. update the `kubebuilder:validation:Enum` annotation for GeneratorRef.Kind (apis/externalsecrets/v1beta1/externalsecret_types.go)
  73. 3. add it to the imports of (pkg/generator/register/register.go)
  74. 4. add it to the ClusterRole called "*-controller" (deploy/charts/external-secrets/templates/rbac.yaml)
  75. 5. support it in ClusterGenerator:
  76. - add a new GeneratorKind enum value (apis/generators/v1alpha1/types_cluster.go)
  77. - update the `kubebuilder:validation:Enum` annotation for the GeneratorKind enum
  78. - add a spec field to GeneratorSpec (apis/generators/v1alpha1/types_cluster.go)
  79. - update the clusterGeneratorToVirtual() function (pkg/utils/resolvers/generator.go)
  80. ===============================================================================
  81. */
  82. SchemeBuilder.Register(&ACRAccessToken{}, &ACRAccessTokenList{})
  83. SchemeBuilder.Register(&ClusterGenerator{}, &ClusterGeneratorList{})
  84. SchemeBuilder.Register(&CloudsmithAccessToken{}, &CloudsmithAccessTokenList{})
  85. SchemeBuilder.Register(&ECRAuthorizationToken{}, &ECRAuthorizationTokenList{})
  86. SchemeBuilder.Register(&Fake{}, &FakeList{})
  87. SchemeBuilder.Register(&GCRAccessToken{}, &GCRAccessTokenList{})
  88. SchemeBuilder.Register(&GithubAccessToken{}, &GithubAccessTokenList{})
  89. SchemeBuilder.Register(&QuayAccessToken{}, &QuayAccessTokenList{})
  90. SchemeBuilder.Register(&Password{}, &PasswordList{})
  91. SchemeBuilder.Register(&SSHKey{}, &SSHKeyList{})
  92. SchemeBuilder.Register(&STSSessionToken{}, &STSSessionTokenList{})
  93. SchemeBuilder.Register(&UUID{}, &UUIDList{})
  94. SchemeBuilder.Register(&VaultDynamicSecret{}, &VaultDynamicSecretList{})
  95. SchemeBuilder.Register(&Webhook{}, &WebhookList{})
  96. SchemeBuilder.Register(&Grafana{}, &GrafanaList{})
  97. SchemeBuilder.Register(&MFA{}, &MFAList{})
  98. }