本文整理汇总了Golang中github.com/openshift/origin/pkg/client.Interface类的典型用法代码示例。如果您正苦于以下问题:Golang Interface类的具体用法?Golang Interface怎么用?Golang Interface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Interface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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(),
}
}
开发者ID:balv14,项目名称:origin,代码行数:32,代码来源:newapp.go
示例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(),
}
}
开发者ID:vikaslaad,项目名称:origin,代码行数:31,代码来源:newapp.go
示例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
}
}
开发者ID:asiainfoLDP,项目名称:datafactory,代码行数:11,代码来源:controller.go
示例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
}
开发者ID:cjnygard,项目名称:origin,代码行数:13,代码来源:controller.go
示例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
}
开发者ID:RomainVabre,项目名称:origin,代码行数:13,代码来源:controller.go
示例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)
},
}
}
开发者ID:cjnygard,项目名称:origin,代码行数:15,代码来源:rollback.go
示例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
}
开发者ID:asiainfoLDP,项目名称:datafactory,代码行数:14,代码来源:controller_label.go
示例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
}
开发者ID:LalatenduMohanty,项目名称:origin,代码行数:27,代码来源:logging.go
示例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(),
},
}
}
开发者ID:nak3,项目名称:origin,代码行数:43,代码来源:newapp.go
示例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)
}
}
}
开发者ID:Vitogee,项目名称:origin,代码行数:11,代码来源:project_reqlimit_test.go
示例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
}
开发者ID:johnmccawley,项目名称:origin,代码行数:21,代码来源:router.go
示例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))
}
开发者ID:asiainfoLDP,项目名称:datafactory,代码行数:20,代码来源:controller.go
示例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))
}
开发者ID:RomainVabre,项目名称:origin,代码行数:40,代码来源:imagestreamtag_evaluator.go
示例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
}
开发者ID:Risar,项目名称:origin,代码行数:14,代码来源:projectstatus.go
示例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
}
开发者ID:Risar,项目名称:origin,代码行数:14,代码来源:projectstatus.go
示例16: GetRepositoryBuildConfigs
func GetRepositoryBuildConfigs(c client.Interface, name string, out io.Writer) error {
ns := os.Getenv("POD_NAMESPACE")
buildConfigList, err := c.BuildConfigs(ns).List(kapi.ListOptions{})
if err != nil {
return err
}
matchingBuildConfigs := []*buildapi.BuildConfig{}
for i := range buildConfigList.Items {
bc := &buildConfigList.Items[i]
repoAnnotation, hasAnnotation := bc.Annotations[gitRepositoryAnnotationKey]
if hasAnnotation {
if repoAnnotation == name {
matchingBuildConfigs = append(matchingBuildConfigs, bc)
}
continue
}
if bc.Name == name {
matchingBuildConfigs = append(matchingBuildConfigs, bc)
}
}
for _, bc := range matchingBuildConfigs {
var ref string
if bc.Spec.Source.Git != nil {
ref = bc.Spec.Source.Git.Ref
}
if ref == "" {
ref = "master"
}
fmt.Fprintf(out, "%s %s\n", bc.Name, ref)
}
return nil
}
开发者ID:juanluisvaladas,项目名称:origin,代码行数:37,代码来源:getbuildconfigs.go
示例17: waitForProject
// waitForProject will execute a client list of projects looking for the project with specified name
// if not found, it will retry up to numRetries at the specified delayInterval
func waitForProject(t *testing.T, client client.Interface, projectName string, delayInterval time.Duration, numRetries int) {
for i := 0; i <= numRetries; i++ {
projects, err := client.Projects().List(labels.Everything(), fields.Everything())
if err != nil {
t.Errorf("unexpected error: %v", err)
}
if (len(projects.Items) == 1) && (projects.Items[0].Name == projectName) {
fmt.Printf("Waited %v times with interval %v\n", i, delayInterval)
return
} else {
time.Sleep(delayInterval)
}
}
t.Errorf("expected project %v not found", projectName)
}
开发者ID:cjnygard,项目名称:origin,代码行数:17,代码来源:authorization_test.go
示例18: NewImageStreamEvaluator
// NewImageStreamEvaluator computes resource usage of ImageStreams. Instantiating this is necessary for
// resource quota admission controller to properly work on image stream related objects.
func NewImageStreamEvaluator(osClient osclient.Interface) kquota.Evaluator {
computeResources := []kapi.ResourceName{
imageapi.ResourceImages,
}
matchesScopeFunc := func(kapi.ResourceQuotaScope, runtime.Object) bool { return true }
getFuncByNamespace := func(namespace, name string) (runtime.Object, error) {
return osClient.ImageStreams(namespace).Get(name)
}
listFuncByNamespace := func(namespace string, options kapi.ListOptions) (runtime.Object, error) {
return osClient.ImageStreams(namespace).List(options)
}
return quotautil.NewSharedContextEvaluator(
imageStreamEvaluatorName,
kapi.Kind("ImageStream"),
nil,
computeResources,
matchesScopeFunc,
getFuncByNamespace,
listFuncByNamespace,
imageStreamConstraintsFunc,
makeImageStreamUsageComputerFactory(osClient))
}
开发者ID:RomainVabre,项目名称:origin,代码行数:26,代码来源:imagestream_evaluator.go
示例19: loadImageStreams
func loadImageStreams(g osgraph.Graph, graphLock sync.Mutex, namespace string, kclient kclient.Interface, client client.Interface) error {
iss, err := client.ImageStreams(namespace).List(labels.Everything(), fields.Everything())
if err != nil {
return err
}
graphLock.Lock()
defer graphLock.Unlock()
for i := range iss.Items {
imagegraph.EnsureImageStreamNode(g, &iss.Items[i])
imagegraph.EnsureAllImageStreamTagNodes(g, &iss.Items[i])
}
return nil
}
开发者ID:Risar,项目名称:origin,代码行数:15,代码来源:projectstatus.go
示例20: testPodNodeConstraintsObjectCreationWithPodTemplate
// testPodNodeConstraintsObjectCreationWithPodTemplate attempts to create different object types that contain pod templates
// using the passed in nodeName and nodeSelector. It will use the expectError flag to determine if an error should be returned or not
func testPodNodeConstraintsObjectCreationWithPodTemplate(t *testing.T, name string, kclientset kclientset.Interface, client client.Interface, nodeName string, nodeSelector map[string]string, expectError bool) {
checkForbiddenErr := func(objType string, err error) {
if err == nil && expectError {
t.Errorf("%s (%s): expected forbidden error but did not receive one", name, objType)
return
}
if err != nil && !expectError {
t.Errorf("%s (%s): got error but did not expect one: %v", name, objType, err)
return
}
if err != nil && expectError && !kapierrors.IsForbidden(err) {
t.Errorf("%s (%s): did not get an expected forbidden error: %v", name, objType, err)
return
}
}
// Pod
pod := testPodNodeConstraintsPod(nodeName, nodeSelector)
_, err := kclientset.Core().Pods(testutil.Namespace()).Create(pod)
checkForbiddenErr("pod", err)
// ReplicationController
rc := testPodNodeConstraintsReplicationController(nodeName, nodeSelector)
_, err = kclientset.Core().ReplicationControllers(testutil.Namespace()).Create(rc)
checkForbiddenErr("rc", err)
// TODO: Enable when the deployments endpoint is supported in Origin
// Deployment
// d := testPodNodeConstraintsDeployment(nodeName, nodeSelector)
// _, err = kclientset.Extensions().Deployments(testutil.Namespace()).Create(d)
// checkForbiddenErr("deployment", err)
// ReplicaSet
rs := testPodNodeConstraintsReplicaSet(nodeName, nodeSelector)
_, err = kclientset.Extensions().ReplicaSets(testutil.Namespace()).Create(rs)
checkForbiddenErr("replicaset", err)
// Job
job := testPodNodeConstraintsJob(nodeName, nodeSelector)
_, err = kclientset.Batch().Jobs(testutil.Namespace()).Create(job)
checkForbiddenErr("job", err)
// DeploymentConfig
dc := testPodNodeConstraintsDeploymentConfig(nodeName, nodeSelector)
_, err = client.DeploymentConfigs(testutil.Namespace()).Create(dc)
checkForbiddenErr("dc", err)
}
开发者ID:dcbw,项目名称:origin,代码行数:50,代码来源:pod_node_constraints_test.go
注:本文中的github.com/openshift/origin/pkg/client.Interface类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论