models.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 webhook
  13. import (
  14. metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
  15. )
  16. type Spec struct {
  17. // Webhook Method
  18. // +optional, default GET
  19. Method string `json:"method,omitempty"`
  20. // Webhook url to call
  21. URL string `json:"url"`
  22. // Headers
  23. // +optional
  24. Headers map[string]string `json:"headers,omitempty"`
  25. // Body
  26. // +optional
  27. Body string `json:"body,omitempty"`
  28. // Timeout
  29. // +optional
  30. Timeout *metav1.Duration `json:"timeout,omitempty"`
  31. // Result formatting
  32. Result Result `json:"result"`
  33. // Secrets to fill in templates
  34. // These secrets will be passed to the templating function as key value pairs under the given name
  35. // +optional
  36. Secrets []Secret `json:"secrets,omitempty"`
  37. // PEM encoded CA bundle used to validate webhook server certificate. Only used
  38. // if the Server URL is using HTTPS protocol. This parameter is ignored for
  39. // plain HTTP protocol connection. If not set the system root certificates
  40. // are used to validate the TLS connection.
  41. // +optional
  42. CABundle []byte `json:"caBundle,omitempty"`
  43. // The provider for the CA bundle to use to validate webhook server certificate.
  44. // +optional
  45. CAProvider *CAProvider `json:"caProvider,omitempty"`
  46. }
  47. type CAProviderType string
  48. const (
  49. CAProviderTypeSecret CAProviderType = "Secret"
  50. CAProviderTypeConfigMap CAProviderType = "ConfigMap"
  51. )
  52. // Defines a location to fetch the cert for the webhook provider from.
  53. type CAProvider struct {
  54. // The type of provider to use such as "Secret", or "ConfigMap".
  55. // +kubebuilder:validation:Enum="Secret";"ConfigMap"
  56. Type CAProviderType `json:"type"`
  57. // The name of the object located at the provider type.
  58. Name string `json:"name"`
  59. // The key the value inside of the provider type to use, only used with "Secret" type
  60. // +kubebuilder:validation:Optional
  61. Key string `json:"key,omitempty"`
  62. // The namespace the Provider type is in.
  63. // +optional
  64. Namespace *string `json:"namespace,omitempty"`
  65. }
  66. type Result struct {
  67. // Json path of return value
  68. // +optional
  69. JSONPath string `json:"jsonPath,omitempty"`
  70. }
  71. type Secret struct {
  72. // Name of this secret in templates
  73. Name string `json:"name"`
  74. // Secret ref to fill in credentials
  75. SecretRef SecretKeySelector `json:"secretRef"`
  76. }
  77. type SecretKeySelector struct {
  78. // The name of the Secret resource being referred to.
  79. Name string `json:"name,omitempty"`
  80. // The key where the token is found.
  81. Key string `json:"key,omitempty"`
  82. Namespace *string `json:"namespace,omitempty"`
  83. }