kubernetes: github.com/erimatnor/kubernetes/pkg/kubectl/cmd/util Index | Files

package util

import "github.com/erimatnor/kubernetes/pkg/kubectl/cmd/util"

Index

Package Files

clientcache.go factory.go helpers.go printing.go

Constants

const (
    FlagMatchBinaryVersion = "match-server-version"
)

func AddPrinterFlags Uses

func AddPrinterFlags(cmd *cobra.Command)

func CheckErr Uses

func CheckErr(err error)

func DefaultClientConfig Uses

func DefaultClientConfig(flags *pflag.FlagSet) clientcmd.ClientConfig

DefaultClientConfig creates a clientcmd.ClientConfig with the following hierarchy:

  1.  Use the kubeconfig builder.  The number of merges and overrides here gets a little crazy.  Stay with me.
      1.  Merge together the kubeconfig itself.  This is done with the following hierarchy rules:
          1.  CommandLineLocation - this parsed from the command line, so it must be late bound.  If you specify this,
              then no other kubeconfig files are merged.  This file must exist.
          2.  If $KUBECONFIG is set, then it is treated as a list of files that should be merged.
			 3.  HomeDirectoryLocation
          Empty filenames are ignored.  Files with non-deserializable content produced errors.
          The first file to set a particular value or map key wins and the value or map key is never changed.
          This means that the first file to set CurrentContext will have its context preserved.  It also means
          that if two files specify a "red-user", only values from the first file's red-user are used.  Even
          non-conflicting entries from the second file's "red-user" are discarded.
      2.  Determine the context to use based on the first hit in this chain
          1.  command line argument - again, parsed from the command line, so it must be late bound
          2.  CurrentContext from the merged kubeconfig file
          3.  Empty is allowed at this stage
      3.  Determine the cluster info and auth info to use.  At this point, we may or may not have a context.  They
          are built based on the first hit in this chain.  (run it twice, once for auth, once for cluster)
          1.  command line argument
          2.  If context is present, then use the context value
          3.  Empty is allowed
      4.  Determine the actual cluster info to use.  At this point, we may or may not have a cluster info.  Build
          each piece of the cluster info based on the chain:
          1.  command line argument
          2.  If cluster info is present and a value for the attribute is present, use it.
          3.  If you don't have a server location, bail.
      5.  Auth info is build using the same rules as cluster info, EXCEPT that you can only have one authentication
          technique per auth info.  The following conditions result in an error:
          1.  If there are two conflicting techniques specified from the command line, fail.
          2.  If the command line does not specify one, and the auth info has conflicting techniques, fail.
          3.  If the command line specifies one and the auth info specifies another, honor the command line technique.
  2.  Use default values and potentially prompt for auth information

func GetFlagBool Uses

func GetFlagBool(cmd *cobra.Command, flag string) bool

func GetFlagDuration Uses

func GetFlagDuration(cmd *cobra.Command, flag string) time.Duration

func GetFlagInt Uses

func GetFlagInt(cmd *cobra.Command, flag string) int

Assumes the flag has a default value.

func GetFlagString Uses

func GetFlagString(cmd *cobra.Command, flag string) string

func Merge Uses

func Merge(dst runtime.Object, fragment, kind string) (runtime.Object, error)

func MultilineError Uses

func MultilineError(prefix string, err error) string

func OutputVersion Uses

func OutputVersion(cmd *cobra.Command, defaultVersion string) string

OutputVersion returns the preferred output version for generic content (JSON, YAML, or templates)

func PrinterForCommand Uses

func PrinterForCommand(cmd *cobra.Command) (kubectl.ResourcePrinter, bool, error)

PrinterForCommand returns the default printer for this command. Requires that printer flags have been added to cmd (see AddPrinterFlags).

func ReadConfigData Uses

func ReadConfigData(location string) ([]byte, error)

ReadConfigData reads the bytes from the specified filesytem or network location or from stdin if location == "-". TODO: replace with resource.Builder

func ReadConfigDataFromLocation Uses

func ReadConfigDataFromLocation(location string) ([]byte, error)

TODO: replace with resource.Builder

func ReadConfigDataFromReader Uses

func ReadConfigDataFromReader(reader io.Reader, source string) ([]byte, error)

func UsageError Uses

func UsageError(cmd *cobra.Command, format string, args ...interface{}) error

type Factory Uses

type Factory struct {

    // Returns interfaces for dealing with arbitrary runtime.Objects.
    Object func() (meta.RESTMapper, runtime.ObjectTyper)
    // Returns a client for accessing Kubernetes resources or an error.
    Client func() (*client.Client, error)
    // Returns a client.Config for accessing the Kubernetes server.
    ClientConfig func() (*client.Config, error)
    // Returns a RESTClient for working with the specified RESTMapping or an error. This is intended
    // for working with arbitrary resources and is not guaranteed to point to a Kubernetes APIServer.
    RESTClient func(mapping *meta.RESTMapping) (resource.RESTClient, error)
    // Returns a Describer for displaying the specified RESTMapping type or an error.
    Describer func(mapping *meta.RESTMapping) (kubectl.Describer, error)
    // Returns a Printer for formatting objects of the given type or an error.
    Printer func(mapping *meta.RESTMapping, noHeaders bool) (kubectl.ResourcePrinter, error)
    // Returns a Resizer for changing the size of the specified RESTMapping type or an error
    Resizer func(mapping *meta.RESTMapping) (kubectl.Resizer, error)
    // Returns a Reaper for gracefully shutting down resources.
    Reaper func(mapping *meta.RESTMapping) (kubectl.Reaper, error)
    // PodSelectorForResource returns the pod selector associated with the provided resource name
    // or an error.
    PodSelectorForResource func(mapping *meta.RESTMapping, namespace, name string) (string, error)
    // PortForResource returns the ports associated with the provided resource name or an error
    PortsForResource func(mapping *meta.RESTMapping, namespace, name string) ([]string, error)
    // Returns a schema that can validate objects stored on disk.
    Validator func() (validation.Schema, error)
    // Returns the default namespace to use in cases where no other namespace is specified
    DefaultNamespace func() (string, error)
    // Returns the generator for the provided generator name
    Generator func(name string) (kubectl.Generator, bool)
    // contains filtered or unexported fields
}

Factory provides abstractions that allow the Kubectl command to be extended across multiple types of resources and different API sets. TODO: make the functions interfaces TODO: pass the various interfaces on the factory directly into the command constructors (so the commands are decoupled from the factory).

func NewFactory Uses

func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory

NewFactory creates a factory with the default Kubernetes resources defined if optionalClientConfig is nil, then flags will be bound to a new clientcmd.ClientConfig. if optionalClientConfig is not nil, then this factory will make use of it.

func (*Factory) BindFlags Uses

func (f *Factory) BindFlags(flags *pflag.FlagSet)

BindFlags adds any flags that are common to all kubectl sub commands.

func (*Factory) ClientMapperForCommand Uses

func (f *Factory) ClientMapperForCommand() resource.ClientMapper

ClientMapperForCommand returns a ClientMapper for the factory.

func (*Factory) PrintObject Uses

func (f *Factory) PrintObject(cmd *cobra.Command, obj runtime.Object, out io.Writer) error

PrintObject prints an api object given command line flags to modify the output format

func (*Factory) PrinterForMapping Uses

func (f *Factory) PrinterForMapping(cmd *cobra.Command, mapping *meta.RESTMapping) (kubectl.ResourcePrinter, error)

PrinterForMapping returns a printer suitable for displaying the provided resource type. Requires that printer flags have been added to cmd (see AddPrinterFlags).

Package util imports 28 packages (graph). Updated 2017-05-11. Refresh now. Tools for package owners.