scheduling.go 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. Copyright The Kubernetes Authors.
  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. http://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. // Code generated by applyconfiguration-gen. DO NOT EDIT.
  14. package v1
  15. import (
  16. corev1 "k8s.io/client-go/applyconfigurations/core/v1"
  17. )
  18. // SchedulingApplyConfiguration represents a declarative configuration of the Scheduling type for use
  19. // with apply.
  20. //
  21. // Scheduling specifies the scheduling constraints for nodes supporting a
  22. // RuntimeClass.
  23. type SchedulingApplyConfiguration struct {
  24. // nodeSelector lists labels that must be present on nodes that support this
  25. // RuntimeClass. Pods using this RuntimeClass can only be scheduled to a
  26. // node matched by this selector. The RuntimeClass nodeSelector is merged
  27. // with a pod's existing nodeSelector. Any conflicts will cause the pod to
  28. // be rejected in admission.
  29. NodeSelector map[string]string `json:"nodeSelector,omitempty"`
  30. // tolerations are appended (excluding duplicates) to pods running with this
  31. // RuntimeClass during admission, effectively unioning the set of nodes
  32. // tolerated by the pod and the RuntimeClass.
  33. Tolerations []corev1.TolerationApplyConfiguration `json:"tolerations,omitempty"`
  34. }
  35. // SchedulingApplyConfiguration constructs a declarative configuration of the Scheduling type for use with
  36. // apply.
  37. func Scheduling() *SchedulingApplyConfiguration {
  38. return &SchedulingApplyConfiguration{}
  39. }
  40. // WithNodeSelector puts the entries into the NodeSelector field in the declarative configuration
  41. // and returns the receiver, so that objects can be build by chaining "With" function invocations.
  42. // If called multiple times, the entries provided by each call will be put on the NodeSelector field,
  43. // overwriting an existing map entries in NodeSelector field with the same key.
  44. func (b *SchedulingApplyConfiguration) WithNodeSelector(entries map[string]string) *SchedulingApplyConfiguration {
  45. if b.NodeSelector == nil && len(entries) > 0 {
  46. b.NodeSelector = make(map[string]string, len(entries))
  47. }
  48. for k, v := range entries {
  49. b.NodeSelector[k] = v
  50. }
  51. return b
  52. }
  53. // WithTolerations adds the given value to the Tolerations field in the declarative configuration
  54. // and returns the receiver, so that objects can be build by chaining "With" function invocations.
  55. // If called multiple times, values provided by each call will be appended to the Tolerations field.
  56. func (b *SchedulingApplyConfiguration) WithTolerations(values ...*corev1.TolerationApplyConfiguration) *SchedulingApplyConfiguration {
  57. for i := range values {
  58. if values[i] == nil {
  59. panic("nil value passed to WithTolerations")
  60. }
  61. b.Tolerations = append(b.Tolerations, *values[i])
  62. }
  63. return b
  64. }