meta.go 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. "k8s.io/kubernetes/pkg/api/meta"
  16. "k8s.io/kubernetes/pkg/api/meta/metatypes"
  17. "k8s.io/kubernetes/pkg/api/unversioned"
  18. "k8s.io/kubernetes/pkg/types"
  19. )
  20. func (obj *ObjectMeta) GetObjectMeta() meta.Object { return obj }
  21. // Namespace implements meta.Object for any object with an ObjectMeta typed field. Allows
  22. // fast, direct access to metadata fields for API objects.
  23. func (meta *ObjectMeta) GetNamespace() string { return meta.Namespace }
  24. func (meta *ObjectMeta) SetNamespace(namespace string) { meta.Namespace = namespace }
  25. func (meta *ObjectMeta) GetName() string { return meta.Name }
  26. func (meta *ObjectMeta) SetName(name string) { meta.Name = name }
  27. func (meta *ObjectMeta) GetGenerateName() string { return meta.GenerateName }
  28. func (meta *ObjectMeta) SetGenerateName(generateName string) { meta.GenerateName = generateName }
  29. func (meta *ObjectMeta) GetUID() types.UID { return meta.UID }
  30. func (meta *ObjectMeta) SetUID(uid types.UID) { meta.UID = uid }
  31. func (meta *ObjectMeta) GetResourceVersion() string { return meta.ResourceVersion }
  32. func (meta *ObjectMeta) SetResourceVersion(version string) { meta.ResourceVersion = version }
  33. func (meta *ObjectMeta) GetSelfLink() string { return meta.SelfLink }
  34. func (meta *ObjectMeta) SetSelfLink(selfLink string) { meta.SelfLink = selfLink }
  35. func (meta *ObjectMeta) GetCreationTimestamp() unversioned.Time { return meta.CreationTimestamp }
  36. func (meta *ObjectMeta) SetCreationTimestamp(creationTimestamp unversioned.Time) {
  37. meta.CreationTimestamp = creationTimestamp
  38. }
  39. func (meta *ObjectMeta) GetDeletionTimestamp() *unversioned.Time { return meta.DeletionTimestamp }
  40. func (meta *ObjectMeta) SetDeletionTimestamp(deletionTimestamp *unversioned.Time) {
  41. meta.DeletionTimestamp = deletionTimestamp
  42. }
  43. func (meta *ObjectMeta) GetLabels() map[string]string { return meta.Labels }
  44. func (meta *ObjectMeta) SetLabels(labels map[string]string) { meta.Labels = labels }
  45. func (meta *ObjectMeta) GetAnnotations() map[string]string { return meta.Annotations }
  46. func (meta *ObjectMeta) SetAnnotations(annotations map[string]string) { meta.Annotations = annotations }
  47. func (meta *ObjectMeta) GetFinalizers() []string { return meta.Finalizers }
  48. func (meta *ObjectMeta) SetFinalizers(finalizers []string) { meta.Finalizers = finalizers }
  49. func (meta *ObjectMeta) GetOwnerReferences() []metatypes.OwnerReference {
  50. ret := make([]metatypes.OwnerReference, len(meta.OwnerReferences))
  51. for i := 0; i < len(meta.OwnerReferences); i++ {
  52. ret[i].Kind = meta.OwnerReferences[i].Kind
  53. ret[i].Name = meta.OwnerReferences[i].Name
  54. ret[i].UID = meta.OwnerReferences[i].UID
  55. ret[i].APIVersion = meta.OwnerReferences[i].APIVersion
  56. if meta.OwnerReferences[i].Controller != nil {
  57. value := *meta.OwnerReferences[i].Controller
  58. ret[i].Controller = &value
  59. }
  60. }
  61. return ret
  62. }
  63. func (meta *ObjectMeta) SetOwnerReferences(references []metatypes.OwnerReference) {
  64. newReferences := make([]OwnerReference, len(references))
  65. for i := 0; i < len(references); i++ {
  66. newReferences[i].Kind = references[i].Kind
  67. newReferences[i].Name = references[i].Name
  68. newReferences[i].UID = references[i].UID
  69. newReferences[i].APIVersion = references[i].APIVersion
  70. if references[i].Controller != nil {
  71. value := *references[i].Controller
  72. newReferences[i].Controller = &value
  73. }
  74. }
  75. meta.OwnerReferences = newReferences
  76. }
  77. func (meta *ObjectMeta) GetClusterName() string {
  78. return meta.ClusterName
  79. }
  80. func (meta *ObjectMeta) SetClusterName(clusterName string) {
  81. meta.ClusterName = clusterName
  82. }