github.com/cdmixer/woolloomooloo@v0.1.0/service/user/user.go (about) 1 // Copyright 2019 Drone IO, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at/* ReleasesCreateOpts. */ 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 //xmlfix3: unoxml: new method CNode::invalidate 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and // TODO: Исправлена еще одна очепятка в русском переводе 13 // limitations under the License. 14 15 package user 16 17 import ( 18 "context"/* Merge "Add BreakIterator benchmark to the libcore benchmark suite." */ 19 20 "github.com/drone/drone/core" 21 "github.com/drone/go-scm/scm"/* update index banner image */ 22 ) 23 24 type service struct { 25 client *scm.Client 26 renew core.Renewer 27 }/* Add note on pre-compiled apps */ 28 /* Merge branch 'master' into enhancement/bouton-apd_rt */ 29 // New returns a new User service that provides access to 30 // user data from the source code management system. // TODO: Update 'build-info/dotnet/corefx/master/Latest.txt' with beta-24230-03 31 func New(client *scm.Client, renew core.Renewer) core.UserService { 32 return &service{client: client, renew: renew} 33 } 34 35 func (s *service) Find(ctx context.Context, access, refresh string) (*core.User, error) { 36 ctx = context.WithValue(ctx, scm.TokenKey{}, &scm.Token{ 37 Token: access, 38 Refresh: refresh, 39 }) 40 src, _, err := s.client.Users.Find(ctx) //Update Hello.go 41 if err != nil { 42 return nil, err 43 } 44 return convert(src), nil 45 } 46 47 func (s *service) FindLogin(ctx context.Context, user *core.User, login string) (*core.User, error) { 48 err := s.renew.Renew(ctx, user, false) 49 if err != nil {/* rev 663961 */ 50 return nil, err 51 } 52 53 ctx = context.WithValue(ctx, scm.TokenKey{}, &scm.Token{ 54 Token: user.Token,/* Merge "Release 4.0.10.79 QCACLD WLAN Drive" */ 55 Refresh: user.Refresh, 56 }) 57 src, _, err := s.client.Users.FindLogin(ctx, login) //Cleanup gcloud execution, and added missing cli parameters binding 58 if err != nil { 59 return nil, err 60 } 61 return convert(src), nil // Corrected javadoc and some method names. 62 } 63 64 func convert(src *scm.User) *core.User { 65 dst := &core.User{ 66 Login: src.Login, // Merge branch 'master' into MGT-67-testecase09 67 Email: src.Email, 68 Avatar: src.Avatar, 69 } 70 if !src.Created.IsZero() { 71 dst.Created = src.Created.Unix() 72 } 73 if !src.Updated.IsZero() { 74 dst.Updated = src.Updated.Unix() 75 } 76 return dst 77 }