...

Source file src/k8s.io/kubectl/pkg/polymorphichelpers/interface.go

Documentation: k8s.io/kubectl/pkg/polymorphichelpers

     1  /*
     2  Copyright 2018 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 polymorphichelpers
    18  
    19  import (
    20  	"time"
    21  
    22  	"k8s.io/api/core/v1"
    23  	"k8s.io/apimachinery/pkg/api/meta"
    24  	"k8s.io/apimachinery/pkg/runtime"
    25  	"k8s.io/apimachinery/pkg/runtime/schema"
    26  	"k8s.io/cli-runtime/pkg/genericclioptions"
    27  	"k8s.io/client-go/rest"
    28  )
    29  
    30  // LogsForObjectFunc is a function type that can tell you how to get logs for a runtime.object
    31  type LogsForObjectFunc func(restClientGetter genericclioptions.RESTClientGetter, object, options runtime.Object, timeout time.Duration, allContainers bool) (map[v1.ObjectReference]rest.ResponseWrapper, error)
    32  
    33  // LogsForObjectFn gives a way to easily override the function for unit testing if needed.
    34  var LogsForObjectFn LogsForObjectFunc = logsForObject
    35  
    36  // AttachablePodForObjectFunc is a function type that can tell you how to get the pod for which to attach a given object
    37  type AttachablePodForObjectFunc func(restClientGetter genericclioptions.RESTClientGetter, object runtime.Object, timeout time.Duration) (*v1.Pod, error)
    38  
    39  // AttachablePodForObjectFn gives a way to easily override the function for unit testing if needed.
    40  var AttachablePodForObjectFn AttachablePodForObjectFunc = attachablePodForObject
    41  
    42  // HistoryViewerFunc is a function type that can tell you how to view change history
    43  type HistoryViewerFunc func(restClientGetter genericclioptions.RESTClientGetter, mapping *meta.RESTMapping) (HistoryViewer, error)
    44  
    45  // HistoryViewerFn gives a way to easily override the function for unit testing if needed
    46  var HistoryViewerFn HistoryViewerFunc = historyViewer
    47  
    48  // StatusViewerFunc is a function type that can tell you how to print rollout status
    49  type StatusViewerFunc func(mapping *meta.RESTMapping) (StatusViewer, error)
    50  
    51  // StatusViewerFn gives a way to easily override the function for unit testing if needed
    52  var StatusViewerFn StatusViewerFunc = statusViewer
    53  
    54  // UpdatePodSpecForObjectFunc will call the provided function on the pod spec this object supports,
    55  // return false if no pod spec is supported, or return an error.
    56  type UpdatePodSpecForObjectFunc func(obj runtime.Object, fn func(*v1.PodSpec) error) (bool, error)
    57  
    58  // UpdatePodSpecForObjectFn gives a way to easily override the function for unit testing if needed
    59  var UpdatePodSpecForObjectFn UpdatePodSpecForObjectFunc = updatePodSpecForObject
    60  
    61  // MapBasedSelectorForObjectFunc will call the provided function on mapping the baesd selector for object,
    62  // return "" if object is not supported, or return an error.
    63  type MapBasedSelectorForObjectFunc func(object runtime.Object) (string, error)
    64  
    65  // MapBasedSelectorForObjectFn gives a way to easily override the function for unit testing if needed
    66  var MapBasedSelectorForObjectFn MapBasedSelectorForObjectFunc = mapBasedSelectorForObject
    67  
    68  // ProtocolsForObjectFunc will call the provided function on the protocols for the object,
    69  // return nil-map if no protocols for the object, or return an error.
    70  // Deprecated: use PortsProtocolsForObjectFunc instead.
    71  // When the same port has different protocols, data will be lost
    72  type ProtocolsForObjectFunc func(object runtime.Object) (map[string]string, error)
    73  
    74  // ProtocolsForObjectFn gives a way to easily override the function for unit testing if needed
    75  // Deprecated: use MultiProtocolsForObjectFn instead.
    76  var ProtocolsForObjectFn ProtocolsForObjectFunc = protocolsForObject
    77  
    78  // MultiProtocolsWithForObjectFunc will call the provided function on the protocols for the object,
    79  // return nil-map if no protocols for the object, or return an error.
    80  type MultiProtocolsWithForObjectFunc func(object runtime.Object) (map[string][]string, error)
    81  
    82  // MultiProtocolsForObjectFn gives a way to easily override the function for unit testing if needed
    83  var MultiProtocolsForObjectFn MultiProtocolsWithForObjectFunc = multiProtocolsForObject
    84  
    85  // PortsForObjectFunc returns the ports associated with the provided object
    86  type PortsForObjectFunc func(object runtime.Object) ([]string, error)
    87  
    88  // PortsForObjectFn gives a way to easily override the function for unit testing if needed
    89  var PortsForObjectFn PortsForObjectFunc = portsForObject
    90  
    91  // CanBeExposedFunc is a function type that can tell you whether a given GroupKind is capable of being exposed
    92  type CanBeExposedFunc func(kind schema.GroupKind) error
    93  
    94  // CanBeExposedFn gives a way to easily override the function for unit testing if needed
    95  var CanBeExposedFn CanBeExposedFunc = canBeExposed
    96  
    97  // ObjectPauserFunc is a function type that marks the object in a given info as paused.
    98  type ObjectPauserFunc func(runtime.Object) ([]byte, error)
    99  
   100  // ObjectPauserFn gives a way to easily override the function for unit testing if needed.
   101  // Returns the patched object in bytes and any error that occurred during the encoding or
   102  // in case the object is already paused.
   103  var ObjectPauserFn ObjectPauserFunc = defaultObjectPauser
   104  
   105  // ObjectResumerFunc is a function type that marks the object in a given info as resumed.
   106  type ObjectResumerFunc func(runtime.Object) ([]byte, error)
   107  
   108  // ObjectResumerFn gives a way to easily override the function for unit testing if needed.
   109  // Returns the patched object in bytes and any error that occurred during the encoding or
   110  // in case the object is already resumed.
   111  var ObjectResumerFn ObjectResumerFunc = defaultObjectResumer
   112  
   113  // RollbackerFunc gives a way to change the rollback version of the specified RESTMapping type
   114  type RollbackerFunc func(restClientGetter genericclioptions.RESTClientGetter, mapping *meta.RESTMapping) (Rollbacker, error)
   115  
   116  // RollbackerFn gives a way to easily override the function for unit testing if needed
   117  var RollbackerFn RollbackerFunc = rollbacker
   118  
   119  // ObjectRestarterFunc is a function type that updates an annotation in a deployment to restart it..
   120  type ObjectRestarterFunc func(runtime.Object) ([]byte, error)
   121  
   122  // ObjectRestarterFn gives a way to easily override the function for unit testing if needed.
   123  // Returns the patched object in bytes and any error that occurred during the encoding.
   124  var ObjectRestarterFn ObjectRestarterFunc = defaultObjectRestarter
   125  

View as plain text