本文整理汇总了Golang中github.com/openshift/origin/pkg/image/api.ImageStreamMapping类的典型用法代码示例。如果您正苦于以下问题:Golang ImageStreamMapping类的具体用法?Golang ImageStreamMapping怎么用?Golang ImageStreamMapping使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ImageStreamMapping类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: autoConvert_v1_ImageStreamMapping_To_api_ImageStreamMapping
func autoConvert_v1_ImageStreamMapping_To_api_ImageStreamMapping(in *ImageStreamMapping, out *api.ImageStreamMapping, s conversion.Scope) error {
if err := api_v1.Convert_v1_ObjectMeta_To_api_ObjectMeta(&in.ObjectMeta, &out.ObjectMeta, s); err != nil {
return err
}
if err := Convert_v1_Image_To_api_Image(&in.Image, &out.Image, s); err != nil {
return err
}
out.Tag = in.Tag
return nil
}
示例2: autoConvert_v1_ImageStreamMapping_To_api_ImageStreamMapping
func autoConvert_v1_ImageStreamMapping_To_api_ImageStreamMapping(in *ImageStreamMapping, out *image_api.ImageStreamMapping, s conversion.Scope) error {
if err := api.Convert_unversioned_TypeMeta_To_unversioned_TypeMeta(&in.TypeMeta, &out.TypeMeta, s); err != nil {
return err
}
// TODO: Inefficient conversion - can we improve it?
if err := s.Convert(&in.ObjectMeta, &out.ObjectMeta, 0); err != nil {
return err
}
if err := Convert_v1_Image_To_api_Image(&in.Image, &out.Image, s); err != nil {
return err
}
out.Tag = in.Tag
return nil
}
示例3: autoConvert_v1_ImageStreamMapping_To_api_ImageStreamMapping
func autoConvert_v1_ImageStreamMapping_To_api_ImageStreamMapping(in *ImageStreamMapping, out *image_api.ImageStreamMapping, s conversion.Scope) error {
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*ImageStreamMapping))(in)
}
if err := api.Convert_unversioned_TypeMeta_To_unversioned_TypeMeta(&in.TypeMeta, &out.TypeMeta, s); err != nil {
return err
}
// TODO: Inefficient conversion - can we improve it?
if err := s.Convert(&in.ObjectMeta, &out.ObjectMeta, 0); err != nil {
return err
}
if err := Convert_v1_Image_To_api_Image(&in.Image, &out.Image, s); err != nil {
return err
}
out.Tag = in.Tag
return nil
}
示例4: Put
// Put creates or updates the named manifest.
func (r *repository) Put(ctx context.Context, manifest distribution.Manifest, options ...distribution.ManifestServiceOption) (digest.Digest, error) {
if err := r.checkPendingErrors(ctx); err != nil {
return "", err
}
var canonical []byte
// Resolve the payload in the manifest.
mediatype, payload, err := manifest.Payload()
if err != nil {
return "", err
}
switch manifest.(type) {
case *schema1.SignedManifest:
canonical = manifest.(*schema1.SignedManifest).Canonical
case *schema2.DeserializedManifest:
canonical = payload
default:
err = fmt.Errorf("unrecognized manifest type %T", manifest)
return "", regapi.ErrorCodeManifestInvalid.WithDetail(err)
}
if !r.acceptschema2 {
if _, ok := manifest.(*schema1.SignedManifest); !ok {
err = fmt.Errorf("schema version 2 disabled")
return "", regapi.ErrorCodeManifestInvalid.WithDetail(err)
}
}
// Calculate digest
dgst := digest.FromBytes(canonical)
// Upload to openshift
ism := imageapi.ImageStreamMapping{
ObjectMeta: kapi.ObjectMeta{
Namespace: r.namespace,
Name: r.name,
},
Image: imageapi.Image{
ObjectMeta: kapi.ObjectMeta{
Name: dgst.String(),
Annotations: map[string]string{
imageapi.ManagedByOpenShiftAnnotation: "true",
},
},
DockerImageReference: fmt.Sprintf("%s/%s/%[email protected]%s", r.registryAddr, r.namespace, r.name, dgst.String()),
DockerImageManifest: string(payload),
DockerImageManifestMediaType: mediatype,
},
}
for _, option := range options {
if opt, ok := option.(distribution.WithTagOption); ok {
ism.Tag = opt.Tag
break
}
}
if err = r.fillImageWithMetadata(manifest, &ism.Image); err != nil {
return "", err
}
if err = r.registryOSClient.ImageStreamMappings(r.namespace).Create(&ism); err != nil {
// if the error was that the image stream wasn't found, try to auto provision it
statusErr, ok := err.(*kerrors.StatusError)
if !ok {
context.GetLogger(r.ctx).Errorf("error creating ImageStreamMapping: %s", err)
return "", err
}
if quotautil.IsErrorQuotaExceeded(statusErr) {
context.GetLogger(r.ctx).Errorf("denied creating ImageStreamMapping: %v", statusErr)
return "", distribution.ErrAccessDenied
}
status := statusErr.ErrStatus
if status.Code != http.StatusNotFound || (strings.ToLower(status.Details.Kind) != "imagestream" /*pre-1.2*/ && strings.ToLower(status.Details.Kind) != "imagestreams") || status.Details.Name != r.name {
context.GetLogger(r.ctx).Errorf("error creating ImageStreamMapping: %s", err)
return "", err
}
stream := imageapi.ImageStream{
ObjectMeta: kapi.ObjectMeta{
Name: r.name,
},
}
uclient, ok := UserClientFrom(r.ctx)
if !ok {
context.GetLogger(r.ctx).Errorf("error creating user client to auto provision image stream: Origin user client unavailable")
return "", statusErr
}
if _, err := uclient.ImageStreams(r.namespace).Create(&stream); err != nil {
if quotautil.IsErrorQuotaExceeded(err) {
context.GetLogger(r.ctx).Errorf("denied creating ImageStream: %v", err)
return "", distribution.ErrAccessDenied
}
//.........这里部分代码省略.........