repo
stringlengths
5
67
path
stringlengths
4
218
func_name
stringlengths
0
151
original_string
stringlengths
52
373k
language
stringclasses
6 values
code
stringlengths
52
373k
code_tokens
listlengths
10
512
docstring
stringlengths
3
47.2k
docstring_tokens
listlengths
3
234
sha
stringlengths
40
40
url
stringlengths
85
339
partition
stringclasses
3 values
pachyderm/pachyderm
src/server/pkg/hashtree/db.go
PutDir
func (o *Ordered) PutDir(path string) { path = clean(path) if path == "" { return } nodeProto := &NodeProto{ Name: base(path), DirNode: &DirectoryNodeProto{}, } o.putDir(path, nodeProto) }
go
func (o *Ordered) PutDir(path string) { path = clean(path) if path == "" { return } nodeProto := &NodeProto{ Name: base(path), DirNode: &DirectoryNodeProto{}, } o.putDir(path, nodeProto) }
[ "func", "(", "o", "*", "Ordered", ")", "PutDir", "(", "path", "string", ")", "{", "path", "=", "clean", "(", "path", ")", "\n", "if", "path", "==", "\"\"", "{", "return", "\n", "}", "\n", "nodeProto", ":=", "&", "NodeProto", "{", "Name", ":", "base", "(", "path", ")", ",", "DirNode", ":", "&", "DirectoryNodeProto", "{", "}", ",", "}", "\n", "o", ".", "putDir", "(", "path", ",", "nodeProto", ")", "\n", "}" ]
// PutDir puts a directory in the hashtree.
[ "PutDir", "puts", "a", "directory", "in", "the", "hashtree", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/hashtree/db.go#L1664-L1674
test
pachyderm/pachyderm
src/server/pkg/hashtree/db.go
Serialize
func (o *Ordered) Serialize(_w io.Writer) error { w := NewWriter(_w) // Unwind directory stack for len(o.dirStack) > 1 { child := o.dirStack[len(o.dirStack)-1] child.nodeProto.Hash = child.hash.Sum(nil) o.dirStack = o.dirStack[:len(o.dirStack)-1] parent := o.dirStack[len(o.dirStack)-1] parent.hash.Write([]byte(fmt.Sprintf("%s:%s:", child.nodeProto.Name, child.nodeProto.Hash))) parent.nodeProto.SubtreeSize += 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 }
go
func (o *Ordered) Serialize(_w io.Writer) error { w := NewWriter(_w) // Unwind directory stack for len(o.dirStack) > 1 { child := o.dirStack[len(o.dirStack)-1] child.nodeProto.Hash = child.hash.Sum(nil) o.dirStack = o.dirStack[:len(o.dirStack)-1] parent := o.dirStack[len(o.dirStack)-1] parent.hash.Write([]byte(fmt.Sprintf("%s:%s:", child.nodeProto.Name, child.nodeProto.Hash))) parent.nodeProto.SubtreeSize += 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 }
[ "func", "(", "o", "*", "Ordered", ")", "Serialize", "(", "_w", "io", ".", "Writer", ")", "error", "{", "w", ":=", "NewWriter", "(", "_w", ")", "\n", "for", "len", "(", "o", ".", "dirStack", ")", ">", "1", "{", "child", ":=", "o", ".", "dirStack", "[", "len", "(", "o", ".", "dirStack", ")", "-", "1", "]", "\n", "child", ".", "nodeProto", ".", "Hash", "=", "child", ".", "hash", ".", "Sum", "(", "nil", ")", "\n", "o", ".", "dirStack", "=", "o", ".", "dirStack", "[", ":", "len", "(", "o", ".", "dirStack", ")", "-", "1", "]", "\n", "parent", ":=", "o", ".", "dirStack", "[", "len", "(", "o", ".", "dirStack", ")", "-", "1", "]", "\n", "parent", ".", "hash", ".", "Write", "(", "[", "]", "byte", "(", "fmt", ".", "Sprintf", "(", "\"%s:%s:\"", ",", "child", ".", "nodeProto", ".", "Name", ",", "child", ".", "nodeProto", ".", "Hash", ")", ")", ")", "\n", "parent", ".", "nodeProto", ".", "SubtreeSize", "+=", "child", ".", "nodeProto", ".", "SubtreeSize", "\n", "}", "\n", "o", ".", "fs", "[", "0", "]", ".", "nodeProto", ".", "Hash", "=", "o", ".", "fs", "[", "0", "]", ".", "hash", ".", "Sum", "(", "nil", ")", "\n", "for", "_", ",", "n", ":=", "range", "o", ".", "fs", "{", "if", "err", ":=", "w", ".", "Write", "(", "&", "MergeNode", "{", "k", ":", "b", "(", "n", ".", "path", ")", ",", "nodeProto", ":", "n", ".", "nodeProto", ",", "}", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Serialize serializes an ordered hashtree.
[ "Serialize", "serializes", "an", "ordered", "hashtree", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/hashtree/db.go#L1725-L1746
test
pachyderm/pachyderm
src/server/pkg/hashtree/db.go
NewUnordered
func NewUnordered(root string) *Unordered { return &Unordered{ fs: make(map[string]*NodeProto), root: clean(root), } }
go
func NewUnordered(root string) *Unordered { return &Unordered{ fs: make(map[string]*NodeProto), root: clean(root), } }
[ "func", "NewUnordered", "(", "root", "string", ")", "*", "Unordered", "{", "return", "&", "Unordered", "{", "fs", ":", "make", "(", "map", "[", "string", "]", "*", "NodeProto", ")", ",", "root", ":", "clean", "(", "root", ")", ",", "}", "\n", "}" ]
// NewUnordered creates a new unordered hashtree.
[ "NewUnordered", "creates", "a", "new", "unordered", "hashtree", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/hashtree/db.go#L1755-L1760
test
pachyderm/pachyderm
src/server/pkg/hashtree/db.go
Ordered
func (u *Unordered) Ordered() *Ordered { paths := make([]string, len(u.fs)) i := 0 for path := range u.fs { paths[i] = path i++ } sort.Strings(paths) o := NewOrdered("") for i := 1; i < len(paths); i++ { path := paths[i] n := u.fs[path] if n.DirNode != nil { o.putDir(path, n) } else { o.putFile(path, n) } } return o }
go
func (u *Unordered) Ordered() *Ordered { paths := make([]string, len(u.fs)) i := 0 for path := range u.fs { paths[i] = path i++ } sort.Strings(paths) o := NewOrdered("") for i := 1; i < len(paths); i++ { path := paths[i] n := u.fs[path] if n.DirNode != nil { o.putDir(path, n) } else { o.putFile(path, n) } } return o }
[ "func", "(", "u", "*", "Unordered", ")", "Ordered", "(", ")", "*", "Ordered", "{", "paths", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "u", ".", "fs", ")", ")", "\n", "i", ":=", "0", "\n", "for", "path", ":=", "range", "u", ".", "fs", "{", "paths", "[", "i", "]", "=", "path", "\n", "i", "++", "\n", "}", "\n", "sort", ".", "Strings", "(", "paths", ")", "\n", "o", ":=", "NewOrdered", "(", "\"\"", ")", "\n", "for", "i", ":=", "1", ";", "i", "<", "len", "(", "paths", ")", ";", "i", "++", "{", "path", ":=", "paths", "[", "i", "]", "\n", "n", ":=", "u", ".", "fs", "[", "path", "]", "\n", "if", "n", ".", "DirNode", "!=", "nil", "{", "o", ".", "putDir", "(", "path", ",", "n", ")", "\n", "}", "else", "{", "o", ".", "putFile", "(", "path", ",", "n", ")", "\n", "}", "\n", "}", "\n", "return", "o", "\n", "}" ]
// Ordered converts an unordered hashtree into an ordered hashtree.
[ "Ordered", "converts", "an", "unordered", "hashtree", "into", "an", "ordered", "hashtree", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/hashtree/db.go#L1794-L1813
test
pachyderm/pachyderm
src/plugin/vault/pachyderm/revoke.go
revokeUserCredentials
func revokeUserCredentials(ctx context.Context, pachdAddress string, userToken string, adminToken string) error { // Setup a single use client w the given admin token / address client, err := pclient.NewFromAddress(pachdAddress) if err != nil { return err } defer client.Close() // avoid leaking connections client = client.WithCtx(ctx) client.SetAuthToken(adminToken) _, err = client.AuthAPIClient.RevokeAuthToken(client.Ctx(), &auth.RevokeAuthTokenRequest{ Token: userToken, }) return err }
go
func revokeUserCredentials(ctx context.Context, pachdAddress string, userToken string, adminToken string) error { // Setup a single use client w the given admin token / address client, err := pclient.NewFromAddress(pachdAddress) if err != nil { return err } defer client.Close() // avoid leaking connections client = client.WithCtx(ctx) client.SetAuthToken(adminToken) _, err = client.AuthAPIClient.RevokeAuthToken(client.Ctx(), &auth.RevokeAuthTokenRequest{ Token: userToken, }) return err }
[ "func", "revokeUserCredentials", "(", "ctx", "context", ".", "Context", ",", "pachdAddress", "string", ",", "userToken", "string", ",", "adminToken", "string", ")", "error", "{", "client", ",", "err", ":=", "pclient", ".", "NewFromAddress", "(", "pachdAddress", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "client", ".", "Close", "(", ")", "\n", "client", "=", "client", ".", "WithCtx", "(", "ctx", ")", "\n", "client", ".", "SetAuthToken", "(", "adminToken", ")", "\n", "_", ",", "err", "=", "client", ".", "AuthAPIClient", ".", "RevokeAuthToken", "(", "client", ".", "Ctx", "(", ")", ",", "&", "auth", ".", "RevokeAuthTokenRequest", "{", "Token", ":", "userToken", ",", "}", ")", "\n", "return", "err", "\n", "}" ]
// revokeUserCredentials revokes the Pachyderm authentication token 'userToken' // using the vault plugin's Admin credentials.
[ "revokeUserCredentials", "revokes", "the", "Pachyderm", "authentication", "token", "userToken", "using", "the", "vault", "plugin", "s", "Admin", "credentials", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/plugin/vault/pachyderm/revoke.go#L57-L71
test
pachyderm/pachyderm
src/client/version/api_server.go
NewAPIServer
func NewAPIServer(version *pb.Version, options APIServerOptions) pb.APIServer { return newAPIServer(version, options) }
go
func NewAPIServer(version *pb.Version, options APIServerOptions) pb.APIServer { return newAPIServer(version, options) }
[ "func", "NewAPIServer", "(", "version", "*", "pb", ".", "Version", ",", "options", "APIServerOptions", ")", "pb", ".", "APIServer", "{", "return", "newAPIServer", "(", "version", ",", "options", ")", "\n", "}" ]
// NewAPIServer creates a new APIServer for the given Version.
[ "NewAPIServer", "creates", "a", "new", "APIServer", "for", "the", "given", "Version", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/version/api_server.go#L32-L34
test
pachyderm/pachyderm
src/client/version/api_server.go
String
func String(v *pb.Version) string { return fmt.Sprintf("%d.%d.%d%s", v.Major, v.Minor, v.Micro, v.Additional) }
go
func String(v *pb.Version) string { return fmt.Sprintf("%d.%d.%d%s", v.Major, v.Minor, v.Micro, v.Additional) }
[ "func", "String", "(", "v", "*", "pb", ".", "Version", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"%d.%d.%d%s\"", ",", "v", ".", "Major", ",", "v", ".", "Minor", ",", "v", ".", "Micro", ",", "v", ".", "Additional", ")", "\n", "}" ]
// String returns a string representation of the Version.
[ "String", "returns", "a", "string", "representation", "of", "the", "Version", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/version/api_server.go#L45-L47
test
pachyderm/pachyderm
src/server/cmd/worker/main.go
getPipelineInfo
func getPipelineInfo(pachClient *client.APIClient, env *serviceenv.ServiceEnv) (*pps.PipelineInfo, error) { ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() resp, err := env.GetEtcdClient().Get(ctx, path.Join(env.PPSEtcdPrefix, "pipelines", env.PPSPipelineName)) if err != nil { return nil, err } if len(resp.Kvs) != 1 { return nil, fmt.Errorf("expected to find 1 pipeline (%s), got %d: %v", env.PPSPipelineName, len(resp.Kvs), resp) } var pipelinePtr pps.EtcdPipelineInfo if err := pipelinePtr.Unmarshal(resp.Kvs[0].Value); err != nil { return nil, err } pachClient.SetAuthToken(pipelinePtr.AuthToken) // Notice we use 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) }
go
func getPipelineInfo(pachClient *client.APIClient, env *serviceenv.ServiceEnv) (*pps.PipelineInfo, error) { ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() resp, err := env.GetEtcdClient().Get(ctx, path.Join(env.PPSEtcdPrefix, "pipelines", env.PPSPipelineName)) if err != nil { return nil, err } if len(resp.Kvs) != 1 { return nil, fmt.Errorf("expected to find 1 pipeline (%s), got %d: %v", env.PPSPipelineName, len(resp.Kvs), resp) } var pipelinePtr pps.EtcdPipelineInfo if err := pipelinePtr.Unmarshal(resp.Kvs[0].Value); err != nil { return nil, err } pachClient.SetAuthToken(pipelinePtr.AuthToken) // Notice we use 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) }
[ "func", "getPipelineInfo", "(", "pachClient", "*", "client", ".", "APIClient", ",", "env", "*", "serviceenv", ".", "ServiceEnv", ")", "(", "*", "pps", ".", "PipelineInfo", ",", "error", ")", "{", "ctx", ",", "cancel", ":=", "context", ".", "WithTimeout", "(", "context", ".", "Background", "(", ")", ",", "30", "*", "time", ".", "Second", ")", "\n", "defer", "cancel", "(", ")", "\n", "resp", ",", "err", ":=", "env", ".", "GetEtcdClient", "(", ")", ".", "Get", "(", "ctx", ",", "path", ".", "Join", "(", "env", ".", "PPSEtcdPrefix", ",", "\"pipelines\"", ",", "env", ".", "PPSPipelineName", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "len", "(", "resp", ".", "Kvs", ")", "!=", "1", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"expected to find 1 pipeline (%s), got %d: %v\"", ",", "env", ".", "PPSPipelineName", ",", "len", "(", "resp", ".", "Kvs", ")", ",", "resp", ")", "\n", "}", "\n", "var", "pipelinePtr", "pps", ".", "EtcdPipelineInfo", "\n", "if", "err", ":=", "pipelinePtr", ".", "Unmarshal", "(", "resp", ".", "Kvs", "[", "0", "]", ".", "Value", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "pachClient", ".", "SetAuthToken", "(", "pipelinePtr", ".", "AuthToken", ")", "\n", "pipelinePtr", ".", "SpecCommit", ".", "ID", "=", "env", ".", "PPSSpecCommitID", "\n", "return", "ppsutil", ".", "GetPipelineInfo", "(", "pachClient", ",", "&", "pipelinePtr", ",", "true", ")", "\n", "}" ]
// getPipelineInfo gets the PipelineInfo proto describing the pipeline that this // worker is part of. // getPipelineInfo has the side effect of adding auth to the passed pachClient // which is necessary to get the PipelineInfo from pfs.
[ "getPipelineInfo", "gets", "the", "PipelineInfo", "proto", "describing", "the", "pipeline", "that", "this", "worker", "is", "part", "of", ".", "getPipelineInfo", "has", "the", "side", "effect", "of", "adding", "auth", "to", "the", "passed", "pachClient", "which", "is", "necessary", "to", "get", "the", "PipelineInfo", "from", "pfs", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/cmd/worker/main.go#L104-L125
test
pachyderm/pachyderm
src/server/pkg/hashtree/sorted_list.go
removeStr
func removeStr(ss *[]string, s string) bool { idx := sort.SearchStrings(*ss, s) if idx == len(*ss) { return false } copy((*ss)[idx:], (*ss)[idx+1:]) *ss = (*ss)[:len(*ss)-1] return true }
go
func removeStr(ss *[]string, s string) bool { idx := sort.SearchStrings(*ss, s) if idx == len(*ss) { return false } copy((*ss)[idx:], (*ss)[idx+1:]) *ss = (*ss)[:len(*ss)-1] return true }
[ "func", "removeStr", "(", "ss", "*", "[", "]", "string", ",", "s", "string", ")", "bool", "{", "idx", ":=", "sort", ".", "SearchStrings", "(", "*", "ss", ",", "s", ")", "\n", "if", "idx", "==", "len", "(", "*", "ss", ")", "{", "return", "false", "\n", "}", "\n", "copy", "(", "(", "*", "ss", ")", "[", "idx", ":", "]", ",", "(", "*", "ss", ")", "[", "idx", "+", "1", ":", "]", ")", "\n", "*", "ss", "=", "(", "*", "ss", ")", "[", ":", "len", "(", "*", "ss", ")", "-", "1", "]", "\n", "return", "true", "\n", "}" ]
// removeStr removes 's' from 'ss', preserving the sorted order of 'ss' (for // removing child strings from DirectoryNodes.
[ "removeStr", "removes", "s", "from", "ss", "preserving", "the", "sorted", "order", "of", "ss", "(", "for", "removing", "child", "strings", "from", "DirectoryNodes", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/hashtree/sorted_list.go#L54-L62
test
pachyderm/pachyderm
src/server/pkg/cert/cert.go
PublicCertToPEM
func PublicCertToPEM(cert *tls.Certificate) []byte { return pem.EncodeToMemory(&pem.Block{ Type: "CERTIFICATE", Bytes: cert.Certificate[0], }) }
go
func PublicCertToPEM(cert *tls.Certificate) []byte { return pem.EncodeToMemory(&pem.Block{ Type: "CERTIFICATE", Bytes: cert.Certificate[0], }) }
[ "func", "PublicCertToPEM", "(", "cert", "*", "tls", ".", "Certificate", ")", "[", "]", "byte", "{", "return", "pem", ".", "EncodeToMemory", "(", "&", "pem", ".", "Block", "{", "Type", ":", "\"CERTIFICATE\"", ",", "Bytes", ":", "cert", ".", "Certificate", "[", "0", "]", ",", "}", ")", "\n", "}" ]
// PublicCertToPEM serializes the public x509 cert in 'cert' to a PEM-formatted // block
[ "PublicCertToPEM", "serializes", "the", "public", "x509", "cert", "in", "cert", "to", "a", "PEM", "-", "formatted", "block" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/cert/cert.go#L29-L34
test
pachyderm/pachyderm
src/server/pkg/cert/cert.go
GenerateSelfSignedCert
func GenerateSelfSignedCert(address string, name *pkix.Name, ipAddresses ...string) (*tls.Certificate, error) { // Generate Subject Distinguished Name if name == nil { name = &pkix.Name{} } switch { case address == "" && name.CommonName == "": return nil, errors.New("must set either \"address\" or \"name.CommonName\"") case address != "" && name.CommonName == "": name.CommonName = address case address != "" && name.CommonName != "" && name.CommonName != address: return nil, fmt.Errorf("set address to \"%s\" but name.CommonName to \"%s\"", address, name.CommonName) default: // name.CommonName is already valid--nothing to do } // Parse IPs in ipAddresses parsedIPs := []net.IP{} for _, strIP := range ipAddresses { nextParsedIP := net.ParseIP(strIP) if nextParsedIP == nil { return nil, fmt.Errorf("invalid IP: %s", strIP) } parsedIPs = append(parsedIPs, nextParsedIP) } // Generate key pair. According to // https://security.stackexchange.com/questions/5096/rsa-vs-dsa-for-ssh-authentication-keys // RSA is likely to be faster and more secure in practice than DSA/ECDSA, so // this only generates RSA keys key, err := rsa.GenerateKey(rand.Reader, rsaKeySize) if err != nil { return nil, fmt.Errorf("could not generate RSA private key: %v", err) } // Generate unsigned cert cert := x509.Certificate{ // the x509 spec requires every x509 cert must have a serial number that is // unique for the signing CA. All of the certs generated by this package // are self-signed, so this just starts at 1 and counts up SerialNumber: big.NewInt(atomic.AddInt64(&serialNumber, 1)), Subject: *name, NotBefore: time.Now().Add(-1 * time.Second), NotAfter: time.Now().Add(validDur), KeyUsage: x509.KeyUsageCertSign | // can sign certs (need for self-signing) x509.KeyUsageKeyEncipherment | // can encrypt other keys (need for TLS in symmetric mode) x509.KeyUsageKeyAgreement, // can establish keys (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 }
go
func GenerateSelfSignedCert(address string, name *pkix.Name, ipAddresses ...string) (*tls.Certificate, error) { // Generate Subject Distinguished Name if name == nil { name = &pkix.Name{} } switch { case address == "" && name.CommonName == "": return nil, errors.New("must set either \"address\" or \"name.CommonName\"") case address != "" && name.CommonName == "": name.CommonName = address case address != "" && name.CommonName != "" && name.CommonName != address: return nil, fmt.Errorf("set address to \"%s\" but name.CommonName to \"%s\"", address, name.CommonName) default: // name.CommonName is already valid--nothing to do } // Parse IPs in ipAddresses parsedIPs := []net.IP{} for _, strIP := range ipAddresses { nextParsedIP := net.ParseIP(strIP) if nextParsedIP == nil { return nil, fmt.Errorf("invalid IP: %s", strIP) } parsedIPs = append(parsedIPs, nextParsedIP) } // Generate key pair. According to // https://security.stackexchange.com/questions/5096/rsa-vs-dsa-for-ssh-authentication-keys // RSA is likely to be faster and more secure in practice than DSA/ECDSA, so // this only generates RSA keys key, err := rsa.GenerateKey(rand.Reader, rsaKeySize) if err != nil { return nil, fmt.Errorf("could not generate RSA private key: %v", err) } // Generate unsigned cert cert := x509.Certificate{ // the x509 spec requires every x509 cert must have a serial number that is // unique for the signing CA. All of the certs generated by this package // are self-signed, so this just starts at 1 and counts up SerialNumber: big.NewInt(atomic.AddInt64(&serialNumber, 1)), Subject: *name, NotBefore: time.Now().Add(-1 * time.Second), NotAfter: time.Now().Add(validDur), KeyUsage: x509.KeyUsageCertSign | // can sign certs (need for self-signing) x509.KeyUsageKeyEncipherment | // can encrypt other keys (need for TLS in symmetric mode) x509.KeyUsageKeyAgreement, // can establish keys (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 }
[ "func", "GenerateSelfSignedCert", "(", "address", "string", ",", "name", "*", "pkix", ".", "Name", ",", "ipAddresses", "...", "string", ")", "(", "*", "tls", ".", "Certificate", ",", "error", ")", "{", "if", "name", "==", "nil", "{", "name", "=", "&", "pkix", ".", "Name", "{", "}", "\n", "}", "\n", "switch", "{", "case", "address", "==", "\"\"", "&&", "name", ".", "CommonName", "==", "\"\"", ":", "return", "nil", ",", "errors", ".", "New", "(", "\"must set either \\\"address\\\" or \\\"name.CommonName\\\"\"", ")", "\n", "\\\"", "\\\"", "\\\"", "}", "\n", "\\\"", "\n", "case", "address", "!=", "\"\"", "&&", "name", ".", "CommonName", "==", "\"\"", ":", "name", ".", "CommonName", "=", "address", "\n", "\n", "case", "address", "!=", "\"\"", "&&", "name", ".", "CommonName", "!=", "\"\"", "&&", "name", ".", "CommonName", "!=", "address", ":", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"set address to \\\"%s\\\" but name.CommonName to \\\"%s\\\"\"", ",", "\\\"", ",", "\\\"", ")", "\n", "\n", "\\\"", "\n", "\\\"", "\n", "address", "\n", "name", ".", "CommonName", "\n", "default", ":", "\n", "parsedIPs", ":=", "[", "]", "net", ".", "IP", "{", "}", "\n", "for", "_", ",", "strIP", ":=", "range", "ipAddresses", "{", "nextParsedIP", ":=", "net", ".", "ParseIP", "(", "strIP", ")", "\n", "if", "nextParsedIP", "==", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"invalid IP: %s\"", ",", "strIP", ")", "\n", "}", "\n", "parsedIPs", "=", "append", "(", "parsedIPs", ",", "nextParsedIP", ")", "\n", "}", "\n", "}" ]
// GenerateSelfSignedCert generates a self-signed TLS cert for the domain name // 'address', with a private key. Other attributes of the subject can be set in // 'name' and ip addresses can be set in 'ipAddresses'
[ "GenerateSelfSignedCert", "generates", "a", "self", "-", "signed", "TLS", "cert", "for", "the", "domain", "name", "address", "with", "a", "private", "key", ".", "Other", "attributes", "of", "the", "subject", "can", "be", "set", "in", "name", "and", "ip", "addresses", "can", "be", "set", "in", "ipAddresses" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/cert/cert.go#L54-L124
test
pachyderm/pachyderm
src/server/auth/cmds/cmds.go
ActivateCmd
func ActivateCmd(noMetrics, noPortForwarding *bool) *cobra.Command { var initialAdmin string activate := &cobra.Command{ Short: "Activate Pachyderm's auth system", Long: ` Activate Pachyderm's auth system, and restrict access to existing data to the user running the command (or the argument to --initial-admin), who will be the first cluster admin`[1:], Run: cmdutil.Run(func(args []string) error { var token string var err error if !strings.HasPrefix(initialAdmin, auth.RobotPrefix) { token, err = githubLogin() if err != nil { return err } } fmt.Println("Retrieving Pachyderm token...") // Exchange GitHub token for Pachyderm token c, err := client.NewOnUserMachine(!*noMetrics, !*noPortForwarding, "user") if err != nil { return fmt.Errorf("could not connect: %v", err) } 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") }
go
func ActivateCmd(noMetrics, noPortForwarding *bool) *cobra.Command { var initialAdmin string activate := &cobra.Command{ Short: "Activate Pachyderm's auth system", Long: ` Activate Pachyderm's auth system, and restrict access to existing data to the user running the command (or the argument to --initial-admin), who will be the first cluster admin`[1:], Run: cmdutil.Run(func(args []string) error { var token string var err error if !strings.HasPrefix(initialAdmin, auth.RobotPrefix) { token, err = githubLogin() if err != nil { return err } } fmt.Println("Retrieving Pachyderm token...") // Exchange GitHub token for Pachyderm token c, err := client.NewOnUserMachine(!*noMetrics, !*noPortForwarding, "user") if err != nil { return fmt.Errorf("could not connect: %v", err) } 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") }
[ "func", "ActivateCmd", "(", "noMetrics", ",", "noPortForwarding", "*", "bool", ")", "*", "cobra", ".", "Command", "{", "var", "initialAdmin", "string", "\n", "activate", ":=", "&", "cobra", ".", "Command", "{", "Short", ":", "\"Activate Pachyderm's auth system\"", ",", "Long", ":", "`Activate Pachyderm's auth system, and restrict access to existing data to theuser running the command (or the argument to --initial-admin), who will be thefirst cluster admin`", "[", "1", ":", "]", ",", "Run", ":", "cmdutil", ".", "Run", "(", "func", "(", "args", "[", "]", "string", ")", "error", "{", "var", "token", "string", "\n", "var", "err", "error", "\n", "if", "!", "strings", ".", "HasPrefix", "(", "initialAdmin", ",", "auth", ".", "RobotPrefix", ")", "{", "token", ",", "err", "=", "githubLogin", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "fmt", ".", "Println", "(", "\"Retrieving Pachyderm token...\"", ")", "\n", "c", ",", "err", ":=", "client", ".", "NewOnUserMachine", "(", "!", "*", "noMetrics", ",", "!", "*", "noPortForwarding", ",", "\"user\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"could not connect: %v\"", ",", "err", ")", "\n", "}", "\n", "defer", "c", ".", "Close", "(", ")", "\n", "resp", ",", "err", ":=", "c", ".", "Activate", "(", "c", ".", "Ctx", "(", ")", ",", "&", "auth", ".", "ActivateRequest", "{", "GitHubToken", ":", "token", ",", "Subject", ":", "initialAdmin", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"error activating Pachyderm auth: %v\"", ",", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", ")", "\n", "}", "\n", "if", "err", ":=", "writePachTokenToCfg", "(", "resp", ".", "PachToken", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "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 \"", "+", "\\n", ")", "\n", "\"OF YOUR CLUSTER!\"", "\n", "}", "\n", "fmt", ".", "Printf", "(", "\"Pachyderm token for \\\"%s\\\":\\n%s\\n\"", ",", "\\\"", ",", "\\\"", ")", "\n", "}", ")", ",", "}", "\n", "\\n", "\n", "\\n", "\n", "}" ]
// ActivateCmd returns a cobra.Command to activate Pachyderm's auth system
[ "ActivateCmd", "returns", "a", "cobra", ".", "Command", "to", "activate", "Pachyderm", "s", "auth", "system" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/auth/cmds/cmds.go#L54-L108
test
pachyderm/pachyderm
src/server/auth/cmds/cmds.go
DeactivateCmd
func DeactivateCmd(noMetrics, noPortForwarding *bool) *cobra.Command { deactivate := &cobra.Command{ Short: "Delete all ACLs, tokens, and admins, and deactivate Pachyderm auth", Long: "Deactivate Pachyderm's auth system, which will delete ALL auth " + "tokens, ACLs and admins, and expose all data in the cluster to any " + "user with cluster access. Use with caution.", Run: cmdutil.Run(func(args []string) error { fmt.Println("Are you sure you want to delete ALL auth information " + "(ACLs, tokens, and admins) in this cluster, and expose ALL data? yN") confirm, err := 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") }
go
func DeactivateCmd(noMetrics, noPortForwarding *bool) *cobra.Command { deactivate := &cobra.Command{ Short: "Delete all ACLs, tokens, and admins, and deactivate Pachyderm auth", Long: "Deactivate Pachyderm's auth system, which will delete ALL auth " + "tokens, ACLs and admins, and expose all data in the cluster to any " + "user with cluster access. Use with caution.", Run: cmdutil.Run(func(args []string) error { fmt.Println("Are you sure you want to delete ALL auth information " + "(ACLs, tokens, and admins) in this cluster, and expose ALL data? yN") confirm, err := 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") }
[ "func", "DeactivateCmd", "(", "noMetrics", ",", "noPortForwarding", "*", "bool", ")", "*", "cobra", ".", "Command", "{", "deactivate", ":=", "&", "cobra", ".", "Command", "{", "Short", ":", "\"Delete all ACLs, tokens, and admins, and deactivate Pachyderm auth\"", ",", "Long", ":", "\"Deactivate Pachyderm's auth system, which will delete ALL auth \"", "+", "\"tokens, ACLs and admins, and expose all data in the cluster to any \"", "+", "\"user with cluster access. Use with caution.\"", ",", "Run", ":", "cmdutil", ".", "Run", "(", "func", "(", "args", "[", "]", "string", ")", "error", "{", "fmt", ".", "Println", "(", "\"Are you sure you want to delete ALL auth information \"", "+", "\"(ACLs, tokens, and admins) in this cluster, and expose ALL data? yN\"", ")", "\n", "confirm", ",", "err", ":=", "bufio", ".", "NewReader", "(", "os", ".", "Stdin", ")", ".", "ReadString", "(", "'\\n'", ")", "\n", "if", "!", "strings", ".", "Contains", "(", "\"yY\"", ",", "confirm", "[", ":", "1", "]", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"operation aborted\"", ")", "\n", "}", "\n", "c", ",", "err", ":=", "client", ".", "NewOnUserMachine", "(", "!", "*", "noMetrics", ",", "!", "*", "noPortForwarding", ",", "\"user\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"could not connect: %v\"", ",", "err", ")", "\n", "}", "\n", "defer", "c", ".", "Close", "(", ")", "\n", "_", ",", "err", "=", "c", ".", "Deactivate", "(", "c", ".", "Ctx", "(", ")", ",", "&", "auth", ".", "DeactivateRequest", "{", "}", ")", "\n", "return", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", "\n", "}", ")", ",", "}", "\n", "return", "cmdutil", ".", "CreateAlias", "(", "deactivate", ",", "\"auth deactivate\"", ")", "\n", "}" ]
// DeactivateCmd returns a cobra.Command to delete all ACLs, tokens, and admins, // deactivating Pachyderm's auth system
[ "DeactivateCmd", "returns", "a", "cobra", ".", "Command", "to", "delete", "all", "ACLs", "tokens", "and", "admins", "deactivating", "Pachyderm", "s", "auth", "system" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/auth/cmds/cmds.go#L112-L135
test
pachyderm/pachyderm
src/server/auth/cmds/cmds.go
LoginCmd
func LoginCmd(noMetrics, noPortForwarding *bool) *cobra.Command { var useOTP bool login := &cobra.Command{ Short: "Log in to Pachyderm", Long: "Login to Pachyderm. Any resources that have been restricted to " + "the account you have with your ID provider (e.g. GitHub, Okta) " + "account will subsequently be accessible.", Run: cmdutil.Run(func([]string) error { c, err := client.NewOnUserMachine(!*noMetrics, !*noPortForwarding, "user") if err != nil { return fmt.Errorf("could not connect: %v", err) } defer c.Close() // Issue authentication request to Pachyderm and get response var resp *auth.AuthenticateResponse var authErr error if useOTP { // Exhange short-lived Pachyderm auth code for long-lived Pachyderm token fmt.Println("Please enter your Pachyderm One-Time Password:") code, err := bufio.NewReader(os.Stdin).ReadString('\n') if err != nil { return fmt.Errorf("error reading One-Time Password: %v", err) } code = strings.TrimSpace(code) // drop trailing newline resp, authErr = c.Authenticate( c.Ctx(), &auth.AuthenticateRequest{OneTimePassword: code}) } else { // Exchange GitHub token for Pachyderm token token, err := githubLogin() if err != nil { return err } fmt.Println("Retrieving Pachyderm token...") resp, authErr = c.Authenticate( c.Ctx(), &auth.AuthenticateRequest{GitHubToken: token}) } // Write new Pachyderm token to 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") }
go
func LoginCmd(noMetrics, noPortForwarding *bool) *cobra.Command { var useOTP bool login := &cobra.Command{ Short: "Log in to Pachyderm", Long: "Login to Pachyderm. Any resources that have been restricted to " + "the account you have with your ID provider (e.g. GitHub, Okta) " + "account will subsequently be accessible.", Run: cmdutil.Run(func([]string) error { c, err := client.NewOnUserMachine(!*noMetrics, !*noPortForwarding, "user") if err != nil { return fmt.Errorf("could not connect: %v", err) } defer c.Close() // Issue authentication request to Pachyderm and get response var resp *auth.AuthenticateResponse var authErr error if useOTP { // Exhange short-lived Pachyderm auth code for long-lived Pachyderm token fmt.Println("Please enter your Pachyderm One-Time Password:") code, err := bufio.NewReader(os.Stdin).ReadString('\n') if err != nil { return fmt.Errorf("error reading One-Time Password: %v", err) } code = strings.TrimSpace(code) // drop trailing newline resp, authErr = c.Authenticate( c.Ctx(), &auth.AuthenticateRequest{OneTimePassword: code}) } else { // Exchange GitHub token for Pachyderm token token, err := githubLogin() if err != nil { return err } fmt.Println("Retrieving Pachyderm token...") resp, authErr = c.Authenticate( c.Ctx(), &auth.AuthenticateRequest{GitHubToken: token}) } // Write new Pachyderm token to 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") }
[ "func", "LoginCmd", "(", "noMetrics", ",", "noPortForwarding", "*", "bool", ")", "*", "cobra", ".", "Command", "{", "var", "useOTP", "bool", "\n", "login", ":=", "&", "cobra", ".", "Command", "{", "Short", ":", "\"Log in to Pachyderm\"", ",", "Long", ":", "\"Login to Pachyderm. Any resources that have been restricted to \"", "+", "\"the account you have with your ID provider (e.g. GitHub, Okta) \"", "+", "\"account will subsequently be accessible.\"", ",", "Run", ":", "cmdutil", ".", "Run", "(", "func", "(", "[", "]", "string", ")", "error", "{", "c", ",", "err", ":=", "client", ".", "NewOnUserMachine", "(", "!", "*", "noMetrics", ",", "!", "*", "noPortForwarding", ",", "\"user\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"could not connect: %v\"", ",", "err", ")", "\n", "}", "\n", "defer", "c", ".", "Close", "(", ")", "\n", "var", "resp", "*", "auth", ".", "AuthenticateResponse", "\n", "var", "authErr", "error", "\n", "if", "useOTP", "{", "fmt", ".", "Println", "(", "\"Please enter your Pachyderm One-Time Password:\"", ")", "\n", "code", ",", "err", ":=", "bufio", ".", "NewReader", "(", "os", ".", "Stdin", ")", ".", "ReadString", "(", "'\\n'", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"error reading One-Time Password: %v\"", ",", "err", ")", "\n", "}", "\n", "code", "=", "strings", ".", "TrimSpace", "(", "code", ")", "\n", "resp", ",", "authErr", "=", "c", ".", "Authenticate", "(", "c", ".", "Ctx", "(", ")", ",", "&", "auth", ".", "AuthenticateRequest", "{", "OneTimePassword", ":", "code", "}", ")", "\n", "}", "else", "{", "token", ",", "err", ":=", "githubLogin", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "fmt", ".", "Println", "(", "\"Retrieving Pachyderm token...\"", ")", "\n", "resp", ",", "authErr", "=", "c", ".", "Authenticate", "(", "c", ".", "Ctx", "(", ")", ",", "&", "auth", ".", "AuthenticateRequest", "{", "GitHubToken", ":", "token", "}", ")", "\n", "}", "\n", "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", ")", "\n", "}", "\n", "return", "fmt", ".", "Errorf", "(", "\"error authenticating with Pachyderm cluster: %v\"", ",", "grpcutil", ".", "ScrubGRPC", "(", "authErr", ")", ")", "\n", "}", "\n", "return", "writePachTokenToCfg", "(", "resp", ".", "PachToken", ")", "\n", "}", ")", ",", "}", "\n", "login", ".", "PersistentFlags", "(", ")", ".", "BoolVarP", "(", "&", "useOTP", ",", "\"one-time-password\"", ",", "\"o\"", ",", "false", ",", "\"If set, authenticate with a Dash-provided One-Time Password, rather than \"", "+", "\"via GitHub\"", ")", "\n", "return", "cmdutil", ".", "CreateAlias", "(", "login", ",", "\"auth login\"", ")", "\n", "}" ]
// LoginCmd returns a cobra.Command to login to a Pachyderm cluster with your // GitHub account. Any resources that have been restricted to the email address // registered with your GitHub account will subsequently be accessible.
[ "LoginCmd", "returns", "a", "cobra", ".", "Command", "to", "login", "to", "a", "Pachyderm", "cluster", "with", "your", "GitHub", "account", ".", "Any", "resources", "that", "have", "been", "restricted", "to", "the", "email", "address", "registered", "with", "your", "GitHub", "account", "will", "subsequently", "be", "accessible", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/auth/cmds/cmds.go#L140-L197
test
pachyderm/pachyderm
src/server/auth/cmds/cmds.go
LogoutCmd
func LogoutCmd() *cobra.Command { logout := &cobra.Command{ Short: "Log out of Pachyderm by deleting your local credential", Long: "Log out of Pachyderm by deleting your local credential. Note that " + "it's not necessary to log out before logging in with another account " + "(simply run 'pachctl auth login' twice) but 'logout' can be useful on " + "shared workstations.", Run: cmdutil.Run(func([]string) error { cfg, err := config.Read() if err != 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") }
go
func LogoutCmd() *cobra.Command { logout := &cobra.Command{ Short: "Log out of Pachyderm by deleting your local credential", Long: "Log out of Pachyderm by deleting your local credential. Note that " + "it's not necessary to log out before logging in with another account " + "(simply run 'pachctl auth login' twice) but 'logout' can be useful on " + "shared workstations.", Run: cmdutil.Run(func([]string) error { cfg, err := config.Read() if err != 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") }
[ "func", "LogoutCmd", "(", ")", "*", "cobra", ".", "Command", "{", "logout", ":=", "&", "cobra", ".", "Command", "{", "Short", ":", "\"Log out of Pachyderm by deleting your local credential\"", ",", "Long", ":", "\"Log out of Pachyderm by deleting your local credential. Note that \"", "+", "\"it's not necessary to log out before logging in with another account \"", "+", "\"(simply run 'pachctl auth login' twice) but 'logout' can be useful on \"", "+", "\"shared workstations.\"", ",", "Run", ":", "cmdutil", ".", "Run", "(", "func", "(", "[", "]", "string", ")", "error", "{", "cfg", ",", "err", ":=", "config", ".", "Read", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"error reading Pachyderm config (for cluster \"", "+", "\"address): %v\"", ",", "err", ")", "\n", "}", "\n", "if", "cfg", ".", "V1", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "cfg", ".", "V1", ".", "SessionToken", "=", "\"\"", "\n", "return", "cfg", ".", "Write", "(", ")", "\n", "}", ")", ",", "}", "\n", "return", "cmdutil", ".", "CreateAlias", "(", "logout", ",", "\"auth logout\"", ")", "\n", "}" ]
// LogoutCmd returns a cobra.Command that deletes your local Pachyderm // credential, logging you out of your cluster. Note that this is not necessary // to do before logging in as another user, but is useful for testing.
[ "LogoutCmd", "returns", "a", "cobra", ".", "Command", "that", "deletes", "your", "local", "Pachyderm", "credential", "logging", "you", "out", "of", "your", "cluster", ".", "Note", "that", "this", "is", "not", "necessary", "to", "do", "before", "logging", "in", "as", "another", "user", "but", "is", "useful", "for", "testing", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/auth/cmds/cmds.go#L202-L223
test
pachyderm/pachyderm
src/server/auth/cmds/cmds.go
WhoamiCmd
func WhoamiCmd(noMetrics, noPortForwarding *bool) *cobra.Command { whoami := &cobra.Command{ Short: "Print your Pachyderm identity", Long: "Print your Pachyderm identity.", Run: cmdutil.Run(func([]string) error { c, err := client.NewOnUserMachine(!*noMetrics, !*noPortForwarding, "user") if err != nil { return fmt.Errorf("could not connect: %v", err) } defer c.Close() resp, err := c.WhoAmI(c.Ctx(), &auth.WhoAmIRequest{}) if err != nil { return fmt.Errorf("error: %v", grpcutil.ScrubGRPC(err)) } 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") }
go
func WhoamiCmd(noMetrics, noPortForwarding *bool) *cobra.Command { whoami := &cobra.Command{ Short: "Print your Pachyderm identity", Long: "Print your Pachyderm identity.", Run: cmdutil.Run(func([]string) error { c, err := client.NewOnUserMachine(!*noMetrics, !*noPortForwarding, "user") if err != nil { return fmt.Errorf("could not connect: %v", err) } defer c.Close() resp, err := c.WhoAmI(c.Ctx(), &auth.WhoAmIRequest{}) if err != nil { return fmt.Errorf("error: %v", grpcutil.ScrubGRPC(err)) } 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") }
[ "func", "WhoamiCmd", "(", "noMetrics", ",", "noPortForwarding", "*", "bool", ")", "*", "cobra", ".", "Command", "{", "whoami", ":=", "&", "cobra", ".", "Command", "{", "Short", ":", "\"Print your Pachyderm identity\"", ",", "Long", ":", "\"Print your Pachyderm identity.\"", ",", "Run", ":", "cmdutil", ".", "Run", "(", "func", "(", "[", "]", "string", ")", "error", "{", "c", ",", "err", ":=", "client", ".", "NewOnUserMachine", "(", "!", "*", "noMetrics", ",", "!", "*", "noPortForwarding", ",", "\"user\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"could not connect: %v\"", ",", "err", ")", "\n", "}", "\n", "defer", "c", ".", "Close", "(", ")", "\n", "resp", ",", "err", ":=", "c", ".", "WhoAmI", "(", "c", ".", "Ctx", "(", ")", ",", "&", "auth", ".", "WhoAmIRequest", "{", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"error: %v\"", ",", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", ")", "\n", "}", "\n", "fmt", ".", "Printf", "(", "\"You are \\\"%s\\\"\\n\"", ",", "\\\"", ")", "\n", "\\\"", "\n", "\\n", "\n", "resp", ".", "Username", "\n", "}", ")", ",", "}", "\n", "if", "resp", ".", "TTL", ">", "0", "{", "fmt", ".", "Printf", "(", "\"session expires: %v\\n\"", ",", "\\n", ")", "\n", "}", "\n", "}" ]
// WhoamiCmd returns a cobra.Command that deletes your local Pachyderm // credential, logging you out of your cluster. Note that this is not necessary // to do before logging in as another user, but is useful for testing.
[ "WhoamiCmd", "returns", "a", "cobra", ".", "Command", "that", "deletes", "your", "local", "Pachyderm", "credential", "logging", "you", "out", "of", "your", "cluster", ".", "Note", "that", "this", "is", "not", "necessary", "to", "do", "before", "logging", "in", "as", "another", "user", "but", "is", "useful", "for", "testing", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/auth/cmds/cmds.go#L228-L253
test
pachyderm/pachyderm
src/server/auth/cmds/cmds.go
CheckCmd
func CheckCmd(noMetrics, noPortForwarding *bool) *cobra.Command { check := &cobra.Command{ Use: "{{alias}} (none|reader|writer|owner) <repo>", Short: "Check whether you have reader/writer/etc-level access to 'repo'", Long: "Check whether you have reader/writer/etc-level access to 'repo'. " + "For example, 'pachctl auth check reader private-data' prints \"true\" " + "if the you have at least \"reader\" access to the repo " + "\"private-data\" (you could be a reader, writer, or owner). Unlike " + "`pachctl auth get`, you do not need to have access to 'repo' to " + "discover your own access level.", Run: cmdutil.RunFixedArgs(2, func(args []string) error { scope, err := auth.ParseScope(args[0]) if err != nil { return err } repo := args[1] 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") }
go
func CheckCmd(noMetrics, noPortForwarding *bool) *cobra.Command { check := &cobra.Command{ Use: "{{alias}} (none|reader|writer|owner) <repo>", Short: "Check whether you have reader/writer/etc-level access to 'repo'", Long: "Check whether you have reader/writer/etc-level access to 'repo'. " + "For example, 'pachctl auth check reader private-data' prints \"true\" " + "if the you have at least \"reader\" access to the repo " + "\"private-data\" (you could be a reader, writer, or owner). Unlike " + "`pachctl auth get`, you do not need to have access to 'repo' to " + "discover your own access level.", Run: cmdutil.RunFixedArgs(2, func(args []string) error { scope, err := auth.ParseScope(args[0]) if err != nil { return err } repo := args[1] 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") }
[ "func", "CheckCmd", "(", "noMetrics", ",", "noPortForwarding", "*", "bool", ")", "*", "cobra", ".", "Command", "{", "check", ":=", "&", "cobra", ".", "Command", "{", "Use", ":", "\"{{alias}} (none|reader|writer|owner) <repo>\"", ",", "Short", ":", "\"Check whether you have reader/writer/etc-level access to 'repo'\"", ",", "Long", ":", "\"Check whether you have reader/writer/etc-level access to 'repo'. \"", "+", "\"For example, 'pachctl auth check reader private-data' prints \\\"true\\\" \"", "+", "\\\"", "+", "\\\"", "+", "\"if the you have at least \\\"reader\\\" access to the repo \"", "+", "\\\"", ",", "\\\"", ",", "}", "\n", "\"\\\"private-data\\\" (you could be a reader, writer, or owner). Unlike \"", "\n", "}" ]
// CheckCmd returns a cobra command that sends an "Authorize" RPC to Pachd, to // determine whether the specified user has access to the specified repo.
[ "CheckCmd", "returns", "a", "cobra", "command", "that", "sends", "an", "Authorize", "RPC", "to", "Pachd", "to", "determine", "whether", "the", "specified", "user", "has", "access", "to", "the", "specified", "repo", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/auth/cmds/cmds.go#L257-L290
test
pachyderm/pachyderm
src/server/auth/cmds/cmds.go
GetCmd
func GetCmd(noMetrics, noPortForwarding *bool) *cobra.Command { get := &cobra.Command{ Use: "{{alias}} [<username>] <repo>", Short: "Get the ACL for 'repo' or the access that 'username' has to 'repo'", Long: "Get the ACL for 'repo' or the access that 'username' has to " + "'repo'. For example, 'pachctl auth get github-alice private-data' " + "prints \"reader\", \"writer\", \"owner\", or \"none\", depending on " + "the privileges that \"github-alice\" has in \"repo\". Currently all " + "Pachyderm authentication uses GitHub OAuth, so 'username' must be a " + "GitHub username", Run: cmdutil.RunBoundedArgs(1, 2, func(args []string) error { c, err := client.NewOnUserMachine(!*noMetrics, !*noPortForwarding, "user") if err != nil { return fmt.Errorf("could not connect: %v", err) } defer c.Close() if len(args) == 1 { // Get ACL for a repo repo := args[0] resp, err := 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") }
go
func GetCmd(noMetrics, noPortForwarding *bool) *cobra.Command { get := &cobra.Command{ Use: "{{alias}} [<username>] <repo>", Short: "Get the ACL for 'repo' or the access that 'username' has to 'repo'", Long: "Get the ACL for 'repo' or the access that 'username' has to " + "'repo'. For example, 'pachctl auth get github-alice private-data' " + "prints \"reader\", \"writer\", \"owner\", or \"none\", depending on " + "the privileges that \"github-alice\" has in \"repo\". Currently all " + "Pachyderm authentication uses GitHub OAuth, so 'username' must be a " + "GitHub username", Run: cmdutil.RunBoundedArgs(1, 2, func(args []string) error { c, err := client.NewOnUserMachine(!*noMetrics, !*noPortForwarding, "user") if err != nil { return fmt.Errorf("could not connect: %v", err) } defer c.Close() if len(args) == 1 { // Get ACL for a repo repo := args[0] resp, err := 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") }
[ "func", "GetCmd", "(", "noMetrics", ",", "noPortForwarding", "*", "bool", ")", "*", "cobra", ".", "Command", "{", "get", ":=", "&", "cobra", ".", "Command", "{", "Use", ":", "\"{{alias}} [<username>] <repo>\"", ",", "Short", ":", "\"Get the ACL for 'repo' or the access that 'username' has to 'repo'\"", ",", "Long", ":", "\"Get the ACL for 'repo' or the access that 'username' has to \"", "+", "\"'repo'. For example, 'pachctl auth get github-alice private-data' \"", "+", "\"prints \\\"reader\\\", \\\"writer\\\", \\\"owner\\\", or \\\"none\\\", depending on \"", "+", "\\\"", "+", "\\\"", "+", "\\\"", ",", "\\\"", ",", "}", "\n", "\\\"", "\n", "}" ]
// GetCmd returns a cobra command that gets either the ACL for a Pachyderm // repo or another user's scope of access to that repo
[ "GetCmd", "returns", "a", "cobra", "command", "that", "gets", "either", "the", "ACL", "for", "a", "Pachyderm", "repo", "or", "another", "user", "s", "scope", "of", "access", "to", "that", "repo" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/auth/cmds/cmds.go#L294-L337
test
pachyderm/pachyderm
src/server/auth/cmds/cmds.go
SetScopeCmd
func SetScopeCmd(noMetrics, noPortForwarding *bool) *cobra.Command { setScope := &cobra.Command{ Use: "{{alias}} <username> (none|reader|writer|owner) <repo>", Short: "Set the scope of access that 'username' has to 'repo'", Long: "Set the scope of access that 'username' has to 'repo'. For " + "example, 'pachctl auth set github-alice none private-data' prevents " + "\"github-alice\" from interacting with the \"private-data\" repo in any " + "way (the default). Similarly, 'pachctl auth set github-alice reader " + "private-data' would let \"github-alice\" read from \"private-data\" but " + "not create commits (writer) or modify the repo's access permissions " + "(owner). Currently all Pachyderm authentication uses GitHub OAuth, so " + "'username' must be a GitHub username", Run: cmdutil.RunFixedArgs(3, func(args []string) error { scope, err := auth.ParseScope(args[1]) if err != nil { 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") }
go
func SetScopeCmd(noMetrics, noPortForwarding *bool) *cobra.Command { setScope := &cobra.Command{ Use: "{{alias}} <username> (none|reader|writer|owner) <repo>", Short: "Set the scope of access that 'username' has to 'repo'", Long: "Set the scope of access that 'username' has to 'repo'. For " + "example, 'pachctl auth set github-alice none private-data' prevents " + "\"github-alice\" from interacting with the \"private-data\" repo in any " + "way (the default). Similarly, 'pachctl auth set github-alice reader " + "private-data' would let \"github-alice\" read from \"private-data\" but " + "not create commits (writer) or modify the repo's access permissions " + "(owner). Currently all Pachyderm authentication uses GitHub OAuth, so " + "'username' must be a GitHub username", Run: cmdutil.RunFixedArgs(3, func(args []string) error { scope, err := auth.ParseScope(args[1]) if err != nil { 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") }
[ "func", "SetScopeCmd", "(", "noMetrics", ",", "noPortForwarding", "*", "bool", ")", "*", "cobra", ".", "Command", "{", "setScope", ":=", "&", "cobra", ".", "Command", "{", "Use", ":", "\"{{alias}} <username> (none|reader|writer|owner) <repo>\"", ",", "Short", ":", "\"Set the scope of access that 'username' has to 'repo'\"", ",", "Long", ":", "\"Set the scope of access that 'username' has to 'repo'. For \"", "+", "\"example, 'pachctl auth set github-alice none private-data' prevents \"", "+", "\"\\\"github-alice\\\" from interacting with the \\\"private-data\\\" repo in any \"", "+", "\\\"", "+", "\\\"", "+", "\\\"", "+", "\\\"", "+", "\"way (the default). Similarly, 'pachctl auth set github-alice reader \"", ",", "\"private-data' would let \\\"github-alice\\\" read from \\\"private-data\\\" but \"", ",", "}", "\n", "\\\"", "\n", "}" ]
// SetScopeCmd returns a cobra command that lets a user set the level of access // that another user has to a repo
[ "SetScopeCmd", "returns", "a", "cobra", "command", "that", "lets", "a", "user", "set", "the", "level", "of", "access", "that", "another", "user", "has", "to", "a", "repo" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/auth/cmds/cmds.go#L341-L373
test
pachyderm/pachyderm
src/server/auth/cmds/cmds.go
ListAdminsCmd
func ListAdminsCmd(noMetrics, noPortForwarding *bool) *cobra.Command { listAdmins := &cobra.Command{ Short: "List the current cluster admins", Long: "List the current cluster admins", Run: cmdutil.Run(func([]string) error { c, err := client.NewOnUserMachine(!*noMetrics, !*noPortForwarding, "user") if err != nil { return err } defer c.Close() resp, err := c.GetAdmins(c.Ctx(), &auth.GetAdminsRequest{}) if err != nil { return grpcutil.ScrubGRPC(err) } for _, user := range resp.Admins { fmt.Println(user) } return nil }), } return cmdutil.CreateAlias(listAdmins, "auth list-admins") }
go
func ListAdminsCmd(noMetrics, noPortForwarding *bool) *cobra.Command { listAdmins := &cobra.Command{ Short: "List the current cluster admins", Long: "List the current cluster admins", Run: cmdutil.Run(func([]string) error { c, err := client.NewOnUserMachine(!*noMetrics, !*noPortForwarding, "user") if err != nil { return err } defer c.Close() resp, err := c.GetAdmins(c.Ctx(), &auth.GetAdminsRequest{}) if err != nil { return grpcutil.ScrubGRPC(err) } for _, user := range resp.Admins { fmt.Println(user) } return nil }), } return cmdutil.CreateAlias(listAdmins, "auth list-admins") }
[ "func", "ListAdminsCmd", "(", "noMetrics", ",", "noPortForwarding", "*", "bool", ")", "*", "cobra", ".", "Command", "{", "listAdmins", ":=", "&", "cobra", ".", "Command", "{", "Short", ":", "\"List the current cluster admins\"", ",", "Long", ":", "\"List the current cluster admins\"", ",", "Run", ":", "cmdutil", ".", "Run", "(", "func", "(", "[", "]", "string", ")", "error", "{", "c", ",", "err", ":=", "client", ".", "NewOnUserMachine", "(", "!", "*", "noMetrics", ",", "!", "*", "noPortForwarding", ",", "\"user\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "c", ".", "Close", "(", ")", "\n", "resp", ",", "err", ":=", "c", ".", "GetAdmins", "(", "c", ".", "Ctx", "(", ")", ",", "&", "auth", ".", "GetAdminsRequest", "{", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", "\n", "}", "\n", "for", "_", ",", "user", ":=", "range", "resp", ".", "Admins", "{", "fmt", ".", "Println", "(", "user", ")", "\n", "}", "\n", "return", "nil", "\n", "}", ")", ",", "}", "\n", "return", "cmdutil", ".", "CreateAlias", "(", "listAdmins", ",", "\"auth list-admins\"", ")", "\n", "}" ]
// ListAdminsCmd returns a cobra command that lists the current cluster admins
[ "ListAdminsCmd", "returns", "a", "cobra", "command", "that", "lists", "the", "current", "cluster", "admins" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/auth/cmds/cmds.go#L376-L397
test
pachyderm/pachyderm
src/server/auth/cmds/cmds.go
ModifyAdminsCmd
func ModifyAdminsCmd(noMetrics, noPortForwarding *bool) *cobra.Command { var add []string var remove []string modifyAdmins := &cobra.Command{ Short: "Modify the current cluster admins", Long: "Modify the current cluster admins. --add accepts a comma-" + "separated list of users to grant admin status, and --remove accepts a " + "comma-separated list of users to revoke admin status", Run: cmdutil.Run(func([]string) error { c, err := client.NewOnUserMachine(!*noMetrics, !*noPortForwarding, "user") if err != nil { return err } defer c.Close() _, err = c.ModifyAdmins(c.Ctx(), &auth.ModifyAdminsRequest{ Add: add, Remove: remove, }) if auth.IsErrPartiallyActivated(err) { 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", 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") }
go
func ModifyAdminsCmd(noMetrics, noPortForwarding *bool) *cobra.Command { var add []string var remove []string modifyAdmins := &cobra.Command{ Short: "Modify the current cluster admins", Long: "Modify the current cluster admins. --add accepts a comma-" + "separated list of users to grant admin status, and --remove accepts a " + "comma-separated list of users to revoke admin status", Run: cmdutil.Run(func([]string) error { c, err := client.NewOnUserMachine(!*noMetrics, !*noPortForwarding, "user") if err != nil { return err } defer c.Close() _, err = c.ModifyAdmins(c.Ctx(), &auth.ModifyAdminsRequest{ Add: add, Remove: remove, }) if auth.IsErrPartiallyActivated(err) { 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", 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") }
[ "func", "ModifyAdminsCmd", "(", "noMetrics", ",", "noPortForwarding", "*", "bool", ")", "*", "cobra", ".", "Command", "{", "var", "add", "[", "]", "string", "\n", "var", "remove", "[", "]", "string", "\n", "modifyAdmins", ":=", "&", "cobra", ".", "Command", "{", "Short", ":", "\"Modify the current cluster admins\"", ",", "Long", ":", "\"Modify the current cluster admins. --add accepts a comma-\"", "+", "\"separated list of users to grant admin status, and --remove accepts a \"", "+", "\"comma-separated list of users to revoke admin status\"", ",", "Run", ":", "cmdutil", ".", "Run", "(", "func", "(", "[", "]", "string", ")", "error", "{", "c", ",", "err", ":=", "client", ".", "NewOnUserMachine", "(", "!", "*", "noMetrics", ",", "!", "*", "noPortForwarding", ",", "\"user\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "c", ".", "Close", "(", ")", "\n", "_", ",", "err", "=", "c", ".", "ModifyAdmins", "(", "c", ".", "Ctx", "(", ")", ",", "&", "auth", ".", "ModifyAdminsRequest", "{", "Add", ":", "add", ",", "Remove", ":", "remove", ",", "}", ")", "\n", "if", "auth", ".", "IsErrPartiallyActivated", "(", "err", ")", "{", "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\"", ",", "err", ")", "\n", "}", "\n", "return", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", "\n", "}", ")", ",", "}", "\n", "modifyAdmins", ".", "PersistentFlags", "(", ")", ".", "StringSliceVar", "(", "&", "add", ",", "\"add\"", ",", "[", "]", "string", "{", "}", ",", "\"Comma-separated list of users to grant admin status\"", ")", "\n", "modifyAdmins", ".", "PersistentFlags", "(", ")", ".", "StringSliceVar", "(", "&", "remove", ",", "\"remove\"", ",", "[", "]", "string", "{", "}", ",", "\"Comma-separated list of users revoke admin status\"", ")", "\n", "return", "cmdutil", ".", "CreateAlias", "(", "modifyAdmins", ",", "\"auth modify-admins\"", ")", "\n", "}" ]
// ModifyAdminsCmd returns a cobra command that modifies the set of current // cluster admins
[ "ModifyAdminsCmd", "returns", "a", "cobra", "command", "that", "modifies", "the", "set", "of", "current", "cluster", "admins" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/auth/cmds/cmds.go#L401-L432
test
pachyderm/pachyderm
src/server/auth/cmds/cmds.go
GetAuthTokenCmd
func GetAuthTokenCmd(noMetrics, noPortForwarding *bool) *cobra.Command { var quiet bool getAuthToken := &cobra.Command{ Use: "{{alias}} <username>", Short: "Get an auth token that authenticates the holder as \"username\"", Long: "Get an auth token that authenticates the holder as \"username\"; " + "this can only be called by cluster admins", Run: cmdutil.RunFixedArgs(1, func(args []string) error { subject := args[0] c, err := client.NewOnUserMachine(!*noMetrics, !*noPortForwarding, "user") if err != nil { return fmt.Errorf("could not connect: %v", err) } defer c.Close() resp, err := c.GetAuthToken(c.Ctx(), &auth.GetAuthTokenRequest{ Subject: subject, }) if err != nil { return grpcutil.ScrubGRPC(err) } if quiet { 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") }
go
func GetAuthTokenCmd(noMetrics, noPortForwarding *bool) *cobra.Command { var quiet bool getAuthToken := &cobra.Command{ Use: "{{alias}} <username>", Short: "Get an auth token that authenticates the holder as \"username\"", Long: "Get an auth token that authenticates the holder as \"username\"; " + "this can only be called by cluster admins", Run: cmdutil.RunFixedArgs(1, func(args []string) error { subject := args[0] c, err := client.NewOnUserMachine(!*noMetrics, !*noPortForwarding, "user") if err != nil { return fmt.Errorf("could not connect: %v", err) } defer c.Close() resp, err := c.GetAuthToken(c.Ctx(), &auth.GetAuthTokenRequest{ Subject: subject, }) if err != nil { return grpcutil.ScrubGRPC(err) } if quiet { 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") }
[ "func", "GetAuthTokenCmd", "(", "noMetrics", ",", "noPortForwarding", "*", "bool", ")", "*", "cobra", ".", "Command", "{", "var", "quiet", "bool", "\n", "getAuthToken", ":=", "&", "cobra", ".", "Command", "{", "Use", ":", "\"{{alias}} <username>\"", ",", "Short", ":", "\"Get an auth token that authenticates the holder as \\\"username\\\"\"", ",", "\\\"", ",", "\\\"", ",", "}", "\n", "Long", ":", "\"Get an auth token that authenticates the holder as \\\"username\\\"; \"", "+", "\\\"", "\n", "\\\"", "\n", "}" ]
// GetAuthTokenCmd returns a cobra command that lets a user get a pachyderm // token on behalf of themselves or another user
[ "GetAuthTokenCmd", "returns", "a", "cobra", "command", "that", "lets", "a", "user", "get", "a", "pachyderm", "token", "on", "behalf", "of", "themselves", "or", "another", "user" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/auth/cmds/cmds.go#L436-L468
test
pachyderm/pachyderm
src/server/auth/cmds/cmds.go
UseAuthTokenCmd
func UseAuthTokenCmd() *cobra.Command { useAuthToken := &cobra.Command{ Short: "Read a Pachyderm auth token from stdin, and write it to the " + "current user's Pachyderm config file", Long: "Read a Pachyderm auth token from stdin, and write it to the " + "current user's Pachyderm config file", Run: cmdutil.RunFixedArgs(0, func(args []string) error { fmt.Println("Please paste your Pachyderm auth token:") token, err := bufio.NewReader(os.Stdin).ReadString('\n') if err != nil { 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") }
go
func UseAuthTokenCmd() *cobra.Command { useAuthToken := &cobra.Command{ Short: "Read a Pachyderm auth token from stdin, and write it to the " + "current user's Pachyderm config file", Long: "Read a Pachyderm auth token from stdin, and write it to the " + "current user's Pachyderm config file", Run: cmdutil.RunFixedArgs(0, func(args []string) error { fmt.Println("Please paste your Pachyderm auth token:") token, err := bufio.NewReader(os.Stdin).ReadString('\n') if err != nil { 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") }
[ "func", "UseAuthTokenCmd", "(", ")", "*", "cobra", ".", "Command", "{", "useAuthToken", ":=", "&", "cobra", ".", "Command", "{", "Short", ":", "\"Read a Pachyderm auth token from stdin, and write it to the \"", "+", "\"current user's Pachyderm config file\"", ",", "Long", ":", "\"Read a Pachyderm auth token from stdin, and write it to the \"", "+", "\"current user's Pachyderm config file\"", ",", "Run", ":", "cmdutil", ".", "RunFixedArgs", "(", "0", ",", "func", "(", "args", "[", "]", "string", ")", "error", "{", "fmt", ".", "Println", "(", "\"Please paste your Pachyderm auth token:\"", ")", "\n", "token", ",", "err", ":=", "bufio", ".", "NewReader", "(", "os", ".", "Stdin", ")", ".", "ReadString", "(", "'\\n'", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"error reading token: %v\"", ",", "err", ")", "\n", "}", "\n", "writePachTokenToCfg", "(", "strings", ".", "TrimSpace", "(", "token", ")", ")", "\n", "return", "nil", "\n", "}", ")", ",", "}", "\n", "return", "cmdutil", ".", "CreateAlias", "(", "useAuthToken", ",", "\"auth use-auth-token\"", ")", "\n", "}" ]
// UseAuthTokenCmd returns a cobra command that lets a user get a pachyderm // token on behalf of themselves or another user
[ "UseAuthTokenCmd", "returns", "a", "cobra", "command", "that", "lets", "a", "user", "get", "a", "pachyderm", "token", "on", "behalf", "of", "themselves", "or", "another", "user" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/auth/cmds/cmds.go#L472-L489
test
pachyderm/pachyderm
src/server/auth/cmds/cmds.go
Cmds
func Cmds(noMetrics, noPortForwarding *bool) []*cobra.Command { var commands []*cobra.Command auth := &cobra.Command{ Short: "Auth commands manage access to data in a Pachyderm cluster", Long: "Auth commands manage access to data in a Pachyderm cluster", } commands = append(commands, cmdutil.CreateAlias(auth, "auth")) commands = append(commands, ActivateCmd(noMetrics, noPortForwarding)) commands = append(commands, DeactivateCmd(noMetrics, noPortForwarding)) commands = append(commands, LoginCmd(noMetrics, noPortForwarding)) 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 }
go
func Cmds(noMetrics, noPortForwarding *bool) []*cobra.Command { var commands []*cobra.Command auth := &cobra.Command{ Short: "Auth commands manage access to data in a Pachyderm cluster", Long: "Auth commands manage access to data in a Pachyderm cluster", } commands = append(commands, cmdutil.CreateAlias(auth, "auth")) commands = append(commands, ActivateCmd(noMetrics, noPortForwarding)) commands = append(commands, DeactivateCmd(noMetrics, noPortForwarding)) commands = append(commands, LoginCmd(noMetrics, noPortForwarding)) 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 }
[ "func", "Cmds", "(", "noMetrics", ",", "noPortForwarding", "*", "bool", ")", "[", "]", "*", "cobra", ".", "Command", "{", "var", "commands", "[", "]", "*", "cobra", ".", "Command", "\n", "auth", ":=", "&", "cobra", ".", "Command", "{", "Short", ":", "\"Auth commands manage access to data in a Pachyderm cluster\"", ",", "Long", ":", "\"Auth commands manage access to data in a Pachyderm cluster\"", ",", "}", "\n", "commands", "=", "append", "(", "commands", ",", "cmdutil", ".", "CreateAlias", "(", "auth", ",", "\"auth\"", ")", ")", "\n", "commands", "=", "append", "(", "commands", ",", "ActivateCmd", "(", "noMetrics", ",", "noPortForwarding", ")", ")", "\n", "commands", "=", "append", "(", "commands", ",", "DeactivateCmd", "(", "noMetrics", ",", "noPortForwarding", ")", ")", "\n", "commands", "=", "append", "(", "commands", ",", "LoginCmd", "(", "noMetrics", ",", "noPortForwarding", ")", ")", "\n", "commands", "=", "append", "(", "commands", ",", "LogoutCmd", "(", ")", ")", "\n", "commands", "=", "append", "(", "commands", ",", "WhoamiCmd", "(", "noMetrics", ",", "noPortForwarding", ")", ")", "\n", "commands", "=", "append", "(", "commands", ",", "CheckCmd", "(", "noMetrics", ",", "noPortForwarding", ")", ")", "\n", "commands", "=", "append", "(", "commands", ",", "SetScopeCmd", "(", "noMetrics", ",", "noPortForwarding", ")", ")", "\n", "commands", "=", "append", "(", "commands", ",", "GetCmd", "(", "noMetrics", ",", "noPortForwarding", ")", ")", "\n", "commands", "=", "append", "(", "commands", ",", "ListAdminsCmd", "(", "noMetrics", ",", "noPortForwarding", ")", ")", "\n", "commands", "=", "append", "(", "commands", ",", "ModifyAdminsCmd", "(", "noMetrics", ",", "noPortForwarding", ")", ")", "\n", "commands", "=", "append", "(", "commands", ",", "GetAuthTokenCmd", "(", "noMetrics", ",", "noPortForwarding", ")", ")", "\n", "commands", "=", "append", "(", "commands", ",", "UseAuthTokenCmd", "(", ")", ")", "\n", "commands", "=", "append", "(", "commands", ",", "GetConfigCmd", "(", "noPortForwarding", ")", ")", "\n", "commands", "=", "append", "(", "commands", ",", "SetConfigCmd", "(", "noPortForwarding", ")", ")", "\n", "return", "commands", "\n", "}" ]
// Cmds returns a list of cobra commands for authenticating and authorizing // users in an auth-enabled Pachyderm cluster.
[ "Cmds", "returns", "a", "list", "of", "cobra", "commands", "for", "authenticating", "and", "authorizing", "users", "in", "an", "auth", "-", "enabled", "Pachyderm", "cluster", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/auth/cmds/cmds.go#L493-L518
test
pachyderm/pachyderm
src/client/auth/auth.go
ParseScope
func ParseScope(s string) (Scope, error) { for name, value := range Scope_value { if strings.EqualFold(s, name) { return Scope(value), nil } } return Scope_NONE, fmt.Errorf("unrecognized scope: %s", s) }
go
func ParseScope(s string) (Scope, error) { for name, value := range Scope_value { if strings.EqualFold(s, name) { return Scope(value), nil } } return Scope_NONE, fmt.Errorf("unrecognized scope: %s", s) }
[ "func", "ParseScope", "(", "s", "string", ")", "(", "Scope", ",", "error", ")", "{", "for", "name", ",", "value", ":=", "range", "Scope_value", "{", "if", "strings", ".", "EqualFold", "(", "s", ",", "name", ")", "{", "return", "Scope", "(", "value", ")", ",", "nil", "\n", "}", "\n", "}", "\n", "return", "Scope_NONE", ",", "fmt", ".", "Errorf", "(", "\"unrecognized scope: %s\"", ",", "s", ")", "\n", "}" ]
// ParseScope parses the string 's' to a scope (for example, parsing a command- // line argument.
[ "ParseScope", "parses", "the", "string", "s", "to", "a", "scope", "(", "for", "example", "parsing", "a", "command", "-", "line", "argument", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/auth/auth.go#L39-L46
test
pachyderm/pachyderm
src/client/auth/auth.go
IsErrNotActivated
func IsErrNotActivated(err error) bool { if err == nil { return false } // TODO(msteffen) This is unstructured because we have no way to propagate // structured errors across GRPC boundaries. Fix return strings.Contains(err.Error(), status.Convert(ErrNotActivated).Message()) }
go
func IsErrNotActivated(err error) bool { if err == nil { return false } // TODO(msteffen) This is unstructured because we have no way to propagate // structured errors across GRPC boundaries. Fix return strings.Contains(err.Error(), status.Convert(ErrNotActivated).Message()) }
[ "func", "IsErrNotActivated", "(", "err", "error", ")", "bool", "{", "if", "err", "==", "nil", "{", "return", "false", "\n", "}", "\n", "return", "strings", ".", "Contains", "(", "err", ".", "Error", "(", ")", ",", "status", ".", "Convert", "(", "ErrNotActivated", ")", ".", "Message", "(", ")", ")", "\n", "}" ]
// IsErrNotActivated checks if an error is a ErrNotActivated
[ "IsErrNotActivated", "checks", "if", "an", "error", "is", "a", "ErrNotActivated" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/auth/auth.go#L77-L84
test
pachyderm/pachyderm
src/client/auth/auth.go
IsErrPartiallyActivated
func IsErrPartiallyActivated(err error) bool { if err == nil { return false } // TODO(msteffen) This is unstructured because we have no way to propagate // structured errors across GRPC boundaries. Fix return strings.Contains(err.Error(), status.Convert(ErrPartiallyActivated).Message()) }
go
func IsErrPartiallyActivated(err error) bool { if err == nil { return false } // TODO(msteffen) This is unstructured because we have no way to propagate // structured errors across GRPC boundaries. Fix return strings.Contains(err.Error(), status.Convert(ErrPartiallyActivated).Message()) }
[ "func", "IsErrPartiallyActivated", "(", "err", "error", ")", "bool", "{", "if", "err", "==", "nil", "{", "return", "false", "\n", "}", "\n", "return", "strings", ".", "Contains", "(", "err", ".", "Error", "(", ")", ",", "status", ".", "Convert", "(", "ErrPartiallyActivated", ")", ".", "Message", "(", ")", ")", "\n", "}" ]
// IsErrPartiallyActivated checks if an error is a ErrPartiallyActivated
[ "IsErrPartiallyActivated", "checks", "if", "an", "error", "is", "a", "ErrPartiallyActivated" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/auth/auth.go#L87-L94
test
pachyderm/pachyderm
src/client/auth/auth.go
IsErrNotSignedIn
func IsErrNotSignedIn(err error) bool { if err == nil { return false } // TODO(msteffen) This is unstructured because we have no way to propagate // structured errors across GRPC boundaries. Fix return strings.Contains(err.Error(), status.Convert(ErrNotSignedIn).Message()) }
go
func IsErrNotSignedIn(err error) bool { if err == nil { return false } // TODO(msteffen) This is unstructured because we have no way to propagate // structured errors across GRPC boundaries. Fix return strings.Contains(err.Error(), status.Convert(ErrNotSignedIn).Message()) }
[ "func", "IsErrNotSignedIn", "(", "err", "error", ")", "bool", "{", "if", "err", "==", "nil", "{", "return", "false", "\n", "}", "\n", "return", "strings", ".", "Contains", "(", "err", ".", "Error", "(", ")", ",", "status", ".", "Convert", "(", "ErrNotSignedIn", ")", ".", "Message", "(", ")", ")", "\n", "}" ]
// IsErrNotSignedIn returns true if 'err' is a ErrNotSignedIn
[ "IsErrNotSignedIn", "returns", "true", "if", "err", "is", "a", "ErrNotSignedIn" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/auth/auth.go#L97-L104
test
pachyderm/pachyderm
src/client/auth/auth.go
IsErrBadToken
func IsErrBadToken(err error) bool { if err == nil { return false } return strings.Contains(err.Error(), status.Convert(ErrBadToken).Message()) }
go
func IsErrBadToken(err error) bool { if err == nil { return false } return strings.Contains(err.Error(), status.Convert(ErrBadToken).Message()) }
[ "func", "IsErrBadToken", "(", "err", "error", ")", "bool", "{", "if", "err", "==", "nil", "{", "return", "false", "\n", "}", "\n", "return", "strings", ".", "Contains", "(", "err", ".", "Error", "(", ")", ",", "status", ".", "Convert", "(", "ErrBadToken", ")", ".", "Message", "(", ")", ")", "\n", "}" ]
// IsErrBadToken returns true if 'err' is a ErrBadToken
[ "IsErrBadToken", "returns", "true", "if", "err", "is", "a", "ErrBadToken" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/auth/auth.go#L116-L121
test
pachyderm/pachyderm
src/client/auth/auth.go
IsErrNotAuthorized
func IsErrNotAuthorized(err error) bool { if err == nil { return false } // TODO(msteffen) This is unstructured because we have no way to propagate // structured errors across GRPC boundaries. Fix return strings.Contains(err.Error(), errNotAuthorizedMsg) }
go
func IsErrNotAuthorized(err error) bool { if err == nil { return false } // TODO(msteffen) This is unstructured because we have no way to propagate // structured errors across GRPC boundaries. Fix return strings.Contains(err.Error(), errNotAuthorizedMsg) }
[ "func", "IsErrNotAuthorized", "(", "err", "error", ")", "bool", "{", "if", "err", "==", "nil", "{", "return", "false", "\n", "}", "\n", "return", "strings", ".", "Contains", "(", "err", ".", "Error", "(", ")", ",", "errNotAuthorizedMsg", ")", "\n", "}" ]
// IsErrNotAuthorized checks if an error is a ErrNotAuthorized
[ "IsErrNotAuthorized", "checks", "if", "an", "error", "is", "a", "ErrNotAuthorized" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/auth/auth.go#L165-L172
test
pachyderm/pachyderm
src/client/auth/auth.go
IsErrInvalidPrincipal
func IsErrInvalidPrincipal(err error) bool { if err == nil { return false } return strings.Contains(err.Error(), "invalid principal \"") && strings.Contains(err.Error(), "\"; must start with one of \"pipeline:\", \"github:\", or \"robot:\", or have no \":\"") }
go
func IsErrInvalidPrincipal(err error) bool { if err == nil { return false } return strings.Contains(err.Error(), "invalid principal \"") && strings.Contains(err.Error(), "\"; must start with one of \"pipeline:\", \"github:\", or \"robot:\", or have no \":\"") }
[ "func", "IsErrInvalidPrincipal", "(", "err", "error", ")", "bool", "{", "if", "err", "==", "nil", "{", "return", "false", "\n", "}", "\n", "return", "strings", ".", "Contains", "(", "err", ".", "Error", "(", ")", ",", "\"invalid principal \\\"\"", ")", "&&", "\\\"", "\n", "}" ]
// IsErrInvalidPrincipal returns true if 'err' is an ErrInvalidPrincipal
[ "IsErrInvalidPrincipal", "returns", "true", "if", "err", "is", "an", "ErrInvalidPrincipal" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/auth/auth.go#L185-L191
test
pachyderm/pachyderm
src/client/auth/auth.go
IsErrTooShortTTL
func IsErrTooShortTTL(err error) bool { if err == nil { return false } errMsg := err.Error() return strings.Contains(errMsg, "provided TTL (") && strings.Contains(errMsg, ") is shorter than token's existing TTL (") && strings.Contains(errMsg, ")") }
go
func IsErrTooShortTTL(err error) bool { if err == nil { return false } errMsg := err.Error() return strings.Contains(errMsg, "provided TTL (") && strings.Contains(errMsg, ") is shorter than token's existing TTL (") && strings.Contains(errMsg, ")") }
[ "func", "IsErrTooShortTTL", "(", "err", "error", ")", "bool", "{", "if", "err", "==", "nil", "{", "return", "false", "\n", "}", "\n", "errMsg", ":=", "err", ".", "Error", "(", ")", "\n", "return", "strings", ".", "Contains", "(", "errMsg", ",", "\"provided TTL (\"", ")", "&&", "strings", ".", "Contains", "(", "errMsg", ",", "\") is shorter than token's existing TTL (\"", ")", "&&", "strings", ".", "Contains", "(", "errMsg", ",", "\")\"", ")", "\n", "}" ]
// IsErrTooShortTTL returns true if 'err' is a ErrTooShortTTL
[ "IsErrTooShortTTL", "returns", "true", "if", "err", "is", "a", "ErrTooShortTTL" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/auth/auth.go#L206-L214
test
pachyderm/pachyderm
src/server/worker/datum_set.go
NewDatumFactory
func NewDatumFactory(pachClient *client.APIClient, input *pps.Input) (DatumFactory, error) { switch { case input.Pfs != nil: return newPFSDatumFactory(pachClient, input.Pfs) case input.Union != nil: return newUnionDatumFactory(pachClient, input.Union) case input.Cross != nil: return newCrossDatumFactory(pachClient, input.Cross) case input.Cron != nil: return newCronDatumFactory(pachClient, input.Cron) case input.Git != nil: return newGitDatumFactory(pachClient, input.Git) } return nil, fmt.Errorf("unrecognized input type") }
go
func NewDatumFactory(pachClient *client.APIClient, input *pps.Input) (DatumFactory, error) { switch { case input.Pfs != nil: return newPFSDatumFactory(pachClient, input.Pfs) case input.Union != nil: return newUnionDatumFactory(pachClient, input.Union) case input.Cross != nil: return newCrossDatumFactory(pachClient, input.Cross) case input.Cron != nil: return newCronDatumFactory(pachClient, input.Cron) case input.Git != nil: return newGitDatumFactory(pachClient, input.Git) } return nil, fmt.Errorf("unrecognized input type") }
[ "func", "NewDatumFactory", "(", "pachClient", "*", "client", ".", "APIClient", ",", "input", "*", "pps", ".", "Input", ")", "(", "DatumFactory", ",", "error", ")", "{", "switch", "{", "case", "input", ".", "Pfs", "!=", "nil", ":", "return", "newPFSDatumFactory", "(", "pachClient", ",", "input", ".", "Pfs", ")", "\n", "case", "input", ".", "Union", "!=", "nil", ":", "return", "newUnionDatumFactory", "(", "pachClient", ",", "input", ".", "Union", ")", "\n", "case", "input", ".", "Cross", "!=", "nil", ":", "return", "newCrossDatumFactory", "(", "pachClient", ",", "input", ".", "Cross", ")", "\n", "case", "input", ".", "Cron", "!=", "nil", ":", "return", "newCronDatumFactory", "(", "pachClient", ",", "input", ".", "Cron", ")", "\n", "case", "input", ".", "Git", "!=", "nil", ":", "return", "newGitDatumFactory", "(", "pachClient", ",", "input", ".", "Git", ")", "\n", "}", "\n", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"unrecognized input type\"", ")", "\n", "}" ]
// NewDatumFactory creates a datumFactory for an input.
[ "NewDatumFactory", "creates", "a", "datumFactory", "for", "an", "input", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/worker/datum_set.go#L195-L209
test
pachyderm/pachyderm
src/server/pkg/collection/collection.go
NewCollection
func NewCollection(etcdClient *etcd.Client, prefix string, indexes []*Index, template proto.Message, keyCheck func(string) error, valCheck func(proto.Message) error) Collection { // We want to ensure that the prefix always ends with a trailing // slash. Otherwise, when you list the items under a collection // such as `foo`, you might end up listing items under `foobar` // as well. if len(prefix) > 0 && prefix[len(prefix)-1] != '/' { prefix = prefix + "/" } return &collection{ prefix: prefix, etcdClient: etcdClient, indexes: indexes, limit: defaultLimit, template: template, keyCheck: keyCheck, valCheck: valCheck, } }
go
func NewCollection(etcdClient *etcd.Client, prefix string, indexes []*Index, template proto.Message, keyCheck func(string) error, valCheck func(proto.Message) error) Collection { // We want to ensure that the prefix always ends with a trailing // slash. Otherwise, when you list the items under a collection // such as `foo`, you might end up listing items under `foobar` // as well. if len(prefix) > 0 && prefix[len(prefix)-1] != '/' { prefix = prefix + "/" } return &collection{ prefix: prefix, etcdClient: etcdClient, indexes: indexes, limit: defaultLimit, template: template, keyCheck: keyCheck, valCheck: valCheck, } }
[ "func", "NewCollection", "(", "etcdClient", "*", "etcd", ".", "Client", ",", "prefix", "string", ",", "indexes", "[", "]", "*", "Index", ",", "template", "proto", ".", "Message", ",", "keyCheck", "func", "(", "string", ")", "error", ",", "valCheck", "func", "(", "proto", ".", "Message", ")", "error", ")", "Collection", "{", "if", "len", "(", "prefix", ")", ">", "0", "&&", "prefix", "[", "len", "(", "prefix", ")", "-", "1", "]", "!=", "'/'", "{", "prefix", "=", "prefix", "+", "\"/\"", "\n", "}", "\n", "return", "&", "collection", "{", "prefix", ":", "prefix", ",", "etcdClient", ":", "etcdClient", ",", "indexes", ":", "indexes", ",", "limit", ":", "defaultLimit", ",", "template", ":", "template", ",", "keyCheck", ":", "keyCheck", ",", "valCheck", ":", "valCheck", ",", "}", "\n", "}" ]
// NewCollection creates a new collection.
[ "NewCollection", "creates", "a", "new", "collection", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/collection/collection.go#L61-L79
test
pachyderm/pachyderm
src/server/pkg/collection/collection.go
Path
func (c *collection) Path(key string) string { return path.Join(c.prefix, key) }
go
func (c *collection) Path(key string) string { return path.Join(c.prefix, key) }
[ "func", "(", "c", "*", "collection", ")", "Path", "(", "key", "string", ")", "string", "{", "return", "path", ".", "Join", "(", "c", ".", "prefix", ",", "key", ")", "\n", "}" ]
// Path returns the full path of a key in the etcd namespace
[ "Path", "returns", "the", "full", "path", "of", "a", "key", "in", "the", "etcd", "namespace" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/collection/collection.go#L148-L150
test
pachyderm/pachyderm
src/server/pkg/collection/collection.go
getIndexPath
func (c *readWriteCollection) getIndexPath(val interface{}, index *Index, key string) string { reflVal := reflect.ValueOf(val) field := reflect.Indirect(reflVal).FieldByName(index.Field).Interface() return c.indexPath(index, field, key) }
go
func (c *readWriteCollection) getIndexPath(val interface{}, index *Index, key string) string { reflVal := reflect.ValueOf(val) field := reflect.Indirect(reflVal).FieldByName(index.Field).Interface() return c.indexPath(index, field, key) }
[ "func", "(", "c", "*", "readWriteCollection", ")", "getIndexPath", "(", "val", "interface", "{", "}", ",", "index", "*", "Index", ",", "key", "string", ")", "string", "{", "reflVal", ":=", "reflect", ".", "ValueOf", "(", "val", ")", "\n", "field", ":=", "reflect", ".", "Indirect", "(", "reflVal", ")", ".", "FieldByName", "(", "index", ".", "Field", ")", ".", "Interface", "(", ")", "\n", "return", "c", ".", "indexPath", "(", "index", ",", "field", ",", "key", ")", "\n", "}" ]
// Giving a value, an index, and the key of the item, return the path // under which the new index item should be stored.
[ "Giving", "a", "value", "an", "index", "and", "the", "key", "of", "the", "item", "return", "the", "path", "under", "which", "the", "new", "index", "item", "should", "be", "stored", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/collection/collection.go#L219-L223
test
pachyderm/pachyderm
src/server/pkg/collection/collection.go
getMultiIndexPaths
func (c *readWriteCollection) getMultiIndexPaths(val interface{}, index *Index, key string) []string { var indexPaths []string field := reflect.Indirect(reflect.ValueOf(val)).FieldByName(index.Field) for i := 0; i < field.Len(); i++ { indexPaths = append(indexPaths, c.indexPath(index, field.Index(i).Interface(), key)) } return indexPaths }
go
func (c *readWriteCollection) getMultiIndexPaths(val interface{}, index *Index, key string) []string { var indexPaths []string field := reflect.Indirect(reflect.ValueOf(val)).FieldByName(index.Field) for i := 0; i < field.Len(); i++ { indexPaths = append(indexPaths, c.indexPath(index, field.Index(i).Interface(), key)) } return indexPaths }
[ "func", "(", "c", "*", "readWriteCollection", ")", "getMultiIndexPaths", "(", "val", "interface", "{", "}", ",", "index", "*", "Index", ",", "key", "string", ")", "[", "]", "string", "{", "var", "indexPaths", "[", "]", "string", "\n", "field", ":=", "reflect", ".", "Indirect", "(", "reflect", ".", "ValueOf", "(", "val", ")", ")", ".", "FieldByName", "(", "index", ".", "Field", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "field", ".", "Len", "(", ")", ";", "i", "++", "{", "indexPaths", "=", "append", "(", "indexPaths", ",", "c", ".", "indexPath", "(", "index", ",", "field", ".", "Index", "(", "i", ")", ".", "Interface", "(", ")", ",", "key", ")", ")", "\n", "}", "\n", "return", "indexPaths", "\n", "}" ]
// Giving a value, a multi-index, and the key of the item, return the // paths under which the multi-index items should be stored.
[ "Giving", "a", "value", "a", "multi", "-", "index", "and", "the", "key", "of", "the", "item", "return", "the", "paths", "under", "which", "the", "multi", "-", "index", "items", "should", "be", "stored", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/collection/collection.go#L227-L234
test
pachyderm/pachyderm
src/server/pkg/collection/collection.go
Upsert
func (c *readWriteCollection) Upsert(key string, val proto.Message, f func() error) error { if err := watch.CheckType(c.template, val); err != nil { return err } if err := c.Get(key, val); err != nil && !IsErrNotFound(err) { return err } if err := f(); err != nil { return err } return c.Put(key, val) }
go
func (c *readWriteCollection) Upsert(key string, val proto.Message, f func() error) error { if err := watch.CheckType(c.template, val); err != nil { return err } if err := c.Get(key, val); err != nil && !IsErrNotFound(err) { return err } if err := f(); err != nil { return err } return c.Put(key, val) }
[ "func", "(", "c", "*", "readWriteCollection", ")", "Upsert", "(", "key", "string", ",", "val", "proto", ".", "Message", ",", "f", "func", "(", ")", "error", ")", "error", "{", "if", "err", ":=", "watch", ".", "CheckType", "(", "c", ".", "template", ",", "val", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "c", ".", "Get", "(", "key", ",", "val", ")", ";", "err", "!=", "nil", "&&", "!", "IsErrNotFound", "(", "err", ")", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "f", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "c", ".", "Put", "(", "key", ",", "val", ")", "\n", "}" ]
// Upsert is like Update but 'key' is not required to be present
[ "Upsert", "is", "like", "Update", "but", "key", "is", "not", "required", "to", "be", "present" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/collection/collection.go#L341-L352
test
pachyderm/pachyderm
src/server/pkg/collection/collection.go
get
func (c *readonlyCollection) get(key string, opts ...etcd.OpOption) (*etcd.GetResponse, error) { span, ctx := tracing.AddSpanToAnyExisting(c.ctx, "etcd.Get") defer tracing.FinishAnySpan(span) resp, err := c.etcdClient.Get(ctx, key, opts...) return resp, err }
go
func (c *readonlyCollection) get(key string, opts ...etcd.OpOption) (*etcd.GetResponse, error) { span, ctx := tracing.AddSpanToAnyExisting(c.ctx, "etcd.Get") defer tracing.FinishAnySpan(span) resp, err := c.etcdClient.Get(ctx, key, opts...) return resp, err }
[ "func", "(", "c", "*", "readonlyCollection", ")", "get", "(", "key", "string", ",", "opts", "...", "etcd", ".", "OpOption", ")", "(", "*", "etcd", ".", "GetResponse", ",", "error", ")", "{", "span", ",", "ctx", ":=", "tracing", ".", "AddSpanToAnyExisting", "(", "c", ".", "ctx", ",", "\"etcd.Get\"", ")", "\n", "defer", "tracing", ".", "FinishAnySpan", "(", "span", ")", "\n", "resp", ",", "err", ":=", "c", ".", "etcdClient", ".", "Get", "(", "ctx", ",", "key", ",", "opts", "...", ")", "\n", "return", "resp", ",", "err", "\n", "}" ]
// get is an internal wrapper around etcdClient.Get that wraps the call in a // trace
[ "get", "is", "an", "internal", "wrapper", "around", "etcdClient", ".", "Get", "that", "wraps", "the", "call", "in", "a", "trace" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/collection/collection.go#L482-L487
test
pachyderm/pachyderm
src/server/pkg/collection/collection.go
List
func (c *readonlyCollection) List(val proto.Message, opts *Options, f func(string) error) error { if err := watch.CheckType(c.template, val); err != nil { return err } return c.list(c.prefix, &c.limit, opts, func(kv *mvccpb.KeyValue) error { if err := proto.Unmarshal(kv.Value, val); err != nil { return err } return f(strings.TrimPrefix(string(kv.Key), c.prefix)) }) }
go
func (c *readonlyCollection) List(val proto.Message, opts *Options, f func(string) error) error { if err := watch.CheckType(c.template, val); err != nil { return err } return c.list(c.prefix, &c.limit, opts, func(kv *mvccpb.KeyValue) error { if err := proto.Unmarshal(kv.Value, val); err != nil { return err } return f(strings.TrimPrefix(string(kv.Key), c.prefix)) }) }
[ "func", "(", "c", "*", "readonlyCollection", ")", "List", "(", "val", "proto", ".", "Message", ",", "opts", "*", "Options", ",", "f", "func", "(", "string", ")", "error", ")", "error", "{", "if", "err", ":=", "watch", ".", "CheckType", "(", "c", ".", "template", ",", "val", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "c", ".", "list", "(", "c", ".", "prefix", ",", "&", "c", ".", "limit", ",", "opts", ",", "func", "(", "kv", "*", "mvccpb", ".", "KeyValue", ")", "error", "{", "if", "err", ":=", "proto", ".", "Unmarshal", "(", "kv", ".", "Value", ",", "val", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "f", "(", "strings", ".", "TrimPrefix", "(", "string", "(", "kv", ".", "Key", ")", ",", "c", ".", "prefix", ")", ")", "\n", "}", ")", "\n", "}" ]
// List returns objects sorted based on the options passed in. f will be called with each key, val will contain the // corresponding value. Val is not an argument to f because that would require // f to perform a cast before it could be used. // You can break out of iteration by returning errutil.ErrBreak.
[ "List", "returns", "objects", "sorted", "based", "on", "the", "options", "passed", "in", ".", "f", "will", "be", "called", "with", "each", "key", "val", "will", "contain", "the", "corresponding", "value", ".", "Val", "is", "not", "an", "argument", "to", "f", "because", "that", "would", "require", "f", "to", "perform", "a", "cast", "before", "it", "could", "be", "used", ".", "You", "can", "break", "out", "of", "iteration", "by", "returning", "errutil", ".", "ErrBreak", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/collection/collection.go#L582-L592
test
pachyderm/pachyderm
src/server/pkg/collection/collection.go
Watch
func (c *readonlyCollection) Watch(opts ...watch.OpOption) (watch.Watcher, error) { return watch.NewWatcher(c.ctx, c.etcdClient, c.prefix, c.prefix, c.template, opts...) }
go
func (c *readonlyCollection) Watch(opts ...watch.OpOption) (watch.Watcher, error) { return watch.NewWatcher(c.ctx, c.etcdClient, c.prefix, c.prefix, c.template, opts...) }
[ "func", "(", "c", "*", "readonlyCollection", ")", "Watch", "(", "opts", "...", "watch", ".", "OpOption", ")", "(", "watch", ".", "Watcher", ",", "error", ")", "{", "return", "watch", ".", "NewWatcher", "(", "c", ".", "ctx", ",", "c", ".", "etcdClient", ",", "c", ".", "prefix", ",", "c", ".", "prefix", ",", "c", ".", "template", ",", "opts", "...", ")", "\n", "}" ]
// Watch a collection, returning the current content of the collection as // well as any future additions.
[ "Watch", "a", "collection", "returning", "the", "current", "content", "of", "the", "collection", "as", "well", "as", "any", "future", "additions", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/collection/collection.go#L612-L614
test
pachyderm/pachyderm
src/server/pkg/collection/collection.go
WatchByIndex
func (c *readonlyCollection) WatchByIndex(index *Index, val interface{}) (watch.Watcher, error) { eventCh := make(chan *watch.Event) done := make(chan struct{}) watcher, err := watch.NewWatcher(c.ctx, c.etcdClient, c.prefix, c.indexDir(index, val), c.template) if err != nil { return nil, err } go func() (retErr error) { defer func() { if retErr != nil { eventCh <- &watch.Event{ Type: watch.EventError, Err: retErr, } watcher.Close() } close(eventCh) }() for { var ev *watch.Event var ok bool select { case ev, ok = <-watcher.Watch(): case <-done: watcher.Close() 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 }
go
func (c *readonlyCollection) WatchByIndex(index *Index, val interface{}) (watch.Watcher, error) { eventCh := make(chan *watch.Event) done := make(chan struct{}) watcher, err := watch.NewWatcher(c.ctx, c.etcdClient, c.prefix, c.indexDir(index, val), c.template) if err != nil { return nil, err } go func() (retErr error) { defer func() { if retErr != nil { eventCh <- &watch.Event{ Type: watch.EventError, Err: retErr, } watcher.Close() } close(eventCh) }() for { var ev *watch.Event var ok bool select { case ev, ok = <-watcher.Watch(): case <-done: watcher.Close() 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 }
[ "func", "(", "c", "*", "readonlyCollection", ")", "WatchByIndex", "(", "index", "*", "Index", ",", "val", "interface", "{", "}", ")", "(", "watch", ".", "Watcher", ",", "error", ")", "{", "eventCh", ":=", "make", "(", "chan", "*", "watch", ".", "Event", ")", "\n", "done", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "watcher", ",", "err", ":=", "watch", ".", "NewWatcher", "(", "c", ".", "ctx", ",", "c", ".", "etcdClient", ",", "c", ".", "prefix", ",", "c", ".", "indexDir", "(", "index", ",", "val", ")", ",", "c", ".", "template", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "go", "func", "(", ")", "(", "retErr", "error", ")", "{", "defer", "func", "(", ")", "{", "if", "retErr", "!=", "nil", "{", "eventCh", "<-", "&", "watch", ".", "Event", "{", "Type", ":", "watch", ".", "EventError", ",", "Err", ":", "retErr", ",", "}", "\n", "watcher", ".", "Close", "(", ")", "\n", "}", "\n", "close", "(", "eventCh", ")", "\n", "}", "(", ")", "\n", "for", "{", "var", "ev", "*", "watch", ".", "Event", "\n", "var", "ok", "bool", "\n", "select", "{", "case", "ev", ",", "ok", "=", "<-", "watcher", ".", "Watch", "(", ")", ":", "case", "<-", "done", ":", "watcher", ".", "Close", "(", ")", "\n", "return", "nil", "\n", "}", "\n", "if", "!", "ok", "{", "watcher", ".", "Close", "(", ")", "\n", "return", "nil", "\n", "}", "\n", "var", "directEv", "*", "watch", ".", "Event", "\n", "switch", "ev", ".", "Type", "{", "case", "watch", ".", "EventError", ":", "return", "ev", ".", "Err", "\n", "case", "watch", ".", "EventPut", ":", "resp", ",", "err", ":=", "c", ".", "get", "(", "c", ".", "Path", "(", "path", ".", "Base", "(", "string", "(", "ev", ".", "Key", ")", ")", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "len", "(", "resp", ".", "Kvs", ")", "==", "0", "{", "continue", "\n", "}", "\n", "directEv", "=", "&", "watch", ".", "Event", "{", "Key", ":", "[", "]", "byte", "(", "path", ".", "Base", "(", "string", "(", "ev", ".", "Key", ")", ")", ")", ",", "Value", ":", "resp", ".", "Kvs", "[", "0", "]", ".", "Value", ",", "Type", ":", "ev", ".", "Type", ",", "Template", ":", "c", ".", "template", ",", "}", "\n", "case", "watch", ".", "EventDelete", ":", "directEv", "=", "&", "watch", ".", "Event", "{", "Key", ":", "[", "]", "byte", "(", "path", ".", "Base", "(", "string", "(", "ev", ".", "Key", ")", ")", ")", ",", "Type", ":", "ev", ".", "Type", ",", "Template", ":", "c", ".", "template", ",", "}", "\n", "}", "\n", "eventCh", "<-", "directEv", "\n", "}", "\n", "}", "(", ")", "\n", "return", "watch", ".", "MakeWatcher", "(", "eventCh", ",", "done", ")", ",", "nil", "\n", "}" ]
// WatchByIndex watches items in a collection that match a particular index
[ "WatchByIndex", "watches", "items", "in", "a", "collection", "that", "match", "a", "particular", "index" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/collection/collection.go#L617-L681
test
pachyderm/pachyderm
src/server/pkg/collection/collection.go
WatchOne
func (c *readonlyCollection) WatchOne(key string) (watch.Watcher, error) { return watch.NewWatcher(c.ctx, c.etcdClient, c.prefix, c.Path(key), c.template) }
go
func (c *readonlyCollection) WatchOne(key string) (watch.Watcher, error) { return watch.NewWatcher(c.ctx, c.etcdClient, c.prefix, c.Path(key), c.template) }
[ "func", "(", "c", "*", "readonlyCollection", ")", "WatchOne", "(", "key", "string", ")", "(", "watch", ".", "Watcher", ",", "error", ")", "{", "return", "watch", ".", "NewWatcher", "(", "c", ".", "ctx", ",", "c", ".", "etcdClient", ",", "c", ".", "prefix", ",", "c", ".", "Path", "(", "key", ")", ",", "c", ".", "template", ")", "\n", "}" ]
// WatchOne watches a given item. The first value returned from the watch // will be the current value of the item.
[ "WatchOne", "watches", "a", "given", "item", ".", "The", "first", "value", "returned", "from", "the", "watch", "will", "be", "the", "current", "value", "of", "the", "item", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/collection/collection.go#L685-L687
test
pachyderm/pachyderm
src/server/pkg/collection/collection.go
WatchOneF
func (c *readonlyCollection) WatchOneF(key string, f func(e *watch.Event) error) error { watcher, err := watch.NewWatcher(c.ctx, c.etcdClient, c.prefix, c.Path(key), c.template) if err != nil { return err } defer watcher.Close() for { select { case e := <-watcher.Watch(): if err := f(e); err != nil { if err == errutil.ErrBreak { return nil } return err } case <-c.ctx.Done(): return c.ctx.Err() } } }
go
func (c *readonlyCollection) WatchOneF(key string, f func(e *watch.Event) error) error { watcher, err := watch.NewWatcher(c.ctx, c.etcdClient, c.prefix, c.Path(key), c.template) if err != nil { return err } defer watcher.Close() for { select { case e := <-watcher.Watch(): if err := f(e); err != nil { if err == errutil.ErrBreak { return nil } return err } case <-c.ctx.Done(): return c.ctx.Err() } } }
[ "func", "(", "c", "*", "readonlyCollection", ")", "WatchOneF", "(", "key", "string", ",", "f", "func", "(", "e", "*", "watch", ".", "Event", ")", "error", ")", "error", "{", "watcher", ",", "err", ":=", "watch", ".", "NewWatcher", "(", "c", ".", "ctx", ",", "c", ".", "etcdClient", ",", "c", ".", "prefix", ",", "c", ".", "Path", "(", "key", ")", ",", "c", ".", "template", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "watcher", ".", "Close", "(", ")", "\n", "for", "{", "select", "{", "case", "e", ":=", "<-", "watcher", ".", "Watch", "(", ")", ":", "if", "err", ":=", "f", "(", "e", ")", ";", "err", "!=", "nil", "{", "if", "err", "==", "errutil", ".", "ErrBreak", "{", "return", "nil", "\n", "}", "\n", "return", "err", "\n", "}", "\n", "case", "<-", "c", ".", "ctx", ".", "Done", "(", ")", ":", "return", "c", ".", "ctx", ".", "Err", "(", ")", "\n", "}", "\n", "}", "\n", "}" ]
// WatchOneF watches a given item and executes a callback function each time an event occurs. // The first value returned from the watch will be the current value of the item.
[ "WatchOneF", "watches", "a", "given", "item", "and", "executes", "a", "callback", "function", "each", "time", "an", "event", "occurs", ".", "The", "first", "value", "returned", "from", "the", "watch", "will", "be", "the", "current", "value", "of", "the", "item", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/collection/collection.go#L691-L710
test
pachyderm/pachyderm
src/server/pkg/localcache/cache.go
Get
func (c *Cache) Get(key string) (io.ReadCloser, error) { c.mu.Lock() defer c.mu.Unlock() if !c.keys[key] { 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 }
go
func (c *Cache) Get(key string) (io.ReadCloser, error) { c.mu.Lock() defer c.mu.Unlock() if !c.keys[key] { 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 }
[ "func", "(", "c", "*", "Cache", ")", "Get", "(", "key", "string", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "c", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "!", "c", ".", "keys", "[", "key", "]", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"key %v not found in cache\"", ",", "key", ")", "\n", "}", "\n", "f", ",", "err", ":=", "os", ".", "Open", "(", "filepath", ".", "Join", "(", "c", ".", "root", ",", "key", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "f", ",", "nil", "\n", "}" ]
// Get gets a key's value by returning an io.ReadCloser that should be closed when done.
[ "Get", "gets", "a", "key", "s", "value", "by", "returning", "an", "io", ".", "ReadCloser", "that", "should", "be", "closed", "when", "done", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/localcache/cache.go#L52-L63
test
pachyderm/pachyderm
src/server/pkg/localcache/cache.go
Keys
func (c *Cache) Keys() []string { c.mu.Lock() defer c.mu.Unlock() var keys []string for key := range c.keys { keys = append(keys, key) } sort.Strings(keys) return keys }
go
func (c *Cache) Keys() []string { c.mu.Lock() defer c.mu.Unlock() var keys []string for key := range c.keys { keys = append(keys, key) } sort.Strings(keys) return keys }
[ "func", "(", "c", "*", "Cache", ")", "Keys", "(", ")", "[", "]", "string", "{", "c", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mu", ".", "Unlock", "(", ")", "\n", "var", "keys", "[", "]", "string", "\n", "for", "key", ":=", "range", "c", ".", "keys", "{", "keys", "=", "append", "(", "keys", ",", "key", ")", "\n", "}", "\n", "sort", ".", "Strings", "(", "keys", ")", "\n", "return", "keys", "\n", "}" ]
// Keys returns the keys in sorted order.
[ "Keys", "returns", "the", "keys", "in", "sorted", "order", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/localcache/cache.go#L66-L75
test
pachyderm/pachyderm
src/server/pkg/localcache/cache.go
Clear
func (c *Cache) Clear() error { c.mu.Lock() defer c.mu.Unlock() defer func() { c.keys = make(map[string]bool) }() for key := range c.keys { if err := os.Remove(filepath.Join(c.root, key)); err != nil { return err } } return nil }
go
func (c *Cache) Clear() error { c.mu.Lock() defer c.mu.Unlock() defer func() { c.keys = make(map[string]bool) }() for key := range c.keys { if err := os.Remove(filepath.Join(c.root, key)); err != nil { return err } } return nil }
[ "func", "(", "c", "*", "Cache", ")", "Clear", "(", ")", "error", "{", "c", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mu", ".", "Unlock", "(", ")", "\n", "defer", "func", "(", ")", "{", "c", ".", "keys", "=", "make", "(", "map", "[", "string", "]", "bool", ")", "\n", "}", "(", ")", "\n", "for", "key", ":=", "range", "c", ".", "keys", "{", "if", "err", ":=", "os", ".", "Remove", "(", "filepath", ".", "Join", "(", "c", ".", "root", ",", "key", ")", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Clear clears the cache.
[ "Clear", "clears", "the", "cache", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/localcache/cache.go#L89-L101
test
pachyderm/pachyderm
src/server/http/http.go
NewHTTPServer
func NewHTTPServer(address string) (http.Handler, error) { router := httprouter.New() s := &server{ router: router, address: address, httpClient: &http.Client{}, } router.GET(getFilePath, s.getFileHandler) router.GET(servicePath, s.serviceHandler) router.POST(loginPath, s.authLoginHandler) router.POST(logoutPath, s.authLogoutHandler) router.POST(servicePath, s.serviceHandler) router.NotFound = http.HandlerFunc(notFound) return s, nil }
go
func NewHTTPServer(address string) (http.Handler, error) { router := httprouter.New() s := &server{ router: router, address: address, httpClient: &http.Client{}, } router.GET(getFilePath, s.getFileHandler) router.GET(servicePath, s.serviceHandler) router.POST(loginPath, s.authLoginHandler) router.POST(logoutPath, s.authLogoutHandler) router.POST(servicePath, s.serviceHandler) router.NotFound = http.HandlerFunc(notFound) return s, nil }
[ "func", "NewHTTPServer", "(", "address", "string", ")", "(", "http", ".", "Handler", ",", "error", ")", "{", "router", ":=", "httprouter", ".", "New", "(", ")", "\n", "s", ":=", "&", "server", "{", "router", ":", "router", ",", "address", ":", "address", ",", "httpClient", ":", "&", "http", ".", "Client", "{", "}", ",", "}", "\n", "router", ".", "GET", "(", "getFilePath", ",", "s", ".", "getFileHandler", ")", "\n", "router", ".", "GET", "(", "servicePath", ",", "s", ".", "serviceHandler", ")", "\n", "router", ".", "POST", "(", "loginPath", ",", "s", ".", "authLoginHandler", ")", "\n", "router", ".", "POST", "(", "logoutPath", ",", "s", ".", "authLogoutHandler", ")", "\n", "router", ".", "POST", "(", "servicePath", ",", "s", ".", "serviceHandler", ")", "\n", "router", ".", "NotFound", "=", "http", ".", "HandlerFunc", "(", "notFound", ")", "\n", "return", "s", ",", "nil", "\n", "}" ]
// NewHTTPServer returns a Pachyderm HTTP server.
[ "NewHTTPServer", "returns", "a", "Pachyderm", "HTTP", "server", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/http/http.go#L47-L64
test
pachyderm/pachyderm
src/server/deploy/deploy.go
NewDeployServer
func NewDeployServer(kubeClient *kube.Clientset, kubeNamespace string) deploy.APIServer { return &apiServer{ kubeClient: kubeClient, kubeNamespace: kubeNamespace, } }
go
func NewDeployServer(kubeClient *kube.Clientset, kubeNamespace string) deploy.APIServer { return &apiServer{ kubeClient: kubeClient, kubeNamespace: kubeNamespace, } }
[ "func", "NewDeployServer", "(", "kubeClient", "*", "kube", ".", "Clientset", ",", "kubeNamespace", "string", ")", "deploy", ".", "APIServer", "{", "return", "&", "apiServer", "{", "kubeClient", ":", "kubeClient", ",", "kubeNamespace", ":", "kubeNamespace", ",", "}", "\n", "}" ]
// NewDeployServer creates a deploy server
[ "NewDeployServer", "creates", "a", "deploy", "server" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/deploy/deploy.go#L20-L25
test
pachyderm/pachyderm
src/server/pkg/deploy/images/images.go
Export
func Export(opts *assets.AssetOpts, out io.Writer) error { client, err := docker.NewClientFromEnv() if err != nil { return err } authConfigs, err := docker.NewAuthConfigurationsFromDockerCfg() if err != nil { return fmt.Errorf("error parsing auth: %s, try running `docker login`", err.Error()) } if len(authConfigs.Configs) == 0 { return fmt.Errorf("didn't find any valid auth configurations") } images := assets.Images(opts) for _, image := range images { repository, tag := docker.ParseRepositoryTag(image) pulled := false var loopErr []error for registry, authConfig := range authConfigs.Configs { if err := client.PullImage( docker.PullImageOptions{ Repository: repository, Tag: tag, InactivityTimeout: 5 * 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, }) }
go
func Export(opts *assets.AssetOpts, out io.Writer) error { client, err := docker.NewClientFromEnv() if err != nil { return err } authConfigs, err := docker.NewAuthConfigurationsFromDockerCfg() if err != nil { return fmt.Errorf("error parsing auth: %s, try running `docker login`", err.Error()) } if len(authConfigs.Configs) == 0 { return fmt.Errorf("didn't find any valid auth configurations") } images := assets.Images(opts) for _, image := range images { repository, tag := docker.ParseRepositoryTag(image) pulled := false var loopErr []error for registry, authConfig := range authConfigs.Configs { if err := client.PullImage( docker.PullImageOptions{ Repository: repository, Tag: tag, InactivityTimeout: 5 * 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, }) }
[ "func", "Export", "(", "opts", "*", "assets", ".", "AssetOpts", ",", "out", "io", ".", "Writer", ")", "error", "{", "client", ",", "err", ":=", "docker", ".", "NewClientFromEnv", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "authConfigs", ",", "err", ":=", "docker", ".", "NewAuthConfigurationsFromDockerCfg", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"error parsing auth: %s, try running `docker login`\"", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "if", "len", "(", "authConfigs", ".", "Configs", ")", "==", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"didn't find any valid auth configurations\"", ")", "\n", "}", "\n", "images", ":=", "assets", ".", "Images", "(", "opts", ")", "\n", "for", "_", ",", "image", ":=", "range", "images", "{", "repository", ",", "tag", ":=", "docker", ".", "ParseRepositoryTag", "(", "image", ")", "\n", "pulled", ":=", "false", "\n", "var", "loopErr", "[", "]", "error", "\n", "for", "registry", ",", "authConfig", ":=", "range", "authConfigs", ".", "Configs", "{", "if", "err", ":=", "client", ".", "PullImage", "(", "docker", ".", "PullImageOptions", "{", "Repository", ":", "repository", ",", "Tag", ":", "tag", ",", "InactivityTimeout", ":", "5", "*", "time", ".", "Second", ",", "}", ",", "authConfig", ",", ")", ";", "err", "!=", "nil", "{", "loopErr", "=", "append", "(", "loopErr", ",", "fmt", ".", "Errorf", "(", "\"error pulling from %s: %v\"", ",", "registry", ",", "err", ")", ")", "\n", "continue", "\n", "}", "\n", "pulled", "=", "true", "\n", "break", "\n", "}", "\n", "if", "!", "pulled", "{", "errStr", ":=", "\"\"", "\n", "for", "_", ",", "err", ":=", "range", "loopErr", "{", "errStr", "+=", "err", ".", "Error", "(", ")", "+", "\"\\n\"", "\n", "}", "\n", "\\n", "\n", "}", "\n", "}", "\n", "return", "fmt", ".", "Errorf", "(", "\"errors pulling image %s:%s:\\n%s\"", ",", "\\n", ",", "repository", ",", "tag", ")", "\n", "}" ]
// Export a tarball of the images needed by a deployment.
[ "Export", "a", "tarball", "of", "the", "images", "needed", "by", "a", "deployment", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/deploy/images/images.go#L13-L57
test
pachyderm/pachyderm
src/server/pkg/deploy/images/images.go
Import
func Import(opts *assets.AssetOpts, in io.Reader) error { client, err := docker.NewClientFromEnv() if err != nil { return err } authConfigs, err := docker.NewAuthConfigurationsFromDockerCfg() if err != nil { return fmt.Errorf("error parsing auth: %s, try running `docker login`", err.Error()) } if len(authConfigs.Configs) == 0 { return fmt.Errorf("didn't find any valid auth configurations") } if err := client.LoadImage(docker.LoadImageOptions{ InputStream: in, }); err != nil { return err } registry := opts.Registry opts.Registry = "" // pretend we're using default images so we can get targets to tag images := assets.Images(opts) opts.Registry = registry for _, image := range images { repository, tag := docker.ParseRepositoryTag(image) registryRepo := assets.AddRegistry(opts.Registry, repository) if err := client.TagImage(image, docker.TagImageOptions{ Repo: registryRepo, Tag: tag, }, ); err != nil { return fmt.Errorf("error tagging image: %v", err) } pushed := false var loopErr []error for 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 }
go
func Import(opts *assets.AssetOpts, in io.Reader) error { client, err := docker.NewClientFromEnv() if err != nil { return err } authConfigs, err := docker.NewAuthConfigurationsFromDockerCfg() if err != nil { return fmt.Errorf("error parsing auth: %s, try running `docker login`", err.Error()) } if len(authConfigs.Configs) == 0 { return fmt.Errorf("didn't find any valid auth configurations") } if err := client.LoadImage(docker.LoadImageOptions{ InputStream: in, }); err != nil { return err } registry := opts.Registry opts.Registry = "" // pretend we're using default images so we can get targets to tag images := assets.Images(opts) opts.Registry = registry for _, image := range images { repository, tag := docker.ParseRepositoryTag(image) registryRepo := assets.AddRegistry(opts.Registry, repository) if err := client.TagImage(image, docker.TagImageOptions{ Repo: registryRepo, Tag: tag, }, ); err != nil { return fmt.Errorf("error tagging image: %v", err) } pushed := false var loopErr []error for 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 }
[ "func", "Import", "(", "opts", "*", "assets", ".", "AssetOpts", ",", "in", "io", ".", "Reader", ")", "error", "{", "client", ",", "err", ":=", "docker", ".", "NewClientFromEnv", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "authConfigs", ",", "err", ":=", "docker", ".", "NewAuthConfigurationsFromDockerCfg", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"error parsing auth: %s, try running `docker login`\"", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "if", "len", "(", "authConfigs", ".", "Configs", ")", "==", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"didn't find any valid auth configurations\"", ")", "\n", "}", "\n", "if", "err", ":=", "client", ".", "LoadImage", "(", "docker", ".", "LoadImageOptions", "{", "InputStream", ":", "in", ",", "}", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "registry", ":=", "opts", ".", "Registry", "\n", "opts", ".", "Registry", "=", "\"\"", "\n", "images", ":=", "assets", ".", "Images", "(", "opts", ")", "\n", "opts", ".", "Registry", "=", "registry", "\n", "for", "_", ",", "image", ":=", "range", "images", "{", "repository", ",", "tag", ":=", "docker", ".", "ParseRepositoryTag", "(", "image", ")", "\n", "registryRepo", ":=", "assets", ".", "AddRegistry", "(", "opts", ".", "Registry", ",", "repository", ")", "\n", "if", "err", ":=", "client", ".", "TagImage", "(", "image", ",", "docker", ".", "TagImageOptions", "{", "Repo", ":", "registryRepo", ",", "Tag", ":", "tag", ",", "}", ",", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"error tagging image: %v\"", ",", "err", ")", "\n", "}", "\n", "pushed", ":=", "false", "\n", "var", "loopErr", "[", "]", "error", "\n", "for", "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", ")", ")", "\n", "continue", "\n", "}", "\n", "pushed", "=", "true", "\n", "break", "\n", "}", "\n", "if", "!", "pushed", "{", "errStr", ":=", "\"\"", "\n", "for", "_", ",", "err", ":=", "range", "loopErr", "{", "errStr", "+=", "err", ".", "Error", "(", ")", "+", "\"\\n\"", "\n", "}", "\n", "\\n", "\n", "}", "\n", "}", "\n", "return", "fmt", ".", "Errorf", "(", "\"errors pushing image %s:%s:\\n%s\"", ",", "\\n", ",", "registryRepo", ",", "tag", ")", "\n", "}" ]
// Import a tarball of the images needed by a deployment such as the one // created by Export and push those images to the registry specific in opts.
[ "Import", "a", "tarball", "of", "the", "images", "needed", "by", "a", "deployment", "such", "as", "the", "one", "created", "by", "Export", "and", "push", "those", "images", "to", "the", "registry", "specific", "in", "opts", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/deploy/images/images.go#L61-L119
test
pachyderm/pachyderm
src/client/pps.go
DatumTagPrefix
func DatumTagPrefix(salt string) string { // We need to hash the salt because UUIDs are not necessarily // random in every bit. h := sha256.New() h.Write([]byte(salt)) return hex.EncodeToString(h.Sum(nil))[:4] }
go
func DatumTagPrefix(salt string) string { // We need to hash the salt because UUIDs are not necessarily // random in every bit. h := sha256.New() h.Write([]byte(salt)) return hex.EncodeToString(h.Sum(nil))[:4] }
[ "func", "DatumTagPrefix", "(", "salt", "string", ")", "string", "{", "h", ":=", "sha256", ".", "New", "(", ")", "\n", "h", ".", "Write", "(", "[", "]", "byte", "(", "salt", ")", ")", "\n", "return", "hex", ".", "EncodeToString", "(", "h", ".", "Sum", "(", "nil", ")", ")", "[", ":", "4", "]", "\n", "}" ]
// DatumTagPrefix hashes a pipeline salt to a string of a fixed size for use as // the prefix for datum output trees. This prefix allows us to do garbage // collection correctly.
[ "DatumTagPrefix", "hashes", "a", "pipeline", "salt", "to", "a", "string", "of", "a", "fixed", "size", "for", "use", "as", "the", "prefix", "for", "datum", "output", "trees", ".", "This", "prefix", "allows", "us", "to", "do", "garbage", "collection", "correctly", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L81-L87
test
pachyderm/pachyderm
src/client/pps.go
NewPFSInput
func NewPFSInput(repo string, glob string) *pps.Input { return &pps.Input{ Pfs: &pps.PFSInput{ Repo: repo, Glob: glob, }, } }
go
func NewPFSInput(repo string, glob string) *pps.Input { return &pps.Input{ Pfs: &pps.PFSInput{ Repo: repo, Glob: glob, }, } }
[ "func", "NewPFSInput", "(", "repo", "string", ",", "glob", "string", ")", "*", "pps", ".", "Input", "{", "return", "&", "pps", ".", "Input", "{", "Pfs", ":", "&", "pps", ".", "PFSInput", "{", "Repo", ":", "repo", ",", "Glob", ":", "glob", ",", "}", ",", "}", "\n", "}" ]
// NewPFSInput returns a new PFS input. It only includes required options.
[ "NewPFSInput", "returns", "a", "new", "PFS", "input", ".", "It", "only", "includes", "required", "options", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L90-L97
test
pachyderm/pachyderm
src/client/pps.go
NewPFSInputOpts
func NewPFSInputOpts(name string, repo string, branch string, glob string, lazy bool) *pps.Input { return &pps.Input{ Pfs: &pps.PFSInput{ Name: name, Repo: repo, Branch: branch, Glob: glob, Lazy: lazy, }, } }
go
func NewPFSInputOpts(name string, repo string, branch string, glob string, lazy bool) *pps.Input { return &pps.Input{ Pfs: &pps.PFSInput{ Name: name, Repo: repo, Branch: branch, Glob: glob, Lazy: lazy, }, } }
[ "func", "NewPFSInputOpts", "(", "name", "string", ",", "repo", "string", ",", "branch", "string", ",", "glob", "string", ",", "lazy", "bool", ")", "*", "pps", ".", "Input", "{", "return", "&", "pps", ".", "Input", "{", "Pfs", ":", "&", "pps", ".", "PFSInput", "{", "Name", ":", "name", ",", "Repo", ":", "repo", ",", "Branch", ":", "branch", ",", "Glob", ":", "glob", ",", "Lazy", ":", "lazy", ",", "}", ",", "}", "\n", "}" ]
// NewPFSInputOpts returns a new PFS input. It includes all options.
[ "NewPFSInputOpts", "returns", "a", "new", "PFS", "input", ".", "It", "includes", "all", "options", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L100-L110
test
pachyderm/pachyderm
src/client/pps.go
NewJobInput
func NewJobInput(repoName string, commitID string, glob string) *pps.JobInput { return &pps.JobInput{ Commit: NewCommit(repoName, commitID), Glob: glob, } }
go
func NewJobInput(repoName string, commitID string, glob string) *pps.JobInput { return &pps.JobInput{ Commit: NewCommit(repoName, commitID), Glob: glob, } }
[ "func", "NewJobInput", "(", "repoName", "string", ",", "commitID", "string", ",", "glob", "string", ")", "*", "pps", ".", "JobInput", "{", "return", "&", "pps", ".", "JobInput", "{", "Commit", ":", "NewCommit", "(", "repoName", ",", "commitID", ")", ",", "Glob", ":", "glob", ",", "}", "\n", "}" ]
// NewJobInput creates a pps.JobInput.
[ "NewJobInput", "creates", "a", "pps", ".", "JobInput", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L144-L149
test
pachyderm/pachyderm
src/client/pps.go
NewPipelineInput
func NewPipelineInput(repoName string, glob string) *pps.PipelineInput { return &pps.PipelineInput{ Repo: NewRepo(repoName), Glob: glob, } }
go
func NewPipelineInput(repoName string, glob string) *pps.PipelineInput { return &pps.PipelineInput{ Repo: NewRepo(repoName), Glob: glob, } }
[ "func", "NewPipelineInput", "(", "repoName", "string", ",", "glob", "string", ")", "*", "pps", ".", "PipelineInput", "{", "return", "&", "pps", ".", "PipelineInput", "{", "Repo", ":", "NewRepo", "(", "repoName", ")", ",", "Glob", ":", "glob", ",", "}", "\n", "}" ]
// NewPipelineInput creates a new pps.PipelineInput
[ "NewPipelineInput", "creates", "a", "new", "pps", ".", "PipelineInput" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L157-L162
test
pachyderm/pachyderm
src/client/pps.go
CreateJob
func (c APIClient) CreateJob(pipeline string, outputCommit *pfs.Commit) (*pps.Job, error) { job, err := c.PpsAPIClient.CreateJob( c.Ctx(), &pps.CreateJobRequest{ Pipeline: NewPipeline(pipeline), OutputCommit: outputCommit, }, ) return job, grpcutil.ScrubGRPC(err) }
go
func (c APIClient) CreateJob(pipeline string, outputCommit *pfs.Commit) (*pps.Job, error) { job, err := c.PpsAPIClient.CreateJob( c.Ctx(), &pps.CreateJobRequest{ Pipeline: NewPipeline(pipeline), OutputCommit: outputCommit, }, ) return job, grpcutil.ScrubGRPC(err) }
[ "func", "(", "c", "APIClient", ")", "CreateJob", "(", "pipeline", "string", ",", "outputCommit", "*", "pfs", ".", "Commit", ")", "(", "*", "pps", ".", "Job", ",", "error", ")", "{", "job", ",", "err", ":=", "c", ".", "PpsAPIClient", ".", "CreateJob", "(", "c", ".", "Ctx", "(", ")", ",", "&", "pps", ".", "CreateJobRequest", "{", "Pipeline", ":", "NewPipeline", "(", "pipeline", ")", ",", "OutputCommit", ":", "outputCommit", ",", "}", ",", ")", "\n", "return", "job", ",", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", "\n", "}" ]
// CreateJob creates and runs a job in PPS. // This function is mostly useful internally, users should generally run work // by creating pipelines as well.
[ "CreateJob", "creates", "and", "runs", "a", "job", "in", "PPS", ".", "This", "function", "is", "mostly", "useful", "internally", "users", "should", "generally", "run", "work", "by", "creating", "pipelines", "as", "well", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L167-L176
test
pachyderm/pachyderm
src/client/pps.go
ListJob
func (c APIClient) ListJob(pipelineName string, inputCommit []*pfs.Commit, outputCommit *pfs.Commit) ([]*pps.JobInfo, error) { var result []*pps.JobInfo if err := c.ListJobF(pipelineName, inputCommit, outputCommit, func(ji *pps.JobInfo) error { result = append(result, ji) return nil }); err != nil { return nil, err } return result, nil }
go
func (c APIClient) ListJob(pipelineName string, inputCommit []*pfs.Commit, outputCommit *pfs.Commit) ([]*pps.JobInfo, error) { var result []*pps.JobInfo if err := c.ListJobF(pipelineName, inputCommit, outputCommit, func(ji *pps.JobInfo) error { result = append(result, ji) return nil }); err != nil { return nil, err } return result, nil }
[ "func", "(", "c", "APIClient", ")", "ListJob", "(", "pipelineName", "string", ",", "inputCommit", "[", "]", "*", "pfs", ".", "Commit", ",", "outputCommit", "*", "pfs", ".", "Commit", ")", "(", "[", "]", "*", "pps", ".", "JobInfo", ",", "error", ")", "{", "var", "result", "[", "]", "*", "pps", ".", "JobInfo", "\n", "if", "err", ":=", "c", ".", "ListJobF", "(", "pipelineName", ",", "inputCommit", ",", "outputCommit", ",", "func", "(", "ji", "*", "pps", ".", "JobInfo", ")", "error", "{", "result", "=", "append", "(", "result", ",", "ji", ")", "\n", "return", "nil", "\n", "}", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "result", ",", "nil", "\n", "}" ]
// ListJob returns info about all jobs. // If pipelineName is non empty then only jobs that were started by the named pipeline will be returned // If inputCommit is non-nil then only jobs which took the specific commits as inputs will be returned. // The order of the inputCommits doesn't matter. // If outputCommit is non-nil then only the job which created that commit as output will be returned.
[ "ListJob", "returns", "info", "about", "all", "jobs", ".", "If", "pipelineName", "is", "non", "empty", "then", "only", "jobs", "that", "were", "started", "by", "the", "named", "pipeline", "will", "be", "returned", "If", "inputCommit", "is", "non", "-", "nil", "then", "only", "jobs", "which", "took", "the", "specific", "commits", "as", "inputs", "will", "be", "returned", ".", "The", "order", "of", "the", "inputCommits", "doesn", "t", "matter", ".", "If", "outputCommit", "is", "non", "-", "nil", "then", "only", "the", "job", "which", "created", "that", "commit", "as", "output", "will", "be", "returned", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L207-L216
test
pachyderm/pachyderm
src/client/pps.go
ListJobF
func (c APIClient) ListJobF(pipelineName string, inputCommit []*pfs.Commit, outputCommit *pfs.Commit, f func(*pps.JobInfo) error) error { var pipeline *pps.Pipeline if pipelineName != "" { pipeline = NewPipeline(pipelineName) } client, err := c.PpsAPIClient.ListJobStream( c.Ctx(), &pps.ListJobRequest{ Pipeline: pipeline, InputCommit: inputCommit, OutputCommit: outputCommit, }) if err != nil { 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 } } }
go
func (c APIClient) ListJobF(pipelineName string, inputCommit []*pfs.Commit, outputCommit *pfs.Commit, f func(*pps.JobInfo) error) error { var pipeline *pps.Pipeline if pipelineName != "" { pipeline = NewPipeline(pipelineName) } client, err := c.PpsAPIClient.ListJobStream( c.Ctx(), &pps.ListJobRequest{ Pipeline: pipeline, InputCommit: inputCommit, OutputCommit: outputCommit, }) if err != nil { 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 } } }
[ "func", "(", "c", "APIClient", ")", "ListJobF", "(", "pipelineName", "string", ",", "inputCommit", "[", "]", "*", "pfs", ".", "Commit", ",", "outputCommit", "*", "pfs", ".", "Commit", ",", "f", "func", "(", "*", "pps", ".", "JobInfo", ")", "error", ")", "error", "{", "var", "pipeline", "*", "pps", ".", "Pipeline", "\n", "if", "pipelineName", "!=", "\"\"", "{", "pipeline", "=", "NewPipeline", "(", "pipelineName", ")", "\n", "}", "\n", "client", ",", "err", ":=", "c", ".", "PpsAPIClient", ".", "ListJobStream", "(", "c", ".", "Ctx", "(", ")", ",", "&", "pps", ".", "ListJobRequest", "{", "Pipeline", ":", "pipeline", ",", "InputCommit", ":", "inputCommit", ",", "OutputCommit", ":", "outputCommit", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", "\n", "}", "\n", "for", "{", "ji", ",", "err", ":=", "client", ".", "Recv", "(", ")", "\n", "if", "err", "==", "io", ".", "EOF", "{", "return", "nil", "\n", "}", "else", "if", "err", "!=", "nil", "{", "return", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", "\n", "}", "\n", "if", "err", ":=", "f", "(", "ji", ")", ";", "err", "!=", "nil", "{", "if", "err", "==", "errutil", ".", "ErrBreak", "{", "return", "nil", "\n", "}", "\n", "return", "err", "\n", "}", "\n", "}", "\n", "}" ]
// ListJobF returns info about all jobs, calling f with each JobInfo. // If f returns an error iteration of jobs will stop and ListJobF will return // that error, unless the error is errutil.ErrBreak in which case it will // return nil. // If pipelineName is non empty then only jobs that were started by the named pipeline will be returned // If inputCommit is non-nil then only jobs which took the specific commits as inputs will be returned. // The order of the inputCommits doesn't matter. // If outputCommit is non-nil then only the job which created that commit as output will be returned.
[ "ListJobF", "returns", "info", "about", "all", "jobs", "calling", "f", "with", "each", "JobInfo", ".", "If", "f", "returns", "an", "error", "iteration", "of", "jobs", "will", "stop", "and", "ListJobF", "will", "return", "that", "error", "unless", "the", "error", "is", "errutil", ".", "ErrBreak", "in", "which", "case", "it", "will", "return", "nil", ".", "If", "pipelineName", "is", "non", "empty", "then", "only", "jobs", "that", "were", "started", "by", "the", "named", "pipeline", "will", "be", "returned", "If", "inputCommit", "is", "non", "-", "nil", "then", "only", "jobs", "which", "took", "the", "specific", "commits", "as", "inputs", "will", "be", "returned", ".", "The", "order", "of", "the", "inputCommits", "doesn", "t", "matter", ".", "If", "outputCommit", "is", "non", "-", "nil", "then", "only", "the", "job", "which", "created", "that", "commit", "as", "output", "will", "be", "returned", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L226-L255
test
pachyderm/pachyderm
src/client/pps.go
FlushJob
func (c APIClient) FlushJob(commits []*pfs.Commit, toPipelines []string, f func(*pps.JobInfo) error) error { req := &pps.FlushJobRequest{ Commits: commits, } for _, pipeline := range toPipelines { req.ToPipelines = append(req.ToPipelines, NewPipeline(pipeline)) } client, err := c.PpsAPIClient.FlushJob(c.Ctx(), req) if err != nil { return 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 } } }
go
func (c APIClient) FlushJob(commits []*pfs.Commit, toPipelines []string, f func(*pps.JobInfo) error) error { req := &pps.FlushJobRequest{ Commits: commits, } for _, pipeline := range toPipelines { req.ToPipelines = append(req.ToPipelines, NewPipeline(pipeline)) } client, err := c.PpsAPIClient.FlushJob(c.Ctx(), req) if err != nil { return 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 } } }
[ "func", "(", "c", "APIClient", ")", "FlushJob", "(", "commits", "[", "]", "*", "pfs", ".", "Commit", ",", "toPipelines", "[", "]", "string", ",", "f", "func", "(", "*", "pps", ".", "JobInfo", ")", "error", ")", "error", "{", "req", ":=", "&", "pps", ".", "FlushJobRequest", "{", "Commits", ":", "commits", ",", "}", "\n", "for", "_", ",", "pipeline", ":=", "range", "toPipelines", "{", "req", ".", "ToPipelines", "=", "append", "(", "req", ".", "ToPipelines", ",", "NewPipeline", "(", "pipeline", ")", ")", "\n", "}", "\n", "client", ",", "err", ":=", "c", ".", "PpsAPIClient", ".", "FlushJob", "(", "c", ".", "Ctx", "(", ")", ",", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", "\n", "}", "\n", "for", "{", "jobInfo", ",", "err", ":=", "client", ".", "Recv", "(", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "io", ".", "EOF", "{", "return", "nil", "\n", "}", "\n", "return", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", "\n", "}", "\n", "if", "err", ":=", "f", "(", "jobInfo", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "}" ]
// FlushJob calls f with all the jobs which were triggered by commits. // If toPipelines is non-nil then only the jobs between commits and those // pipelines in the DAG will be returned.
[ "FlushJob", "calls", "f", "with", "all", "the", "jobs", "which", "were", "triggered", "by", "commits", ".", "If", "toPipelines", "is", "non", "-", "nil", "then", "only", "the", "jobs", "between", "commits", "and", "those", "pipelines", "in", "the", "DAG", "will", "be", "returned", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L260-L283
test
pachyderm/pachyderm
src/client/pps.go
FlushJobAll
func (c APIClient) FlushJobAll(commits []*pfs.Commit, toPipelines []string) ([]*pps.JobInfo, error) { var result []*pps.JobInfo if err := c.FlushJob(commits, toPipelines, func(ji *pps.JobInfo) error { result = append(result, ji) return nil }); err != nil { return nil, err } return result, nil }
go
func (c APIClient) FlushJobAll(commits []*pfs.Commit, toPipelines []string) ([]*pps.JobInfo, error) { var result []*pps.JobInfo if err := c.FlushJob(commits, toPipelines, func(ji *pps.JobInfo) error { result = append(result, ji) return nil }); err != nil { return nil, err } return result, nil }
[ "func", "(", "c", "APIClient", ")", "FlushJobAll", "(", "commits", "[", "]", "*", "pfs", ".", "Commit", ",", "toPipelines", "[", "]", "string", ")", "(", "[", "]", "*", "pps", ".", "JobInfo", ",", "error", ")", "{", "var", "result", "[", "]", "*", "pps", ".", "JobInfo", "\n", "if", "err", ":=", "c", ".", "FlushJob", "(", "commits", ",", "toPipelines", ",", "func", "(", "ji", "*", "pps", ".", "JobInfo", ")", "error", "{", "result", "=", "append", "(", "result", ",", "ji", ")", "\n", "return", "nil", "\n", "}", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "result", ",", "nil", "\n", "}" ]
// FlushJobAll returns all the jobs which were triggered by commits. // If toPipelines is non-nil then only the jobs between commits and those // pipelines in the DAG will be returned.
[ "FlushJobAll", "returns", "all", "the", "jobs", "which", "were", "triggered", "by", "commits", ".", "If", "toPipelines", "is", "non", "-", "nil", "then", "only", "the", "jobs", "between", "commits", "and", "those", "pipelines", "in", "the", "DAG", "will", "be", "returned", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L288-L297
test
pachyderm/pachyderm
src/client/pps.go
DeleteJob
func (c APIClient) DeleteJob(jobID string) error { _, err := c.PpsAPIClient.DeleteJob( c.Ctx(), &pps.DeleteJobRequest{ Job: NewJob(jobID), }, ) return grpcutil.ScrubGRPC(err) }
go
func (c APIClient) DeleteJob(jobID string) error { _, err := c.PpsAPIClient.DeleteJob( c.Ctx(), &pps.DeleteJobRequest{ Job: NewJob(jobID), }, ) return grpcutil.ScrubGRPC(err) }
[ "func", "(", "c", "APIClient", ")", "DeleteJob", "(", "jobID", "string", ")", "error", "{", "_", ",", "err", ":=", "c", ".", "PpsAPIClient", ".", "DeleteJob", "(", "c", ".", "Ctx", "(", ")", ",", "&", "pps", ".", "DeleteJobRequest", "{", "Job", ":", "NewJob", "(", "jobID", ")", ",", "}", ",", ")", "\n", "return", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", "\n", "}" ]
// DeleteJob deletes a job.
[ "DeleteJob", "deletes", "a", "job", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L300-L308
test
pachyderm/pachyderm
src/client/pps.go
StopJob
func (c APIClient) StopJob(jobID string) error { _, err := c.PpsAPIClient.StopJob( c.Ctx(), &pps.StopJobRequest{ Job: NewJob(jobID), }, ) return grpcutil.ScrubGRPC(err) }
go
func (c APIClient) StopJob(jobID string) error { _, err := c.PpsAPIClient.StopJob( c.Ctx(), &pps.StopJobRequest{ Job: NewJob(jobID), }, ) return grpcutil.ScrubGRPC(err) }
[ "func", "(", "c", "APIClient", ")", "StopJob", "(", "jobID", "string", ")", "error", "{", "_", ",", "err", ":=", "c", ".", "PpsAPIClient", ".", "StopJob", "(", "c", ".", "Ctx", "(", ")", ",", "&", "pps", ".", "StopJobRequest", "{", "Job", ":", "NewJob", "(", "jobID", ")", ",", "}", ",", ")", "\n", "return", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", "\n", "}" ]
// StopJob stops a job.
[ "StopJob", "stops", "a", "job", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L311-L319
test
pachyderm/pachyderm
src/client/pps.go
RestartDatum
func (c APIClient) RestartDatum(jobID string, datumFilter []string) error { _, err := c.PpsAPIClient.RestartDatum( c.Ctx(), &pps.RestartDatumRequest{ Job: NewJob(jobID), DataFilters: datumFilter, }, ) return grpcutil.ScrubGRPC(err) }
go
func (c APIClient) RestartDatum(jobID string, datumFilter []string) error { _, err := c.PpsAPIClient.RestartDatum( c.Ctx(), &pps.RestartDatumRequest{ Job: NewJob(jobID), DataFilters: datumFilter, }, ) return grpcutil.ScrubGRPC(err) }
[ "func", "(", "c", "APIClient", ")", "RestartDatum", "(", "jobID", "string", ",", "datumFilter", "[", "]", "string", ")", "error", "{", "_", ",", "err", ":=", "c", ".", "PpsAPIClient", ".", "RestartDatum", "(", "c", ".", "Ctx", "(", ")", ",", "&", "pps", ".", "RestartDatumRequest", "{", "Job", ":", "NewJob", "(", "jobID", ")", ",", "DataFilters", ":", "datumFilter", ",", "}", ",", ")", "\n", "return", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", "\n", "}" ]
// RestartDatum restarts a datum that's being processed as part of a job. // datumFilter is a slice of strings which are matched against either the Path // or Hash of the datum, the order of the strings in datumFilter is irrelevant.
[ "RestartDatum", "restarts", "a", "datum", "that", "s", "being", "processed", "as", "part", "of", "a", "job", ".", "datumFilter", "is", "a", "slice", "of", "strings", "which", "are", "matched", "against", "either", "the", "Path", "or", "Hash", "of", "the", "datum", "the", "order", "of", "the", "strings", "in", "datumFilter", "is", "irrelevant", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L324-L333
test
pachyderm/pachyderm
src/client/pps.go
ListDatum
func (c APIClient) ListDatum(jobID string, pageSize int64, page int64) (*pps.ListDatumResponse, error) { client, err := c.PpsAPIClient.ListDatumStream( c.Ctx(), &pps.ListDatumRequest{ Job: NewJob(jobID), PageSize: pageSize, Page: page, }, ) if err != nil { return nil, grpcutil.ScrubGRPC(err) } resp := &pps.ListDatumResponse{} first := true for { r, err := client.Recv() if err == io.EOF { 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 }
go
func (c APIClient) ListDatum(jobID string, pageSize int64, page int64) (*pps.ListDatumResponse, error) { client, err := c.PpsAPIClient.ListDatumStream( c.Ctx(), &pps.ListDatumRequest{ Job: NewJob(jobID), PageSize: pageSize, Page: page, }, ) if err != nil { return nil, grpcutil.ScrubGRPC(err) } resp := &pps.ListDatumResponse{} first := true for { r, err := client.Recv() if err == io.EOF { 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 }
[ "func", "(", "c", "APIClient", ")", "ListDatum", "(", "jobID", "string", ",", "pageSize", "int64", ",", "page", "int64", ")", "(", "*", "pps", ".", "ListDatumResponse", ",", "error", ")", "{", "client", ",", "err", ":=", "c", ".", "PpsAPIClient", ".", "ListDatumStream", "(", "c", ".", "Ctx", "(", ")", ",", "&", "pps", ".", "ListDatumRequest", "{", "Job", ":", "NewJob", "(", "jobID", ")", ",", "PageSize", ":", "pageSize", ",", "Page", ":", "page", ",", "}", ",", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", "\n", "}", "\n", "resp", ":=", "&", "pps", ".", "ListDatumResponse", "{", "}", "\n", "first", ":=", "true", "\n", "for", "{", "r", ",", "err", ":=", "client", ".", "Recv", "(", ")", "\n", "if", "err", "==", "io", ".", "EOF", "{", "break", "\n", "}", "else", "if", "err", "!=", "nil", "{", "return", "nil", ",", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", "\n", "}", "\n", "if", "first", "{", "resp", ".", "TotalPages", "=", "r", ".", "TotalPages", "\n", "resp", ".", "Page", "=", "r", ".", "Page", "\n", "first", "=", "false", "\n", "}", "\n", "resp", ".", "DatumInfos", "=", "append", "(", "resp", ".", "DatumInfos", ",", "r", ".", "DatumInfo", ")", "\n", "}", "\n", "return", "resp", ",", "nil", "\n", "}" ]
// ListDatum returns info about all datums in a Job
[ "ListDatum", "returns", "info", "about", "all", "datums", "in", "a", "Job" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L336-L365
test
pachyderm/pachyderm
src/client/pps.go
ListDatumF
func (c APIClient) ListDatumF(jobID string, pageSize int64, page int64, f func(di *pps.DatumInfo) error) error { client, err := c.PpsAPIClient.ListDatumStream( c.Ctx(), &pps.ListDatumRequest{ Job: NewJob(jobID), PageSize: pageSize, Page: page, }, ) if err != nil { return grpcutil.ScrubGRPC(err) } for { resp, err := client.Recv() 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 } } }
go
func (c APIClient) ListDatumF(jobID string, pageSize int64, page int64, f func(di *pps.DatumInfo) error) error { client, err := c.PpsAPIClient.ListDatumStream( c.Ctx(), &pps.ListDatumRequest{ Job: NewJob(jobID), PageSize: pageSize, Page: page, }, ) if err != nil { return grpcutil.ScrubGRPC(err) } for { resp, err := client.Recv() 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 } } }
[ "func", "(", "c", "APIClient", ")", "ListDatumF", "(", "jobID", "string", ",", "pageSize", "int64", ",", "page", "int64", ",", "f", "func", "(", "di", "*", "pps", ".", "DatumInfo", ")", "error", ")", "error", "{", "client", ",", "err", ":=", "c", ".", "PpsAPIClient", ".", "ListDatumStream", "(", "c", ".", "Ctx", "(", ")", ",", "&", "pps", ".", "ListDatumRequest", "{", "Job", ":", "NewJob", "(", "jobID", ")", ",", "PageSize", ":", "pageSize", ",", "Page", ":", "page", ",", "}", ",", ")", "\n", "if", "err", "!=", "nil", "{", "return", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", "\n", "}", "\n", "for", "{", "resp", ",", "err", ":=", "client", ".", "Recv", "(", ")", "\n", "if", "err", "==", "io", ".", "EOF", "{", "return", "nil", "\n", "}", "else", "if", "err", "!=", "nil", "{", "return", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", "\n", "}", "\n", "if", "err", ":=", "f", "(", "resp", ".", "DatumInfo", ")", ";", "err", "!=", "nil", "{", "if", "err", "==", "errutil", ".", "ErrBreak", "{", "return", "nil", "\n", "}", "\n", "return", "err", "\n", "}", "\n", "}", "\n", "}" ]
// ListDatumF returns info about all datums in a Job, calling f with each datum info.
[ "ListDatumF", "returns", "info", "about", "all", "datums", "in", "a", "Job", "calling", "f", "with", "each", "datum", "info", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L368-L394
test
pachyderm/pachyderm
src/client/pps.go
InspectDatum
func (c APIClient) InspectDatum(jobID string, datumID string) (*pps.DatumInfo, error) { datumInfo, err := c.PpsAPIClient.InspectDatum( c.Ctx(), &pps.InspectDatumRequest{ Datum: &pps.Datum{ ID: datumID, Job: NewJob(jobID), }, }, ) if err != nil { return nil, grpcutil.ScrubGRPC(err) } return datumInfo, nil }
go
func (c APIClient) InspectDatum(jobID string, datumID string) (*pps.DatumInfo, error) { datumInfo, err := c.PpsAPIClient.InspectDatum( c.Ctx(), &pps.InspectDatumRequest{ Datum: &pps.Datum{ ID: datumID, Job: NewJob(jobID), }, }, ) if err != nil { return nil, grpcutil.ScrubGRPC(err) } return datumInfo, nil }
[ "func", "(", "c", "APIClient", ")", "InspectDatum", "(", "jobID", "string", ",", "datumID", "string", ")", "(", "*", "pps", ".", "DatumInfo", ",", "error", ")", "{", "datumInfo", ",", "err", ":=", "c", ".", "PpsAPIClient", ".", "InspectDatum", "(", "c", ".", "Ctx", "(", ")", ",", "&", "pps", ".", "InspectDatumRequest", "{", "Datum", ":", "&", "pps", ".", "Datum", "{", "ID", ":", "datumID", ",", "Job", ":", "NewJob", "(", "jobID", ")", ",", "}", ",", "}", ",", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", "\n", "}", "\n", "return", "datumInfo", ",", "nil", "\n", "}" ]
// InspectDatum returns info about a single datum
[ "InspectDatum", "returns", "info", "about", "a", "single", "datum" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L397-L411
test
pachyderm/pachyderm
src/client/pps.go
Next
func (l *LogsIter) Next() bool { if l.err != nil { l.msg = nil return false } l.msg, l.err = l.logsClient.Recv() if l.err != nil { return false } return true }
go
func (l *LogsIter) Next() bool { if l.err != nil { l.msg = nil return false } l.msg, l.err = l.logsClient.Recv() if l.err != nil { return false } return true }
[ "func", "(", "l", "*", "LogsIter", ")", "Next", "(", ")", "bool", "{", "if", "l", ".", "err", "!=", "nil", "{", "l", ".", "msg", "=", "nil", "\n", "return", "false", "\n", "}", "\n", "l", ".", "msg", ",", "l", ".", "err", "=", "l", ".", "logsClient", ".", "Recv", "(", ")", "\n", "if", "l", ".", "err", "!=", "nil", "{", "return", "false", "\n", "}", "\n", "return", "true", "\n", "}" ]
// Next retrieves the next relevant log message from pachd
[ "Next", "retrieves", "the", "next", "relevant", "log", "message", "from", "pachd" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L423-L433
test
pachyderm/pachyderm
src/client/pps.go
InspectPipeline
func (c APIClient) InspectPipeline(pipelineName string) (*pps.PipelineInfo, error) { pipelineInfo, err := c.PpsAPIClient.InspectPipeline( c.Ctx(), &pps.InspectPipelineRequest{ Pipeline: NewPipeline(pipelineName), }, ) return pipelineInfo, grpcutil.ScrubGRPC(err) }
go
func (c APIClient) InspectPipeline(pipelineName string) (*pps.PipelineInfo, error) { pipelineInfo, err := c.PpsAPIClient.InspectPipeline( c.Ctx(), &pps.InspectPipelineRequest{ Pipeline: NewPipeline(pipelineName), }, ) return pipelineInfo, grpcutil.ScrubGRPC(err) }
[ "func", "(", "c", "APIClient", ")", "InspectPipeline", "(", "pipelineName", "string", ")", "(", "*", "pps", ".", "PipelineInfo", ",", "error", ")", "{", "pipelineInfo", ",", "err", ":=", "c", ".", "PpsAPIClient", ".", "InspectPipeline", "(", "c", ".", "Ctx", "(", ")", ",", "&", "pps", ".", "InspectPipelineRequest", "{", "Pipeline", ":", "NewPipeline", "(", "pipelineName", ")", ",", "}", ",", ")", "\n", "return", "pipelineInfo", ",", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", "\n", "}" ]
// InspectPipeline returns info about a specific pipeline.
[ "InspectPipeline", "returns", "info", "about", "a", "specific", "pipeline", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L534-L542
test
pachyderm/pachyderm
src/client/pps.go
ListPipeline
func (c APIClient) ListPipeline() ([]*pps.PipelineInfo, error) { pipelineInfos, err := c.PpsAPIClient.ListPipeline( c.Ctx(), &pps.ListPipelineRequest{}, ) if err != nil { return nil, grpcutil.ScrubGRPC(err) } return pipelineInfos.PipelineInfo, nil }
go
func (c APIClient) ListPipeline() ([]*pps.PipelineInfo, error) { pipelineInfos, err := c.PpsAPIClient.ListPipeline( c.Ctx(), &pps.ListPipelineRequest{}, ) if err != nil { return nil, grpcutil.ScrubGRPC(err) } return pipelineInfos.PipelineInfo, nil }
[ "func", "(", "c", "APIClient", ")", "ListPipeline", "(", ")", "(", "[", "]", "*", "pps", ".", "PipelineInfo", ",", "error", ")", "{", "pipelineInfos", ",", "err", ":=", "c", ".", "PpsAPIClient", ".", "ListPipeline", "(", "c", ".", "Ctx", "(", ")", ",", "&", "pps", ".", "ListPipelineRequest", "{", "}", ",", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", "\n", "}", "\n", "return", "pipelineInfos", ".", "PipelineInfo", ",", "nil", "\n", "}" ]
// ListPipeline returns info about all pipelines.
[ "ListPipeline", "returns", "info", "about", "all", "pipelines", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L545-L554
test
pachyderm/pachyderm
src/client/pps.go
DeletePipeline
func (c APIClient) DeletePipeline(name string, force bool) error { _, err := c.PpsAPIClient.DeletePipeline( c.Ctx(), &pps.DeletePipelineRequest{ Pipeline: NewPipeline(name), Force: force, }, ) return grpcutil.ScrubGRPC(err) }
go
func (c APIClient) DeletePipeline(name string, force bool) error { _, err := c.PpsAPIClient.DeletePipeline( c.Ctx(), &pps.DeletePipelineRequest{ Pipeline: NewPipeline(name), Force: force, }, ) return grpcutil.ScrubGRPC(err) }
[ "func", "(", "c", "APIClient", ")", "DeletePipeline", "(", "name", "string", ",", "force", "bool", ")", "error", "{", "_", ",", "err", ":=", "c", ".", "PpsAPIClient", ".", "DeletePipeline", "(", "c", ".", "Ctx", "(", ")", ",", "&", "pps", ".", "DeletePipelineRequest", "{", "Pipeline", ":", "NewPipeline", "(", "name", ")", ",", "Force", ":", "force", ",", "}", ",", ")", "\n", "return", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", "\n", "}" ]
// DeletePipeline deletes a pipeline along with its output Repo.
[ "DeletePipeline", "deletes", "a", "pipeline", "along", "with", "its", "output", "Repo", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L557-L566
test
pachyderm/pachyderm
src/client/pps.go
StartPipeline
func (c APIClient) StartPipeline(name string) error { _, err := c.PpsAPIClient.StartPipeline( c.Ctx(), &pps.StartPipelineRequest{ Pipeline: NewPipeline(name), }, ) return grpcutil.ScrubGRPC(err) }
go
func (c APIClient) StartPipeline(name string) error { _, err := c.PpsAPIClient.StartPipeline( c.Ctx(), &pps.StartPipelineRequest{ Pipeline: NewPipeline(name), }, ) return grpcutil.ScrubGRPC(err) }
[ "func", "(", "c", "APIClient", ")", "StartPipeline", "(", "name", "string", ")", "error", "{", "_", ",", "err", ":=", "c", ".", "PpsAPIClient", ".", "StartPipeline", "(", "c", ".", "Ctx", "(", ")", ",", "&", "pps", ".", "StartPipelineRequest", "{", "Pipeline", ":", "NewPipeline", "(", "name", ")", ",", "}", ",", ")", "\n", "return", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", "\n", "}" ]
// StartPipeline restarts a stopped pipeline.
[ "StartPipeline", "restarts", "a", "stopped", "pipeline", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L569-L577
test
pachyderm/pachyderm
src/client/pps.go
StopPipeline
func (c APIClient) StopPipeline(name string) error { _, err := c.PpsAPIClient.StopPipeline( c.Ctx(), &pps.StopPipelineRequest{ Pipeline: NewPipeline(name), }, ) return grpcutil.ScrubGRPC(err) }
go
func (c APIClient) StopPipeline(name string) error { _, err := c.PpsAPIClient.StopPipeline( c.Ctx(), &pps.StopPipelineRequest{ Pipeline: NewPipeline(name), }, ) return grpcutil.ScrubGRPC(err) }
[ "func", "(", "c", "APIClient", ")", "StopPipeline", "(", "name", "string", ")", "error", "{", "_", ",", "err", ":=", "c", ".", "PpsAPIClient", ".", "StopPipeline", "(", "c", ".", "Ctx", "(", ")", ",", "&", "pps", ".", "StopPipelineRequest", "{", "Pipeline", ":", "NewPipeline", "(", "name", ")", ",", "}", ",", ")", "\n", "return", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", "\n", "}" ]
// StopPipeline prevents a pipeline from processing things, it can be restarted // with StartPipeline.
[ "StopPipeline", "prevents", "a", "pipeline", "from", "processing", "things", "it", "can", "be", "restarted", "with", "StartPipeline", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L581-L589
test
pachyderm/pachyderm
src/client/pps.go
RerunPipeline
func (c APIClient) RerunPipeline(name string, include []*pfs.Commit, exclude []*pfs.Commit) error { _, err := c.PpsAPIClient.RerunPipeline( c.Ctx(), &pps.RerunPipelineRequest{ Pipeline: NewPipeline(name), Include: include, Exclude: exclude, }, ) return grpcutil.ScrubGRPC(err) }
go
func (c APIClient) RerunPipeline(name string, include []*pfs.Commit, exclude []*pfs.Commit) error { _, err := c.PpsAPIClient.RerunPipeline( c.Ctx(), &pps.RerunPipelineRequest{ Pipeline: NewPipeline(name), Include: include, Exclude: exclude, }, ) return grpcutil.ScrubGRPC(err) }
[ "func", "(", "c", "APIClient", ")", "RerunPipeline", "(", "name", "string", ",", "include", "[", "]", "*", "pfs", ".", "Commit", ",", "exclude", "[", "]", "*", "pfs", ".", "Commit", ")", "error", "{", "_", ",", "err", ":=", "c", ".", "PpsAPIClient", ".", "RerunPipeline", "(", "c", ".", "Ctx", "(", ")", ",", "&", "pps", ".", "RerunPipelineRequest", "{", "Pipeline", ":", "NewPipeline", "(", "name", ")", ",", "Include", ":", "include", ",", "Exclude", ":", "exclude", ",", "}", ",", ")", "\n", "return", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", "\n", "}" ]
// RerunPipeline reruns a pipeline over a given set of commits. Exclude and // include are filters that either include or exclude the ancestors of the // given commits. A commit is considered the ancestor of itself. The behavior // is the same as that of ListCommit.
[ "RerunPipeline", "reruns", "a", "pipeline", "over", "a", "given", "set", "of", "commits", ".", "Exclude", "and", "include", "are", "filters", "that", "either", "include", "or", "exclude", "the", "ancestors", "of", "the", "given", "commits", ".", "A", "commit", "is", "considered", "the", "ancestor", "of", "itself", ".", "The", "behavior", "is", "the", "same", "as", "that", "of", "ListCommit", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L595-L605
test
pachyderm/pachyderm
src/client/pps.go
CreatePipelineService
func (c APIClient) CreatePipelineService( name string, image string, cmd []string, stdin []string, parallelismSpec *pps.ParallelismSpec, input *pps.Input, update bool, internalPort int32, externalPort int32, ) error { _, err := c.PpsAPIClient.CreatePipeline( c.Ctx(), &pps.CreatePipelineRequest{ Pipeline: NewPipeline(name), Transform: &pps.Transform{ Image: image, Cmd: cmd, Stdin: stdin, }, ParallelismSpec: parallelismSpec, Input: input, Update: update, Service: &pps.Service{ InternalPort: internalPort, ExternalPort: externalPort, }, }, ) return grpcutil.ScrubGRPC(err) }
go
func (c APIClient) CreatePipelineService( name string, image string, cmd []string, stdin []string, parallelismSpec *pps.ParallelismSpec, input *pps.Input, update bool, internalPort int32, externalPort int32, ) error { _, err := c.PpsAPIClient.CreatePipeline( c.Ctx(), &pps.CreatePipelineRequest{ Pipeline: NewPipeline(name), Transform: &pps.Transform{ Image: image, Cmd: cmd, Stdin: stdin, }, ParallelismSpec: parallelismSpec, Input: input, Update: update, Service: &pps.Service{ InternalPort: internalPort, ExternalPort: externalPort, }, }, ) return grpcutil.ScrubGRPC(err) }
[ "func", "(", "c", "APIClient", ")", "CreatePipelineService", "(", "name", "string", ",", "image", "string", ",", "cmd", "[", "]", "string", ",", "stdin", "[", "]", "string", ",", "parallelismSpec", "*", "pps", ".", "ParallelismSpec", ",", "input", "*", "pps", ".", "Input", ",", "update", "bool", ",", "internalPort", "int32", ",", "externalPort", "int32", ",", ")", "error", "{", "_", ",", "err", ":=", "c", ".", "PpsAPIClient", ".", "CreatePipeline", "(", "c", ".", "Ctx", "(", ")", ",", "&", "pps", ".", "CreatePipelineRequest", "{", "Pipeline", ":", "NewPipeline", "(", "name", ")", ",", "Transform", ":", "&", "pps", ".", "Transform", "{", "Image", ":", "image", ",", "Cmd", ":", "cmd", ",", "Stdin", ":", "stdin", ",", "}", ",", "ParallelismSpec", ":", "parallelismSpec", ",", "Input", ":", "input", ",", "Update", ":", "update", ",", "Service", ":", "&", "pps", ".", "Service", "{", "InternalPort", ":", "internalPort", ",", "ExternalPort", ":", "externalPort", ",", "}", ",", "}", ",", ")", "\n", "return", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", "\n", "}" ]
// CreatePipelineService creates a new pipeline service.
[ "CreatePipelineService", "creates", "a", "new", "pipeline", "service", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L608-L638
test
pachyderm/pachyderm
src/client/pps.go
GetDatumTotalTime
func GetDatumTotalTime(s *pps.ProcessStats) time.Duration { totalDuration := time.Duration(0) duration, _ := types.DurationFromProto(s.DownloadTime) totalDuration += duration duration, _ = types.DurationFromProto(s.ProcessTime) totalDuration += duration duration, _ = types.DurationFromProto(s.UploadTime) totalDuration += duration return totalDuration }
go
func GetDatumTotalTime(s *pps.ProcessStats) time.Duration { totalDuration := time.Duration(0) duration, _ := types.DurationFromProto(s.DownloadTime) totalDuration += duration duration, _ = types.DurationFromProto(s.ProcessTime) totalDuration += duration duration, _ = types.DurationFromProto(s.UploadTime) totalDuration += duration return totalDuration }
[ "func", "GetDatumTotalTime", "(", "s", "*", "pps", ".", "ProcessStats", ")", "time", ".", "Duration", "{", "totalDuration", ":=", "time", ".", "Duration", "(", "0", ")", "\n", "duration", ",", "_", ":=", "types", ".", "DurationFromProto", "(", "s", ".", "DownloadTime", ")", "\n", "totalDuration", "+=", "duration", "\n", "duration", ",", "_", "=", "types", ".", "DurationFromProto", "(", "s", ".", "ProcessTime", ")", "\n", "totalDuration", "+=", "duration", "\n", "duration", ",", "_", "=", "types", ".", "DurationFromProto", "(", "s", ".", "UploadTime", ")", "\n", "totalDuration", "+=", "duration", "\n", "return", "totalDuration", "\n", "}" ]
// GetDatumTotalTime sums the timing stats from a DatumInfo
[ "GetDatumTotalTime", "sums", "the", "timing", "stats", "from", "a", "DatumInfo" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L658-L667
test
pachyderm/pachyderm
src/server/pfs/fuse/filesystem.go
Mount
func Mount(c *client.APIClient, mountPoint string, opts *Options) error { nfs := pathfs.NewPathNodeFs(newFileSystem(c, opts.getCommits()), nil) server, _, err := nodefs.MountRoot(mountPoint, nfs.Root(), opts.getFuse()) if err != nil { return fmt.Errorf("nodefs.MountRoot: %v", err) } sigChan := make(chan os.Signal, 1) signal.Notify(sigChan, os.Interrupt) go func() { select { case <-sigChan: case <-opts.getUnmount(): } server.Unmount() }() server.Serve() return nil }
go
func Mount(c *client.APIClient, mountPoint string, opts *Options) error { nfs := pathfs.NewPathNodeFs(newFileSystem(c, opts.getCommits()), nil) server, _, err := nodefs.MountRoot(mountPoint, nfs.Root(), opts.getFuse()) if err != nil { return fmt.Errorf("nodefs.MountRoot: %v", err) } sigChan := make(chan os.Signal, 1) signal.Notify(sigChan, os.Interrupt) go func() { select { case <-sigChan: case <-opts.getUnmount(): } server.Unmount() }() server.Serve() return nil }
[ "func", "Mount", "(", "c", "*", "client", ".", "APIClient", ",", "mountPoint", "string", ",", "opts", "*", "Options", ")", "error", "{", "nfs", ":=", "pathfs", ".", "NewPathNodeFs", "(", "newFileSystem", "(", "c", ",", "opts", ".", "getCommits", "(", ")", ")", ",", "nil", ")", "\n", "server", ",", "_", ",", "err", ":=", "nodefs", ".", "MountRoot", "(", "mountPoint", ",", "nfs", ".", "Root", "(", ")", ",", "opts", ".", "getFuse", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"nodefs.MountRoot: %v\"", ",", "err", ")", "\n", "}", "\n", "sigChan", ":=", "make", "(", "chan", "os", ".", "Signal", ",", "1", ")", "\n", "signal", ".", "Notify", "(", "sigChan", ",", "os", ".", "Interrupt", ")", "\n", "go", "func", "(", ")", "{", "select", "{", "case", "<-", "sigChan", ":", "case", "<-", "opts", ".", "getUnmount", "(", ")", ":", "}", "\n", "server", ".", "Unmount", "(", ")", "\n", "}", "(", ")", "\n", "server", ".", "Serve", "(", ")", "\n", "return", "nil", "\n", "}" ]
// Mount pfs to mountPoint, opts may be left nil.
[ "Mount", "pfs", "to", "mountPoint", "opts", "may", "be", "left", "nil", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pfs/fuse/filesystem.go#L25-L42
test
pachyderm/pachyderm
src/client/pkg/grpcutil/buffer.go
NewBufPool
func NewBufPool(size int) *BufPool { return &BufPool{sync.Pool{ New: func() interface{} { return make([]byte, size) }, }} }
go
func NewBufPool(size int) *BufPool { return &BufPool{sync.Pool{ New: func() interface{} { return make([]byte, size) }, }} }
[ "func", "NewBufPool", "(", "size", "int", ")", "*", "BufPool", "{", "return", "&", "BufPool", "{", "sync", ".", "Pool", "{", "New", ":", "func", "(", ")", "interface", "{", "}", "{", "return", "make", "(", "[", "]", "byte", ",", "size", ")", "}", ",", "}", "}", "\n", "}" ]
// NewBufPool creates a new BufPool that returns buffers of the given size.
[ "NewBufPool", "creates", "a", "new", "BufPool", "that", "returns", "buffers", "of", "the", "given", "size", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pkg/grpcutil/buffer.go#L14-L18
test
pachyderm/pachyderm
src/server/pkg/obj/obj.go
StorageRootFromEnv
func StorageRootFromEnv() (string, error) { storageRoot, ok := os.LookupEnv(PachRootEnvVar) if !ok { return "", fmt.Errorf("%s not found", PachRootEnvVar) } storageBackend, ok := os.LookupEnv(StorageBackendEnvVar) if !ok { return "", fmt.Errorf("%s not found", StorageBackendEnvVar) } // These storage 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 }
go
func StorageRootFromEnv() (string, error) { storageRoot, ok := os.LookupEnv(PachRootEnvVar) if !ok { return "", fmt.Errorf("%s not found", PachRootEnvVar) } storageBackend, ok := os.LookupEnv(StorageBackendEnvVar) if !ok { return "", fmt.Errorf("%s not found", StorageBackendEnvVar) } // These storage 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 }
[ "func", "StorageRootFromEnv", "(", ")", "(", "string", ",", "error", ")", "{", "storageRoot", ",", "ok", ":=", "os", ".", "LookupEnv", "(", "PachRootEnvVar", ")", "\n", "if", "!", "ok", "{", "return", "\"\"", ",", "fmt", ".", "Errorf", "(", "\"%s not found\"", ",", "PachRootEnvVar", ")", "\n", "}", "\n", "storageBackend", ",", "ok", ":=", "os", ".", "LookupEnv", "(", "StorageBackendEnvVar", ")", "\n", "if", "!", "ok", "{", "return", "\"\"", ",", "fmt", ".", "Errorf", "(", "\"%s not found\"", ",", "StorageBackendEnvVar", ")", "\n", "}", "\n", "switch", "storageBackend", "{", "case", "Amazon", ":", "fallthrough", "\n", "case", "Minio", ":", "if", "len", "(", "storageRoot", ")", ">", "0", "&&", "storageRoot", "[", "0", "]", "==", "'/'", "{", "storageRoot", "=", "storageRoot", "[", "1", ":", "]", "\n", "}", "\n", "}", "\n", "return", "storageRoot", ",", "nil", "\n", "}" ]
// StorageRootFromEnv gets the storage root based on environment variables.
[ "StorageRootFromEnv", "gets", "the", "storage", "root", "based", "on", "environment", "variables", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/obj/obj.go#L106-L125
test
pachyderm/pachyderm
src/server/pkg/obj/obj.go
BlockPathFromEnv
func BlockPathFromEnv(block *pfs.Block) (string, error) { storageRoot, err := StorageRootFromEnv() if err != nil { return "", err } return filepath.Join(storageRoot, "block", block.Hash), nil }
go
func BlockPathFromEnv(block *pfs.Block) (string, error) { storageRoot, err := StorageRootFromEnv() if err != nil { return "", err } return filepath.Join(storageRoot, "block", block.Hash), nil }
[ "func", "BlockPathFromEnv", "(", "block", "*", "pfs", ".", "Block", ")", "(", "string", ",", "error", ")", "{", "storageRoot", ",", "err", ":=", "StorageRootFromEnv", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"\"", ",", "err", "\n", "}", "\n", "return", "filepath", ".", "Join", "(", "storageRoot", ",", "\"block\"", ",", "block", ".", "Hash", ")", ",", "nil", "\n", "}" ]
// BlockPathFromEnv gets the path to an object storage block based on environment variables.
[ "BlockPathFromEnv", "gets", "the", "path", "to", "an", "object", "storage", "block", "based", "on", "environment", "variables", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/obj/obj.go#L128-L134
test
pachyderm/pachyderm
src/server/pkg/obj/obj.go
NewGoogleClient
func NewGoogleClient(bucket string, opts []option.ClientOption) (Client, error) { return newGoogleClient(bucket, opts) }
go
func NewGoogleClient(bucket string, opts []option.ClientOption) (Client, error) { return newGoogleClient(bucket, opts) }
[ "func", "NewGoogleClient", "(", "bucket", "string", ",", "opts", "[", "]", "option", ".", "ClientOption", ")", "(", "Client", ",", "error", ")", "{", "return", "newGoogleClient", "(", "bucket", ",", "opts", ")", "\n", "}" ]
// NewGoogleClient creates a google client with the given bucket name.
[ "NewGoogleClient", "creates", "a", "google", "client", "with", "the", "given", "bucket", "name", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/obj/obj.go#L164-L166
test
pachyderm/pachyderm
src/server/pkg/obj/obj.go
NewGoogleClientFromSecret
func NewGoogleClientFromSecret(bucket string) (Client, error) { var err error if bucket == "" { bucket, err = readSecretFile("/google-bucket") if err != nil { return nil, fmt.Errorf("google-bucket not found") } } cred, err := readSecretFile("/google-cred") 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) }
go
func NewGoogleClientFromSecret(bucket string) (Client, error) { var err error if bucket == "" { bucket, err = readSecretFile("/google-bucket") if err != nil { return nil, fmt.Errorf("google-bucket not found") } } cred, err := readSecretFile("/google-cred") 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) }
[ "func", "NewGoogleClientFromSecret", "(", "bucket", "string", ")", "(", "Client", ",", "error", ")", "{", "var", "err", "error", "\n", "if", "bucket", "==", "\"\"", "{", "bucket", ",", "err", "=", "readSecretFile", "(", "\"/google-bucket\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"google-bucket not found\"", ")", "\n", "}", "\n", "}", "\n", "cred", ",", "err", ":=", "readSecretFile", "(", "\"/google-cred\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"google-cred not found\"", ")", "\n", "}", "\n", "var", "opts", "[", "]", "option", ".", "ClientOption", "\n", "if", "cred", "!=", "\"\"", "{", "opts", "=", "append", "(", "opts", ",", "option", ".", "WithCredentialsFile", "(", "secretFile", "(", "\"/google-cred\"", ")", ")", ")", "\n", "}", "else", "{", "opts", "=", "append", "(", "opts", ",", "option", ".", "WithTokenSource", "(", "google", ".", "ComputeTokenSource", "(", "\"\"", ")", ")", ")", "\n", "}", "\n", "return", "NewGoogleClient", "(", "bucket", ",", "opts", ")", "\n", "}" ]
// NewGoogleClientFromSecret creates a google client by reading credentials // from a mounted GoogleSecret. You may pass "" for bucket in which case it // will read the bucket from the secret.
[ "NewGoogleClientFromSecret", "creates", "a", "google", "client", "by", "reading", "credentials", "from", "a", "mounted", "GoogleSecret", ".", "You", "may", "pass", "for", "bucket", "in", "which", "case", "it", "will", "read", "the", "bucket", "from", "the", "secret", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/obj/obj.go#L183-L202
test
pachyderm/pachyderm
src/server/pkg/obj/obj.go
NewGoogleClientFromEnv
func NewGoogleClientFromEnv() (Client, error) { bucket, ok := os.LookupEnv(GoogleBucketEnvVar) if !ok { return nil, fmt.Errorf("%s not found", GoogleBucketEnvVar) } creds, ok := os.LookupEnv(GoogleCredEnvVar) if !ok { return nil, fmt.Errorf("%s not found", GoogleCredEnvVar) } opts := []option.ClientOption{option.WithCredentialsJSON([]byte(creds))} return NewGoogleClient(bucket, opts) }
go
func NewGoogleClientFromEnv() (Client, error) { bucket, ok := os.LookupEnv(GoogleBucketEnvVar) if !ok { return nil, fmt.Errorf("%s not found", GoogleBucketEnvVar) } creds, ok := os.LookupEnv(GoogleCredEnvVar) if !ok { return nil, fmt.Errorf("%s not found", GoogleCredEnvVar) } opts := []option.ClientOption{option.WithCredentialsJSON([]byte(creds))} return NewGoogleClient(bucket, opts) }
[ "func", "NewGoogleClientFromEnv", "(", ")", "(", "Client", ",", "error", ")", "{", "bucket", ",", "ok", ":=", "os", ".", "LookupEnv", "(", "GoogleBucketEnvVar", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"%s not found\"", ",", "GoogleBucketEnvVar", ")", "\n", "}", "\n", "creds", ",", "ok", ":=", "os", ".", "LookupEnv", "(", "GoogleCredEnvVar", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"%s not found\"", ",", "GoogleCredEnvVar", ")", "\n", "}", "\n", "opts", ":=", "[", "]", "option", ".", "ClientOption", "{", "option", ".", "WithCredentialsJSON", "(", "[", "]", "byte", "(", "creds", ")", ")", "}", "\n", "return", "NewGoogleClient", "(", "bucket", ",", "opts", ")", "\n", "}" ]
// NewGoogleClientFromEnv creates a Google client based on environment variables.
[ "NewGoogleClientFromEnv", "creates", "a", "Google", "client", "based", "on", "environment", "variables", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/obj/obj.go#L205-L216
test
pachyderm/pachyderm
src/server/pkg/obj/obj.go
NewMicrosoftClientFromSecret
func NewMicrosoftClientFromSecret(container string) (Client, error) { var err error if container == "" { container, err = readSecretFile("/microsoft-container") if err != nil { return nil, fmt.Errorf("microsoft-container not found") } } 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) }
go
func NewMicrosoftClientFromSecret(container string) (Client, error) { var err error if container == "" { container, err = readSecretFile("/microsoft-container") if err != nil { return nil, fmt.Errorf("microsoft-container not found") } } 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) }
[ "func", "NewMicrosoftClientFromSecret", "(", "container", "string", ")", "(", "Client", ",", "error", ")", "{", "var", "err", "error", "\n", "if", "container", "==", "\"\"", "{", "container", ",", "err", "=", "readSecretFile", "(", "\"/microsoft-container\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"microsoft-container not found\"", ")", "\n", "}", "\n", "}", "\n", "id", ",", "err", ":=", "readSecretFile", "(", "\"/microsoft-id\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"microsoft-id not found\"", ")", "\n", "}", "\n", "secret", ",", "err", ":=", "readSecretFile", "(", "\"/microsoft-secret\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"microsoft-secret not found\"", ")", "\n", "}", "\n", "return", "NewMicrosoftClient", "(", "container", ",", "id", ",", "secret", ")", "\n", "}" ]
// NewMicrosoftClientFromSecret creates a microsoft client by reading // credentials from a mounted MicrosoftSecret. You may pass "" for container in // which case it will read the container from the secret.
[ "NewMicrosoftClientFromSecret", "creates", "a", "microsoft", "client", "by", "reading", "credentials", "from", "a", "mounted", "MicrosoftSecret", ".", "You", "may", "pass", "for", "container", "in", "which", "case", "it", "will", "read", "the", "container", "from", "the", "secret", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/obj/obj.go#L229-L246
test
pachyderm/pachyderm
src/server/pkg/obj/obj.go
NewMicrosoftClientFromEnv
func NewMicrosoftClientFromEnv() (Client, error) { container, ok := os.LookupEnv(MicrosoftContainerEnvVar) if !ok { return nil, fmt.Errorf("%s not found", MicrosoftContainerEnvVar) } id, ok := os.LookupEnv(MicrosoftIDEnvVar) if !ok { return nil, fmt.Errorf("%s not found", MicrosoftIDEnvVar) } secret, ok := os.LookupEnv(MicrosoftSecretEnvVar) if !ok { return nil, fmt.Errorf("%s not found", MicrosoftSecretEnvVar) } return NewMicrosoftClient(container, id, secret) }
go
func NewMicrosoftClientFromEnv() (Client, error) { container, ok := os.LookupEnv(MicrosoftContainerEnvVar) if !ok { return nil, fmt.Errorf("%s not found", MicrosoftContainerEnvVar) } id, ok := os.LookupEnv(MicrosoftIDEnvVar) if !ok { return nil, fmt.Errorf("%s not found", MicrosoftIDEnvVar) } secret, ok := os.LookupEnv(MicrosoftSecretEnvVar) if !ok { return nil, fmt.Errorf("%s not found", MicrosoftSecretEnvVar) } return NewMicrosoftClient(container, id, secret) }
[ "func", "NewMicrosoftClientFromEnv", "(", ")", "(", "Client", ",", "error", ")", "{", "container", ",", "ok", ":=", "os", ".", "LookupEnv", "(", "MicrosoftContainerEnvVar", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"%s not found\"", ",", "MicrosoftContainerEnvVar", ")", "\n", "}", "\n", "id", ",", "ok", ":=", "os", ".", "LookupEnv", "(", "MicrosoftIDEnvVar", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"%s not found\"", ",", "MicrosoftIDEnvVar", ")", "\n", "}", "\n", "secret", ",", "ok", ":=", "os", ".", "LookupEnv", "(", "MicrosoftSecretEnvVar", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"%s not found\"", ",", "MicrosoftSecretEnvVar", ")", "\n", "}", "\n", "return", "NewMicrosoftClient", "(", "container", ",", "id", ",", "secret", ")", "\n", "}" ]
// NewMicrosoftClientFromEnv creates a Microsoft client based on environment variables.
[ "NewMicrosoftClientFromEnv", "creates", "a", "Microsoft", "client", "based", "on", "environment", "variables", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/obj/obj.go#L249-L263
test
pachyderm/pachyderm
src/server/pkg/obj/obj.go
NewMinioClientFromSecret
func NewMinioClientFromSecret(bucket string) (Client, error) { var err error if bucket == "" { bucket, err = readSecretFile("/minio-bucket") if err != nil { return nil, err } } endpoint, err := readSecretFile("/minio-endpoint") if err != nil { return nil, err } id, err := readSecretFile("/minio-id") if err != nil { return nil, err } secret, err := readSecretFile("/minio-secret") if err != nil { return nil, err } secure, 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") }
go
func NewMinioClientFromSecret(bucket string) (Client, error) { var err error if bucket == "" { bucket, err = readSecretFile("/minio-bucket") if err != nil { return nil, err } } endpoint, err := readSecretFile("/minio-endpoint") if err != nil { return nil, err } id, err := readSecretFile("/minio-id") if err != nil { return nil, err } secret, err := readSecretFile("/minio-secret") if err != nil { return nil, err } secure, 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") }
[ "func", "NewMinioClientFromSecret", "(", "bucket", "string", ")", "(", "Client", ",", "error", ")", "{", "var", "err", "error", "\n", "if", "bucket", "==", "\"\"", "{", "bucket", ",", "err", "=", "readSecretFile", "(", "\"/minio-bucket\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n", "endpoint", ",", "err", ":=", "readSecretFile", "(", "\"/minio-endpoint\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "id", ",", "err", ":=", "readSecretFile", "(", "\"/minio-id\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "secret", ",", "err", ":=", "readSecretFile", "(", "\"/minio-secret\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "secure", ",", "err", ":=", "readSecretFile", "(", "\"/minio-secure\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "isS3V2", ",", "err", ":=", "readSecretFile", "(", "\"/minio-signature\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "NewMinioClient", "(", "endpoint", ",", "bucket", ",", "id", ",", "secret", ",", "secure", "==", "\"1\"", ",", "isS3V2", "==", "\"1\"", ")", "\n", "}" ]
// NewMinioClientFromSecret constructs an s3 compatible client by reading // credentials from a mounted AmazonSecret. You may pass "" for bucket in which case it // will read the bucket from the secret.
[ "NewMinioClientFromSecret", "constructs", "an", "s3", "compatible", "client", "by", "reading", "credentials", "from", "a", "mounted", "AmazonSecret", ".", "You", "may", "pass", "for", "bucket", "in", "which", "case", "it", "will", "read", "the", "bucket", "from", "the", "secret", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/obj/obj.go#L293-L322
test
pachyderm/pachyderm
src/server/pkg/obj/obj.go
NewMinioClientFromEnv
func NewMinioClientFromEnv() (Client, error) { bucket, ok := os.LookupEnv(MinioBucketEnvVar) if !ok { return nil, fmt.Errorf("%s not found", MinioBucketEnvVar) } endpoint, ok := os.LookupEnv(MinioEndpointEnvVar) if !ok { return nil, fmt.Errorf("%s not found", MinioEndpointEnvVar) } id, ok := os.LookupEnv(MinioIDEnvVar) if !ok { return nil, fmt.Errorf("%s not found", MinioIDEnvVar) } secret, ok := os.LookupEnv(MinioSecretEnvVar) if !ok { return nil, fmt.Errorf("%s not found", MinioSecretEnvVar) } secure, ok := os.LookupEnv(MinioSecureEnvVar) if !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") }
go
func NewMinioClientFromEnv() (Client, error) { bucket, ok := os.LookupEnv(MinioBucketEnvVar) if !ok { return nil, fmt.Errorf("%s not found", MinioBucketEnvVar) } endpoint, ok := os.LookupEnv(MinioEndpointEnvVar) if !ok { return nil, fmt.Errorf("%s not found", MinioEndpointEnvVar) } id, ok := os.LookupEnv(MinioIDEnvVar) if !ok { return nil, fmt.Errorf("%s not found", MinioIDEnvVar) } secret, ok := os.LookupEnv(MinioSecretEnvVar) if !ok { return nil, fmt.Errorf("%s not found", MinioSecretEnvVar) } secure, ok := os.LookupEnv(MinioSecureEnvVar) if !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") }
[ "func", "NewMinioClientFromEnv", "(", ")", "(", "Client", ",", "error", ")", "{", "bucket", ",", "ok", ":=", "os", ".", "LookupEnv", "(", "MinioBucketEnvVar", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"%s not found\"", ",", "MinioBucketEnvVar", ")", "\n", "}", "\n", "endpoint", ",", "ok", ":=", "os", ".", "LookupEnv", "(", "MinioEndpointEnvVar", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"%s not found\"", ",", "MinioEndpointEnvVar", ")", "\n", "}", "\n", "id", ",", "ok", ":=", "os", ".", "LookupEnv", "(", "MinioIDEnvVar", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"%s not found\"", ",", "MinioIDEnvVar", ")", "\n", "}", "\n", "secret", ",", "ok", ":=", "os", ".", "LookupEnv", "(", "MinioSecretEnvVar", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"%s not found\"", ",", "MinioSecretEnvVar", ")", "\n", "}", "\n", "secure", ",", "ok", ":=", "os", ".", "LookupEnv", "(", "MinioSecureEnvVar", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"%s not found\"", ",", "MinioSecureEnvVar", ")", "\n", "}", "\n", "isS3V2", ",", "ok", ":=", "os", ".", "LookupEnv", "(", "MinioSignatureEnvVar", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"%s not found\"", ",", "MinioSignatureEnvVar", ")", "\n", "}", "\n", "return", "NewMinioClient", "(", "endpoint", ",", "bucket", ",", "id", ",", "secret", ",", "secure", "==", "\"1\"", ",", "isS3V2", "==", "\"1\"", ")", "\n", "}" ]
// NewMinioClientFromEnv creates a Minio client based on environment variables.
[ "NewMinioClientFromEnv", "creates", "a", "Minio", "client", "based", "on", "environment", "variables", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/obj/obj.go#L325-L351
test
pachyderm/pachyderm
src/server/pkg/obj/obj.go
NewAmazonClientFromSecret
func NewAmazonClientFromSecret(bucket string, reversed ...bool) (Client, error) { // Get AWS region (required for constructing an AWS client) region, err := readSecretFile("/amazon-region") if err != nil { return nil, fmt.Errorf("amazon-region not found") } // Use or retrieve S3 bucket if bucket == "" { bucket, err = readSecretFile("/amazon-bucket") if err != nil { return nil, err } } // Retrieve either static or vault credentials; if neither are found, we will // use IAM roles (i.e. the EC2 metadata service) var creds AmazonCreds creds.ID, err = readSecretFile("/amazon-id") if err != nil && !os.IsNotExist(err) { return nil, err } creds.Secret, err = readSecretFile("/amazon-secret") if err != nil && !os.IsNotExist(err) { return nil, err } creds.Token, err = readSecretFile("/amazon-token") if err != nil && !os.IsNotExist(err) { return nil, err } creds.VaultAddress, err = readSecretFile("/amazon-vault-addr") if err != nil && !os.IsNotExist(err) { return nil, err } creds.VaultRole, err = readSecretFile("/amazon-vault-role") if err != nil && !os.IsNotExist(err) { return nil, err } creds.VaultToken, err = readSecretFile("/amazon-vault-token") if err != nil && !os.IsNotExist(err) { return nil, err } // Get Cloudfront distribution (not required, though we can log a warning) distribution, err := readSecretFile("/amazon-distribution") return NewAmazonClient(region, bucket, &creds, distribution, reversed...) }
go
func NewAmazonClientFromSecret(bucket string, reversed ...bool) (Client, error) { // Get AWS region (required for constructing an AWS client) region, err := readSecretFile("/amazon-region") if err != nil { return nil, fmt.Errorf("amazon-region not found") } // Use or retrieve S3 bucket if bucket == "" { bucket, err = readSecretFile("/amazon-bucket") if err != nil { return nil, err } } // Retrieve either static or vault credentials; if neither are found, we will // use IAM roles (i.e. the EC2 metadata service) var creds AmazonCreds creds.ID, err = readSecretFile("/amazon-id") if err != nil && !os.IsNotExist(err) { return nil, err } creds.Secret, err = readSecretFile("/amazon-secret") if err != nil && !os.IsNotExist(err) { return nil, err } creds.Token, err = readSecretFile("/amazon-token") if err != nil && !os.IsNotExist(err) { return nil, err } creds.VaultAddress, err = readSecretFile("/amazon-vault-addr") if err != nil && !os.IsNotExist(err) { return nil, err } creds.VaultRole, err = readSecretFile("/amazon-vault-role") if err != nil && !os.IsNotExist(err) { return nil, err } creds.VaultToken, err = readSecretFile("/amazon-vault-token") if err != nil && !os.IsNotExist(err) { return nil, err } // Get Cloudfront distribution (not required, though we can log a warning) distribution, err := readSecretFile("/amazon-distribution") return NewAmazonClient(region, bucket, &creds, distribution, reversed...) }
[ "func", "NewAmazonClientFromSecret", "(", "bucket", "string", ",", "reversed", "...", "bool", ")", "(", "Client", ",", "error", ")", "{", "region", ",", "err", ":=", "readSecretFile", "(", "\"/amazon-region\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"amazon-region not found\"", ")", "\n", "}", "\n", "if", "bucket", "==", "\"\"", "{", "bucket", ",", "err", "=", "readSecretFile", "(", "\"/amazon-bucket\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n", "var", "creds", "AmazonCreds", "\n", "creds", ".", "ID", ",", "err", "=", "readSecretFile", "(", "\"/amazon-id\"", ")", "\n", "if", "err", "!=", "nil", "&&", "!", "os", ".", "IsNotExist", "(", "err", ")", "{", "return", "nil", ",", "err", "\n", "}", "\n", "creds", ".", "Secret", ",", "err", "=", "readSecretFile", "(", "\"/amazon-secret\"", ")", "\n", "if", "err", "!=", "nil", "&&", "!", "os", ".", "IsNotExist", "(", "err", ")", "{", "return", "nil", ",", "err", "\n", "}", "\n", "creds", ".", "Token", ",", "err", "=", "readSecretFile", "(", "\"/amazon-token\"", ")", "\n", "if", "err", "!=", "nil", "&&", "!", "os", ".", "IsNotExist", "(", "err", ")", "{", "return", "nil", ",", "err", "\n", "}", "\n", "creds", ".", "VaultAddress", ",", "err", "=", "readSecretFile", "(", "\"/amazon-vault-addr\"", ")", "\n", "if", "err", "!=", "nil", "&&", "!", "os", ".", "IsNotExist", "(", "err", ")", "{", "return", "nil", ",", "err", "\n", "}", "\n", "creds", ".", "VaultRole", ",", "err", "=", "readSecretFile", "(", "\"/amazon-vault-role\"", ")", "\n", "if", "err", "!=", "nil", "&&", "!", "os", ".", "IsNotExist", "(", "err", ")", "{", "return", "nil", ",", "err", "\n", "}", "\n", "creds", ".", "VaultToken", ",", "err", "=", "readSecretFile", "(", "\"/amazon-vault-token\"", ")", "\n", "if", "err", "!=", "nil", "&&", "!", "os", ".", "IsNotExist", "(", "err", ")", "{", "return", "nil", ",", "err", "\n", "}", "\n", "distribution", ",", "err", ":=", "readSecretFile", "(", "\"/amazon-distribution\"", ")", "\n", "return", "NewAmazonClient", "(", "region", ",", "bucket", ",", "&", "creds", ",", "distribution", ",", "reversed", "...", ")", "\n", "}" ]
// NewAmazonClientFromSecret constructs an amazon client by reading credentials // from a mounted AmazonSecret. You may pass "" for bucket in which case it // will read the bucket from the secret.
[ "NewAmazonClientFromSecret", "constructs", "an", "amazon", "client", "by", "reading", "credentials", "from", "a", "mounted", "AmazonSecret", ".", "You", "may", "pass", "for", "bucket", "in", "which", "case", "it", "will", "read", "the", "bucket", "from", "the", "secret", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/obj/obj.go#L356-L402
test
pachyderm/pachyderm
src/server/pkg/obj/obj.go
NewAmazonClientFromEnv
func NewAmazonClientFromEnv() (Client, error) { region, ok := os.LookupEnv(AmazonRegionEnvVar) if !ok { return nil, fmt.Errorf("%s not found", AmazonRegionEnvVar) } bucket, ok := os.LookupEnv(AmazonBucketEnvVar) if !ok { return nil, fmt.Errorf("%s not found", AmazonBucketEnvVar) } var creds AmazonCreds creds.ID, _ = os.LookupEnv(AmazonIDEnvVar) creds.Secret, _ = os.LookupEnv(AmazonSecretEnvVar) creds.Token, _ = os.LookupEnv(AmazonTokenEnvVar) creds.VaultAddress, _ = os.LookupEnv(AmazonVaultAddrEnvVar) creds.VaultRole, _ = os.LookupEnv(AmazonVaultRoleEnvVar) creds.VaultToken, _ = os.LookupEnv(AmazonVaultTokenEnvVar) distribution, _ := os.LookupEnv(AmazonDistributionEnvVar) return NewAmazonClient(region, bucket, &creds, distribution) }
go
func NewAmazonClientFromEnv() (Client, error) { region, ok := os.LookupEnv(AmazonRegionEnvVar) if !ok { return nil, fmt.Errorf("%s not found", AmazonRegionEnvVar) } bucket, ok := os.LookupEnv(AmazonBucketEnvVar) if !ok { return nil, fmt.Errorf("%s not found", AmazonBucketEnvVar) } var creds AmazonCreds creds.ID, _ = os.LookupEnv(AmazonIDEnvVar) creds.Secret, _ = os.LookupEnv(AmazonSecretEnvVar) creds.Token, _ = os.LookupEnv(AmazonTokenEnvVar) creds.VaultAddress, _ = os.LookupEnv(AmazonVaultAddrEnvVar) creds.VaultRole, _ = os.LookupEnv(AmazonVaultRoleEnvVar) creds.VaultToken, _ = os.LookupEnv(AmazonVaultTokenEnvVar) distribution, _ := os.LookupEnv(AmazonDistributionEnvVar) return NewAmazonClient(region, bucket, &creds, distribution) }
[ "func", "NewAmazonClientFromEnv", "(", ")", "(", "Client", ",", "error", ")", "{", "region", ",", "ok", ":=", "os", ".", "LookupEnv", "(", "AmazonRegionEnvVar", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"%s not found\"", ",", "AmazonRegionEnvVar", ")", "\n", "}", "\n", "bucket", ",", "ok", ":=", "os", ".", "LookupEnv", "(", "AmazonBucketEnvVar", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"%s not found\"", ",", "AmazonBucketEnvVar", ")", "\n", "}", "\n", "var", "creds", "AmazonCreds", "\n", "creds", ".", "ID", ",", "_", "=", "os", ".", "LookupEnv", "(", "AmazonIDEnvVar", ")", "\n", "creds", ".", "Secret", ",", "_", "=", "os", ".", "LookupEnv", "(", "AmazonSecretEnvVar", ")", "\n", "creds", ".", "Token", ",", "_", "=", "os", ".", "LookupEnv", "(", "AmazonTokenEnvVar", ")", "\n", "creds", ".", "VaultAddress", ",", "_", "=", "os", ".", "LookupEnv", "(", "AmazonVaultAddrEnvVar", ")", "\n", "creds", ".", "VaultRole", ",", "_", "=", "os", ".", "LookupEnv", "(", "AmazonVaultRoleEnvVar", ")", "\n", "creds", ".", "VaultToken", ",", "_", "=", "os", ".", "LookupEnv", "(", "AmazonVaultTokenEnvVar", ")", "\n", "distribution", ",", "_", ":=", "os", ".", "LookupEnv", "(", "AmazonDistributionEnvVar", ")", "\n", "return", "NewAmazonClient", "(", "region", ",", "bucket", ",", "&", "creds", ",", "distribution", ")", "\n", "}" ]
// NewAmazonClientFromEnv creates a Amazon client based on environment variables.
[ "NewAmazonClientFromEnv", "creates", "a", "Amazon", "client", "based", "on", "environment", "variables", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/obj/obj.go#L405-L425
test
pachyderm/pachyderm
src/server/pkg/obj/obj.go
NewClientFromURLAndSecret
func NewClientFromURLAndSecret(url *ObjectStoreURL, reversed ...bool) (c Client, err error) { switch url.Store { case "s3": c, err = NewAmazonClientFromSecret(url.Bucket, reversed...) case "gcs": fallthrough case "gs": c, err = NewGoogleClientFromSecret(url.Bucket) case "as": fallthrough case "wasb": // In Azure, the first part of the path is the container name. c, err = NewMicrosoftClientFromSecret(url.Bucket) case "local": c, err = NewLocalClient("/" + url.Bucket) } switch { case err != nil: return nil, err case c != nil: return TracingObjClient(url.Store, c), nil default: return nil, fmt.Errorf("unrecognized object store: %s", url.Bucket) } }
go
func NewClientFromURLAndSecret(url *ObjectStoreURL, reversed ...bool) (c Client, err error) { switch url.Store { case "s3": c, err = NewAmazonClientFromSecret(url.Bucket, reversed...) case "gcs": fallthrough case "gs": c, err = NewGoogleClientFromSecret(url.Bucket) case "as": fallthrough case "wasb": // In Azure, the first part of the path is the container name. c, err = NewMicrosoftClientFromSecret(url.Bucket) case "local": c, err = NewLocalClient("/" + url.Bucket) } switch { case err != nil: return nil, err case c != nil: return TracingObjClient(url.Store, c), nil default: return nil, fmt.Errorf("unrecognized object store: %s", url.Bucket) } }
[ "func", "NewClientFromURLAndSecret", "(", "url", "*", "ObjectStoreURL", ",", "reversed", "...", "bool", ")", "(", "c", "Client", ",", "err", "error", ")", "{", "switch", "url", ".", "Store", "{", "case", "\"s3\"", ":", "c", ",", "err", "=", "NewAmazonClientFromSecret", "(", "url", ".", "Bucket", ",", "reversed", "...", ")", "\n", "case", "\"gcs\"", ":", "fallthrough", "\n", "case", "\"gs\"", ":", "c", ",", "err", "=", "NewGoogleClientFromSecret", "(", "url", ".", "Bucket", ")", "\n", "case", "\"as\"", ":", "fallthrough", "\n", "case", "\"wasb\"", ":", "c", ",", "err", "=", "NewMicrosoftClientFromSecret", "(", "url", ".", "Bucket", ")", "\n", "case", "\"local\"", ":", "c", ",", "err", "=", "NewLocalClient", "(", "\"/\"", "+", "url", ".", "Bucket", ")", "\n", "}", "\n", "switch", "{", "case", "err", "!=", "nil", ":", "return", "nil", ",", "err", "\n", "case", "c", "!=", "nil", ":", "return", "TracingObjClient", "(", "url", ".", "Store", ",", "c", ")", ",", "nil", "\n", "default", ":", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"unrecognized object store: %s\"", ",", "url", ".", "Bucket", ")", "\n", "}", "\n", "}" ]
// NewClientFromURLAndSecret constructs a client by parsing `URL` and then // constructing the correct client for that URL using secrets.
[ "NewClientFromURLAndSecret", "constructs", "a", "client", "by", "parsing", "URL", "and", "then", "constructing", "the", "correct", "client", "for", "that", "URL", "using", "secrets", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/obj/obj.go#L429-L453
test
pachyderm/pachyderm
src/server/pkg/obj/obj.go
ParseURL
func ParseURL(urlStr string) (*ObjectStoreURL, error) { url, err := url.Parse(urlStr) if err != nil { return nil, fmt.Errorf("error parsing url %v: %v", urlStr, err) } switch url.Scheme { case "s3", "gcs", "gs", "local": return &ObjectStoreURL{ Store: url.Scheme, Bucket: url.Host, Object: strings.Trim(url.Path, "/"), }, nil case "as", "wasb": // In Azure, the first part of the path is the container name. parts := strings.Split(strings.Trim(url.Path, "/"), "/") if len(parts) < 1 { return nil, fmt.Errorf("malformed Azure URI: %v", urlStr) } return &ObjectStoreURL{ Store: url.Scheme, Bucket: parts[0], Object: strings.Trim(path.Join(parts[1:]...), "/"), }, nil } return nil, fmt.Errorf("unrecognized object store: %s", url.Scheme) }
go
func ParseURL(urlStr string) (*ObjectStoreURL, error) { url, err := url.Parse(urlStr) if err != nil { return nil, fmt.Errorf("error parsing url %v: %v", urlStr, err) } switch url.Scheme { case "s3", "gcs", "gs", "local": return &ObjectStoreURL{ Store: url.Scheme, Bucket: url.Host, Object: strings.Trim(url.Path, "/"), }, nil case "as", "wasb": // In Azure, the first part of the path is the container name. parts := strings.Split(strings.Trim(url.Path, "/"), "/") if len(parts) < 1 { return nil, fmt.Errorf("malformed Azure URI: %v", urlStr) } return &ObjectStoreURL{ Store: url.Scheme, Bucket: parts[0], Object: strings.Trim(path.Join(parts[1:]...), "/"), }, nil } return nil, fmt.Errorf("unrecognized object store: %s", url.Scheme) }
[ "func", "ParseURL", "(", "urlStr", "string", ")", "(", "*", "ObjectStoreURL", ",", "error", ")", "{", "url", ",", "err", ":=", "url", ".", "Parse", "(", "urlStr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"error parsing url %v: %v\"", ",", "urlStr", ",", "err", ")", "\n", "}", "\n", "switch", "url", ".", "Scheme", "{", "case", "\"s3\"", ",", "\"gcs\"", ",", "\"gs\"", ",", "\"local\"", ":", "return", "&", "ObjectStoreURL", "{", "Store", ":", "url", ".", "Scheme", ",", "Bucket", ":", "url", ".", "Host", ",", "Object", ":", "strings", ".", "Trim", "(", "url", ".", "Path", ",", "\"/\"", ")", ",", "}", ",", "nil", "\n", "case", "\"as\"", ",", "\"wasb\"", ":", "parts", ":=", "strings", ".", "Split", "(", "strings", ".", "Trim", "(", "url", ".", "Path", ",", "\"/\"", ")", ",", "\"/\"", ")", "\n", "if", "len", "(", "parts", ")", "<", "1", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"malformed Azure URI: %v\"", ",", "urlStr", ")", "\n", "}", "\n", "return", "&", "ObjectStoreURL", "{", "Store", ":", "url", ".", "Scheme", ",", "Bucket", ":", "parts", "[", "0", "]", ",", "Object", ":", "strings", ".", "Trim", "(", "path", ".", "Join", "(", "parts", "[", "1", ":", "]", "...", ")", ",", "\"/\"", ")", ",", "}", ",", "nil", "\n", "}", "\n", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"unrecognized object store: %s\"", ",", "url", ".", "Scheme", ")", "\n", "}" ]
// ParseURL parses an URL into ObjectStoreURL.
[ "ParseURL", "parses", "an", "URL", "into", "ObjectStoreURL", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/obj/obj.go#L466-L491
test
pachyderm/pachyderm
src/server/pkg/obj/obj.go
NewClientFromEnv
func NewClientFromEnv(storageRoot string) (c Client, err error) { storageBackend, ok := os.LookupEnv(StorageBackendEnvVar) if !ok { return nil, fmt.Errorf("storage backend environment variable not found") } switch storageBackend { case Amazon: c, err = NewAmazonClientFromEnv() case Google: c, err = NewGoogleClientFromEnv() case Microsoft: c, err = NewMicrosoftClientFromEnv() case Minio: c, err = NewMinioClientFromEnv() case Local: c, err = NewLocalClient(storageRoot) } switch { case err != nil: return nil, err case c != nil: return TracingObjClient(storageBackend, c), nil default: return nil, fmt.Errorf("unrecognized storage backend: %s", storageBackend) } }
go
func NewClientFromEnv(storageRoot string) (c Client, err error) { storageBackend, ok := os.LookupEnv(StorageBackendEnvVar) if !ok { return nil, fmt.Errorf("storage backend environment variable not found") } switch storageBackend { case Amazon: c, err = NewAmazonClientFromEnv() case Google: c, err = NewGoogleClientFromEnv() case Microsoft: c, err = NewMicrosoftClientFromEnv() case Minio: c, err = NewMinioClientFromEnv() case Local: c, err = NewLocalClient(storageRoot) } switch { case err != nil: return nil, err case c != nil: return TracingObjClient(storageBackend, c), nil default: return nil, fmt.Errorf("unrecognized storage backend: %s", storageBackend) } }
[ "func", "NewClientFromEnv", "(", "storageRoot", "string", ")", "(", "c", "Client", ",", "err", "error", ")", "{", "storageBackend", ",", "ok", ":=", "os", ".", "LookupEnv", "(", "StorageBackendEnvVar", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"storage backend environment variable not found\"", ")", "\n", "}", "\n", "switch", "storageBackend", "{", "case", "Amazon", ":", "c", ",", "err", "=", "NewAmazonClientFromEnv", "(", ")", "\n", "case", "Google", ":", "c", ",", "err", "=", "NewGoogleClientFromEnv", "(", ")", "\n", "case", "Microsoft", ":", "c", ",", "err", "=", "NewMicrosoftClientFromEnv", "(", ")", "\n", "case", "Minio", ":", "c", ",", "err", "=", "NewMinioClientFromEnv", "(", ")", "\n", "case", "Local", ":", "c", ",", "err", "=", "NewLocalClient", "(", "storageRoot", ")", "\n", "}", "\n", "switch", "{", "case", "err", "!=", "nil", ":", "return", "nil", ",", "err", "\n", "case", "c", "!=", "nil", ":", "return", "TracingObjClient", "(", "storageBackend", ",", "c", ")", ",", "nil", "\n", "default", ":", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"unrecognized storage backend: %s\"", ",", "storageBackend", ")", "\n", "}", "\n", "}" ]
// NewClientFromEnv creates a client based on environment variables.
[ "NewClientFromEnv", "creates", "a", "client", "based", "on", "environment", "variables", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/obj/obj.go#L494-L519
test
pachyderm/pachyderm
src/server/pkg/obj/obj.go
NewExponentialBackOffConfig
func NewExponentialBackOffConfig() *backoff.ExponentialBackOff { config := backoff.NewExponentialBackOff() // We want to backoff more aggressively (i.e. wait longer) than the default config.InitialInterval = 1 * time.Second config.Multiplier = 2 config.MaxInterval = 15 * time.Minute return config }
go
func NewExponentialBackOffConfig() *backoff.ExponentialBackOff { config := backoff.NewExponentialBackOff() // We want to backoff more aggressively (i.e. wait longer) than the default config.InitialInterval = 1 * time.Second config.Multiplier = 2 config.MaxInterval = 15 * time.Minute return config }
[ "func", "NewExponentialBackOffConfig", "(", ")", "*", "backoff", ".", "ExponentialBackOff", "{", "config", ":=", "backoff", ".", "NewExponentialBackOff", "(", ")", "\n", "config", ".", "InitialInterval", "=", "1", "*", "time", ".", "Second", "\n", "config", ".", "Multiplier", "=", "2", "\n", "config", ".", "MaxInterval", "=", "15", "*", "time", ".", "Minute", "\n", "return", "config", "\n", "}" ]
// NewExponentialBackOffConfig creates an exponential back-off config with // longer wait times than the default.
[ "NewExponentialBackOffConfig", "creates", "an", "exponential", "back", "-", "off", "config", "with", "longer", "wait", "times", "than", "the", "default", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/obj/obj.go#L523-L530
test
pachyderm/pachyderm
src/server/pkg/obj/obj.go
Close
func (b *BackoffReadCloser) Close() error { span, _ := tracing.AddSpanToAnyExisting(b.ctx, "obj/BackoffReadCloser.Close") defer tracing.FinishAnySpan(span) return b.reader.Close() }
go
func (b *BackoffReadCloser) Close() error { span, _ := tracing.AddSpanToAnyExisting(b.ctx, "obj/BackoffReadCloser.Close") defer tracing.FinishAnySpan(span) return b.reader.Close() }
[ "func", "(", "b", "*", "BackoffReadCloser", ")", "Close", "(", ")", "error", "{", "span", ",", "_", ":=", "tracing", ".", "AddSpanToAnyExisting", "(", "b", ".", "ctx", ",", "\"obj/BackoffReadCloser.Close\"", ")", "\n", "defer", "tracing", ".", "FinishAnySpan", "(", "span", ")", "\n", "return", "b", ".", "reader", ".", "Close", "(", ")", "\n", "}" ]
// Close closes the ReaderCloser contained in b.
[ "Close", "closes", "the", "ReaderCloser", "contained", "in", "b", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/obj/obj.go#L581-L585
test
pachyderm/pachyderm
src/server/pkg/obj/obj.go
Close
func (b *BackoffWriteCloser) Close() error { span, _ := tracing.AddSpanToAnyExisting(b.ctx, "obj/BackoffWriteCloser.Close") defer tracing.FinishAnySpan(span) err := b.writer.Close() if b.client.IsIgnorable(err) { return nil } return err }
go
func (b *BackoffWriteCloser) Close() error { span, _ := tracing.AddSpanToAnyExisting(b.ctx, "obj/BackoffWriteCloser.Close") defer tracing.FinishAnySpan(span) err := b.writer.Close() if b.client.IsIgnorable(err) { return nil } return err }
[ "func", "(", "b", "*", "BackoffWriteCloser", ")", "Close", "(", ")", "error", "{", "span", ",", "_", ":=", "tracing", ".", "AddSpanToAnyExisting", "(", "b", ".", "ctx", ",", "\"obj/BackoffWriteCloser.Close\"", ")", "\n", "defer", "tracing", ".", "FinishAnySpan", "(", "span", ")", "\n", "err", ":=", "b", ".", "writer", ".", "Close", "(", ")", "\n", "if", "b", ".", "client", ".", "IsIgnorable", "(", "err", ")", "{", "return", "nil", "\n", "}", "\n", "return", "err", "\n", "}" ]
// Close closes the WriteCloser contained in b.
[ "Close", "closes", "the", "WriteCloser", "contained", "in", "b", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/obj/obj.go#L629-L637
test
pachyderm/pachyderm
src/server/pkg/obj/obj.go
IsRetryable
func IsRetryable(client Client, err error) bool { return isNetRetryable(err) || client.IsRetryable(err) }
go
func IsRetryable(client Client, err error) bool { return isNetRetryable(err) || client.IsRetryable(err) }
[ "func", "IsRetryable", "(", "client", "Client", ",", "err", "error", ")", "bool", "{", "return", "isNetRetryable", "(", "err", ")", "||", "client", ".", "IsRetryable", "(", "err", ")", "\n", "}" ]
// IsRetryable determines if an operation should be retried given an error
[ "IsRetryable", "determines", "if", "an", "operation", "should", "be", "retried", "given", "an", "error" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/obj/obj.go#L640-L642
test
pachyderm/pachyderm
src/server/pkg/cmdutil/exec.go
RunStdin
func RunStdin(stdin io.Reader, args ...string) error { return RunIO(IO{Stdin: stdin}, args...) }
go
func RunStdin(stdin io.Reader, args ...string) error { return RunIO(IO{Stdin: stdin}, args...) }
[ "func", "RunStdin", "(", "stdin", "io", ".", "Reader", ",", "args", "...", "string", ")", "error", "{", "return", "RunIO", "(", "IO", "{", "Stdin", ":", "stdin", "}", ",", "args", "...", ")", "\n", "}" ]
// RunStdin runs the command with the given stdin and arguments.
[ "RunStdin", "runs", "the", "command", "with", "the", "given", "stdin", "and", "arguments", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/cmdutil/exec.go#L25-L27
test
pachyderm/pachyderm
src/server/pkg/cmdutil/exec.go
RunIODirPath
func RunIODirPath(ioObj IO, dirPath string, args ...string) error { var debugStderr io.ReadWriter = bytes.NewBuffer(nil) var stderr io.Writer = debugStderr if ioObj.Stderr != nil { stderr = io.MultiWriter(debugStderr, ioObj.Stderr) } cmd := exec.Command(args[0], args[1:]...) cmd.Stdin = ioObj.Stdin cmd.Stdout = ioObj.Stdout cmd.Stderr = stderr cmd.Dir = dirPath if err := cmd.Run(); err != nil { data, _ := ioutil.ReadAll(debugStderr) if data != nil && len(data) > 0 { return fmt.Errorf("%s: %s\n%s", strings.Join(args, " "), err.Error(), string(data)) } return fmt.Errorf("%s: %s", strings.Join(args, " "), err.Error()) } return nil }
go
func RunIODirPath(ioObj IO, dirPath string, args ...string) error { var debugStderr io.ReadWriter = bytes.NewBuffer(nil) var stderr io.Writer = debugStderr if ioObj.Stderr != nil { stderr = io.MultiWriter(debugStderr, ioObj.Stderr) } cmd := exec.Command(args[0], args[1:]...) cmd.Stdin = ioObj.Stdin cmd.Stdout = ioObj.Stdout cmd.Stderr = stderr cmd.Dir = dirPath if err := cmd.Run(); err != nil { data, _ := ioutil.ReadAll(debugStderr) if data != nil && len(data) > 0 { return fmt.Errorf("%s: %s\n%s", strings.Join(args, " "), err.Error(), string(data)) } return fmt.Errorf("%s: %s", strings.Join(args, " "), err.Error()) } return nil }
[ "func", "RunIODirPath", "(", "ioObj", "IO", ",", "dirPath", "string", ",", "args", "...", "string", ")", "error", "{", "var", "debugStderr", "io", ".", "ReadWriter", "=", "bytes", ".", "NewBuffer", "(", "nil", ")", "\n", "var", "stderr", "io", ".", "Writer", "=", "debugStderr", "\n", "if", "ioObj", ".", "Stderr", "!=", "nil", "{", "stderr", "=", "io", ".", "MultiWriter", "(", "debugStderr", ",", "ioObj", ".", "Stderr", ")", "\n", "}", "\n", "cmd", ":=", "exec", ".", "Command", "(", "args", "[", "0", "]", ",", "args", "[", "1", ":", "]", "...", ")", "\n", "cmd", ".", "Stdin", "=", "ioObj", ".", "Stdin", "\n", "cmd", ".", "Stdout", "=", "ioObj", ".", "Stdout", "\n", "cmd", ".", "Stderr", "=", "stderr", "\n", "cmd", ".", "Dir", "=", "dirPath", "\n", "if", "err", ":=", "cmd", ".", "Run", "(", ")", ";", "err", "!=", "nil", "{", "data", ",", "_", ":=", "ioutil", ".", "ReadAll", "(", "debugStderr", ")", "\n", "if", "data", "!=", "nil", "&&", "len", "(", "data", ")", ">", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"%s: %s\\n%s\"", ",", "\\n", ",", "strings", ".", "Join", "(", "args", ",", "\" \"", ")", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "string", "(", "data", ")", "\n", "}", "\n", "return", "fmt", ".", "Errorf", "(", "\"%s: %s\"", ",", "strings", ".", "Join", "(", "args", ",", "\" \"", ")", ",", "err", ".", "Error", "(", ")", ")", "\n", "}" ]
// RunIODirPath runs the command with the given IO and arguments in the given directory specified by dirPath.
[ "RunIODirPath", "runs", "the", "command", "with", "the", "given", "IO", "and", "arguments", "in", "the", "given", "directory", "specified", "by", "dirPath", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/cmdutil/exec.go#L30-L49
test
pachyderm/pachyderm
src/server/auth/server/api_server.go
NewAuthServer
func NewAuthServer(env *serviceenv.ServiceEnv, etcdPrefix string, public bool) (authclient.APIServer, error) { s := &apiServer{ env: env, pachLogger: log.NewLogger("authclient.API"), adminCache: make(map[string]struct{}), tokens: col.NewCollection( env.GetEtcdClient(), path.Join(etcdPrefix, tokensPrefix), nil, &authclient.TokenInfo{}, nil, nil, ), authenticationCodes: col.NewCollection( env.GetEtcdClient(), path.Join(etcdPrefix, authenticationCodesPrefix), nil, &authclient.OTPInfo{}, nil, nil, ), acls: col.NewCollection( env.GetEtcdClient(), path.Join(etcdPrefix, aclsPrefix), nil, &authclient.ACL{}, nil, nil, ), admins: col.NewCollection( env.GetEtcdClient(), path.Join(etcdPrefix, adminsPrefix), nil, &types.BoolValue{}, // smallest value that etcd actually stores nil, nil, ), members: col.NewCollection( env.GetEtcdClient(), path.Join(etcdPrefix, membersPrefix), nil, &authclient.Groups{}, nil, nil, ), groups: col.NewCollection( env.GetEtcdClient(), path.Join(etcdPrefix, groupsPrefix), nil, &authclient.Users{}, nil, nil, ), authConfig: col.NewCollection( env.GetEtcdClient(), path.Join(etcdPrefix, configKey), nil, &authclient.AuthConfig{}, nil, nil, ), public: public, } go s.retrieveOrGeneratePPSToken() go s.watchAdmins(path.Join(etcdPrefix, adminsPrefix)) if public { // start SAML service (won't respond to // anything until config is set) go s.serveSAML() } // Watch for new auth config options go s.watchConfig() return s, nil }
go
func NewAuthServer(env *serviceenv.ServiceEnv, etcdPrefix string, public bool) (authclient.APIServer, error) { s := &apiServer{ env: env, pachLogger: log.NewLogger("authclient.API"), adminCache: make(map[string]struct{}), tokens: col.NewCollection( env.GetEtcdClient(), path.Join(etcdPrefix, tokensPrefix), nil, &authclient.TokenInfo{}, nil, nil, ), authenticationCodes: col.NewCollection( env.GetEtcdClient(), path.Join(etcdPrefix, authenticationCodesPrefix), nil, &authclient.OTPInfo{}, nil, nil, ), acls: col.NewCollection( env.GetEtcdClient(), path.Join(etcdPrefix, aclsPrefix), nil, &authclient.ACL{}, nil, nil, ), admins: col.NewCollection( env.GetEtcdClient(), path.Join(etcdPrefix, adminsPrefix), nil, &types.BoolValue{}, // smallest value that etcd actually stores nil, nil, ), members: col.NewCollection( env.GetEtcdClient(), path.Join(etcdPrefix, membersPrefix), nil, &authclient.Groups{}, nil, nil, ), groups: col.NewCollection( env.GetEtcdClient(), path.Join(etcdPrefix, groupsPrefix), nil, &authclient.Users{}, nil, nil, ), authConfig: col.NewCollection( env.GetEtcdClient(), path.Join(etcdPrefix, configKey), nil, &authclient.AuthConfig{}, nil, nil, ), public: public, } go s.retrieveOrGeneratePPSToken() go s.watchAdmins(path.Join(etcdPrefix, adminsPrefix)) if public { // start SAML service (won't respond to // anything until config is set) go s.serveSAML() } // Watch for new auth config options go s.watchConfig() return s, nil }
[ "func", "NewAuthServer", "(", "env", "*", "serviceenv", ".", "ServiceEnv", ",", "etcdPrefix", "string", ",", "public", "bool", ")", "(", "authclient", ".", "APIServer", ",", "error", ")", "{", "s", ":=", "&", "apiServer", "{", "env", ":", "env", ",", "pachLogger", ":", "log", ".", "NewLogger", "(", "\"authclient.API\"", ")", ",", "adminCache", ":", "make", "(", "map", "[", "string", "]", "struct", "{", "}", ")", ",", "tokens", ":", "col", ".", "NewCollection", "(", "env", ".", "GetEtcdClient", "(", ")", ",", "path", ".", "Join", "(", "etcdPrefix", ",", "tokensPrefix", ")", ",", "nil", ",", "&", "authclient", ".", "TokenInfo", "{", "}", ",", "nil", ",", "nil", ",", ")", ",", "authenticationCodes", ":", "col", ".", "NewCollection", "(", "env", ".", "GetEtcdClient", "(", ")", ",", "path", ".", "Join", "(", "etcdPrefix", ",", "authenticationCodesPrefix", ")", ",", "nil", ",", "&", "authclient", ".", "OTPInfo", "{", "}", ",", "nil", ",", "nil", ",", ")", ",", "acls", ":", "col", ".", "NewCollection", "(", "env", ".", "GetEtcdClient", "(", ")", ",", "path", ".", "Join", "(", "etcdPrefix", ",", "aclsPrefix", ")", ",", "nil", ",", "&", "authclient", ".", "ACL", "{", "}", ",", "nil", ",", "nil", ",", ")", ",", "admins", ":", "col", ".", "NewCollection", "(", "env", ".", "GetEtcdClient", "(", ")", ",", "path", ".", "Join", "(", "etcdPrefix", ",", "adminsPrefix", ")", ",", "nil", ",", "&", "types", ".", "BoolValue", "{", "}", ",", "nil", ",", "nil", ",", ")", ",", "members", ":", "col", ".", "NewCollection", "(", "env", ".", "GetEtcdClient", "(", ")", ",", "path", ".", "Join", "(", "etcdPrefix", ",", "membersPrefix", ")", ",", "nil", ",", "&", "authclient", ".", "Groups", "{", "}", ",", "nil", ",", "nil", ",", ")", ",", "groups", ":", "col", ".", "NewCollection", "(", "env", ".", "GetEtcdClient", "(", ")", ",", "path", ".", "Join", "(", "etcdPrefix", ",", "groupsPrefix", ")", ",", "nil", ",", "&", "authclient", ".", "Users", "{", "}", ",", "nil", ",", "nil", ",", ")", ",", "authConfig", ":", "col", ".", "NewCollection", "(", "env", ".", "GetEtcdClient", "(", ")", ",", "path", ".", "Join", "(", "etcdPrefix", ",", "configKey", ")", ",", "nil", ",", "&", "authclient", ".", "AuthConfig", "{", "}", ",", "nil", ",", "nil", ",", ")", ",", "public", ":", "public", ",", "}", "\n", "go", "s", ".", "retrieveOrGeneratePPSToken", "(", ")", "\n", "go", "s", ".", "watchAdmins", "(", "path", ".", "Join", "(", "etcdPrefix", ",", "adminsPrefix", ")", ")", "\n", "if", "public", "{", "go", "s", ".", "serveSAML", "(", ")", "\n", "}", "\n", "go", "s", ".", "watchConfig", "(", ")", "\n", "return", "s", ",", "nil", "\n", "}" ]
// NewAuthServer returns an implementation of authclient.APIServer.
[ "NewAuthServer", "returns", "an", "implementation", "of", "authclient", ".", "APIServer", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/auth/server/api_server.go#L159-L233
test
pachyderm/pachyderm
src/server/auth/server/api_server.go
expiredClusterAdminCheck
func (a *apiServer) expiredClusterAdminCheck(ctx context.Context, username string) error { state, err := a.getEnterpriseTokenState() if err != nil { return fmt.Errorf("error confirming Pachyderm Enterprise token: %v", err) } isAdmin, err := a.isAdmin(ctx, username) if err != nil { return err } if state != enterpriseclient.State_ACTIVE && !isAdmin { return errors.New("Pachyderm Enterprise is not active in this " + "cluster (until Pachyderm Enterprise is re-activated or Pachyderm " + "auth is deactivated, only cluster admins can perform any operations)") } return nil }
go
func (a *apiServer) expiredClusterAdminCheck(ctx context.Context, username string) error { state, err := a.getEnterpriseTokenState() if err != nil { return fmt.Errorf("error confirming Pachyderm Enterprise token: %v", err) } isAdmin, err := a.isAdmin(ctx, username) if err != nil { return err } if state != enterpriseclient.State_ACTIVE && !isAdmin { return errors.New("Pachyderm Enterprise is not active in this " + "cluster (until Pachyderm Enterprise is re-activated or Pachyderm " + "auth is deactivated, only cluster admins can perform any operations)") } return nil }
[ "func", "(", "a", "*", "apiServer", ")", "expiredClusterAdminCheck", "(", "ctx", "context", ".", "Context", ",", "username", "string", ")", "error", "{", "state", ",", "err", ":=", "a", ".", "getEnterpriseTokenState", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"error confirming Pachyderm Enterprise token: %v\"", ",", "err", ")", "\n", "}", "\n", "isAdmin", ",", "err", ":=", "a", ".", "isAdmin", "(", "ctx", ",", "username", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "state", "!=", "enterpriseclient", ".", "State_ACTIVE", "&&", "!", "isAdmin", "{", "return", "errors", ".", "New", "(", "\"Pachyderm Enterprise is not active in this \"", "+", "\"cluster (until Pachyderm Enterprise is re-activated or Pachyderm \"", "+", "\"auth is deactivated, only cluster admins can perform any operations)\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// expiredClusterAdminCheck enforces that if the cluster's enterprise token is // expired, only admins may log in.
[ "expiredClusterAdminCheck", "enforces", "that", "if", "the", "cluster", "s", "enterprise", "token", "is", "expired", "only", "admins", "may", "log", "in", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/auth/server/api_server.go#L793-L809
test