本文整理汇总了Golang中github.com/openshift/origin/pkg/image/api.SplitImageStreamTag函数的典型用法代码示例。如果您正苦于以下问题:Golang SplitImageStreamTag函数的具体用法?Golang SplitImageStreamTag怎么用?Golang SplitImageStreamTag使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SplitImageStreamTag函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: validateToImageReference
func validateToImageReference(reference *kapi.ObjectReference, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
kind, name, namespace := reference.Kind, reference.Name, reference.Namespace
switch kind {
case "ImageStreamTag":
if len(name) == 0 {
allErrs = append(allErrs, field.Required(fldPath.Child("name"), ""))
} else if _, _, ok := imageapi.SplitImageStreamTag(name); !ok {
allErrs = append(allErrs, field.Invalid(fldPath.Child("name"), name, "ImageStreamTag object references must be in the form <name>:<tag>"))
} else if name, _, _ := imageapi.SplitImageStreamTag(name); len(imageapivalidation.ValidateImageStreamName(name, false)) != 0 {
allErrs = append(allErrs, field.Invalid(fldPath.Child("name"), name, "ImageStreamTag name contains invalid syntax"))
}
if len(namespace) != 0 && len(kvalidation.IsDNS1123Subdomain(namespace)) != 0 {
allErrs = append(allErrs, field.Invalid(fldPath.Child("namespace"), namespace, "namespace must be a valid subdomain"))
}
case "DockerImage":
if len(namespace) != 0 {
allErrs = append(allErrs, field.Invalid(fldPath.Child("namespace"), namespace, "namespace is not valid when used with a 'DockerImage'"))
}
if _, err := imageapi.ParseDockerImageReference(name); err != nil {
allErrs = append(allErrs, field.Invalid(fldPath.Child("name"), name, fmt.Sprintf("name is not a valid Docker pull specification: %v", err)))
}
case "":
allErrs = append(allErrs, field.Required(fldPath.Child("kind"), ""))
default:
allErrs = append(allErrs, field.Invalid(fldPath.Child("kind"), kind, "the target of build output must be an 'ImageStreamTag' or 'DockerImage'"))
}
return allErrs
}
开发者ID:tracyrankin,项目名称:origin,代码行数:31,代码来源:validation.go
示例2: ImageStreamReferenceIndexFunc
// ImageStreamReferenceIndexFunc is a default index function that indexes based on image stream references.
func ImageStreamReferenceIndexFunc(obj interface{}) ([]string, error) {
switch t := obj.(type) {
case *buildapi.BuildConfig:
var keys []string
for _, trigger := range t.Spec.Triggers {
if trigger.Type != buildapi.ImageChangeBuildTriggerType {
continue
}
from := trigger.ImageChange.From
// We're indexing on the imagestream referenced by the imagechangetrigger,
// however buildconfigs allow one "default" imagechangetrigger in which
// the ICT does not explicitly indicate the image it is triggering on,
// instead it triggers on the image being used as the builder/base image
// as referenced in the build strategy, so if this is an ICT w/ no
// explicit image reference, use the image referenced by the strategy
// because this is the default ICT.
if from == nil {
from = buildutil.GetInputReference(t.Spec.Strategy)
if from == nil || from.Kind != "ImageStreamTag" {
continue
}
}
name, _, _ := imageapi.SplitImageStreamTag(from.Name)
namespace := from.Namespace
// if the imagestream reference has no namespace, use the
// namespace of the buildconfig.
if len(namespace) == 0 {
namespace = t.Namespace
}
keys = append(keys, namespace+"/"+name)
}
if len(keys) == 0 {
// Return an empty key for configs that don't hold object references.
keys = append(keys, "")
}
return keys, nil
case *deployapi.DeploymentConfig:
var keys []string
for _, trigger := range t.Spec.Triggers {
if trigger.Type != deployapi.DeploymentTriggerOnImageChange {
continue
}
params := trigger.ImageChangeParams
name, _, _ := imageapi.SplitImageStreamTag(params.From.Name)
keys = append(keys, params.From.Namespace+"/"+name)
}
if len(keys) == 0 {
// Return an empty key for configs that don't hold object references.
keys = append(keys, "")
}
return keys, nil
}
return nil, fmt.Errorf("image stream reference index not implemented for %#v", obj)
}
开发者ID:juanluisvaladas,项目名称:origin,代码行数:60,代码来源:index.go
示例3: convert_v1_DeploymentTriggerImageChangeParams_To_api_DeploymentTriggerImageChangeParams
func convert_v1_DeploymentTriggerImageChangeParams_To_api_DeploymentTriggerImageChangeParams(in *DeploymentTriggerImageChangeParams, out *newer.DeploymentTriggerImageChangeParams, s conversion.Scope) error {
out.Automatic = in.Automatic
out.ContainerNames = make([]string, len(in.ContainerNames))
copy(out.ContainerNames, in.ContainerNames)
out.LastTriggeredImage = in.LastTriggeredImage
if err := s.Convert(&in.From, &out.From, 0); err != nil {
return err
}
switch in.From.Kind {
case "DockerImage":
ref, err := imageapi.ParseDockerImageReference(in.From.Name)
if err != nil {
return err
}
out.Tag = ref.Tag
ref.Tag, ref.ID = "", ""
out.RepositoryName = ref.String()
case "ImageStreamTag":
name, tag, ok := imageapi.SplitImageStreamTag(in.From.Name)
if !ok {
return fmt.Errorf("ImageStreamTag object references must be in the form <name>:<tag>: %s", in.From.Name)
}
out.From.Kind = "ImageStream"
out.From.Name = name
out.Tag = tag
}
return nil
}
开发者ID:dctse,项目名称:openshift-cucumber,代码行数:28,代码来源:conversion.go
示例4: convert_v1_BuildOutput_To_api_BuildOutput
func convert_v1_BuildOutput_To_api_BuildOutput(in *BuildOutput, out *newer.BuildOutput, s conversion.Scope) error {
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
return err
}
if in.To != nil && in.To.Kind == "ImageStreamTag" {
name, tag, ok := imageapi.SplitImageStreamTag(in.To.Name)
if !ok {
return fmt.Errorf("ImageStreamTag object references must be in the form <name>:<tag>: %s", in.To.Name)
}
out.To.Kind = "ImageStream"
out.To.Name = name
out.Tag = tag
return nil
}
if in.To != nil && in.To.Kind == "DockerImage" {
out.To = nil
if ref, err := imageapi.ParseDockerImageReference(in.To.Name); err == nil {
out.Tag = ref.Tag
ref.Tag = ""
out.DockerImageReference = ref.String()
} else {
out.DockerImageReference = in.To.Name
}
}
return nil
}
开发者ID:mignev,项目名称:origin,代码行数:26,代码来源:conversion.go
示例5: validateToImageReference
func validateToImageReference(reference *kapi.ObjectReference) fielderrors.ValidationErrorList {
allErrs := fielderrors.ValidationErrorList{}
kind, name, namespace := reference.Kind, reference.Name, reference.Namespace
switch kind {
case "ImageStreamTag":
if len(name) == 0 {
allErrs = append(allErrs, fielderrors.NewFieldRequired("name"))
} else if _, _, ok := imageapi.SplitImageStreamTag(name); !ok {
allErrs = append(allErrs, fielderrors.NewFieldInvalid("name", name, "ImageStreamTag object references must be in the form <name>:<tag>"))
}
if len(namespace) != 0 && !util.IsDNS1123Subdomain(namespace) {
allErrs = append(allErrs, fielderrors.NewFieldInvalid("namespace", namespace, "namespace must be a valid subdomain"))
}
case "DockerImage":
if len(namespace) != 0 {
allErrs = append(allErrs, fielderrors.NewFieldInvalid("namespace", namespace, "namespace is not valid when used with a 'DockerImage'"))
}
if _, err := imageapi.ParseDockerImageReference(name); err != nil {
allErrs = append(allErrs, fielderrors.NewFieldInvalid("name", name, fmt.Sprintf("name is not a valid Docker pull specification: %v", err)))
}
case "":
allErrs = append(allErrs, fielderrors.NewFieldRequired("kind"))
default:
allErrs = append(allErrs, fielderrors.NewFieldInvalid("kind", kind, "the target of build output must be an 'ImageStreamTag' or 'DockerImage'"))
}
return allErrs
}
开发者ID:MarWestermann,项目名称:gofabric8,代码行数:29,代码来源:validation.go
示例6: ResolveObjectReference
// ResolveObjectReference converts a reference into an image API or returns an error. If the kind is not recognized
// this method will return an error to prevent references that may be images from being ignored.
func (c *imageResolutionCache) ResolveObjectReference(ref *kapi.ObjectReference, defaultNamespace string) (*rules.ImagePolicyAttributes, error) {
switch ref.Kind {
case "ImageStreamTag":
ns := ref.Namespace
if len(ns) == 0 {
ns = defaultNamespace
}
name, tag, ok := imageapi.SplitImageStreamTag(ref.Name)
if !ok {
return &rules.ImagePolicyAttributes{IntegratedRegistry: true}, fmt.Errorf("references of kind ImageStreamTag must be of the form NAME:TAG")
}
return c.resolveImageStreamTag(ns, name, tag)
case "ImageStreamImage":
ns := ref.Namespace
if len(ns) == 0 {
ns = defaultNamespace
}
name, id, ok := imageapi.SplitImageStreamImage(ref.Name)
if !ok {
return &rules.ImagePolicyAttributes{IntegratedRegistry: true}, fmt.Errorf("references of kind ImageStreamImage must be of the form [email protected]")
}
return c.resolveImageStreamImage(ns, name, id)
case "DockerImage":
ref, err := imageapi.ParseDockerImageReference(ref.Name)
if err != nil {
return nil, err
}
return c.resolveImageReference(ref)
default:
return nil, fmt.Errorf("image policy does not allow image references of kind %q", ref.Kind)
}
}
开发者ID:abhgupta,项目名称:origin,代码行数:37,代码来源:imagepolicy.go
示例7: AddTriggerEdges
// AddTriggerEdges creates edges that point to named Docker image repositories for each image used in the deployment.
func AddTriggerEdges(g osgraph.MutableUniqueGraph, node *deploygraph.DeploymentConfigNode) *deploygraph.DeploymentConfigNode {
podTemplate := node.DeploymentConfig.Spec.Template
if podTemplate == nil {
return node
}
deployapi.EachTemplateImage(
&podTemplate.Spec,
deployapi.DeploymentConfigHasTrigger(node.DeploymentConfig),
func(image deployapi.TemplateImage, err error) {
if err != nil {
return
}
if image.From != nil {
if len(image.From.Name) == 0 {
return
}
name, tag, _ := imageapi.SplitImageStreamTag(image.From.Name)
in := imagegraph.FindOrCreateSyntheticImageStreamTagNode(g, imagegraph.MakeImageStreamTagObjectMeta(image.From.Namespace, name, tag))
g.AddEdge(in, node, TriggersDeploymentEdgeKind)
return
}
tag := image.Ref.Tag
image.Ref.Tag = ""
in := imagegraph.EnsureDockerRepositoryNode(g, image.Ref.String(), tag)
g.AddEdge(in, node, UsedInDeploymentEdgeKind)
})
return node
}
开发者ID:asiainfoLDP,项目名称:datafactory,代码行数:32,代码来源:edges.go
示例8: triggerMatchesImage
// triggerMatchesImage decides whether a given trigger for config matches the provided image stream.
func triggerMatchesImage(config *deployapi.DeploymentConfig, params *deployapi.DeploymentTriggerImageChangeParams, stream *imageapi.ImageStream) bool {
namespace := params.From.Namespace
if len(namespace) == 0 {
namespace = config.Namespace
}
name, _, ok := imageapi.SplitImageStreamTag(params.From.Name)
return stream.Namespace == namespace && stream.Name == name && ok
}
开发者ID:abhgupta,项目名称:origin,代码行数:9,代码来源:controller.go
示例9: Create
func (r *REST) Create(ctx kapi.Context, obj runtime.Object) (runtime.Object, error) {
istag, ok := obj.(*imageapi.ImageStreamTag)
if !ok {
return nil, kapierrors.NewBadRequest(fmt.Sprintf("obj is not an ImageStreamTag: %#v", obj))
}
if err := rest.BeforeCreate(Strategy, ctx, obj); err != nil {
return nil, err
}
namespace, ok := kapi.NamespaceFrom(ctx)
if !ok {
return nil, kapierrors.NewBadRequest("a namespace must be specified to import images")
}
imageStreamName, imageTag, ok := imageapi.SplitImageStreamTag(istag.Name)
if !ok {
return nil, fmt.Errorf("%q must be of the form <stream_name>:<tag>", istag.Name)
}
target, err := r.imageStreamRegistry.GetImageStream(ctx, imageStreamName)
if err != nil {
if !kapierrors.IsNotFound(err) {
return nil, err
}
// try to create the target if it doesn't exist
target = &imageapi.ImageStream{
ObjectMeta: kapi.ObjectMeta{
Name: imageStreamName,
Namespace: namespace,
},
}
}
if target.Spec.Tags == nil {
target.Spec.Tags = make(map[string]imageapi.TagReference)
}
// The user wants to symlink a tag.
_, exists := target.Spec.Tags[imageTag]
if exists {
return nil, kapierrors.NewAlreadyExists(imageapi.Resource("imagestreamtag"), istag.Name)
}
target.Spec.Tags[imageTag] = *istag.Tag
// Check the stream creation timestamp and make sure we will not
// create a new image stream while deleting.
if target.CreationTimestamp.IsZero() {
_, err = r.imageStreamRegistry.CreateImageStream(ctx, target)
} else {
_, err = r.imageStreamRegistry.UpdateImageStream(ctx, target)
}
if err != nil {
return nil, err
}
return istag, nil
}
开发者ID:juanluisvaladas,项目名称:origin,代码行数:57,代码来源:rest.go
示例10: AddImageStreamRefEdge
// AddImageStreamRefEdge ensures that a directed edge exists between an IST Node and the IS it references
func AddImageStreamRefEdge(g osgraph.MutableUniqueGraph, node *imagegraph.ImageStreamTagNode) {
isName, _, _ := imageapi.SplitImageStreamTag(node.Name)
imageStream := &imageapi.ImageStream{}
imageStream.Namespace = node.Namespace
imageStream.Name = isName
imageStreamNode := imagegraph.FindOrCreateSyntheticImageStreamNode(g, imageStream)
g.AddEdge(node, imageStreamNode, ReferencedImageStreamGraphEdgeKind)
}
开发者ID:johnmccawley,项目名称:origin,代码行数:10,代码来源:edges.go
示例11: validateImageStreamTagName
func validateImageStreamTagName(istag string) error {
name, _, ok := imageapi.SplitImageStreamTag(istag)
if !ok {
return fmt.Errorf("must be in the form of <name>:<tag>")
}
if reasons := imageval.ValidateImageStreamName(name, false); len(reasons) != 0 {
return errors.New(strings.Join(reasons, ", "))
}
return nil
}
开发者ID:juanluisvaladas,项目名称:origin,代码行数:10,代码来源:validation.go
示例12: validateImageStreamTagName
func validateImageStreamTagName(istag string) error {
name, _, ok := imageapi.SplitImageStreamTag(istag)
if !ok {
return fmt.Errorf("invalid ImageStreamTag: %s", istag)
}
if reasons := imageval.ValidateImageStreamName(name, false); len(reasons) != 0 {
return errors.New(strings.Join(reasons, ", "))
}
return nil
}
开发者ID:legionus,项目名称:origin,代码行数:10,代码来源:validation.go
示例13: validateImageStreamTagName
func validateImageStreamTagName(istag string) error {
name, _, ok := imageapi.SplitImageStreamTag(istag)
if !ok {
return fmt.Errorf("invalid ImageStreamTag: %s", istag)
}
ok, reason := imageval.ValidateImageStreamName(name, false)
if !ok {
return errors.New(reason)
}
return nil
}
开发者ID:rrati,项目名称:origin,代码行数:11,代码来源:validation.go
示例14: validateDockerStrategy
func validateDockerStrategy(strategy *buildapi.DockerBuildStrategy) fielderrors.ValidationErrorList {
allErrs := fielderrors.ValidationErrorList{}
if strategy.From != nil && strategy.From.Kind == "ImageStreamTag" {
if _, _, ok := imageapi.SplitImageStreamTag(strategy.From.Name); !ok {
allErrs = append(allErrs, fielderrors.NewFieldInvalid("from.name", strategy.From.Name, "ImageStreamTag object references must be in the form <name>:<tag>"))
}
}
allErrs = append(allErrs, validateSecretRef(strategy.PullSecret).Prefix("pullSecret")...)
return allErrs
}
开发者ID:cjnygard,项目名称:origin,代码行数:12,代码来源:validation.go
示例15: TestGenerate_fromConfigWithUpdatedImageRef
func TestGenerate_fromConfigWithUpdatedImageRef(t *testing.T) {
newRepoName := "registry:8080/openshift/[email protected]:0000000000000000000000000000000000000000000000000000000000000002"
streamName := "test-image-stream"
newImageID := "sha256:0000000000000000000000000000000000000000000000000000000000000002"
generator := &DeploymentConfigGenerator{
Client: Client{
DCFn: func(ctx kapi.Context, id string) (*deployapi.DeploymentConfig, error) {
return deploytest.OkDeploymentConfig(1), nil
},
ISFn: func(ctx kapi.Context, name string) (*imageapi.ImageStream, error) {
stream := makeStream(
streamName,
imageapi.DefaultImageTag,
newRepoName,
newImageID,
)
return stream, nil
},
},
}
config, err := generator.Generate(kapi.NewDefaultContext(), "deploy1")
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
if config == nil {
t.Fatalf("Expected non-nil config")
}
if config.Status.LatestVersion != 2 {
t.Fatalf("Expected config LatestVersion=2, got %d", config.Status.LatestVersion)
}
if expected, actual := newRepoName, config.Spec.Template.Spec.Containers[0].Image; actual != expected {
t.Fatalf("Expected container image %q, got %q", expected, actual)
}
if expected, actual := newRepoName, config.Spec.Triggers[0].ImageChangeParams.LastTriggeredImage; actual != expected {
t.Fatalf("Expected LastTriggeredImage %q, got %q", expected, actual)
}
name, tag, _ := imageapi.SplitImageStreamTag(config.Status.Details.Causes[0].ImageTrigger.From.Name)
if actual, expected := tag, imageapi.DefaultImageTag; actual != expected {
t.Fatalf("Expected cause tag %q, got %q", expected, actual)
}
if actual, expected := name, streamName; actual != expected {
t.Fatalf("Expected cause stream %q, got %q", expected, actual)
}
}
开发者ID:juanluisvaladas,项目名称:origin,代码行数:53,代码来源:config_generator_test.go
示例16: BuildConfig
// BuildConfig adds a graph node for the specific build config if it does not exist,
// and will link the build config to other nodes for the images and source repositories
// it depends on.
func BuildConfig(g MutableUniqueGraph, config *build.BuildConfig) graph.Node {
node, found := g.FindOrCreate(
UniqueName(fmt.Sprintf("%d|%s/%s", BuildConfigGraphKind, config.Namespace, config.Name)),
func(node Node) graph.Node {
return &BuildConfigNode{
Node: node,
BuildConfig: config,
}
},
)
if found {
return node
}
output := config.Parameters.Output
to := output.To
switch {
case to != nil && len(to.Name) > 0:
out := ImageStreamTag(g, defaultNamespace(to.Namespace, config.Namespace), to.Name, output.Tag)
g.AddEdge(node, out, BuildOutputGraphEdgeKind)
case len(output.DockerImageReference) > 0:
out := DockerRepository(g, output.DockerImageReference, output.Tag)
g.AddEdge(node, out, BuildOutputGraphEdgeKind)
}
if in, ok := SourceRepository(g, config.Parameters.Source); ok {
g.AddEdge(in, node, BuildInputGraphEdgeKind)
}
from := buildutil.GetImageStreamForStrategy(config.Parameters.Strategy)
if from != nil {
switch from.Kind {
case "DockerImage":
if ref, err := image.ParseDockerImageReference(from.Name); err == nil {
tag := ref.Tag
ref.Tag = ""
in := DockerRepository(g, ref.String(), tag)
g.AddEdge(in, node, BuildInputImageGraphEdgeKind)
}
case "ImageStream":
tag := image.DefaultImageTag
in := ImageStreamTag(g, defaultNamespace(from.Namespace, config.Namespace), from.Name, tag)
g.AddEdge(in, node, BuildInputImageGraphEdgeKind)
case "ImageStreamTag":
name, tag, _ := image.SplitImageStreamTag(from.Name)
in := ImageStreamTag(g, defaultNamespace(from.Namespace, config.Namespace), name, tag)
g.AddEdge(in, node, BuildInputImageGraphEdgeKind)
case "ImageStreamImage":
glog.V(4).Infof("Ignoring ImageStreamImage reference in BuildConfig %s/%s", config.Namespace, config.Name)
}
}
return node
}
开发者ID:mignev,项目名称:origin,代码行数:56,代码来源:types.go
示例17: findImageStream
func (g *DeploymentConfigGenerator) findImageStream(config *deployapi.DeploymentConfig, params *deployapi.DeploymentTriggerImageChangeParams) (*imageapi.ImageStream, error) {
if len(params.From.Name) > 0 {
namespace := params.From.Namespace
if len(namespace) == 0 {
namespace = config.Namespace
}
name, _, ok := imageapi.SplitImageStreamTag(params.From.Name)
if !ok {
return nil, fmt.Errorf("invalid ImageStreamTag: %s", params.From.Name)
}
return g.Client.GetImageStream(kapi.WithNamespace(kapi.NewContext(), namespace), name)
}
return nil, fmt.Errorf("couldn't find image stream for config %s trigger params", deployutil.LabelForDeploymentConfig(config))
}
开发者ID:RomainVabre,项目名称:origin,代码行数:14,代码来源:config_generator.go
示例18: ResolveImagePullSpec
// ResolveImagePullSpec resolves the provided source which can be "docker", "istag" or
// "isimage" and returns the full Docker pull spec.
func ResolveImagePullSpec(images client.ImageStreamImagesNamespacer, tags client.ImageStreamTagsNamespacer, source, name, defaultNamespace string) (string, error) {
// for Docker source, just passtrough the image name
if IsDocker(source) {
return name, nil
}
// parse the namespace from the provided image
namespace, image := splitNamespaceAndImage(name)
if len(namespace) == 0 {
namespace = defaultNamespace
}
dockerImageReference := ""
if IsImageStreamTag(source) {
name, tag, ok := imageapi.SplitImageStreamTag(image)
if !ok {
return "", fmt.Errorf("invalid image stream tag %q, must be of the form [NAMESPACE/]NAME:TAG", name)
}
if resolved, err := tags.ImageStreamTags(namespace).Get(name, tag); err != nil {
return "", fmt.Errorf("failed to get image stream tag %q: %v", name, err)
} else {
dockerImageReference = resolved.Image.DockerImageReference
}
}
if IsImageStreamImage(source) {
name, digest, ok := imageapi.SplitImageStreamImage(image)
if !ok {
return "", fmt.Errorf("invalid image stream image %q, must be of the form [NAMESPACE/][email protected]", name)
}
if resolved, err := images.ImageStreamImages(namespace).Get(name, digest); err != nil {
return "", fmt.Errorf("failed to get image stream image %q: %v", name, err)
} else {
dockerImageReference = resolved.Image.DockerImageReference
}
}
if len(dockerImageReference) == 0 {
return "", fmt.Errorf("unable to resolve %s %q", source, name)
}
reference, err := imageapi.ParseDockerImageReference(dockerImageReference)
if err != nil {
return "", err
}
return reference.String(), nil
}
开发者ID:juanluisvaladas,项目名称:origin,代码行数:49,代码来源:resolve.go
示例19: convert_v1_CustomBuildStrategy_To_api_CustomBuildStrategy
func convert_v1_CustomBuildStrategy_To_api_CustomBuildStrategy(in *CustomBuildStrategy, out *newer.CustomBuildStrategy, s conversion.Scope) error {
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
return err
}
if in.From != nil {
switch in.From.Kind {
case "ImageStream":
out.From.Kind = "ImageStreamTag"
out.From.Name = imageapi.JoinImageStreamTag(in.From.Name, "")
case "ImageStreamTag":
_, _, ok := imageapi.SplitImageStreamTag(in.From.Name)
if !ok {
return fmt.Errorf("ImageStreamTag object references must be in the form <name>:<tag>: %s", in.From.Name)
}
}
}
return nil
}
开发者ID:mignev,项目名称:origin,代码行数:18,代码来源:conversion.go
示例20: resolveOutputDockerImageReference
// resolveOutputDockerImageReference returns a reference to a Docker image
// computed from the buid.Spec.Output.To reference.
func (bc *BuildController) resolveOutputDockerImageReference(build *buildapi.Build) (string, error) {
outputTo := build.Spec.Output.To
if outputTo == nil || outputTo.Name == "" {
return "", nil
}
var ref string
switch outputTo.Kind {
case "DockerImage":
ref = outputTo.Name
case "ImageStream", "ImageStreamTag":
// TODO(smarterclayton): security, ensure that the reference image stream is actually visible
namespace := outputTo.Namespace
if len(namespace) == 0 {
namespace = build.Namespace
}
var tag string
streamName := outputTo.Name
if outputTo.Kind == "ImageStreamTag" {
var ok bool
streamName, tag, ok = imageapi.SplitImageStreamTag(streamName)
if !ok {
return "", fmt.Errorf("the referenced image stream tag is invalid: %s", outputTo.Name)
}
tag = ":" + tag
}
stream, err := bc.ImageStreamClient.GetImageStream(namespace, streamName)
if err != nil {
if errors.IsNotFound(err) {
return "", fmt.Errorf("the referenced output image stream %s/%s does not exist", namespace, streamName)
}
return "", fmt.Errorf("the referenced output image stream %s/%s could not be found by build %s/%s: %v", namespace, streamName, build.Namespace, build.Name, err)
}
if len(stream.Status.DockerImageRepository) == 0 {
e := fmt.Errorf("the image stream %s/%s cannot be used as the output for build %s/%s because the integrated Docker registry is not configured and no external registry was defined", namespace, outputTo.Name, build.Namespace, build.Name)
bc.Recorder.Eventf(build, kapi.EventTypeWarning, "invalidOutput", "Error starting build: %v", e)
return "", e
}
ref = fmt.Sprintf("%s%s", stream.Status.DockerImageRepository, tag)
}
return ref, nil
}
开发者ID:RomainVabre,项目名称:origin,代码行数:44,代码来源:controller.go
注:本文中的github.com/openshift/origin/pkg/image/api.SplitImageStreamTag函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论