Documentation ¶
Overview ¶
Package api provides a wrapper on top of the OpenShift API
Index ¶
- Constants
- Variables
- func FilterByApplication(objects interface{}, application string) ([]interface{}, error)
- func FilterByLabelValue(objects interface{}, labelKey string, labelValue string) ([]interface{}, error)
- func FilterByNamespace(objects interface{}, namespace string) ([]interface{}, error)
- type Application
- type Applications
- type ClientWrapper
- func (cw *ClientWrapper) AsyncListResources(resourceType ResourceType, namespaces ...string) <-chan *DataWrapper
- func (cw *ClientWrapper) GetAvailableNamespaces() ([]string, error)
- func (cw *ClientWrapper) ListResources(resourceType ResourceType, namespaces ...string) ([]interface{}, []error)
- func (cw *ClientWrapper) LoadData(resourceTypes ...ResourceType) (*Data, error)
- type Data
- func (d *Data) ExtractApplicationsFromDeploymentConfigs()
- func (d *Data) ExtractContainersFromPods() error
- func (d *Data) Merge(others ...*Data)
- func (d *Data) RemoveBuilderAndDeployerPods() (builderPods []kapi.Pod, deployerPods []kapi.Pod)
- func (d *Data) Set(resourceType ResourceType, resources []interface{}) error
- func (d *Data) SetBuildConfigs(buildConfigs []interface{}) error
- func (d *Data) SetBuilds(builds []interface{}) error
- func (d *Data) SetContainers(containers []interface{}) error
- func (d *Data) SetDeploymentConfigs(deploymentConfigs []interface{}) error
- func (d *Data) SetEvents(events []interface{}) error
- func (d *Data) SetImageStreams(imageStreams []interface{}) error
- func (d *Data) SetPods(pods []interface{}) error
- func (d *Data) SetProjects(projects []interface{}) error
- func (d *Data) SetReplicationControllers(replicationControllers []interface{}) error
- func (d *Data) SetRoutes(routes []interface{}) error
- func (d *Data) SetServices(services []interface{}) error
- type DataWrapper
- type ResourceType
Constants ¶
const (
// ApplicationNameLabel is the name of the label used to store the application
ApplicationNameLabel = "application"
)
Variables ¶
var ( ResourceTypeAll []ResourceType = []ResourceType{ ResourceTypeApplication, ResourceTypeProject, ResourceTypeRoute, ResourceTypeService, ResourceTypePod, ResourceTypeContainer, ResourceTypeImageStream, ResourceTypeBuildConfig, ResourceTypeBuild, ResourceTypeDeploymentConfig, ResourceTypeReplicationController, ResourceTypeEvent, } )
Functions ¶
func FilterByApplication ¶
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 ¶
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 ¶
ExtractContainersFromPods extracts all containers from the pods stored in this Data instance, and stores them in this Data instance.
func (*Data) RemoveBuilderAndDeployerPods ¶
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 (*Data) SetContainers ¶
func (*Data) SetDeploymentConfigs ¶
func (*Data) SetImageStreams ¶
func (*Data) SetProjects ¶
func (*Data) SetReplicationControllers ¶
func (*Data) SetServices ¶
type DataWrapper ¶
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" )