api

package
v0.0.0-...-783bbf4 Latest Latest
Warning

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

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

Documentation

Overview

Package api provides a wrapper on top of the OpenShift API

Index

Constants

View Source
const (
	// ApplicationNameLabel is the name of the label used to store the application
	ApplicationNameLabel = "application"
)

Variables

Functions

func FilterByApplication

func FilterByApplication(objects interface{}, application string) ([]interface{}, error)

FilterByApplication returns all objects that belongs to the given application

func FilterByLabelValue

func FilterByLabelValue(objects interface{}, labelKey string, labelValue string) ([]interface{}, error)

FilterByLabelValue returns all objects that have the given key/value label

func FilterByNamespace

func FilterByNamespace(objects interface{}, namespace string) ([]interface{}, error)

FilterByNamespace returns all objects that belongs to the given namespace (project)

Types

type Application

type Application string

Application is a concept used here to group multiple objects together It is different from the project, because the same project can be used for multiple applications Or some projects can have resources (like BuildConfigs and ImageStreams) but no applications. Objects are linked to an application by a label.

func (*Application) Name

func (app *Application) Name() string

Name returns the name of the application (just to be consistent with others objects that have a "Name" attribute)

type Applications

type Applications []Application

Applications is just a slice of Application used for sorting applications

func (Applications) Len

func (apps Applications) Len() int

func (Applications) Less

func (apps Applications) Less(i, j int) bool

func (Applications) Swap

func (apps Applications) Swap(i, j int)

type ClientWrapper

type ClientWrapper struct {
	// contains filtered or unexported fields
}

ClientWrapper wraps an OpenShift client and supports caching

func NewClientWrapper

func NewClientWrapper(withCache bool) *ClientWrapper

NewClientWrapper build a new ClientWrapper instance with or without caching

func (*ClientWrapper) AsyncListResources

func (cw *ClientWrapper) AsyncListResources(resourceType ResourceType, namespaces ...string) <-chan *DataWrapper

AsyncListResources retrieves the list of resources for the given resource type. You can restrict the resources to one or more namespaces (by default, it will use all available namespaces). It works asynchronously, and returns a channel immediately. When the result will be available, it will be send to the channel, which will then be closed. The result is a DataWrapper instance, that contains the data or an error.

func (*ClientWrapper) GetAvailableNamespaces

func (cw *ClientWrapper) GetAvailableNamespaces() ([]string, error)

GetAvailableNamespaces retrieves all available namespaces.

func (*ClientWrapper) ListResources

func (cw *ClientWrapper) ListResources(resourceType ResourceType, namespaces ...string) ([]interface{}, []error)

ListResources retrieves the list of resources for the given resource type. You can restrict the resources to one or more namespaces (by default, it will use all available namespaces). It returns the resources as a slice of interface{}, or the errors.

func (*ClientWrapper) LoadData

func (cw *ClientWrapper) LoadData(resourceTypes ...ResourceType) (*Data, error)

LoadData build a Data instance, populated with data for the given resource types. You can use ResourceTypeAll to get data for all resources types. If caching is enabled, it will use the cache if there are fresh data in it.

type Data

type Data struct {
	Applications           []Application
	Projects               []projectapi.Project
	Routes                 []routeapi.Route
	Services               []kapi.Service
	Pods                   []kapi.Pod
	Containers             []kapi.Container
	ImageStreams           []imageapi.ImageStream
	BuildConfigs           []buildapi.BuildConfig
	Builds                 []buildapi.Build
	DeploymentConfigs      []deployapi.DeploymentConfig
	ReplicationControllers []kapi.ReplicationController
	Events                 []kapi.Event
}

Data contains all available data retrieved from the API

func (*Data) ExtractApplicationsFromDeploymentConfigs

func (d *Data) ExtractApplicationsFromDeploymentConfigs()

ExtractApplicationsFromDeploymentConfigs extracts all applications from the deploymentConfigs stored in this Data instance, and stores them in this Data instance. The applications are in facts labels values for the label key "application" We inspect the DC to retrieve the different labels values, because it is the object type that all applications are likely to have.

func (*Data) ExtractContainersFromPods

func (d *Data) ExtractContainersFromPods() error

ExtractContainersFromPods extracts all containers from the pods stored in this Data instance, and stores them in this Data instance.

func (*Data) Merge

func (d *Data) Merge(others ...*Data)

Merge merges the given Data instances in this instance

func (*Data) RemoveBuilderAndDeployerPods

func (d *Data) RemoveBuilderAndDeployerPods() (builderPods []kapi.Pod, deployerPods []kapi.Pod)

RemoveBuilderAndDeployerPods removes the builders and deployers pods from the pods stored in this Data instance. It returns the builders and deployers pods that have been removed.

func (*Data) Set

func (d *Data) Set(resourceType ResourceType, resources []interface{}) error

Set adds resources to this Data instance

func (*Data) SetBuildConfigs

func (d *Data) SetBuildConfigs(buildConfigs []interface{}) error

func (*Data) SetBuilds

func (d *Data) SetBuilds(builds []interface{}) error

func (*Data) SetContainers

func (d *Data) SetContainers(containers []interface{}) error

func (*Data) SetDeploymentConfigs

func (d *Data) SetDeploymentConfigs(deploymentConfigs []interface{}) error

func (*Data) SetEvents

func (d *Data) SetEvents(events []interface{}) error

func (*Data) SetImageStreams

func (d *Data) SetImageStreams(imageStreams []interface{}) error

func (*Data) SetPods

func (d *Data) SetPods(pods []interface{}) error

func (*Data) SetProjects

func (d *Data) SetProjects(projects []interface{}) error

func (*Data) SetReplicationControllers

func (d *Data) SetReplicationControllers(replicationControllers []interface{}) error

func (*Data) SetRoutes

func (d *Data) SetRoutes(routes []interface{}) error

func (*Data) SetServices

func (d *Data) SetServices(services []interface{}) error

type DataWrapper

type DataWrapper struct {
	*Data
	Errors []error
}

DataWrapper wraps a Data instance and a slice or errors that may have happened while loading the data

type ResourceType

type ResourceType string

ResourceType describes the possible types of resources.

const (
	// ResourceTypeApplication represents an application, which is just a label on objects
	ResourceTypeApplication           ResourceType = "application"
	ResourceTypeProject               ResourceType = "project"
	ResourceTypeRoute                 ResourceType = "route"
	ResourceTypeService               ResourceType = "service"
	ResourceTypePod                   ResourceType = "pod"
	ResourceTypeContainer             ResourceType = "container"
	ResourceTypeImageStream           ResourceType = "imagestream"
	ResourceTypeBuildConfig           ResourceType = "buildconfig"
	ResourceTypeBuild                 ResourceType = "build"
	ResourceTypeDeploymentConfig      ResourceType = "deploymentconfig"
	ResourceTypeReplicationController ResourceType = "replicationcontroller"
	ResourceTypeEvent                 ResourceType = "event"
)

Jump to

Keyboard shortcuts

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