當前位置: 首頁>>代碼示例>>Golang>>正文


Golang client.ImageStreamsNamespacer類代碼示例

本文整理匯總了Golang中github.com/openshift/origin/pkg/client.ImageStreamsNamespacer的典型用法代碼示例。如果您正苦於以下問題:Golang ImageStreamsNamespacer類的具體用法?Golang ImageStreamsNamespacer怎麽用?Golang ImageStreamsNamespacer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ImageStreamsNamespacer類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: makeImageStreamTagAdmissionUsageFunc

// makeImageStreamTagAdmissionUsageFunc returns a function that computes a resource usage for given image
// stream tag during admission.
func makeImageStreamTagAdmissionUsageFunc(isNamespacer osclient.ImageStreamsNamespacer) generic.UsageFunc {
	return func(object runtime.Object) kapi.ResourceList {
		ist, ok := object.(*imageapi.ImageStreamTag)
		if !ok {
			return kapi.ResourceList{}
		}

		res := map[kapi.ResourceName]resource.Quantity{
			imageapi.ResourceImageStreams: *resource.NewQuantity(0, resource.BinarySI),
		}

		isName, _, err := imageapi.ParseImageStreamTagName(ist.Name)
		if err != nil {
			utilruntime.HandleError(err)
			return kapi.ResourceList{}
		}

		is, err := isNamespacer.ImageStreams(ist.Namespace).Get(isName)
		if err != nil {
			if !kerrors.IsNotFound(err) {
				utilruntime.HandleError(fmt.Errorf("failed to get image stream %s/%s: %v", ist.Namespace, isName, err))
			}
		}
		if is == nil {
			res[imageapi.ResourceImageStreams] = *resource.NewQuantity(1, resource.BinarySI)
		}

		return res
	}
}
開發者ID:Xmagicer,項目名稱:origin,代碼行數:32,代碼來源:imagestreamtag_evaluator.go

示例2: DeletingImageStreamPruneFunc

// DeletingImageStreamPruneFunc returns an ImageStreamPruneFunc that deletes the imageStream.
func DeletingImageStreamPruneFunc(streams client.ImageStreamsNamespacer) ImageStreamPruneFunc {
	return func(stream *imageapi.ImageStream, image *imageapi.Image) (*imageapi.ImageStream, error) {
		glog.V(4).Infof("Checking if ImageStream %s/%s has references to image in status.tags", stream.Namespace, stream.Name)
		for tag, history := range stream.Status.Tags {
			glog.V(4).Infof("Checking tag %q", tag)
			newHistory := imageapi.TagEventList{}
			for i, tagEvent := range history.Items {
				glog.V(4).Infof("Checking tag event %d with image %q", i, tagEvent.Image)
				if tagEvent.Image != image.Name {
					glog.V(4).Infof("Tag event doesn't match deleting image - keeping")
					newHistory.Items = append(newHistory.Items, tagEvent)
				}
			}
			stream.Status.Tags[tag] = newHistory
		}

		glog.V(4).Infof("Updating ImageStream %s/%s", stream.Namespace, stream.Name)
		glog.V(5).Infof("Updated stream: %#v", stream)
		updatedStream, err := streams.ImageStreams(stream.Namespace).UpdateStatus(stream)
		if err != nil {
			return nil, err
		}
		return updatedStream, nil
	}
}
開發者ID:mignev,項目名稱:origin,代碼行數:26,代碼來源:imagepruner.go

示例3: makeImageStreamImportAdmissionUsageFunc

// makeImageStreamImportAdmissionUsageFunc retuns a function for computing a usage of an image stream import.
func makeImageStreamImportAdmissionUsageFunc(isNamespacer osclient.ImageStreamsNamespacer) generic.UsageFunc {
	return func(object runtime.Object) kapi.ResourceList {
		isi, ok := object.(*imageapi.ImageStreamImport)
		if !ok {
			return kapi.ResourceList{}
		}

		usage := map[kapi.ResourceName]resource.Quantity{
			imageapi.ResourceImageStreams: *resource.NewQuantity(0, resource.DecimalSI),
		}

		if !isi.Spec.Import || (len(isi.Spec.Images) == 0 && isi.Spec.Repository == nil) {
			return usage
		}

		is, err := isNamespacer.ImageStreams(isi.Namespace).Get(isi.Name)
		if err != nil {
			if !kerrors.IsNotFound(err) {
				utilruntime.HandleError(fmt.Errorf("failed to list image streams: %v", err))
			}
		}
		if is == nil {
			usage[imageapi.ResourceImageStreams] = *resource.NewQuantity(1, resource.DecimalSI)
		}

		return usage
	}
}
開發者ID:Xmagicer,項目名稱:origin,代碼行數:29,代碼來源:imagestreamimport_evaluator.go

示例4: 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(isNamespacer osclient.ImageStreamsNamespacer) kquota.Evaluator {
	allResources := []kapi.ResourceName{
		imageapi.ResourceImageStreams,
	}

	return &generic.GenericEvaluator{
		Name:              imageStreamEvaluatorName,
		InternalGroupKind: imageapi.Kind("ImageStream"),
		InternalOperationResources: map[admission.Operation][]kapi.ResourceName{
			admission.Create: allResources,
		},
		MatchedResourceNames: allResources,
		MatchesScopeFunc:     generic.MatchesNoScopeFunc,
		ConstraintsFunc:      generic.ObjectCountConstraintsFunc(imageapi.ResourceImageStreams),
		UsageFunc:            generic.ObjectCountUsageFunc(imageapi.ResourceImageStreams),
		ListFuncByNamespace: func(namespace string, options kapi.ListOptions) (runtime.Object, error) {
			return isNamespacer.ImageStreams(namespace).List(options)
		},
	}
}
開發者ID:Xmagicer,項目名稱:origin,代碼行數:22,代碼來源:imagestream_evaluator.go

示例5: processTriggers

// processTriggers will go over all deployment triggers that require processing and update
// the deployment config accordingly. This contains the work that the image change controller
// had been doing up to the point we got the /instantiate endpoint.
func processTriggers(config *deployapi.DeploymentConfig, isn client.ImageStreamsNamespacer, force bool) error {
	errs := []error{}

	// Process any image change triggers.
	for _, trigger := range config.Spec.Triggers {
		if trigger.Type != deployapi.DeploymentTriggerOnImageChange {
			continue
		}

		params := trigger.ImageChangeParams

		// Forced deployments should always try to resolve the images in the template.
		// On the other hand, paused deployments or non-automatic triggers shouldn't.
		if !force && (config.Spec.Paused || !params.Automatic) {
			continue
		}

		// Tag references are already validated
		name, tag, _ := imageapi.SplitImageStreamTag(params.From.Name)
		stream, err := isn.ImageStreams(params.From.Namespace).Get(name)
		if err != nil {
			if !errors.IsNotFound(err) {
				errs = append(errs, err)
			}
			continue
		}

		// Find the latest tag event for the trigger reference.
		latestEvent := imageapi.LatestTaggedImage(stream, tag)
		if latestEvent == nil {
			continue
		}

		// Ensure a change occurred
		latestRef := latestEvent.DockerImageReference
		if len(latestRef) == 0 || latestRef == params.LastTriggeredImage {
			continue
		}

		// Update containers
		names := sets.NewString(params.ContainerNames...)
		for i := range config.Spec.Template.Spec.Containers {
			container := &config.Spec.Template.Spec.Containers[i]
			if !names.Has(container.Name) {
				continue
			}

			if container.Image != latestRef {
				// Update the image
				container.Image = latestRef
				// Log the last triggered image ID
				params.LastTriggeredImage = latestRef
			}
		}
	}

	if err := utilerrors.NewAggregate(errs); err != nil {
		return errors.NewInternalError(err)
	}

	return nil
}
開發者ID:juanluisvaladas,項目名稱:origin,代碼行數:65,代碼來源:rest.go


注:本文中的github.com/openshift/origin/pkg/client.ImageStreamsNamespacer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。