本文整理汇总了Golang中github.com/openshift/origin/pkg/client.Interface类的典型用法代码示例。如果您正苦于以下问题:Golang Interface类的具体用法?Golang Interface怎么用?Golang Interface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Interface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: SetOpenShiftClient
// SetOpenShiftClient sets the passed OpenShift client in the application configuration
func (c *AppConfig) SetOpenShiftClient(osclient client.Interface, originNamespace string) {
c.osclient = osclient
c.originNamespace = originNamespace
namespaces := []string{originNamespace}
if openshiftNamespace := "openshift"; originNamespace != openshiftNamespace {
namespaces = append(namespaces, openshiftNamespace)
}
c.imageStreamSearcher = app.ImageStreamSearcher{
Client: osclient,
ImageStreamImages: osclient,
Namespaces: namespaces,
StopOnMatch: !c.AsSearch,
}
c.imageStreamByAnnotationSearcher = app.NewImageStreamByAnnotationSearcher(osclient, osclient, namespaces)
c.templateSearcher = app.TemplateSearcher{
Client: osclient,
TemplateConfigsNamespacer: osclient,
Namespaces: namespaces,
}
c.templateFileSearcher = &app.TemplateFileSearcher{
Typer: c.typer,
Mapper: c.mapper,
ClientMapper: c.clientMapper,
Namespace: originNamespace,
}
c.dockerSearcher = app.ImageImportSearcher{
Client: osclient.ImageStreams(originNamespace),
AllowInsecure: c.InsecureRegistry,
Fallback: c.dockerImageSearcher(),
}
}
示例2: SetOpenShiftClient
// SetOpenShiftClient sets the passed OpenShift client in the application configuration
func (c *AppConfig) SetOpenShiftClient(osclient client.Interface, OriginNamespace string) {
c.OSClient = osclient
c.OriginNamespace = OriginNamespace
namespaces := []string{OriginNamespace}
if openshiftNamespace := "openshift"; OriginNamespace != openshiftNamespace {
namespaces = append(namespaces, openshiftNamespace)
}
c.ImageStreamSearcher = app.ImageStreamSearcher{
Client: osclient,
ImageStreamImages: osclient,
Namespaces: namespaces,
}
c.ImageStreamByAnnotationSearcher = app.NewImageStreamByAnnotationSearcher(osclient, osclient, namespaces)
c.TemplateSearcher = app.TemplateSearcher{
Client: osclient,
TemplateConfigsNamespacer: osclient,
Namespaces: namespaces,
}
c.TemplateFileSearcher = &app.TemplateFileSearcher{
Typer: c.Typer,
Mapper: c.Mapper,
ClientMapper: c.ClientMapper,
Namespace: OriginNamespace,
}
c.DockerSearcher = app.ImageImportSearcher{
Client: osclient.ImageStreams(OriginNamespace),
AllowInsecure: c.InsecureRegistry,
Fallback: c.DockerImageSearcher(),
}
}
示例3: servicebroker_load
func servicebroker_load(c osclient.Interface, name string) (*ServiceBroker, error) {
servicebroker := &ServiceBroker{}
if sb, err := c.ServiceBrokers().Get(name); err != nil {
return nil, err
} else {
servicebroker.Url = sb.Spec.Url
servicebroker.UserName = sb.Spec.UserName
servicebroker.Password = sb.Spec.Password
return servicebroker, nil
}
}
示例4: deleteBuildConfigs
func deleteBuildConfigs(client osclient.Interface, ns string) error {
items, err := client.BuildConfigs(ns).List(labels.Everything(), fields.Everything())
if err != nil {
return err
}
for i := range items.Items {
err := client.BuildConfigs(ns).Delete(items.Items[i].Name)
if err != nil && !errors.IsNotFound(err) {
return err
}
}
return nil
}
示例5: deleteTemplates
func deleteTemplates(client osclient.Interface, ns string) error {
items, err := client.Templates(ns).List(kapi.ListOptions{})
if err != nil {
return err
}
for i := range items.Items {
err := client.Templates(ns).Delete(items.Items[i].Name)
if err != nil && !errors.IsNotFound(err) {
return err
}
}
return nil
}
示例6: newHelper
// newHelper makes a hew helper using real clients.
func newHelper(oClient client.Interface, kClient kclient.Interface) *helper {
return &helper{
generateRollback: func(namespace string, config *deployapi.DeploymentConfigRollback) (*deployapi.DeploymentConfig, error) {
return oClient.DeploymentConfigs(namespace).Rollback(config)
},
describe: func(config *deployapi.DeploymentConfig) (string, error) {
describer := describe.NewDeploymentConfigDescriberForConfig(oClient, kClient, config)
return describer.Describe(config.Namespace, config.Name)
},
updateConfig: func(namespace string, config *deployapi.DeploymentConfig) (*deployapi.DeploymentConfig, error) {
return oClient.DeploymentConfigs(namespace).Update(config)
},
}
}
示例7: unloadBuildLabel
func unloadBuildLabel(client osclient.Interface, application *api.Application, labelSelector labels.Selector) error {
resourceList, _ := client.Builds(application.Namespace).List(kapi.ListOptions{LabelSelector: labelSelector, FieldSelector: fields.Everything()})
errs := []error{}
for _, resource := range resourceList.Items {
if !hasItem(application.Spec.Items, api.Item{Kind: "Build", Name: resource.Name}) {
delete(resource.Labels, fmt.Sprintf("%s.application.%s", application.Namespace, application.Name))
if _, err := client.Builds(application.Namespace).Update(&resource); err != nil {
errs = append(errs, err)
}
}
}
return nil
}
示例8: instantiateTemplate
func instantiateTemplate(client client.Interface, mapper configcmd.Mapper, templateNamespace, templateName, targetNamespace string, params map[string]string) error {
template, err := client.Templates(templateNamespace).Get(templateName)
if err != nil {
return errors.NewError("cannot retrieve template %q from namespace %q", templateName, templateNamespace).WithCause(err)
}
// process the template
result, err := genappcmd.TransformTemplate(template, client, targetNamespace, params)
if err != nil {
return errors.NewError("cannot process template %s/%s", templateNamespace, templateName).WithCause(err)
}
// Create objects
bulk := &configcmd.Bulk{
Mapper: mapper,
Op: configcmd.Create,
}
itemsToCreate := &kapi.List{
Items: result.Objects,
}
if errs := bulk.Run(itemsToCreate, targetNamespace); len(errs) > 0 {
err = kerrors.NewAggregate(errs)
return errors.NewError("cannot create objects from template %s/%s", templateNamespace, templateName).WithCause(err)
}
return nil
}
示例9: SetOpenShiftClient
// SetOpenShiftClient sets the passed OpenShift client in the application configuration
func (c *AppConfig) SetOpenShiftClient(osclient client.Interface, OriginNamespace string, dockerclient *docker.Client) {
c.OSClient = osclient
c.OriginNamespace = OriginNamespace
namespaces := []string{OriginNamespace}
if openshiftNamespace := "openshift"; OriginNamespace != openshiftNamespace {
namespaces = append(namespaces, openshiftNamespace)
}
c.ImageStreamSearcher = app.ImageStreamSearcher{
Client: osclient,
ImageStreamImages: osclient,
Namespaces: namespaces,
AllowMissingTags: c.AllowMissingImageStreamTags,
}
c.ImageStreamByAnnotationSearcher = app.NewImageStreamByAnnotationSearcher(osclient, osclient, namespaces)
c.TemplateSearcher = app.TemplateSearcher{
Client: osclient,
TemplateConfigsNamespacer: osclient,
Namespaces: namespaces,
}
c.TemplateFileSearcher = &app.TemplateFileSearcher{
Typer: c.Typer,
Mapper: c.Mapper,
ClientMapper: c.ClientMapper,
Namespace: OriginNamespace,
}
// the hierarchy of docker searching is:
// 1) if we have an openshift client - query docker registries via openshift,
// if we're unable to query via openshift, query the docker registries directly(fallback),
// if we don't find a match there and a local docker daemon exists, look in the local registry.
// 2) if we don't have an openshift client - query the docker registries directly,
// if we don't find a match there and a local docker daemon exists, look in the local registry.
c.DockerSearcher = app.DockerClientSearcher{
Client: dockerclient,
Insecure: c.InsecureRegistry,
AllowMissingImages: c.AllowMissingImages,
RegistrySearcher: app.ImageImportSearcher{
Client: osclient.ImageStreams(OriginNamespace),
AllowInsecure: c.InsecureRegistry,
Fallback: c.DockerRegistrySearcher(),
},
}
}
示例10: setupProjectRequestLimitUsers
func setupProjectRequestLimitUsers(t *testing.T, client client.Interface, users map[string]labels.Set) {
for userName, labels := range users {
user := &userapi.User{}
user.Name = userName
user.Labels = map[string]string(labels)
_, err := client.Users().Create(user)
if err != nil {
t.Fatalf("Could not create user %s: %v", userName, err)
}
}
}
示例11: NewFactory
// NewFactory initializes a factory that will watch the requested routes
func (o *RouterSelection) NewFactory(oc oclient.Interface, kc kclient.Interface) *controllerfactory.RouterControllerFactory {
factory := controllerfactory.NewDefaultRouterControllerFactory(oc, kc)
factory.Labels = o.Labels
factory.Fields = o.Fields
factory.Namespace = o.Namespace
factory.ResyncInterval = o.ResyncInterval
switch {
case o.NamespaceLabels != nil:
glog.Infof("Router is only using routes in namespaces matching %s", o.NamespaceLabels)
factory.Namespaces = namespaceNames{kc.Namespaces(), o.NamespaceLabels}
case o.ProjectLabels != nil:
glog.Infof("Router is only using routes in projects matching %s", o.ProjectLabels)
factory.Namespaces = projectNames{oc.Projects(), o.ProjectLabels}
case len(factory.Namespace) > 0:
glog.Infof("Router is only using resources in namespace %s", factory.Namespace)
default:
glog.Infof("Router is including routes in all namespaces")
}
return factory
}
示例12: checkIfPlanidExist
func checkIfPlanidExist(client osclient.Interface, planId string) (bool, *backingserviceapi.BackingService, error) {
items, err := client.BackingServices("openshift").List(kapi.ListOptions{})
if err != nil {
return false, nil, err
}
for _, bs := range items.Items {
for _, plans := range bs.Spec.Plans {
if planId == plans.Id {
glog.Info("we found plan id at plan", bs.Spec.Name)
return true, &bs, nil
}
}
}
return false, nil, fatalError(fmt.Sprintf("Can't find plan id %s", planId))
}
示例13: NewImageStreamTagEvaluator
// NewImageStreamTagEvaluator computes resource usage of ImageStreamsTags. Its sole purpose is to handle
// UPDATE admission operations on imageStreamTags resource.
func NewImageStreamTagEvaluator(osClient osclient.Interface) kquota.Evaluator {
computeResources := []kapi.ResourceName{
imageapi.ResourceImages,
}
matchesScopeFunc := func(kapi.ResourceQuotaScope, runtime.Object) bool { return true }
getFuncByNamespace := func(namespace, id string) (runtime.Object, error) {
nameParts := strings.SplitN(id, ":", 2)
if len(nameParts) != 2 {
return nil, fmt.Errorf("%q is an invalid id for an imagestreamtag. Must be in form <name>:<tag>.", id)
}
obj, err := osClient.ImageStreamTags(namespace).Get(nameParts[0], nameParts[1])
if err != nil {
if !kerrors.IsNotFound(err) {
return nil, err
}
obj = &imageapi.ImageStreamTag{
ObjectMeta: kapi.ObjectMeta{
Namespace: namespace,
Name: id,
},
}
}
return obj, nil
}
return quotautil.NewSharedContextEvaluator(
imageStreamTagEvaluatorName,
kapi.Kind("ImageStreamTag"),
map[admission.Operation][]kapi.ResourceName{admission.Update: computeResources},
computeResources,
matchesScopeFunc,
getFuncByNamespace,
nil,
imageStreamTagConstraintsFunc,
makeImageStreamTagUsageComputerFactory(osClient))
}
示例14: loadDeploymentConfigs
func loadDeploymentConfigs(g osgraph.Graph, graphLock sync.Mutex, namespace string, kclient kclient.Interface, client client.Interface) error {
dcs, err := client.DeploymentConfigs(namespace).List(labels.Everything(), fields.Everything())
if err != nil {
return err
}
graphLock.Lock()
defer graphLock.Unlock()
for i := range dcs.Items {
deploygraph.EnsureDeploymentConfigNode(g, &dcs.Items[i])
}
return nil
}
示例15: loadBuilds
func loadBuilds(g osgraph.Graph, graphLock sync.Mutex, namespace string, kclient kclient.Interface, client client.Interface) error {
builds, err := client.Builds(namespace).List(labels.Everything(), fields.Everything())
if err != nil {
return err
}
graphLock.Lock()
defer graphLock.Unlock()
for i := range builds.Items {
buildgraph.EnsureBuildNode(g, &builds.Items[i])
}
return nil
}