models.go 3.1 KB

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