auth

package
Version: v0.0.0-...-1eb392f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2015 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package auth defines a file format for holding authentication information needed by clients of Kubernetes. Typically, a Kubernetes cluster will put auth info for the admin in a known location when it is created, and will (soon) put it in a known location within a Container's file tree for Containers that need access to the Kubernetes API.

Having a defined format allows:

- clients to be implmented in multiple languages
- applications which link clients to be portable across
  clusters with different authentication styles (e.g.
  some may use SSL Client certs, others may not, etc)
- when the format changes, applications only
  need to update this code.

The file format is json, marshalled from a struct authcfg.Info.

Clinet libraries in other languages should use the same format.

It is not intended to store general preferences, such as default namespace, output options, etc. CLIs (such as kubectl) and UIs should develop their own format and may wish to inline the authcfg.Info type.

The authcfg.Info is just a file format. It is distinct from client.Config which holds options for creating a client.Client. Helper functions are provided in this package to fill in a client.Client from an authcfg.Info.

Example:

import (
    "pkg/client"
    "pkg/client/auth"
)

info, err := auth.LoadFromFile(filename)
if err != nil {
  // handle error
}
clientConfig = client.Config{}
clientConfig.Host = "example.com:4901"
clientConfig = info.MergeWithConfig()
client := client.New(clientConfig)
client.Pods(ns).List()

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Info

type Info struct {
	User        string
	Password    string
	CAFile      string
	CertFile    string
	KeyFile     string
	BearerToken string
	Insecure    *bool
}

Info holds Kubernetes API authorization config. It is intended to be read/written from a file as a JSON object.

func LoadFromFile

func LoadFromFile(path string) (*Info, error)

LoadFromFile parses an Info object from a file path. If the file does not exist, then os.IsNotExist(err) == true

func (Info) Complete

func (info Info) Complete() bool

func (Info) MergeWithConfig

func (info Info) MergeWithConfig(c client.Config) (client.Config, error)

MergeWithConfig returns a copy of a client.Config with values from the Info. The fields of client.Config with a corresponding field in the Info are set with the value from the Info.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL