meta.go 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. Copyright 2014 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. package v1
  14. import (
  15. metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
  16. "k8s.io/apimachinery/pkg/types"
  17. )
  18. func (obj *ObjectMeta) GetObjectMeta() metav1.Object { return obj }
  19. // Namespace implements metav1.Object for any object with an ObjectMeta typed field. Allows
  20. // fast, direct access to metadata fields for API objects.
  21. func (meta *ObjectMeta) GetNamespace() string { return meta.Namespace }
  22. func (meta *ObjectMeta) SetNamespace(namespace string) { meta.Namespace = namespace }
  23. func (meta *ObjectMeta) GetName() string { return meta.Name }
  24. func (meta *ObjectMeta) SetName(name string) { meta.Name = name }
  25. func (meta *ObjectMeta) GetGenerateName() string { return meta.GenerateName }
  26. func (meta *ObjectMeta) SetGenerateName(generateName string) { meta.GenerateName = generateName }
  27. func (meta *ObjectMeta) GetUID() types.UID { return meta.UID }
  28. func (meta *ObjectMeta) SetUID(uid types.UID) { meta.UID = uid }
  29. func (meta *ObjectMeta) GetResourceVersion() string { return meta.ResourceVersion }
  30. func (meta *ObjectMeta) SetResourceVersion(version string) { meta.ResourceVersion = version }
  31. func (meta *ObjectMeta) GetGeneration() int64 { return meta.Generation }
  32. func (meta *ObjectMeta) SetGeneration(generation int64) { meta.Generation = generation }
  33. func (meta *ObjectMeta) GetSelfLink() string { return meta.SelfLink }
  34. func (meta *ObjectMeta) SetSelfLink(selfLink string) { meta.SelfLink = selfLink }
  35. func (meta *ObjectMeta) GetCreationTimestamp() metav1.Time { return meta.CreationTimestamp }
  36. func (meta *ObjectMeta) SetCreationTimestamp(creationTimestamp metav1.Time) {
  37. meta.CreationTimestamp = creationTimestamp
  38. }
  39. func (meta *ObjectMeta) GetDeletionTimestamp() *metav1.Time { return meta.DeletionTimestamp }
  40. func (meta *ObjectMeta) SetDeletionTimestamp(deletionTimestamp *metav1.Time) {
  41. meta.DeletionTimestamp = deletionTimestamp
  42. }
  43. func (meta *ObjectMeta) GetDeletionGracePeriodSeconds() *int64 { return meta.DeletionGracePeriodSeconds }
  44. func (meta *ObjectMeta) SetDeletionGracePeriodSeconds(deletionGracePeriodSeconds *int64) {
  45. meta.DeletionGracePeriodSeconds = deletionGracePeriodSeconds
  46. }
  47. func (meta *ObjectMeta) GetLabels() map[string]string { return meta.Labels }
  48. func (meta *ObjectMeta) SetLabels(labels map[string]string) { meta.Labels = labels }
  49. func (meta *ObjectMeta) GetAnnotations() map[string]string { return meta.Annotations }
  50. func (meta *ObjectMeta) SetAnnotations(annotations map[string]string) { meta.Annotations = annotations }
  51. func (meta *ObjectMeta) GetInitializers() *metav1.Initializers { return meta.Initializers }
  52. func (meta *ObjectMeta) SetInitializers(initializers *metav1.Initializers) {
  53. meta.Initializers = initializers
  54. }
  55. func (meta *ObjectMeta) GetFinalizers() []string { return meta.Finalizers }
  56. func (meta *ObjectMeta) SetFinalizers(finalizers []string) { meta.Finalizers = finalizers }
  57. func (meta *ObjectMeta) GetOwnerReferences() []metav1.OwnerReference {
  58. ret := make([]metav1.OwnerReference, len(meta.OwnerReferences))
  59. for i := 0; i < len(meta.OwnerReferences); i++ {
  60. ret[i].Kind = meta.OwnerReferences[i].Kind
  61. ret[i].Name = meta.OwnerReferences[i].Name
  62. ret[i].UID = meta.OwnerReferences[i].UID
  63. ret[i].APIVersion = meta.OwnerReferences[i].APIVersion
  64. if meta.OwnerReferences[i].Controller != nil {
  65. value := *meta.OwnerReferences[i].Controller
  66. ret[i].Controller = &value
  67. }
  68. if meta.OwnerReferences[i].BlockOwnerDeletion != nil {
  69. value := *meta.OwnerReferences[i].BlockOwnerDeletion
  70. ret[i].BlockOwnerDeletion = &value
  71. }
  72. }
  73. return ret
  74. }
  75. func (meta *ObjectMeta) SetOwnerReferences(references []metav1.OwnerReference) {
  76. newReferences := make([]metav1.OwnerReference, len(references))
  77. for i := 0; i < len(references); i++ {
  78. newReferences[i].Kind = references[i].Kind
  79. newReferences[i].Name = references[i].Name
  80. newReferences[i].UID = references[i].UID
  81. newReferences[i].APIVersion = references[i].APIVersion
  82. if references[i].Controller != nil {
  83. value := *references[i].Controller
  84. newReferences[i].Controller = &value
  85. }
  86. if references[i].BlockOwnerDeletion != nil {
  87. value := *references[i].BlockOwnerDeletion
  88. newReferences[i].BlockOwnerDeletion = &value
  89. }
  90. }
  91. meta.OwnerReferences = newReferences
  92. }
  93. func (meta *ObjectMeta) GetClusterName() string {
  94. return meta.ClusterName
  95. }
  96. func (meta *ObjectMeta) SetClusterName(clusterName string) {
  97. meta.ClusterName = clusterName
  98. }