config

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2015 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddConfigLabels

func AddConfigLabels(c *api.Config, labels labels.Set) errs.ValidationErrorList

AddConfigLabels adds new label(s) to all resources defined in the given Config.

func AddObjectLabels added in v0.2.1

func AddObjectLabels(obj runtime.Object, labels labels.Set) error

AddObjectLabels adds new label(s) to a single runtime.Object

func DecodeDataToObject added in v0.2.1

func DecodeDataToObject(data []byte) (obj runtime.Object, mapping *meta.RESTMapping, err error)

DecodeDataToObject decodes the JSON/YAML content into the runtime Object using the RESTMapper interface. The RESTMapper mappings are returned for the future encoding.

Types

type ApplyResult

type ApplyResult struct {
	Errors  errs.ValidationErrorList
	Message string
}

ApplyResult holds the response from the REST server and potential errors

func Apply

func Apply(namespace string, data []byte, clientFunc func(*kmeta.RESTMapping) (*resource.Helper, error)) ([]ApplyResult, error)

Apply creates and manages resources defined in the Config. The create process won't stop on error, but it will finish the job and then return error and for each item in the config an error and status message string.

Example
kubeClient, _ := kclient.New(&kclient.Config{Host: "127.0.0.1"})
testClientMappings := clientapi.ClientMappings{
	"pods":     {"Pod", kubeClient.RESTClient, klatest.Codec},
	"services": {"Service", kubeClient.RESTClient, klatest.Codec},
}
clientFunc := func(m *kmeta.RESTMapping) (*resource.Helper, error) {
	mapping, ok := testClientMappings[m.Resource]
	if !ok {
		return nil, fmt.Errorf("Unable to provide REST client for %v", m.Resource)
	}
	return resource.NewHelper(mapping.Client, m), nil
}
data, _ := ioutil.ReadFile("../../examples/sample-app/docker-registry-config.json")
Apply(kapi.NamespaceDefault, data, clientFunc)
Output:

Directories

Path Synopsis
api
Package api defines and registers types for Config objects.
Package api defines and registers types for Config objects.

Jump to

Keyboard shortcuts

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