• Kubernetes Submit Queue's avatar
    Merge pull request #54024 from pwittrock/resource-validation-deps · 9403fcc9
    Kubernetes Submit Queue authored
    Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.
    
    kubectl resource builder to use versioned list
    
    Switch to using a versioned listed when return an object from the resource builder.
    
    This is necessary to allow cli's built outside the kubernetes/kubernetes repo to vendor the resource builder logic without vendoring all of Kubernetes.
    
    The following commands call the modified function.  (identified by changing the function name and recompiling)
    
    - [x] `attach`
      - pkg/kubectl/cmd/attach.go:155: builder.Do().Object
      - passes to `AttachablePodForObject` which does not support Lists of any kind
    - [x] `get`
      - pkg/kubectl/cmd/get.go:251: r.Object
      - [x] check if isList with `IsListType` -> `GetItemsPtr` -> check for presence of `Items` field
      - [x] pass to `ResourceVersion` -> `CommonAccessor` -> checks for `metav1.ListInterface` (which this PR introduces a compile time check to ensure v1.List implements this)
      - [x] pass to `ExtractList` -> checks if items implement `runtime.RawExtension`
    - [x] `rolling_update`
      - pkg/kubectl/cmd/rollingupdate.go:207: request.Object
      - only accepts lists of length 1.  updated in PR to support both api.List and v1.List
    - [x] `rollout_status`
      - pkg/kubectl/cmd/rollout/rollout_status.go:107: r.Object
      - passes to `ResourceVersion` -> `CommonAccessor` -> checks for `metav1.ListInterface`
    
    ```release-note
    NONE
    ```
    
    Closes kubernetes/kubectl#81
    9403fcc9
rollingupdate.go 14.7 KB