models.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 webhook
  14. import (
  15. metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
  16. esv1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1"
  17. esmeta "github.com/external-secrets/external-secrets/apis/meta/v1"
  18. )
  19. type Spec struct {
  20. // Webhook Method
  21. // +optional, default GET
  22. Method string `json:"method,omitempty"`
  23. // Webhook url to call
  24. URL string `json:"url"`
  25. // Headers
  26. // +optional
  27. Headers map[string]string `json:"headers,omitempty"`
  28. // Auth specifies a authorization protocol. Only one protocol may be set.
  29. // +optional
  30. Auth *AuthorizationProtocol `json:"auth,omitempty"`
  31. // Body
  32. // +optional
  33. Body string `json:"body,omitempty"`
  34. // Timeout
  35. // +optional
  36. Timeout *metav1.Duration `json:"timeout,omitempty"`
  37. // Result formatting
  38. Result Result `json:"result"`
  39. // Secrets to fill in templates
  40. // These secrets will be passed to the templating function as key value pairs under the given name
  41. // +optional
  42. Secrets []Secret `json:"secrets,omitempty"`
  43. // PEM encoded CA bundle used to validate webhook server certificate. Only used
  44. // if the Server URL is using HTTPS protocol. This parameter is ignored for
  45. // plain HTTP protocol connection. If not set the system root certificates
  46. // are used to validate the TLS connection.
  47. // +optional
  48. CABundle []byte `json:"caBundle,omitempty"`
  49. // The provider for the CA bundle to use to validate webhook server certificate.
  50. // +optional
  51. CAProvider *esv1.CAProvider `json:"caProvider,omitempty"`
  52. }
  53. // AuthorizationProtocol contains the protocol-specific configuration
  54. // +kubebuilder:validation:MinProperties=1
  55. // +kubebuilder:validation:MaxProperties=1
  56. type AuthorizationProtocol struct {
  57. // NTLMProtocol configures the store to use NTLM for auth
  58. // +optional
  59. NTLM *NTLMProtocol `json:"ntlm,omitempty"`
  60. // Define other protocols here
  61. }
  62. // NTLMProtocol contains the NTLM-specific configuration.
  63. type NTLMProtocol struct {
  64. UserName esmeta.SecretKeySelector `json:"usernameSecret"`
  65. Password esmeta.SecretKeySelector `json:"passwordSecret"`
  66. }
  67. type Result struct {
  68. // Json path of return value
  69. // +optional
  70. JSONPath string `json:"jsonPath,omitempty"`
  71. }
  72. type Secret struct {
  73. // Name of this secret in templates
  74. Name string `json:"name"`
  75. // Secret ref to fill in credentials
  76. SecretRef esmeta.SecretKeySelector `json:"secretRef"`
  77. }