k8s.io/client-go@v0.31.1/testing/actions.go (about) 1 /* 2 Copyright 2015 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package testing 18 19 import ( 20 "fmt" 21 "path" 22 "strings" 23 24 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 25 "k8s.io/apimachinery/pkg/fields" 26 "k8s.io/apimachinery/pkg/labels" 27 "k8s.io/apimachinery/pkg/runtime" 28 "k8s.io/apimachinery/pkg/runtime/schema" 29 "k8s.io/apimachinery/pkg/types" 30 ) 31 32 func NewRootGetAction(resource schema.GroupVersionResource, name string) GetActionImpl { 33 return NewRootGetActionWithOptions(resource, name, metav1.GetOptions{}) 34 } 35 36 func NewRootGetActionWithOptions(resource schema.GroupVersionResource, name string, opts metav1.GetOptions) GetActionImpl { 37 action := GetActionImpl{} 38 action.Verb = "get" 39 action.Resource = resource 40 action.Name = name 41 action.GetOptions = opts 42 43 return action 44 } 45 46 func NewGetAction(resource schema.GroupVersionResource, namespace, name string) GetActionImpl { 47 return NewGetActionWithOptions(resource, namespace, name, metav1.GetOptions{}) 48 } 49 50 func NewGetActionWithOptions(resource schema.GroupVersionResource, namespace, name string, opts metav1.GetOptions) GetActionImpl { 51 action := GetActionImpl{} 52 action.Verb = "get" 53 action.Resource = resource 54 action.Namespace = namespace 55 action.Name = name 56 action.GetOptions = opts 57 58 return action 59 } 60 61 func NewGetSubresourceAction(resource schema.GroupVersionResource, namespace, subresource, name string) GetActionImpl { 62 return NewGetSubresourceActionWithOptions(resource, namespace, subresource, name, metav1.GetOptions{}) 63 } 64 65 func NewGetSubresourceActionWithOptions(resource schema.GroupVersionResource, namespace, subresource, name string, opts metav1.GetOptions) GetActionImpl { 66 action := GetActionImpl{} 67 action.Verb = "get" 68 action.Resource = resource 69 action.Subresource = subresource 70 action.Namespace = namespace 71 action.Name = name 72 action.GetOptions = opts 73 74 return action 75 } 76 77 func NewRootGetSubresourceAction(resource schema.GroupVersionResource, subresource, name string) GetActionImpl { 78 return NewRootGetSubresourceActionWithOptions(resource, subresource, name, metav1.GetOptions{}) 79 } 80 81 func NewRootGetSubresourceActionWithOptions(resource schema.GroupVersionResource, subresource, name string, opts metav1.GetOptions) GetActionImpl { 82 action := GetActionImpl{} 83 action.Verb = "get" 84 action.Resource = resource 85 action.Subresource = subresource 86 action.Name = name 87 action.GetOptions = opts 88 89 return action 90 } 91 92 func NewRootListAction(resource schema.GroupVersionResource, kind schema.GroupVersionKind, opts interface{}) ListActionImpl { 93 action := ListActionImpl{} 94 action.Verb = "list" 95 action.Resource = resource 96 action.Kind = kind 97 labelSelector, fieldSelector, _ := ExtractFromListOptions(opts) 98 action.ListRestrictions = ListRestrictions{labelSelector, fieldSelector} 99 action.ListOptions = metav1.ListOptions{LabelSelector: labelSelector.String(), FieldSelector: fieldSelector.String()} 100 101 return action 102 } 103 104 func NewRootListActionWithOptions(resource schema.GroupVersionResource, kind schema.GroupVersionKind, opts metav1.ListOptions) ListActionImpl { 105 action := ListActionImpl{} 106 action.Verb = "list" 107 action.Resource = resource 108 action.Kind = kind 109 action.ListOptions = opts 110 111 labelSelector, fieldSelector, _ := ExtractFromListOptions(opts) 112 action.ListRestrictions = ListRestrictions{labelSelector, fieldSelector} 113 action.ListOptions = metav1.ListOptions{LabelSelector: labelSelector.String(), FieldSelector: fieldSelector.String()} 114 115 return action 116 } 117 118 func NewListAction(resource schema.GroupVersionResource, kind schema.GroupVersionKind, namespace string, opts interface{}) ListActionImpl { 119 action := ListActionImpl{} 120 action.Verb = "list" 121 action.Resource = resource 122 action.Kind = kind 123 action.Namespace = namespace 124 labelSelector, fieldSelector, _ := ExtractFromListOptions(opts) 125 action.ListRestrictions = ListRestrictions{labelSelector, fieldSelector} 126 action.ListOptions = metav1.ListOptions{LabelSelector: labelSelector.String(), FieldSelector: fieldSelector.String()} 127 128 return action 129 } 130 131 func NewListActionWithOptions(resource schema.GroupVersionResource, kind schema.GroupVersionKind, namespace string, opts metav1.ListOptions) ListActionImpl { 132 action := ListActionImpl{} 133 action.Verb = "list" 134 action.Resource = resource 135 action.Kind = kind 136 action.Namespace = namespace 137 action.ListOptions = opts 138 139 labelSelector, fieldSelector, _ := ExtractFromListOptions(opts) 140 action.ListRestrictions = ListRestrictions{labelSelector, fieldSelector} 141 142 return action 143 } 144 145 func NewRootCreateAction(resource schema.GroupVersionResource, object runtime.Object) CreateActionImpl { 146 return NewRootCreateActionWithOptions(resource, object, metav1.CreateOptions{}) 147 } 148 149 func NewRootCreateActionWithOptions(resource schema.GroupVersionResource, object runtime.Object, opts metav1.CreateOptions) CreateActionImpl { 150 action := CreateActionImpl{} 151 action.Verb = "create" 152 action.Resource = resource 153 action.Object = object 154 action.CreateOptions = opts 155 156 return action 157 } 158 159 func NewCreateAction(resource schema.GroupVersionResource, namespace string, object runtime.Object) CreateActionImpl { 160 return NewCreateActionWithOptions(resource, namespace, object, metav1.CreateOptions{}) 161 } 162 163 func NewCreateActionWithOptions(resource schema.GroupVersionResource, namespace string, object runtime.Object, opts metav1.CreateOptions) CreateActionImpl { 164 action := CreateActionImpl{} 165 action.Verb = "create" 166 action.Resource = resource 167 action.Namespace = namespace 168 action.Object = object 169 action.CreateOptions = opts 170 171 return action 172 } 173 174 func NewRootCreateSubresourceAction(resource schema.GroupVersionResource, name, subresource string, object runtime.Object) CreateActionImpl { 175 return NewRootCreateSubresourceActionWithOptions(resource, name, subresource, object, metav1.CreateOptions{}) 176 } 177 178 func NewRootCreateSubresourceActionWithOptions(resource schema.GroupVersionResource, name, subresource string, object runtime.Object, opts metav1.CreateOptions) CreateActionImpl { 179 action := CreateActionImpl{} 180 action.Verb = "create" 181 action.Resource = resource 182 action.Subresource = subresource 183 action.Name = name 184 action.Object = object 185 action.CreateOptions = opts 186 187 return action 188 } 189 190 func NewCreateSubresourceAction(resource schema.GroupVersionResource, name, subresource, namespace string, object runtime.Object) CreateActionImpl { 191 return NewCreateSubresourceActionWithOptions(resource, name, subresource, namespace, object, metav1.CreateOptions{}) 192 } 193 194 func NewCreateSubresourceActionWithOptions(resource schema.GroupVersionResource, name, subresource, namespace string, object runtime.Object, opts metav1.CreateOptions) CreateActionImpl { 195 action := CreateActionImpl{} 196 action.Verb = "create" 197 action.Resource = resource 198 action.Namespace = namespace 199 action.Subresource = subresource 200 action.Name = name 201 action.Object = object 202 action.CreateOptions = opts 203 204 return action 205 } 206 207 func NewRootUpdateAction(resource schema.GroupVersionResource, object runtime.Object) UpdateActionImpl { 208 return NewRootUpdateActionWithOptions(resource, object, metav1.UpdateOptions{}) 209 } 210 211 func NewRootUpdateActionWithOptions(resource schema.GroupVersionResource, object runtime.Object, opts metav1.UpdateOptions) UpdateActionImpl { 212 action := UpdateActionImpl{} 213 action.Verb = "update" 214 action.Resource = resource 215 action.Object = object 216 action.UpdateOptions = opts 217 218 return action 219 } 220 221 func NewUpdateAction(resource schema.GroupVersionResource, namespace string, object runtime.Object) UpdateActionImpl { 222 return NewUpdateActionWithOptions(resource, namespace, object, metav1.UpdateOptions{}) 223 } 224 225 func NewUpdateActionWithOptions(resource schema.GroupVersionResource, namespace string, object runtime.Object, opts metav1.UpdateOptions) UpdateActionImpl { 226 action := UpdateActionImpl{} 227 action.Verb = "update" 228 action.Resource = resource 229 action.Namespace = namespace 230 action.Object = object 231 action.UpdateOptions = opts 232 233 return action 234 } 235 236 func NewRootPatchAction(resource schema.GroupVersionResource, name string, pt types.PatchType, patch []byte) PatchActionImpl { 237 return NewRootPatchActionWithOptions(resource, name, pt, patch, metav1.PatchOptions{}) 238 } 239 240 func NewRootPatchActionWithOptions(resource schema.GroupVersionResource, name string, pt types.PatchType, patch []byte, opts metav1.PatchOptions) PatchActionImpl { 241 action := PatchActionImpl{} 242 action.Verb = "patch" 243 action.Resource = resource 244 action.Name = name 245 action.PatchType = pt 246 action.Patch = patch 247 action.PatchOptions = opts 248 249 return action 250 } 251 252 func NewPatchAction(resource schema.GroupVersionResource, namespace string, name string, pt types.PatchType, patch []byte) PatchActionImpl { 253 return NewPatchActionWithOptions(resource, namespace, name, pt, patch, metav1.PatchOptions{}) 254 } 255 256 func NewPatchActionWithOptions(resource schema.GroupVersionResource, namespace string, name string, pt types.PatchType, patch []byte, opts metav1.PatchOptions) PatchActionImpl { 257 action := PatchActionImpl{} 258 action.Verb = "patch" 259 action.Resource = resource 260 action.Namespace = namespace 261 action.Name = name 262 action.PatchType = pt 263 action.Patch = patch 264 action.PatchOptions = opts 265 266 return action 267 } 268 269 func NewRootPatchSubresourceAction(resource schema.GroupVersionResource, name string, pt types.PatchType, patch []byte, subresources ...string) PatchActionImpl { 270 return NewRootPatchSubresourceActionWithOptions(resource, name, pt, patch, metav1.PatchOptions{}, subresources...) 271 } 272 273 func NewRootPatchSubresourceActionWithOptions(resource schema.GroupVersionResource, name string, pt types.PatchType, patch []byte, opts metav1.PatchOptions, subresources ...string) PatchActionImpl { 274 action := PatchActionImpl{} 275 action.Verb = "patch" 276 action.Resource = resource 277 action.Subresource = path.Join(subresources...) 278 action.Name = name 279 action.PatchType = pt 280 action.Patch = patch 281 action.PatchOptions = opts 282 283 return action 284 } 285 286 func NewPatchSubresourceAction(resource schema.GroupVersionResource, namespace, name string, pt types.PatchType, patch []byte, subresources ...string) PatchActionImpl { 287 return NewPatchSubresourceActionWithOptions(resource, namespace, name, pt, patch, metav1.PatchOptions{}, subresources...) 288 } 289 290 func NewPatchSubresourceActionWithOptions(resource schema.GroupVersionResource, namespace, name string, pt types.PatchType, patch []byte, opts metav1.PatchOptions, subresources ...string) PatchActionImpl { 291 action := PatchActionImpl{} 292 action.Verb = "patch" 293 action.Resource = resource 294 action.Subresource = path.Join(subresources...) 295 action.Namespace = namespace 296 action.Name = name 297 action.PatchType = pt 298 action.Patch = patch 299 action.PatchOptions = opts 300 301 return action 302 } 303 304 func NewRootUpdateSubresourceAction(resource schema.GroupVersionResource, subresource string, object runtime.Object) UpdateActionImpl { 305 return NewRootUpdateSubresourceActionWithOptions(resource, subresource, object, metav1.UpdateOptions{}) 306 } 307 308 func NewRootUpdateSubresourceActionWithOptions(resource schema.GroupVersionResource, subresource string, object runtime.Object, opts metav1.UpdateOptions) UpdateActionImpl { 309 action := UpdateActionImpl{} 310 action.Verb = "update" 311 action.Resource = resource 312 action.Subresource = subresource 313 action.Object = object 314 action.UpdateOptions = opts 315 316 return action 317 } 318 319 func NewUpdateSubresourceAction(resource schema.GroupVersionResource, subresource string, namespace string, object runtime.Object) UpdateActionImpl { 320 return NewUpdateSubresourceActionWithOptions(resource, subresource, namespace, object, metav1.UpdateOptions{}) 321 } 322 323 func NewUpdateSubresourceActionWithOptions(resource schema.GroupVersionResource, subresource string, namespace string, object runtime.Object, opts metav1.UpdateOptions) UpdateActionImpl { 324 action := UpdateActionImpl{} 325 action.Verb = "update" 326 action.Resource = resource 327 action.Subresource = subresource 328 action.Namespace = namespace 329 action.Object = object 330 action.UpdateOptions = opts 331 332 return action 333 } 334 335 func NewRootDeleteAction(resource schema.GroupVersionResource, name string) DeleteActionImpl { 336 return NewRootDeleteActionWithOptions(resource, name, metav1.DeleteOptions{}) 337 } 338 339 func NewRootDeleteActionWithOptions(resource schema.GroupVersionResource, name string, opts metav1.DeleteOptions) DeleteActionImpl { 340 action := DeleteActionImpl{} 341 action.Verb = "delete" 342 action.Resource = resource 343 action.Name = name 344 action.DeleteOptions = opts 345 346 return action 347 } 348 349 func NewRootDeleteSubresourceAction(resource schema.GroupVersionResource, subresource string, name string) DeleteActionImpl { 350 return NewRootDeleteSubresourceActionWithOptions(resource, subresource, name, metav1.DeleteOptions{}) 351 } 352 353 func NewRootDeleteSubresourceActionWithOptions(resource schema.GroupVersionResource, subresource string, name string, opts metav1.DeleteOptions) DeleteActionImpl { 354 action := DeleteActionImpl{} 355 action.Verb = "delete" 356 action.Resource = resource 357 action.Subresource = subresource 358 action.Name = name 359 action.DeleteOptions = opts 360 361 return action 362 } 363 364 func NewDeleteAction(resource schema.GroupVersionResource, namespace, name string) DeleteActionImpl { 365 return NewDeleteActionWithOptions(resource, namespace, name, metav1.DeleteOptions{}) 366 } 367 368 func NewDeleteActionWithOptions(resource schema.GroupVersionResource, namespace, name string, opts metav1.DeleteOptions) DeleteActionImpl { 369 action := DeleteActionImpl{} 370 action.Verb = "delete" 371 action.Resource = resource 372 action.Namespace = namespace 373 action.Name = name 374 action.DeleteOptions = opts 375 376 return action 377 } 378 379 func NewDeleteSubresourceAction(resource schema.GroupVersionResource, subresource, namespace, name string) DeleteActionImpl { 380 return NewDeleteSubresourceActionWithOptions(resource, subresource, namespace, name, metav1.DeleteOptions{}) 381 } 382 383 func NewDeleteSubresourceActionWithOptions(resource schema.GroupVersionResource, subresource, namespace, name string, opts metav1.DeleteOptions) DeleteActionImpl { 384 action := DeleteActionImpl{} 385 action.Verb = "delete" 386 action.Resource = resource 387 action.Subresource = subresource 388 action.Namespace = namespace 389 action.Name = name 390 action.DeleteOptions = opts 391 392 return action 393 } 394 395 func NewRootDeleteCollectionAction(resource schema.GroupVersionResource, opts interface{}) DeleteCollectionActionImpl { 396 listOpts, _ := opts.(metav1.ListOptions) 397 return NewRootDeleteCollectionActionWithOptions(resource, metav1.DeleteOptions{}, listOpts) 398 } 399 400 func NewRootDeleteCollectionActionWithOptions(resource schema.GroupVersionResource, deleteOpts metav1.DeleteOptions, listOpts metav1.ListOptions) DeleteCollectionActionImpl { 401 action := DeleteCollectionActionImpl{} 402 action.Verb = "delete-collection" 403 action.Resource = resource 404 action.DeleteOptions = deleteOpts 405 action.ListOptions = listOpts 406 407 labelSelector, fieldSelector, _ := ExtractFromListOptions(listOpts) 408 action.ListRestrictions = ListRestrictions{labelSelector, fieldSelector} 409 410 return action 411 } 412 413 func NewDeleteCollectionAction(resource schema.GroupVersionResource, namespace string, opts interface{}) DeleteCollectionActionImpl { 414 listOpts, _ := opts.(metav1.ListOptions) 415 return NewDeleteCollectionActionWithOptions(resource, namespace, metav1.DeleteOptions{}, listOpts) 416 } 417 418 func NewDeleteCollectionActionWithOptions(resource schema.GroupVersionResource, namespace string, deleteOpts metav1.DeleteOptions, listOpts metav1.ListOptions) DeleteCollectionActionImpl { 419 action := DeleteCollectionActionImpl{} 420 action.Verb = "delete-collection" 421 action.Resource = resource 422 action.Namespace = namespace 423 action.DeleteOptions = deleteOpts 424 action.ListOptions = listOpts 425 426 labelSelector, fieldSelector, _ := ExtractFromListOptions(listOpts) 427 action.ListRestrictions = ListRestrictions{labelSelector, fieldSelector} 428 429 return action 430 } 431 432 func NewRootWatchAction(resource schema.GroupVersionResource, opts interface{}) WatchActionImpl { 433 listOpts, _ := opts.(metav1.ListOptions) 434 return NewRootWatchActionWithOptions(resource, listOpts) 435 } 436 437 func NewRootWatchActionWithOptions(resource schema.GroupVersionResource, opts metav1.ListOptions) WatchActionImpl { 438 action := WatchActionImpl{} 439 action.Verb = "watch" 440 action.Resource = resource 441 action.ListOptions = opts 442 443 labelSelector, fieldSelector, resourceVersion := ExtractFromListOptions(opts) 444 action.WatchRestrictions = WatchRestrictions{labelSelector, fieldSelector, resourceVersion} 445 446 return action 447 } 448 449 func ExtractFromListOptions(opts interface{}) (labelSelector labels.Selector, fieldSelector fields.Selector, resourceVersion string) { 450 var err error 451 switch t := opts.(type) { 452 case metav1.ListOptions: 453 labelSelector, err = labels.Parse(t.LabelSelector) 454 if err != nil { 455 panic(fmt.Errorf("invalid selector %q: %v", t.LabelSelector, err)) 456 } 457 fieldSelector, err = fields.ParseSelector(t.FieldSelector) 458 if err != nil { 459 panic(fmt.Errorf("invalid selector %q: %v", t.FieldSelector, err)) 460 } 461 resourceVersion = t.ResourceVersion 462 default: 463 panic(fmt.Errorf("expect a ListOptions %T", opts)) 464 } 465 if labelSelector == nil { 466 labelSelector = labels.Everything() 467 } 468 if fieldSelector == nil { 469 fieldSelector = fields.Everything() 470 } 471 return labelSelector, fieldSelector, resourceVersion 472 } 473 474 func NewWatchAction(resource schema.GroupVersionResource, namespace string, opts interface{}) WatchActionImpl { 475 listOpts, _ := opts.(metav1.ListOptions) 476 return NewWatchActionWithOptions(resource, namespace, listOpts) 477 } 478 479 func NewWatchActionWithOptions(resource schema.GroupVersionResource, namespace string, opts metav1.ListOptions) WatchActionImpl { 480 action := WatchActionImpl{} 481 action.Verb = "watch" 482 action.Resource = resource 483 action.Namespace = namespace 484 action.ListOptions = opts 485 486 labelSelector, fieldSelector, resourceVersion := ExtractFromListOptions(opts) 487 action.WatchRestrictions = WatchRestrictions{labelSelector, fieldSelector, resourceVersion} 488 489 return action 490 } 491 492 func NewProxyGetAction(resource schema.GroupVersionResource, namespace, scheme, name, port, path string, params map[string]string) ProxyGetActionImpl { 493 action := ProxyGetActionImpl{} 494 action.Verb = "get" 495 action.Resource = resource 496 action.Namespace = namespace 497 action.Scheme = scheme 498 action.Name = name 499 action.Port = port 500 action.Path = path 501 action.Params = params 502 return action 503 } 504 505 type ListRestrictions struct { 506 Labels labels.Selector 507 Fields fields.Selector 508 } 509 type WatchRestrictions struct { 510 Labels labels.Selector 511 Fields fields.Selector 512 ResourceVersion string 513 } 514 515 type Action interface { 516 GetNamespace() string 517 GetVerb() string 518 GetResource() schema.GroupVersionResource 519 GetSubresource() string 520 Matches(verb, resource string) bool 521 522 // DeepCopy is used to copy an action to avoid any risk of accidental mutation. Most people never need to call this 523 // because the invocation logic deep copies before calls to storage and reactors. 524 DeepCopy() Action 525 } 526 527 type GenericAction interface { 528 Action 529 GetValue() interface{} 530 } 531 532 type GetAction interface { 533 Action 534 GetName() string 535 } 536 537 type ListAction interface { 538 Action 539 GetListRestrictions() ListRestrictions 540 } 541 542 type CreateAction interface { 543 Action 544 GetObject() runtime.Object 545 } 546 547 type UpdateAction interface { 548 Action 549 GetObject() runtime.Object 550 } 551 552 type DeleteAction interface { 553 Action 554 GetName() string 555 GetDeleteOptions() metav1.DeleteOptions 556 } 557 558 type DeleteCollectionAction interface { 559 Action 560 GetListRestrictions() ListRestrictions 561 } 562 563 type PatchAction interface { 564 Action 565 GetName() string 566 GetPatchType() types.PatchType 567 GetPatch() []byte 568 } 569 570 type WatchAction interface { 571 Action 572 GetWatchRestrictions() WatchRestrictions 573 } 574 575 type ProxyGetAction interface { 576 Action 577 GetScheme() string 578 GetName() string 579 GetPort() string 580 GetPath() string 581 GetParams() map[string]string 582 } 583 584 type ActionImpl struct { 585 Namespace string 586 Verb string 587 Resource schema.GroupVersionResource 588 Subresource string 589 } 590 591 func (a ActionImpl) GetNamespace() string { 592 return a.Namespace 593 } 594 func (a ActionImpl) GetVerb() string { 595 return a.Verb 596 } 597 func (a ActionImpl) GetResource() schema.GroupVersionResource { 598 return a.Resource 599 } 600 func (a ActionImpl) GetSubresource() string { 601 return a.Subresource 602 } 603 func (a ActionImpl) Matches(verb, resource string) bool { 604 // Stay backwards compatible. 605 if !strings.Contains(resource, "/") { 606 return strings.EqualFold(verb, a.Verb) && 607 strings.EqualFold(resource, a.Resource.Resource) 608 } 609 610 parts := strings.SplitN(resource, "/", 2) 611 topresource, subresource := parts[0], parts[1] 612 613 return strings.EqualFold(verb, a.Verb) && 614 strings.EqualFold(topresource, a.Resource.Resource) && 615 strings.EqualFold(subresource, a.Subresource) 616 } 617 func (a ActionImpl) DeepCopy() Action { 618 ret := a 619 return ret 620 } 621 622 type GenericActionImpl struct { 623 ActionImpl 624 Value interface{} 625 } 626 627 func (a GenericActionImpl) GetValue() interface{} { 628 return a.Value 629 } 630 631 func (a GenericActionImpl) DeepCopy() Action { 632 return GenericActionImpl{ 633 ActionImpl: a.ActionImpl.DeepCopy().(ActionImpl), 634 // TODO this is wrong, but no worse than before 635 Value: a.Value, 636 } 637 } 638 639 type GetActionImpl struct { 640 ActionImpl 641 Name string 642 GetOptions metav1.GetOptions 643 } 644 645 func (a GetActionImpl) GetName() string { 646 return a.Name 647 } 648 649 func (a GetActionImpl) GetGetOptions() metav1.GetOptions { 650 return a.GetOptions 651 } 652 653 func (a GetActionImpl) DeepCopy() Action { 654 return GetActionImpl{ 655 ActionImpl: a.ActionImpl.DeepCopy().(ActionImpl), 656 Name: a.Name, 657 GetOptions: *a.GetOptions.DeepCopy(), 658 } 659 } 660 661 type ListActionImpl struct { 662 ActionImpl 663 Kind schema.GroupVersionKind 664 Name string 665 ListRestrictions ListRestrictions 666 ListOptions metav1.ListOptions 667 } 668 669 func (a ListActionImpl) GetKind() schema.GroupVersionKind { 670 return a.Kind 671 } 672 673 func (a ListActionImpl) GetListRestrictions() ListRestrictions { 674 return a.ListRestrictions 675 } 676 677 func (a ListActionImpl) GetListOptions() metav1.ListOptions { 678 return a.ListOptions 679 } 680 681 func (a ListActionImpl) DeepCopy() Action { 682 return ListActionImpl{ 683 ActionImpl: a.ActionImpl.DeepCopy().(ActionImpl), 684 Kind: a.Kind, 685 Name: a.Name, 686 ListRestrictions: ListRestrictions{ 687 Labels: a.ListRestrictions.Labels.DeepCopySelector(), 688 Fields: a.ListRestrictions.Fields.DeepCopySelector(), 689 }, 690 ListOptions: *a.ListOptions.DeepCopy(), 691 } 692 } 693 694 type CreateActionImpl struct { 695 ActionImpl 696 Name string 697 Object runtime.Object 698 CreateOptions metav1.CreateOptions 699 } 700 701 func (a CreateActionImpl) GetObject() runtime.Object { 702 return a.Object 703 } 704 705 func (a CreateActionImpl) GetCreateOptions() metav1.CreateOptions { 706 return a.CreateOptions 707 } 708 709 func (a CreateActionImpl) DeepCopy() Action { 710 return CreateActionImpl{ 711 ActionImpl: a.ActionImpl.DeepCopy().(ActionImpl), 712 Name: a.Name, 713 Object: a.Object.DeepCopyObject(), 714 CreateOptions: *a.CreateOptions.DeepCopy(), 715 } 716 } 717 718 type UpdateActionImpl struct { 719 ActionImpl 720 Object runtime.Object 721 UpdateOptions metav1.UpdateOptions 722 } 723 724 func (a UpdateActionImpl) GetObject() runtime.Object { 725 return a.Object 726 } 727 728 func (a UpdateActionImpl) GetUpdateOptions() metav1.UpdateOptions { 729 return a.UpdateOptions 730 } 731 732 func (a UpdateActionImpl) DeepCopy() Action { 733 return UpdateActionImpl{ 734 ActionImpl: a.ActionImpl.DeepCopy().(ActionImpl), 735 Object: a.Object.DeepCopyObject(), 736 UpdateOptions: *a.UpdateOptions.DeepCopy(), 737 } 738 } 739 740 type PatchActionImpl struct { 741 ActionImpl 742 Name string 743 PatchType types.PatchType 744 Patch []byte 745 PatchOptions metav1.PatchOptions 746 } 747 748 func (a PatchActionImpl) GetName() string { 749 return a.Name 750 } 751 752 func (a PatchActionImpl) GetPatch() []byte { 753 return a.Patch 754 } 755 756 func (a PatchActionImpl) GetPatchType() types.PatchType { 757 return a.PatchType 758 } 759 760 func (a PatchActionImpl) GetPatchOptions() metav1.PatchOptions { 761 return a.PatchOptions 762 } 763 764 func (a PatchActionImpl) DeepCopy() Action { 765 patch := make([]byte, len(a.Patch)) 766 copy(patch, a.Patch) 767 return PatchActionImpl{ 768 ActionImpl: a.ActionImpl.DeepCopy().(ActionImpl), 769 Name: a.Name, 770 PatchType: a.PatchType, 771 Patch: patch, 772 PatchOptions: *a.PatchOptions.DeepCopy(), 773 } 774 } 775 776 type DeleteActionImpl struct { 777 ActionImpl 778 Name string 779 DeleteOptions metav1.DeleteOptions 780 } 781 782 func (a DeleteActionImpl) GetName() string { 783 return a.Name 784 } 785 786 func (a DeleteActionImpl) GetDeleteOptions() metav1.DeleteOptions { 787 return a.DeleteOptions 788 } 789 790 func (a DeleteActionImpl) DeepCopy() Action { 791 return DeleteActionImpl{ 792 ActionImpl: a.ActionImpl.DeepCopy().(ActionImpl), 793 Name: a.Name, 794 DeleteOptions: *a.DeleteOptions.DeepCopy(), 795 } 796 } 797 798 type DeleteCollectionActionImpl struct { 799 ActionImpl 800 ListRestrictions ListRestrictions 801 DeleteOptions metav1.DeleteOptions 802 ListOptions metav1.ListOptions 803 } 804 805 func (a DeleteCollectionActionImpl) GetListRestrictions() ListRestrictions { 806 return a.ListRestrictions 807 } 808 809 func (a DeleteCollectionActionImpl) GetDeleteOptions() metav1.DeleteOptions { 810 return a.DeleteOptions 811 } 812 813 func (a DeleteCollectionActionImpl) GetListOptions() metav1.ListOptions { 814 return a.ListOptions 815 } 816 817 func (a DeleteCollectionActionImpl) DeepCopy() Action { 818 return DeleteCollectionActionImpl{ 819 ActionImpl: a.ActionImpl.DeepCopy().(ActionImpl), 820 ListRestrictions: ListRestrictions{ 821 Labels: a.ListRestrictions.Labels.DeepCopySelector(), 822 Fields: a.ListRestrictions.Fields.DeepCopySelector(), 823 }, 824 DeleteOptions: *a.DeleteOptions.DeepCopy(), 825 ListOptions: *a.ListOptions.DeepCopy(), 826 } 827 } 828 829 type WatchActionImpl struct { 830 ActionImpl 831 WatchRestrictions WatchRestrictions 832 ListOptions metav1.ListOptions 833 } 834 835 func (a WatchActionImpl) GetWatchRestrictions() WatchRestrictions { 836 return a.WatchRestrictions 837 } 838 839 func (a WatchActionImpl) GetListOptions() metav1.ListOptions { 840 return a.ListOptions 841 } 842 843 func (a WatchActionImpl) DeepCopy() Action { 844 return WatchActionImpl{ 845 ActionImpl: a.ActionImpl.DeepCopy().(ActionImpl), 846 WatchRestrictions: WatchRestrictions{ 847 Labels: a.WatchRestrictions.Labels.DeepCopySelector(), 848 Fields: a.WatchRestrictions.Fields.DeepCopySelector(), 849 ResourceVersion: a.WatchRestrictions.ResourceVersion, 850 }, 851 ListOptions: *a.ListOptions.DeepCopy(), 852 } 853 } 854 855 type ProxyGetActionImpl struct { 856 ActionImpl 857 Scheme string 858 Name string 859 Port string 860 Path string 861 Params map[string]string 862 } 863 864 func (a ProxyGetActionImpl) GetScheme() string { 865 return a.Scheme 866 } 867 868 func (a ProxyGetActionImpl) GetName() string { 869 return a.Name 870 } 871 872 func (a ProxyGetActionImpl) GetPort() string { 873 return a.Port 874 } 875 876 func (a ProxyGetActionImpl) GetPath() string { 877 return a.Path 878 } 879 880 func (a ProxyGetActionImpl) GetParams() map[string]string { 881 return a.Params 882 } 883 884 func (a ProxyGetActionImpl) DeepCopy() Action { 885 params := map[string]string{} 886 for k, v := range a.Params { 887 params[k] = v 888 } 889 return ProxyGetActionImpl{ 890 ActionImpl: a.ActionImpl.DeepCopy().(ActionImpl), 891 Scheme: a.Scheme, 892 Name: a.Name, 893 Port: a.Port, 894 Path: a.Path, 895 Params: params, 896 } 897 }