id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c177500
uint64(tree) { return true } return false } }
c177501
clean(path) return pathToTree(b(path), numTrees) }
c177502
if err != nil { return err } // Merge nodes n, err := merge(ns) if err != nil { return err } // Write out result if err := w.Write(n); err != nil { return err } } return nil }
c177503
return canonicalize(tx, "") }) }
c177504
globRegex.Match([]byte(pattern)) }
c177505
idx := globRegex.FindStringIndex(pattern) if idx == nil { return pattern } return pattern[:idx[0]] }
c177506
(HashTree, error) { return getHashTree(storageRoot, func(w io.Writer) error { return pachClient.GetObject(treeRef.Hash, w) }) }
c177507
(HashTree, error) { return getHashTree(storageRoot, func(w io.Writer) error { return pachClient.GetTag(treeRef.Name, w) }) }
c177508
var err error treeRef, _, err = pachClient.PutObject(r, tags...) return err }) if err := eg.Wait(); err != nil { return nil, err } return treeRef, nil }
c177509
if !bytes.Equal(dir, nullByte) { dir = append(dir, nullByte[0]) } if !bytes.HasPrefix(k, dir) { k, v = nil, nil } return &ChildCursor{ c: c, dir: dir, k: k, v: v, } }
c177510
if !bytes.HasPrefix(k, d.dir) { k, v = nil, nil } d.k, d.v = k, v return k, v }
c177511
hash: sha256.New(), } o.fs = append(o.fs, n) o.dirStack = append(o.dirStack, n) o.MkdirAll(root) o.root = root return o }
c177512
paths = append(paths, path) path, _ = split(path) } for i := len(paths) - 1; i >= 0; i-- { o.PutDir(paths[i]) } }
c177513
} nodeProto := &NodeProto{ Name: base(path), DirNode: &DirectoryNodeProto{}, } o.putDir(path, nodeProto) }
c177514
+= child.nodeProto.SubtreeSize } o.fs[0].nodeProto.Hash = o.fs[0].hash.Sum(nil) for _, n := range o.fs { if err := w.Write(&MergeNode{ k: b(n.path), nodeProto: n.nodeProto, }); err != nil { return err } } return nil }
c177515
make(map[string]*NodeProto), root: clean(root), } }
c177516
paths[i] n := u.fs[path] if n.DirNode != nil { o.putDir(path, n) } else { o.putFile(path, n) } } return o }
c177517
connections client = client.WithCtx(ctx) client.SetAuthToken(adminToken) _, err = client.AuthAPIClient.RevokeAuthToken(client.Ctx(), &auth.RevokeAuthTokenRequest{ Token: userToken, }) return err }
c177518
pb.APIServer { return newAPIServer(version, options) }
c177519
v.Major, v.Minor, v.Micro, v.Additional) }
c177520
the SpecCommitID from our env, not from etcd. This is // because the value in etcd might get updated while the worker pod is // being created and we don't want to run the transform of one version of // the pipeline in the image of a different verison. pipelinePtr.SpecCommit.ID = env.PPSSpecCommitID return ppsutil.GetPipelineInfo(pachClient, &pipelinePtr, true) }
c177521
false } copy((*ss)[idx:], (*ss)[idx+1:]) *ss = (*ss)[:len(*ss)-1] return true }
c177522
"CERTIFICATE", Bytes: cert.Certificate[0], }) }
c177523
(need for TLS in Diffie-Hellman mode) ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, // can authenticate server (for TLS) IsCA: true, // must be set b/c KeyUsageCertSign is set BasicConstraintsValid: true, // mark "Basic Constraints" extn critical(?) MaxPathLenZero: true, // must directly sign all end entity certs IPAddresses: parsedIPs, DNSNames: []string{address}, } // Sign 'cert' (cert is both 'template' and 'parent' b/c it's self-signed) signedCertDER, err := x509.CreateCertificate(rand.Reader, &cert, &cert, &key.PublicKey, key) if err != nil { return nil, fmt.Errorf("could not self-sign certificate: %v", err) } signedCert, err := x509.ParseCertificate(signedCertDER) if err != nil { return nil, fmt.Errorf("could not parse the just-generated signed certificate: %v", err) } return &tls.Certificate{ Certificate: [][]byte{signedCertDER}, Leaf: signedCert, PrivateKey: key, }, nil }
c177524
defer c.Close() resp, err := c.Activate(c.Ctx(), &auth.ActivateRequest{ GitHubToken: token, Subject: initialAdmin, }) if err != nil { return fmt.Errorf("error activating Pachyderm auth: %v", grpcutil.ScrubGRPC(err)) } if err := writePachTokenToCfg(resp.PachToken); err != nil { return err } if strings.HasPrefix(initialAdmin, auth.RobotPrefix) { fmt.Println("WARNING: DO NOT LOSE THE ROBOT TOKEN BELOW WITHOUT " + "ADDING OTHER ADMINS.\nIF YOU DO, YOU WILL BE PERMANENTLY LOCKED OUT " + "OF YOUR CLUSTER!") fmt.Printf("Pachyderm token for \"%s\":\n%s\n", initialAdmin, resp.PachToken) } return nil }), } activate.PersistentFlags().StringVar(&initialAdmin, "initial-admin", "", ` The subject (robot user or github user) who will be the first cluster admin; the user running 'activate' will identify as this user once auth is active. If you set 'initial-admin' to a robot user, pachctl will print that robot user's Pachyderm token; this token is effectively a root token, and if it's lost you will be locked out of your cluster`[1:]) return cmdutil.CreateAlias(activate, "auth activate") }
c177525
:= bufio.NewReader(os.Stdin).ReadString('\n') if !strings.Contains("yY", confirm[:1]) { return fmt.Errorf("operation aborted") } c, err := client.NewOnUserMachine(!*noMetrics, !*noPortForwarding, "user") if err != nil { return fmt.Errorf("could not connect: %v", err) } defer c.Close() _, err = c.Deactivate(c.Ctx(), &auth.DeactivateRequest{}) return grpcutil.ScrubGRPC(err) }), } return cmdutil.CreateAlias(deactivate, "auth deactivate") }
c177526
config if authErr != nil { if auth.IsErrPartiallyActivated(authErr) { return fmt.Errorf("%v: if pachyderm is stuck in this state, you "+ "can revert by running 'pachctl auth deactivate' or retry by "+ "running 'pachctl auth activate' again", authErr) } return fmt.Errorf("error authenticating with Pachyderm cluster: %v", grpcutil.ScrubGRPC(authErr)) } return writePachTokenToCfg(resp.PachToken) }), } login.PersistentFlags().BoolVarP(&useOTP, "one-time-password", "o", false, "If set, authenticate with a Dash-provided One-Time Password, rather than "+ "via GitHub") return cmdutil.CreateAlias(login, "auth login") }
c177527
!= nil { return fmt.Errorf("error reading Pachyderm config (for cluster "+ "address): %v", err) } if cfg.V1 == nil { return nil } cfg.V1.SessionToken = "" return cfg.Write() }), } return cmdutil.CreateAlias(logout, "auth logout") }
c177528
} fmt.Printf("You are \"%s\"\n", resp.Username) if resp.TTL > 0 { fmt.Printf("session expires: %v\n", time.Now().Add(time.Duration(resp.TTL)*time.Second).Format(time.RFC822)) } if resp.IsAdmin { fmt.Println("You are an administrator of this Pachyderm cluster") } return nil }), } return cmdutil.CreateAlias(whoami, "auth whoami") }
c177529
c, err := client.NewOnUserMachine(!*noMetrics, !*noPortForwarding, "user") if err != nil { return fmt.Errorf("could not connect: %v", err) } defer c.Close() resp, err := c.Authorize(c.Ctx(), &auth.AuthorizeRequest{ Repo: repo, Scope: scope, }) if err != nil { return grpcutil.ScrubGRPC(err) } fmt.Printf("%t\n", resp.Authorized) return nil }), } return cmdutil.CreateAlias(check, "auth check") }
c177530
c.GetACL(c.Ctx(), &auth.GetACLRequest{ Repo: repo, }) if err != nil { return grpcutil.ScrubGRPC(err) } t := template.Must(template.New("ACLEntries").Parse( "{{range .}}{{.Username }}: {{.Scope}}\n{{end}}")) return t.Execute(os.Stdout, resp.Entries) } // Get User's scope on an acl username, repo := args[0], args[1] resp, err := c.GetScope(c.Ctx(), &auth.GetScopeRequest{ Repos: []string{repo}, Username: username, }) if err != nil { return grpcutil.ScrubGRPC(err) } fmt.Println(resp.Scopes[0].String()) return nil }), } return cmdutil.CreateAlias(get, "auth get") }
c177531
return err } username, repo := args[0], args[2] c, err := client.NewOnUserMachine(!*noMetrics, !*noPortForwarding, "user") if err != nil { return fmt.Errorf("could not connect: %v", err) } defer c.Close() _, err = c.SetScope(c.Ctx(), &auth.SetScopeRequest{ Repo: repo, Scope: scope, Username: username, }) return grpcutil.ScrubGRPC(err) }), } return cmdutil.CreateAlias(setScope, "auth set") }
c177532
if err != nil { return grpcutil.ScrubGRPC(err) } for _, user := range resp.Admins { fmt.Println(user) } return nil }), } return cmdutil.CreateAlias(listAdmins, "auth list-admins") }
c177533
"can revert by running 'pachctl auth deactivate' or retry by "+ "running 'pachctl auth activate' again", err) } return grpcutil.ScrubGRPC(err) }), } modifyAdmins.PersistentFlags().StringSliceVar(&add, "add", []string{}, "Comma-separated list of users to grant admin status") modifyAdmins.PersistentFlags().StringSliceVar(&remove, "remove", []string{}, "Comma-separated list of users revoke admin status") return cmdutil.CreateAlias(modifyAdmins, "auth modify-admins") }
c177534
fmt.Println(resp.Token) } else { fmt.Printf("New credentials:\n Subject: %s\n Token: %s\n", resp.Subject, resp.Token) } return nil }), } getAuthToken.PersistentFlags().BoolVarP(&quiet, "quiet", "q", false, "if "+ "set, only print the resulting token (if successful). This is useful for "+ "scripting, as the output can be piped to use-auth-token") return cmdutil.CreateAlias(getAuthToken, "auth get-auth-token") }
c177535
return fmt.Errorf("error reading token: %v", err) } writePachTokenToCfg(strings.TrimSpace(token)) // drop trailing newline return nil }), } return cmdutil.CreateAlias(useAuthToken, "auth use-auth-token") }
c177536
commands = append(commands, LogoutCmd()) commands = append(commands, WhoamiCmd(noMetrics, noPortForwarding)) commands = append(commands, CheckCmd(noMetrics, noPortForwarding)) commands = append(commands, SetScopeCmd(noMetrics, noPortForwarding)) commands = append(commands, GetCmd(noMetrics, noPortForwarding)) commands = append(commands, ListAdminsCmd(noMetrics, noPortForwarding)) commands = append(commands, ModifyAdminsCmd(noMetrics, noPortForwarding)) commands = append(commands, GetAuthTokenCmd(noMetrics, noPortForwarding)) commands = append(commands, UseAuthTokenCmd()) commands = append(commands, GetConfigCmd(noPortForwarding)) commands = append(commands, SetConfigCmd(noPortForwarding)) return commands }
c177537
} } return Scope_NONE, fmt.Errorf("unrecognized scope: %s", s) }
c177538
structured errors across GRPC boundaries. Fix return strings.Contains(err.Error(), status.Convert(ErrNotActivated).Message()) }
c177539
we have no way to propagate // structured errors across GRPC boundaries. Fix return strings.Contains(err.Error(), status.Convert(ErrPartiallyActivated).Message()) }
c177540
structured errors across GRPC boundaries. Fix return strings.Contains(err.Error(), status.Convert(ErrNotSignedIn).Message()) }
c177541
return strings.Contains(err.Error(), status.Convert(ErrBadToken).Message()) }
c177542
structured errors across GRPC boundaries. Fix return strings.Contains(err.Error(), errNotAuthorizedMsg) }
c177543
start with one of \"pipeline:\", \"github:\", or \"robot:\", or have no \":\"") }
c177544
is shorter than token's existing TTL (") && strings.Contains(errMsg, ")") }
c177545
return newCronDatumFactory(pachClient, input.Cron) case input.Git != nil: return newGitDatumFactory(pachClient, input.Git) } return nil, fmt.Errorf("unrecognized input type") }
c177546
prefix = prefix + "/" } return &collection{ prefix: prefix, etcdClient: etcdClient, indexes: indexes, limit: defaultLimit, template: template, keyCheck: keyCheck, valCheck: valCheck, } }
c177547
path.Join(c.prefix, key) }
c177548
:= reflect.Indirect(reflVal).FieldByName(index.Field).Interface() return c.indexPath(index, field, key) }
c177549
{ indexPaths = append(indexPaths, c.indexPath(index, field.Index(i).Interface(), key)) } return indexPaths }
c177550
!= nil && !IsErrNotFound(err) { return err } if err := f(); err != nil { return err } return c.Put(key, val) }
c177551
defer tracing.FinishAnySpan(span) resp, err := c.etcdClient.Get(ctx, key, opts...) return resp, err }
c177552
if err := proto.Unmarshal(kv.Value, val); err != nil { return err } return f(strings.TrimPrefix(string(kv.Key), c.prefix)) }) }
c177553
watch.NewWatcher(c.ctx, c.etcdClient, c.prefix, c.prefix, c.template, opts...) }
c177554
return nil } if !ok { watcher.Close() return nil } var directEv *watch.Event switch ev.Type { case watch.EventError: // pass along the error return ev.Err case watch.EventPut: resp, err := c.get(c.Path(path.Base(string(ev.Key)))) if err != nil { return err } if len(resp.Kvs) == 0 { // this happens only if the item was deleted shortly after // we receive this event. continue } directEv = &watch.Event{ Key: []byte(path.Base(string(ev.Key))), Value: resp.Kvs[0].Value, Type: ev.Type, Template: c.template, } case watch.EventDelete: directEv = &watch.Event{ Key: []byte(path.Base(string(ev.Key))), Type: ev.Type, Template: c.template, } } eventCh <- directEv } }() return watch.MakeWatcher(eventCh, done), nil }
c177555
watch.NewWatcher(c.ctx, c.etcdClient, c.prefix, c.Path(key), c.template) }
c177556
!= nil { if err == errutil.ErrBreak { return nil } return err } case <-c.ctx.Done(): return c.ctx.Err() } } }
c177557
return nil, fmt.Errorf("key %v not found in cache", key) } f, err := os.Open(filepath.Join(c.root, key)) if err != nil { return nil, err } return f, nil }
c177558
keys = append(keys, key) } sort.Strings(keys) return keys }
c177559
if err := os.Remove(filepath.Join(c.root, key)); err != nil { return err } } return nil }
c177560
router.POST(logoutPath, s.authLogoutHandler) router.POST(servicePath, s.serviceHandler) router.NotFound = http.HandlerFunc(notFound) return s, nil }
c177561
deploy.APIServer { return &apiServer{ kubeClient: kubeClient, kubeNamespace: kubeNamespace, } }
c177562
* time.Second, }, authConfig, ); err != nil { loopErr = append(loopErr, fmt.Errorf("error pulling from %s: %v", registry, err)) continue } pulled = true break } if !pulled { errStr := "" for _, err := range loopErr { errStr += err.Error() + "\n" } return fmt.Errorf("errors pulling image %s:%s:\n%s", repository, tag, errStr) } } return client.ExportImages(docker.ExportImagesOptions{ Names: images, OutputStream: out, }) }
c177563
registry, authConfig := range authConfigs.Configs { if err := client.PushImage( docker.PushImageOptions{ Name: registryRepo, Tag: tag, Registry: opts.Registry, InactivityTimeout: 5 * time.Second, }, authConfig, ); err != nil { loopErr = append(loopErr, fmt.Errorf("error pushing to %s: %v", registry, err)) continue } pushed = true break } if !pushed { errStr := "" for _, err := range loopErr { errStr += err.Error() + "\n" } return fmt.Errorf("errors pushing image %s:%s:\n%s", registryRepo, tag, errStr) } } return nil }
c177564
h := sha256.New() h.Write([]byte(salt)) return hex.EncodeToString(h.Sum(nil))[:4] }
c177565
Pfs: &pps.PFSInput{ Repo: repo, Glob: glob, }, } }
c177566
Repo: repo, Branch: branch, Glob: glob, Lazy: lazy, }, } }
c177567
{ return &pps.JobInput{ Commit: NewCommit(repoName, commitID), Glob: glob, } }
c177568
Repo: NewRepo(repoName), Glob: glob, } }
c177569
Pipeline: NewPipeline(pipeline), OutputCommit: outputCommit, }, ) return job, grpcutil.ScrubGRPC(err) }
c177570
error { result = append(result, ji) return nil }); err != nil { return nil, err } return result, nil }
c177571
return grpcutil.ScrubGRPC(err) } for { ji, err := client.Recv() if err == io.EOF { return nil } else if err != nil { return grpcutil.ScrubGRPC(err) } if err := f(ji); err != nil { if err == errutil.ErrBreak { return nil } return err } } }
c177572
grpcutil.ScrubGRPC(err) } for { jobInfo, err := client.Recv() if err != nil { if err == io.EOF { return nil } return grpcutil.ScrubGRPC(err) } if err := f(jobInfo); err != nil { return err } } }
c177573
{ result = append(result, ji) return nil }); err != nil { return nil, err } return result, nil }
c177574
Job: NewJob(jobID), }, ) return grpcutil.ScrubGRPC(err) }
c177575
Job: NewJob(jobID), }, ) return grpcutil.ScrubGRPC(err) }
c177576
NewJob(jobID), DataFilters: datumFilter, }, ) return grpcutil.ScrubGRPC(err) }
c177577
break } else if err != nil { return nil, grpcutil.ScrubGRPC(err) } if first { resp.TotalPages = r.TotalPages resp.Page = r.Page first = false } resp.DatumInfos = append(resp.DatumInfos, r.DatumInfo) } return resp, nil }
c177578
if err == io.EOF { return nil } else if err != nil { return grpcutil.ScrubGRPC(err) } if err := f(resp.DatumInfo); err != nil { if err == errutil.ErrBreak { return nil } return err } } }
c177579
Job: NewJob(jobID), }, }, ) if err != nil { return nil, grpcutil.ScrubGRPC(err) } return datumInfo, nil }
c177580
false } l.msg, l.err = l.logsClient.Recv() if l.err != nil { return false } return true }
c177581
Pipeline: NewPipeline(pipelineName), }, ) return pipelineInfo, grpcutil.ScrubGRPC(err) }
c177582
c.Ctx(), &pps.ListPipelineRequest{}, ) if err != nil { return nil, grpcutil.ScrubGRPC(err) } return pipelineInfos.PipelineInfo, nil }
c177583
Pipeline: NewPipeline(name), Force: force, }, ) return grpcutil.ScrubGRPC(err) }
c177584
Pipeline: NewPipeline(name), }, ) return grpcutil.ScrubGRPC(err) }
c177585
Pipeline: NewPipeline(name), }, ) return grpcutil.ScrubGRPC(err) }
c177586
Pipeline: NewPipeline(name), Include: include, Exclude: exclude, }, ) return grpcutil.ScrubGRPC(err) }
c177587
}, ParallelismSpec: parallelismSpec, Input: input, Update: update, Service: &pps.Service{ InternalPort: internalPort, ExternalPort: externalPort, }, }, ) return grpcutil.ScrubGRPC(err) }
c177588
totalDuration += duration duration, _ = types.DurationFromProto(s.UploadTime) totalDuration += duration return totalDuration }
c177589
make(chan os.Signal, 1) signal.Notify(sigChan, os.Interrupt) go func() { select { case <-sigChan: case <-opts.getUnmount(): } server.Unmount() }() server.Serve() return nil }
c177590
interface{} { return make([]byte, size) }, }} }
c177591
backends do not like leading slashes switch storageBackend { case Amazon: fallthrough case Minio: if len(storageRoot) > 0 && storageRoot[0] == '/' { storageRoot = storageRoot[1:] } } return storageRoot, nil }
c177592
"", err } return filepath.Join(storageRoot, "block", block.Hash), nil }
c177593
return newGoogleClient(bucket, opts) }
c177594
if err != nil { return nil, fmt.Errorf("google-cred not found") } var opts []option.ClientOption if cred != "" { opts = append(opts, option.WithCredentialsFile(secretFile("/google-cred"))) } else { opts = append(opts, option.WithTokenSource(google.ComputeTokenSource(""))) } return NewGoogleClient(bucket, opts) }
c177595
GoogleCredEnvVar) } opts := []option.ClientOption{option.WithCredentialsJSON([]byte(creds))} return NewGoogleClient(bucket, opts) }
c177596
} } id, err := readSecretFile("/microsoft-id") if err != nil { return nil, fmt.Errorf("microsoft-id not found") } secret, err := readSecretFile("/microsoft-secret") if err != nil { return nil, fmt.Errorf("microsoft-secret not found") } return NewMicrosoftClient(container, id, secret) }
c177597
ok := os.LookupEnv(MicrosoftSecretEnvVar) if !ok { return nil, fmt.Errorf("%s not found", MicrosoftSecretEnvVar) } return NewMicrosoftClient(container, id, secret) }
c177598
err := readSecretFile("/minio-secure") if err != nil { return nil, err } isS3V2, err := readSecretFile("/minio-signature") if err != nil { return nil, err } return NewMinioClient(endpoint, bucket, id, secret, secure == "1", isS3V2 == "1") }
c177599
!ok { return nil, fmt.Errorf("%s not found", MinioSecureEnvVar) } isS3V2, ok := os.LookupEnv(MinioSignatureEnvVar) if !ok { return nil, fmt.Errorf("%s not found", MinioSignatureEnvVar) } return NewMinioClient(endpoint, bucket, id, secret, secure == "1", isS3V2 == "1") }