provider_gitlab.go 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. "reflect"
  15. metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
  16. "k8s.io/apimachinery/pkg/runtime/schema"
  17. esmeta "github.com/external-secrets/external-secrets/apis/meta/v1"
  18. )
  19. // +kubebuilder:object:root=true
  20. // +kubebuilder:storageversion
  21. // +kubebuilder:subresource:status
  22. // +kubebuilder:resource:scope=Cluster,categories={gitlab},shortName=gitlab
  23. type Gitlab struct {
  24. metav1.TypeMeta `json:",inline"`
  25. metav1.ObjectMeta `json:"metadata,omitempty"`
  26. Spec GitlabSpec `json:"spec,omitempty"`
  27. }
  28. // Configures a store to sync secrets with a GitLab instance.
  29. type GitlabSpec struct {
  30. // Used to select the correct ESO controller (think: ingress.ingressClassName)
  31. // The ESO controller is instantiated with a specific controller name and filters ES based on this property
  32. // +optional
  33. Controller string `json:"controller,omitempty"`
  34. // Used to configure http retries if failed
  35. // +optional
  36. RetrySettings *esmeta.RetrySettings `json:"retrySettings,omitempty"`
  37. // Used to configure store refresh interval in seconds. Empty or 0 will default to the controller config.
  38. // +optional
  39. RefreshInterval int `json:"refreshInterval,omitempty"`
  40. // URL configures the GitLab instance URL. Defaults to https://gitlab.com/.
  41. URL string `json:"url,omitempty"`
  42. // Auth configures how secret-manager authenticates with a GitLab instance.
  43. Auth GitlabAuth `json:"auth"`
  44. // ProjectID specifies a project where secrets are located.
  45. ProjectID string `json:"projectID,omitempty"`
  46. // InheritFromGroups specifies whether parent groups should be discovered and checked for secrets.
  47. InheritFromGroups bool `json:"inheritFromGroups,omitempty"`
  48. // GroupIDs specify, which gitlab groups to pull secrets from. Group secrets are read from left to right followed by the project variables.
  49. GroupIDs []string `json:"groupIDs,omitempty"`
  50. // Environment environment_scope of gitlab CI/CD variables (Please see https://docs.gitlab.com/ee/ci/environments/#create-a-static-environment on how to create environments)
  51. Environment string `json:"environment,omitempty"`
  52. }
  53. type GitlabAuth struct {
  54. SecretRef GitlabSecretRef `json:"SecretRef"`
  55. }
  56. type GitlabSecretRef struct {
  57. // AccessToken is used for authentication.
  58. AccessToken esmeta.SecretKeySelector `json:"accessToken,omitempty"`
  59. }
  60. // +kubebuilder:object:root=true
  61. // FakeList contains a list of ExternalSecret resources.
  62. type GitlabList struct {
  63. metav1.TypeMeta `json:",inline"`
  64. metav1.ListMeta `json:"metadata,omitempty"`
  65. Items []Gitlab `json:"items"`
  66. }
  67. func init() {
  68. }
  69. // Gitlab type metadata.
  70. var (
  71. GitlabKind = reflect.TypeOf(Gitlab{}).Name()
  72. GitlabGroupKind = schema.GroupKind{Group: Group, Kind: GitlabKind}.String()
  73. GitlabKindAPIVersion = GitlabKind + "." + SchemeGroupVersion.String()
  74. GitlabGroupVersionKind = SchemeGroupVersion.WithKind(GitlabKind)
  75. )