repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
gravitational/teleport | lib/auth/auth_with_roles.go | SetClusterConfig | func (a *AuthWithRoles) SetClusterConfig(c services.ClusterConfig) error {
if err := a.action(defaults.Namespace, services.KindClusterConfig, services.VerbCreate); err != nil {
return trace.Wrap(err)
}
if err := a.action(defaults.Namespace, services.KindClusterConfig, services.VerbUpdate); err != nil {
return tr... | go | func (a *AuthWithRoles) SetClusterConfig(c services.ClusterConfig) error {
if err := a.action(defaults.Namespace, services.KindClusterConfig, services.VerbCreate); err != nil {
return trace.Wrap(err)
}
if err := a.action(defaults.Namespace, services.KindClusterConfig, services.VerbUpdate); err != nil {
return tr... | [
"func",
"(",
"a",
"*",
"AuthWithRoles",
")",
"SetClusterConfig",
"(",
"c",
"services",
".",
"ClusterConfig",
")",
"error",
"{",
"if",
"err",
":=",
"a",
".",
"action",
"(",
"defaults",
".",
"Namespace",
",",
"services",
".",
"KindClusterConfig",
",",
"servi... | // SetClusterConfig sets cluster level configuration. | [
"SetClusterConfig",
"sets",
"cluster",
"level",
"configuration",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth_with_roles.go#L1250-L1258 | train |
gravitational/teleport | lib/auth/auth_with_roles.go | GetClusterName | func (a *AuthWithRoles) GetClusterName(opts ...services.MarshalOption) (services.ClusterName, error) {
if err := a.action(defaults.Namespace, services.KindClusterName, services.VerbRead); err != nil {
return nil, trace.Wrap(err)
}
return a.authServer.GetClusterName()
} | go | func (a *AuthWithRoles) GetClusterName(opts ...services.MarshalOption) (services.ClusterName, error) {
if err := a.action(defaults.Namespace, services.KindClusterName, services.VerbRead); err != nil {
return nil, trace.Wrap(err)
}
return a.authServer.GetClusterName()
} | [
"func",
"(",
"a",
"*",
"AuthWithRoles",
")",
"GetClusterName",
"(",
"opts",
"...",
"services",
".",
"MarshalOption",
")",
"(",
"services",
".",
"ClusterName",
",",
"error",
")",
"{",
"if",
"err",
":=",
"a",
".",
"action",
"(",
"defaults",
".",
"Namespace... | // GetClusterName gets the name of the cluster. | [
"GetClusterName",
"gets",
"the",
"name",
"of",
"the",
"cluster",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth_with_roles.go#L1261-L1266 | train |
gravitational/teleport | lib/auth/auth_with_roles.go | SetClusterName | func (a *AuthWithRoles) SetClusterName(c services.ClusterName) error {
if err := a.action(defaults.Namespace, services.KindClusterName, services.VerbCreate); err != nil {
return trace.Wrap(err)
}
if err := a.action(defaults.Namespace, services.KindClusterName, services.VerbUpdate); err != nil {
return trace.Wrap... | go | func (a *AuthWithRoles) SetClusterName(c services.ClusterName) error {
if err := a.action(defaults.Namespace, services.KindClusterName, services.VerbCreate); err != nil {
return trace.Wrap(err)
}
if err := a.action(defaults.Namespace, services.KindClusterName, services.VerbUpdate); err != nil {
return trace.Wrap... | [
"func",
"(",
"a",
"*",
"AuthWithRoles",
")",
"SetClusterName",
"(",
"c",
"services",
".",
"ClusterName",
")",
"error",
"{",
"if",
"err",
":=",
"a",
".",
"action",
"(",
"defaults",
".",
"Namespace",
",",
"services",
".",
"KindClusterName",
",",
"services",
... | // SetClusterName sets the name of the cluster. SetClusterName can only be called once. | [
"SetClusterName",
"sets",
"the",
"name",
"of",
"the",
"cluster",
".",
"SetClusterName",
"can",
"only",
"be",
"called",
"once",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth_with_roles.go#L1269-L1277 | train |
gravitational/teleport | lib/auth/auth_with_roles.go | NewAdminAuthServer | func NewAdminAuthServer(authServer *AuthServer, sessions session.Service, alog events.IAuditLog) (ClientI, error) {
ctx, err := NewAdminContext()
if err != nil {
return nil, trace.Wrap(err)
}
return &AuthWithRoles{
authServer: authServer,
checker: ctx.Checker,
user: ctx.User,
alog: alog,
... | go | func NewAdminAuthServer(authServer *AuthServer, sessions session.Service, alog events.IAuditLog) (ClientI, error) {
ctx, err := NewAdminContext()
if err != nil {
return nil, trace.Wrap(err)
}
return &AuthWithRoles{
authServer: authServer,
checker: ctx.Checker,
user: ctx.User,
alog: alog,
... | [
"func",
"NewAdminAuthServer",
"(",
"authServer",
"*",
"AuthServer",
",",
"sessions",
"session",
".",
"Service",
",",
"alog",
"events",
".",
"IAuditLog",
")",
"(",
"ClientI",
",",
"error",
")",
"{",
"ctx",
",",
"err",
":=",
"NewAdminContext",
"(",
")",
"\n"... | // NewAdminAuthServer returns auth server authorized as admin,
// used for auth server cached access | [
"NewAdminAuthServer",
"returns",
"auth",
"server",
"authorized",
"as",
"admin",
"used",
"for",
"auth",
"server",
"cached",
"access"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth_with_roles.go#L1510-L1522 | train |
gravitational/teleport | lib/auth/auth_with_roles.go | NewAuthWithRoles | func NewAuthWithRoles(authServer *AuthServer,
checker services.AccessChecker,
user services.User,
sessions session.Service,
alog events.IAuditLog) *AuthWithRoles {
return &AuthWithRoles{
authServer: authServer,
checker: checker,
sessions: sessions,
user: user,
alog: alog,
}
} | go | func NewAuthWithRoles(authServer *AuthServer,
checker services.AccessChecker,
user services.User,
sessions session.Service,
alog events.IAuditLog) *AuthWithRoles {
return &AuthWithRoles{
authServer: authServer,
checker: checker,
sessions: sessions,
user: user,
alog: alog,
}
} | [
"func",
"NewAuthWithRoles",
"(",
"authServer",
"*",
"AuthServer",
",",
"checker",
"services",
".",
"AccessChecker",
",",
"user",
"services",
".",
"User",
",",
"sessions",
"session",
".",
"Service",
",",
"alog",
"events",
".",
"IAuditLog",
")",
"*",
"AuthWithRo... | // NewAuthWithRoles creates new auth server with access control | [
"NewAuthWithRoles",
"creates",
"new",
"auth",
"server",
"with",
"access",
"control"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth_with_roles.go#L1525-L1537 | train |
gravitational/teleport | lib/sshutils/scp/local.go | SetChmod | func (l *localFileSystem) SetChmod(path string, mode int) error {
chmode := os.FileMode(mode & int(os.ModePerm))
if err := os.Chmod(path, chmode); err != nil {
return trace.Wrap(err)
}
return nil
} | go | func (l *localFileSystem) SetChmod(path string, mode int) error {
chmode := os.FileMode(mode & int(os.ModePerm))
if err := os.Chmod(path, chmode); err != nil {
return trace.Wrap(err)
}
return nil
} | [
"func",
"(",
"l",
"*",
"localFileSystem",
")",
"SetChmod",
"(",
"path",
"string",
",",
"mode",
"int",
")",
"error",
"{",
"chmode",
":=",
"os",
".",
"FileMode",
"(",
"mode",
"&",
"int",
"(",
"os",
".",
"ModePerm",
")",
")",
"\n",
"if",
"err",
":=",
... | // SetChmod sets file permissions | [
"SetChmod",
"sets",
"file",
"permissions"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/scp/local.go#L34-L41 | train |
gravitational/teleport | lib/sshutils/scp/local.go | MkDir | func (l *localFileSystem) MkDir(path string, mode int) error {
fileMode := os.FileMode(mode & int(os.ModePerm))
err := os.MkdirAll(path, fileMode)
if err != nil && !os.IsExist(err) {
return trace.ConvertSystemError(err)
}
return nil
} | go | func (l *localFileSystem) MkDir(path string, mode int) error {
fileMode := os.FileMode(mode & int(os.ModePerm))
err := os.MkdirAll(path, fileMode)
if err != nil && !os.IsExist(err) {
return trace.ConvertSystemError(err)
}
return nil
} | [
"func",
"(",
"l",
"*",
"localFileSystem",
")",
"MkDir",
"(",
"path",
"string",
",",
"mode",
"int",
")",
"error",
"{",
"fileMode",
":=",
"os",
".",
"FileMode",
"(",
"mode",
"&",
"int",
"(",
"os",
".",
"ModePerm",
")",
")",
"\n",
"err",
":=",
"os",
... | // MkDir creates a directory | [
"MkDir",
"creates",
"a",
"directory"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/scp/local.go#L44-L52 | train |
gravitational/teleport | lib/sshutils/scp/local.go | OpenFile | func (l *localFileSystem) OpenFile(filePath string) (io.ReadCloser, error) {
f, err := os.Open(filePath)
if err != nil {
return nil, trace.Wrap(err)
}
return f, nil
} | go | func (l *localFileSystem) OpenFile(filePath string) (io.ReadCloser, error) {
f, err := os.Open(filePath)
if err != nil {
return nil, trace.Wrap(err)
}
return f, nil
} | [
"func",
"(",
"l",
"*",
"localFileSystem",
")",
"OpenFile",
"(",
"filePath",
"string",
")",
"(",
"io",
".",
"ReadCloser",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"filePath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // OpenFile opens a file for read operations and returns a Reader | [
"OpenFile",
"opens",
"a",
"file",
"for",
"read",
"operations",
"and",
"returns",
"a",
"Reader"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/scp/local.go#L60-L67 | train |
gravitational/teleport | lib/sshutils/scp/local.go | GetFileInfo | func (l *localFileSystem) GetFileInfo(filePath string) (FileInfo, error) {
info, err := makeFileInfo(filePath)
if err != nil {
return nil, trace.Wrap(err)
}
return info, nil
} | go | func (l *localFileSystem) GetFileInfo(filePath string) (FileInfo, error) {
info, err := makeFileInfo(filePath)
if err != nil {
return nil, trace.Wrap(err)
}
return info, nil
} | [
"func",
"(",
"l",
"*",
"localFileSystem",
")",
"GetFileInfo",
"(",
"filePath",
"string",
")",
"(",
"FileInfo",
",",
"error",
")",
"{",
"info",
",",
"err",
":=",
"makeFileInfo",
"(",
"filePath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",... | // GetFileInfo returns FileInfo for a given file path | [
"GetFileInfo",
"returns",
"FileInfo",
"for",
"a",
"given",
"file",
"path"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/scp/local.go#L70-L77 | train |
gravitational/teleport | lib/sshutils/scp/local.go | CreateFile | func (l *localFileSystem) CreateFile(filePath string, length uint64) (io.WriteCloser, error) {
f, err := os.Create(filePath)
if err != nil {
return nil, trace.Wrap(err)
}
return f, nil
} | go | func (l *localFileSystem) CreateFile(filePath string, length uint64) (io.WriteCloser, error) {
f, err := os.Create(filePath)
if err != nil {
return nil, trace.Wrap(err)
}
return f, nil
} | [
"func",
"(",
"l",
"*",
"localFileSystem",
")",
"CreateFile",
"(",
"filePath",
"string",
",",
"length",
"uint64",
")",
"(",
"io",
".",
"WriteCloser",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Create",
"(",
"filePath",
")",
"\n",
"if",... | // CreateFile creates a new file and returns a Writer | [
"CreateFile",
"creates",
"a",
"new",
"file",
"and",
"returns",
"a",
"Writer"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/scp/local.go#L80-L87 | train |
gravitational/teleport | lib/sshutils/scp/local.go | ReadDir | func (l *localFileInfo) ReadDir() ([]FileInfo, error) {
f, err := os.Open(l.filePath)
if err != nil {
return nil, trace.Wrap(err)
}
fis, err := f.Readdir(0)
if err != nil {
return nil, trace.Wrap(err)
}
infos := make([]FileInfo, len(fis))
for i := range fis {
fi := fis[i]
info, err := makeFileInfo(fil... | go | func (l *localFileInfo) ReadDir() ([]FileInfo, error) {
f, err := os.Open(l.filePath)
if err != nil {
return nil, trace.Wrap(err)
}
fis, err := f.Readdir(0)
if err != nil {
return nil, trace.Wrap(err)
}
infos := make([]FileInfo, len(fis))
for i := range fis {
fi := fis[i]
info, err := makeFileInfo(fil... | [
"func",
"(",
"l",
"*",
"localFileInfo",
")",
"ReadDir",
"(",
")",
"(",
"[",
"]",
"FileInfo",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"l",
".",
"filePath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",... | // ReadDir returns all files in this directory | [
"ReadDir",
"returns",
"all",
"files",
"in",
"this",
"directory"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/scp/local.go#L128-L150 | train |
gravitational/teleport | lib/sshutils/scp/local.go | GetModePerm | func (l *localFileInfo) GetModePerm() os.FileMode {
return l.fileInfo.Mode() & os.ModePerm
} | go | func (l *localFileInfo) GetModePerm() os.FileMode {
return l.fileInfo.Mode() & os.ModePerm
} | [
"func",
"(",
"l",
"*",
"localFileInfo",
")",
"GetModePerm",
"(",
")",
"os",
".",
"FileMode",
"{",
"return",
"l",
".",
"fileInfo",
".",
"Mode",
"(",
")",
"&",
"os",
".",
"ModePerm",
"\n",
"}"
] | // GetModePerm returns file permissions | [
"GetModePerm",
"returns",
"file",
"permissions"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/scp/local.go#L153-L155 | train |
gravitational/teleport | lib/reversetunnel/remotesite.go | Close | func (s *remoteSite) Close() error {
s.Lock()
defer s.Unlock()
s.cancel()
for i := range s.connections {
s.connections[i].Close()
}
s.connections = []*remoteConn{}
return nil
} | go | func (s *remoteSite) Close() error {
s.Lock()
defer s.Unlock()
s.cancel()
for i := range s.connections {
s.connections[i].Close()
}
s.connections = []*remoteConn{}
return nil
} | [
"func",
"(",
"s",
"*",
"remoteSite",
")",
"Close",
"(",
")",
"error",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"Unlock",
"(",
")",
"\n\n",
"s",
".",
"cancel",
"(",
")",
"\n",
"for",
"i",
":=",
"range",
"s",
".",
"connections",
... | // Clos closes remote cluster connections | [
"Clos",
"closes",
"remote",
"cluster",
"connections"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/remotesite.go#L158-L168 | train |
gravitational/teleport | lib/reversetunnel/remotesite.go | nextConn | func (s *remoteSite) nextConn() (*remoteConn, error) {
s.Lock()
defer s.Unlock()
s.removeInvalidConns()
for i := 0; i < len(s.connections); i++ {
s.lastUsed = (s.lastUsed + 1) % len(s.connections)
remoteConn := s.connections[s.lastUsed]
// connection could have been initated, but agent
// on the other sid... | go | func (s *remoteSite) nextConn() (*remoteConn, error) {
s.Lock()
defer s.Unlock()
s.removeInvalidConns()
for i := 0; i < len(s.connections); i++ {
s.lastUsed = (s.lastUsed + 1) % len(s.connections)
remoteConn := s.connections[s.lastUsed]
// connection could have been initated, but agent
// on the other sid... | [
"func",
"(",
"s",
"*",
"remoteSite",
")",
"nextConn",
"(",
")",
"(",
"*",
"remoteConn",
",",
"error",
")",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"Unlock",
"(",
")",
"\n\n",
"s",
".",
"removeInvalidConns",
"(",
")",
"\n\n",
"fo... | // nextConn returns next connection that is ready
// and has not been marked as invalid
// it will close connections marked as invalid | [
"nextConn",
"returns",
"next",
"connection",
"that",
"is",
"ready",
"and",
"has",
"not",
"been",
"marked",
"as",
"invalid",
"it",
"will",
"close",
"connections",
"marked",
"as",
"invalid"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/remotesite.go#L173-L196 | train |
gravitational/teleport | lib/reversetunnel/remotesite.go | removeInvalidConns | func (s *remoteSite) removeInvalidConns() {
// for first pass, do nothing if no connections are marked
count := 0
for _, conn := range s.connections {
if conn.isInvalid() {
count++
}
}
if count == 0 {
return
}
s.lastUsed = 0
conns := make([]*remoteConn, 0, len(s.connections)-count)
for i := range s.co... | go | func (s *remoteSite) removeInvalidConns() {
// for first pass, do nothing if no connections are marked
count := 0
for _, conn := range s.connections {
if conn.isInvalid() {
count++
}
}
if count == 0 {
return
}
s.lastUsed = 0
conns := make([]*remoteConn, 0, len(s.connections)-count)
for i := range s.co... | [
"func",
"(",
"s",
"*",
"remoteSite",
")",
"removeInvalidConns",
"(",
")",
"{",
"// for first pass, do nothing if no connections are marked",
"count",
":=",
"0",
"\n",
"for",
"_",
",",
"conn",
":=",
"range",
"s",
".",
"connections",
"{",
"if",
"conn",
".",
"isI... | // removeInvalidConns removes connections marked as invalid,
// it should be called only under write lock | [
"removeInvalidConns",
"removes",
"connections",
"marked",
"as",
"invalid",
"it",
"should",
"be",
"called",
"only",
"under",
"write",
"lock"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/remotesite.go#L200-L221 | train |
gravitational/teleport | lib/reversetunnel/remotesite.go | addConn | func (s *remoteSite) addConn(conn net.Conn, sconn ssh.Conn) (*remoteConn, error) {
s.Lock()
defer s.Unlock()
cn, err := s.localAccessPoint.GetClusterName()
if err != nil {
return nil, trace.Wrap(err)
}
rconn := newRemoteConn(&connConfig{
conn: conn,
sconn: sconn,
accessPoint: s.localAccessP... | go | func (s *remoteSite) addConn(conn net.Conn, sconn ssh.Conn) (*remoteConn, error) {
s.Lock()
defer s.Unlock()
cn, err := s.localAccessPoint.GetClusterName()
if err != nil {
return nil, trace.Wrap(err)
}
rconn := newRemoteConn(&connConfig{
conn: conn,
sconn: sconn,
accessPoint: s.localAccessP... | [
"func",
"(",
"s",
"*",
"remoteSite",
")",
"addConn",
"(",
"conn",
"net",
".",
"Conn",
",",
"sconn",
"ssh",
".",
"Conn",
")",
"(",
"*",
"remoteConn",
",",
"error",
")",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"Unlock",
"(",
")"... | // addConn helper adds a new active remote cluster connection to the list
// of such connections | [
"addConn",
"helper",
"adds",
"a",
"new",
"active",
"remote",
"cluster",
"connection",
"to",
"the",
"list",
"of",
"such",
"connections"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/remotesite.go#L225-L247 | train |
gravitational/teleport | lib/reversetunnel/remotesite.go | deleteConnectionRecord | func (s *remoteSite) deleteConnectionRecord() {
s.localAccessPoint.DeleteTunnelConnection(s.connInfo.GetClusterName(), s.connInfo.GetName())
} | go | func (s *remoteSite) deleteConnectionRecord() {
s.localAccessPoint.DeleteTunnelConnection(s.connInfo.GetClusterName(), s.connInfo.GetName())
} | [
"func",
"(",
"s",
"*",
"remoteSite",
")",
"deleteConnectionRecord",
"(",
")",
"{",
"s",
".",
"localAccessPoint",
".",
"DeleteTunnelConnection",
"(",
"s",
".",
"connInfo",
".",
"GetClusterName",
"(",
")",
",",
"s",
".",
"connInfo",
".",
"GetName",
"(",
")",... | // deleteConnectionRecord deletes connection record to let know peer proxies
// that this node lost the connection and needs to be discovered | [
"deleteConnectionRecord",
"deletes",
"connection",
"record",
"to",
"let",
"know",
"peer",
"proxies",
"that",
"this",
"node",
"lost",
"the",
"connection",
"and",
"needs",
"to",
"be",
"discovered"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/remotesite.go#L291-L293 | train |
gravitational/teleport | lib/reversetunnel/remotesite.go | handleHeartbeat | func (s *remoteSite) handleHeartbeat(conn *remoteConn, ch ssh.Channel, reqC <-chan *ssh.Request) {
defer func() {
s.Infof("Cluster connection closed.")
conn.Close()
}()
for {
select {
case <-s.ctx.Done():
s.Infof("closing")
return
case req := <-reqC:
if req == nil {
s.Infof("Cluster agent disc... | go | func (s *remoteSite) handleHeartbeat(conn *remoteConn, ch ssh.Channel, reqC <-chan *ssh.Request) {
defer func() {
s.Infof("Cluster connection closed.")
conn.Close()
}()
for {
select {
case <-s.ctx.Done():
s.Infof("closing")
return
case req := <-reqC:
if req == nil {
s.Infof("Cluster agent disc... | [
"func",
"(",
"s",
"*",
"remoteSite",
")",
"handleHeartbeat",
"(",
"conn",
"*",
"remoteConn",
",",
"ch",
"ssh",
".",
"Channel",
",",
"reqC",
"<-",
"chan",
"*",
"ssh",
".",
"Request",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"s",
".",
"Infof",
"(",
... | // handleHearbeat receives heartbeat messages from the connected agent
// if the agent has missed several heartbeats in a row, Proxy marks
// the connection as invalid. | [
"handleHearbeat",
"receives",
"heartbeat",
"messages",
"from",
"the",
"connected",
"agent",
"if",
"the",
"agent",
"has",
"missed",
"several",
"heartbeats",
"in",
"a",
"row",
"Proxy",
"marks",
"the",
"connection",
"as",
"invalid",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/remotesite.go#L298-L338 | train |
gravitational/teleport | lib/reversetunnel/remotesite.go | updateCertAuthorities | func (s *remoteSite) updateCertAuthorities() error {
// update main cluster cert authorities on the remote side
// remote side makes sure that only relevant fields
// are updated
hostCA, err := s.localClient.GetCertAuthority(services.CertAuthID{
Type: services.HostCA,
DomainName: s.srv.ClusterName,
}, fa... | go | func (s *remoteSite) updateCertAuthorities() error {
// update main cluster cert authorities on the remote side
// remote side makes sure that only relevant fields
// are updated
hostCA, err := s.localClient.GetCertAuthority(services.CertAuthID{
Type: services.HostCA,
DomainName: s.srv.ClusterName,
}, fa... | [
"func",
"(",
"s",
"*",
"remoteSite",
")",
"updateCertAuthorities",
"(",
")",
"error",
"{",
"// update main cluster cert authorities on the remote side",
"// remote side makes sure that only relevant fields",
"// are updated",
"hostCA",
",",
"err",
":=",
"s",
".",
"localClient... | // updateCertAuthorities updates local and remote cert authorities | [
"updateCertAuthorities",
"updates",
"local",
"and",
"remote",
"cert",
"authorities"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/remotesite.go#L371-L421 | train |
gravitational/teleport | lib/backend/report.go | CheckAndSetDefaults | func (r *ReporterConfig) CheckAndSetDefaults() error {
if r.Backend == nil {
return trace.BadParameter("missing parameter Backend")
}
if r.Component == "" {
r.Component = teleport.ComponentBackend
}
return nil
} | go | func (r *ReporterConfig) CheckAndSetDefaults() error {
if r.Backend == nil {
return trace.BadParameter("missing parameter Backend")
}
if r.Component == "" {
r.Component = teleport.ComponentBackend
}
return nil
} | [
"func",
"(",
"r",
"*",
"ReporterConfig",
")",
"CheckAndSetDefaults",
"(",
")",
"error",
"{",
"if",
"r",
".",
"Backend",
"==",
"nil",
"{",
"return",
"trace",
".",
"BadParameter",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"r",
".",
"Component",
"=="... | // CheckAndSetDefaults checks and sets | [
"CheckAndSetDefaults",
"checks",
"and",
"sets"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/report.go#L44-L52 | train |
gravitational/teleport | lib/backend/report.go | NewReporter | func NewReporter(cfg ReporterConfig) (*Reporter, error) {
if err := cfg.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
r := &Reporter{
ReporterConfig: cfg,
}
return r, nil
} | go | func NewReporter(cfg ReporterConfig) (*Reporter, error) {
if err := cfg.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
r := &Reporter{
ReporterConfig: cfg,
}
return r, nil
} | [
"func",
"NewReporter",
"(",
"cfg",
"ReporterConfig",
")",
"(",
"*",
"Reporter",
",",
"error",
")",
"{",
"if",
"err",
":=",
"cfg",
".",
"CheckAndSetDefaults",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"trace",
".",
"Wrap",
"(",
"er... | // NewReporter returns a new Reporter. | [
"NewReporter",
"returns",
"a",
"new",
"Reporter",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/report.go#L62-L70 | train |
gravitational/teleport | lib/backend/report.go | trackRequest | func (s *Reporter) trackRequest(opType OpType, key []byte, endKey []byte) {
if !s.TrackTopRequests {
return
}
if len(key) == 0 {
return
}
// take just the first two parts, otherwise too many distinct requests
// can end up in the map
parts := bytes.Split(key, []byte{Separator})
if len(parts) > 3 {
parts =... | go | func (s *Reporter) trackRequest(opType OpType, key []byte, endKey []byte) {
if !s.TrackTopRequests {
return
}
if len(key) == 0 {
return
}
// take just the first two parts, otherwise too many distinct requests
// can end up in the map
parts := bytes.Split(key, []byte{Separator})
if len(parts) > 3 {
parts =... | [
"func",
"(",
"s",
"*",
"Reporter",
")",
"trackRequest",
"(",
"opType",
"OpType",
",",
"key",
"[",
"]",
"byte",
",",
"endKey",
"[",
"]",
"byte",
")",
"{",
"if",
"!",
"s",
".",
"TrackTopRequests",
"{",
"return",
"\n",
"}",
"\n",
"if",
"len",
"(",
"... | // trackRequests tracks top requests, endKey is supplied for ranges | [
"trackRequests",
"tracks",
"top",
"requests",
"endKey",
"is",
"supplied",
"for",
"ranges"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/report.go#L220-L244 | train |
gravitational/teleport | lib/backend/report.go | NewReporterWatcher | func NewReporterWatcher(ctx context.Context, component string, w Watcher) *ReporterWatcher {
rw := &ReporterWatcher{
Watcher: w,
Component: component,
}
go rw.watch(ctx)
return rw
} | go | func NewReporterWatcher(ctx context.Context, component string, w Watcher) *ReporterWatcher {
rw := &ReporterWatcher{
Watcher: w,
Component: component,
}
go rw.watch(ctx)
return rw
} | [
"func",
"NewReporterWatcher",
"(",
"ctx",
"context",
".",
"Context",
",",
"component",
"string",
",",
"w",
"Watcher",
")",
"*",
"ReporterWatcher",
"{",
"rw",
":=",
"&",
"ReporterWatcher",
"{",
"Watcher",
":",
"w",
",",
"Component",
":",
"component",
",",
"... | // NewReporterWatcher creates new reporter watcher instance | [
"NewReporterWatcher",
"creates",
"new",
"reporter",
"watcher",
"instance"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/report.go#L254-L261 | train |
gravitational/teleport | lib/asciitable/table.go | MakeTable | func MakeTable(headers []string) Table {
t := MakeHeadlessTable(len(headers))
for i := range t.columns {
t.columns[i].title = headers[i]
t.columns[i].width = len(headers[i])
}
return t
} | go | func MakeTable(headers []string) Table {
t := MakeHeadlessTable(len(headers))
for i := range t.columns {
t.columns[i].title = headers[i]
t.columns[i].width = len(headers[i])
}
return t
} | [
"func",
"MakeTable",
"(",
"headers",
"[",
"]",
"string",
")",
"Table",
"{",
"t",
":=",
"MakeHeadlessTable",
"(",
"len",
"(",
"headers",
")",
")",
"\n",
"for",
"i",
":=",
"range",
"t",
".",
"columns",
"{",
"t",
".",
"columns",
"[",
"i",
"]",
".",
... | // MakeTable creates a new instance of the table with given column names. | [
"MakeTable",
"creates",
"a",
"new",
"instance",
"of",
"the",
"table",
"with",
"given",
"column",
"names",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/asciitable/table.go#L42-L49 | train |
gravitational/teleport | lib/asciitable/table.go | MakeHeadlessTable | func MakeHeadlessTable(columnCount int) Table {
return Table{
columns: make([]column, columnCount),
rows: make([][]string, 0),
}
} | go | func MakeHeadlessTable(columnCount int) Table {
return Table{
columns: make([]column, columnCount),
rows: make([][]string, 0),
}
} | [
"func",
"MakeHeadlessTable",
"(",
"columnCount",
"int",
")",
"Table",
"{",
"return",
"Table",
"{",
"columns",
":",
"make",
"(",
"[",
"]",
"column",
",",
"columnCount",
")",
",",
"rows",
":",
"make",
"(",
"[",
"]",
"[",
"]",
"string",
",",
"0",
")",
... | // MakeTable creates a new instance of the table without any column names.
// The number of columns is required. | [
"MakeTable",
"creates",
"a",
"new",
"instance",
"of",
"the",
"table",
"without",
"any",
"column",
"names",
".",
"The",
"number",
"of",
"columns",
"is",
"required",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/asciitable/table.go#L53-L58 | train |
gravitational/teleport | lib/asciitable/table.go | AddRow | func (t *Table) AddRow(row []string) {
limit := min(len(row), len(t.columns))
for i := 0; i < limit; i++ {
cellWidth := len(row[i])
t.columns[i].width = max(cellWidth, t.columns[i].width)
}
t.rows = append(t.rows, row[:limit])
} | go | func (t *Table) AddRow(row []string) {
limit := min(len(row), len(t.columns))
for i := 0; i < limit; i++ {
cellWidth := len(row[i])
t.columns[i].width = max(cellWidth, t.columns[i].width)
}
t.rows = append(t.rows, row[:limit])
} | [
"func",
"(",
"t",
"*",
"Table",
")",
"AddRow",
"(",
"row",
"[",
"]",
"string",
")",
"{",
"limit",
":=",
"min",
"(",
"len",
"(",
"row",
")",
",",
"len",
"(",
"t",
".",
"columns",
")",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"limit",... | // AddRow adds a row of cells to the table. | [
"AddRow",
"adds",
"a",
"row",
"of",
"cells",
"to",
"the",
"table",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/asciitable/table.go#L61-L68 | train |
gravitational/teleport | lib/asciitable/table.go | IsHeadless | func (t *Table) IsHeadless() bool {
total := 0
for i := range t.columns {
total += len(t.columns[i].title)
}
return total == 0
} | go | func (t *Table) IsHeadless() bool {
total := 0
for i := range t.columns {
total += len(t.columns[i].title)
}
return total == 0
} | [
"func",
"(",
"t",
"*",
"Table",
")",
"IsHeadless",
"(",
")",
"bool",
"{",
"total",
":=",
"0",
"\n",
"for",
"i",
":=",
"range",
"t",
".",
"columns",
"{",
"total",
"+=",
"len",
"(",
"t",
".",
"columns",
"[",
"i",
"]",
".",
"title",
")",
"\n",
"... | // IsHeadless returns true if none of the table title cells contains any text. | [
"IsHeadless",
"returns",
"true",
"if",
"none",
"of",
"the",
"table",
"title",
"cells",
"contains",
"any",
"text",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/asciitable/table.go#L104-L110 | train |
gravitational/teleport | lib/utils/uri.go | ParseSessionsURI | func ParseSessionsURI(in string) (*url.URL, error) {
if in == "" {
return nil, trace.BadParameter("uri is empty")
}
u, err := url.Parse(in)
if err != nil {
return nil, trace.BadParameter("failed to parse URI %q: %v", in, err)
}
if u.Scheme == "" {
u.Scheme = teleport.SchemeFile
}
return u, nil
} | go | func ParseSessionsURI(in string) (*url.URL, error) {
if in == "" {
return nil, trace.BadParameter("uri is empty")
}
u, err := url.Parse(in)
if err != nil {
return nil, trace.BadParameter("failed to parse URI %q: %v", in, err)
}
if u.Scheme == "" {
u.Scheme = teleport.SchemeFile
}
return u, nil
} | [
"func",
"ParseSessionsURI",
"(",
"in",
"string",
")",
"(",
"*",
"url",
".",
"URL",
",",
"error",
")",
"{",
"if",
"in",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"trace",
".",
"BadParameter",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"u",
",",
"... | // ParseSessionsURI parses uri per convention of session upload URIs
// file is a default scheme | [
"ParseSessionsURI",
"parses",
"uri",
"per",
"convention",
"of",
"session",
"upload",
"URIs",
"file",
"is",
"a",
"default",
"scheme"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/uri.go#L28-L40 | train |
gravitational/teleport | lib/utils/cli.go | GetIterations | func GetIterations() int {
out := os.Getenv(teleport.IterationsEnvVar)
if out == "" {
return 1
}
iter, err := strconv.Atoi(out)
if err != nil {
panic(err)
}
log.Debugf("Starting tests with %v iterations.", iter)
return iter
} | go | func GetIterations() int {
out := os.Getenv(teleport.IterationsEnvVar)
if out == "" {
return 1
}
iter, err := strconv.Atoi(out)
if err != nil {
panic(err)
}
log.Debugf("Starting tests with %v iterations.", iter)
return iter
} | [
"func",
"GetIterations",
"(",
")",
"int",
"{",
"out",
":=",
"os",
".",
"Getenv",
"(",
"teleport",
".",
"IterationsEnvVar",
")",
"\n",
"if",
"out",
"==",
"\"",
"\"",
"{",
"return",
"1",
"\n",
"}",
"\n",
"iter",
",",
"err",
":=",
"strconv",
".",
"Ato... | // GetIterations provides a simple way to add iterations to the test
// by setting environment variable "ITERATIONS", by default it returns 1 | [
"GetIterations",
"provides",
"a",
"simple",
"way",
"to",
"add",
"iterations",
"to",
"the",
"test",
"by",
"setting",
"environment",
"variable",
"ITERATIONS",
"by",
"default",
"it",
"returns",
"1"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/cli.go#L103-L114 | train |
gravitational/teleport | lib/utils/cli.go | UserMessageFromError | func UserMessageFromError(err error) string {
// untrusted cert?
switch innerError := trace.Unwrap(err).(type) {
case x509.HostnameError:
return fmt.Sprintf("Cannot establish https connection to %s:\n%s\n%s\n",
innerError.Host,
innerError.Error(),
"try a different hostname for --proxy or specify --insecur... | go | func UserMessageFromError(err error) string {
// untrusted cert?
switch innerError := trace.Unwrap(err).(type) {
case x509.HostnameError:
return fmt.Sprintf("Cannot establish https connection to %s:\n%s\n%s\n",
innerError.Host,
innerError.Error(),
"try a different hostname for --proxy or specify --insecur... | [
"func",
"UserMessageFromError",
"(",
"err",
"error",
")",
"string",
"{",
"// untrusted cert?",
"switch",
"innerError",
":=",
"trace",
".",
"Unwrap",
"(",
"err",
")",
".",
"(",
"type",
")",
"{",
"case",
"x509",
".",
"HostnameError",
":",
"return",
"fmt",
".... | // UserMessageFromError returns user friendly error message from error | [
"UserMessageFromError",
"returns",
"user",
"friendly",
"error",
"message",
"from",
"error"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/cli.go#L117-L167 | train |
gravitational/teleport | lib/utils/cli.go | InitCLIParser | func InitCLIParser(appName, appHelp string) (app *kingpin.Application) {
app = kingpin.New(appName, appHelp)
// hide "--help" flag
app.HelpFlag.Hidden()
app.HelpFlag.NoEnvar()
// set our own help template
return app.UsageTemplate(defaultUsageTemplate)
} | go | func InitCLIParser(appName, appHelp string) (app *kingpin.Application) {
app = kingpin.New(appName, appHelp)
// hide "--help" flag
app.HelpFlag.Hidden()
app.HelpFlag.NoEnvar()
// set our own help template
return app.UsageTemplate(defaultUsageTemplate)
} | [
"func",
"InitCLIParser",
"(",
"appName",
",",
"appHelp",
"string",
")",
"(",
"app",
"*",
"kingpin",
".",
"Application",
")",
"{",
"app",
"=",
"kingpin",
".",
"New",
"(",
"appName",
",",
"appHelp",
")",
"\n\n",
"// hide \"--help\" flag",
"app",
".",
"HelpFl... | // InitCLIParser configures kingpin command line args parser with
// some defaults common for all Teleport CLI tools | [
"InitCLIParser",
"configures",
"kingpin",
"command",
"line",
"args",
"parser",
"with",
"some",
"defaults",
"common",
"for",
"all",
"Teleport",
"CLI",
"tools"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/cli.go#L185-L194 | train |
gravitational/teleport | lib/utils/cli.go | needsQuoting | func needsQuoting(text string) bool {
for _, r := range text {
if !strconv.IsPrint(r) {
return true
}
}
return false
} | go | func needsQuoting(text string) bool {
for _, r := range text {
if !strconv.IsPrint(r) {
return true
}
}
return false
} | [
"func",
"needsQuoting",
"(",
"text",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"r",
":=",
"range",
"text",
"{",
"if",
"!",
"strconv",
".",
"IsPrint",
"(",
"r",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}... | // needsQuoting returns true if any non-printable characters are found. | [
"needsQuoting",
"returns",
"true",
"if",
"any",
"non",
"-",
"printable",
"characters",
"are",
"found",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/cli.go#L208-L215 | train |
gravitational/teleport | lib/web/ui/server.go | MakeServers | func MakeServers(clusterName string, servers []services.Server) []Server {
uiServers := []Server{}
for _, server := range servers {
uiLabels := []Label{}
serverLabels := server.GetLabels()
for name, value := range serverLabels {
uiLabels = append(uiLabels, Label{
Name: name,
Value: value,
})
}
... | go | func MakeServers(clusterName string, servers []services.Server) []Server {
uiServers := []Server{}
for _, server := range servers {
uiLabels := []Label{}
serverLabels := server.GetLabels()
for name, value := range serverLabels {
uiLabels = append(uiLabels, Label{
Name: name,
Value: value,
})
}
... | [
"func",
"MakeServers",
"(",
"clusterName",
"string",
",",
"servers",
"[",
"]",
"services",
".",
"Server",
")",
"[",
"]",
"Server",
"{",
"uiServers",
":=",
"[",
"]",
"Server",
"{",
"}",
"\n",
"for",
"_",
",",
"server",
":=",
"range",
"servers",
"{",
"... | // MakeServers creates server objects for webapp | [
"MakeServers",
"creates",
"server",
"objects",
"for",
"webapp"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/web/ui/server.go#L63-L95 | train |
gravitational/teleport | lib/service/signals.go | printShutdownStatus | func (process *TeleportProcess) printShutdownStatus(ctx context.Context) {
t := time.NewTicker(defaults.HighResReportingPeriod)
defer t.Stop()
for {
select {
case <-ctx.Done():
return
case <-t.C:
log.Infof("Waiting for services: %v to finish.", process.Supervisor.Services())
}
}
} | go | func (process *TeleportProcess) printShutdownStatus(ctx context.Context) {
t := time.NewTicker(defaults.HighResReportingPeriod)
defer t.Stop()
for {
select {
case <-ctx.Done():
return
case <-t.C:
log.Infof("Waiting for services: %v to finish.", process.Supervisor.Services())
}
}
} | [
"func",
"(",
"process",
"*",
"TeleportProcess",
")",
"printShutdownStatus",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"t",
":=",
"time",
".",
"NewTicker",
"(",
"defaults",
".",
"HighResReportingPeriod",
")",
"\n",
"defer",
"t",
".",
"Stop",
"(",
")"... | // printShutdownStatus prints running services until shut down | [
"printShutdownStatus",
"prints",
"running",
"services",
"until",
"shut",
"down"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/signals.go#L38-L49 | train |
gravitational/teleport | lib/service/signals.go | closeImportedDescriptors | func (process *TeleportProcess) closeImportedDescriptors(prefix string) error {
process.Lock()
defer process.Unlock()
var errors []error
for i := range process.importedDescriptors {
d := process.importedDescriptors[i]
if strings.HasPrefix(d.Type, prefix) {
process.Infof("Closing imported but unused descript... | go | func (process *TeleportProcess) closeImportedDescriptors(prefix string) error {
process.Lock()
defer process.Unlock()
var errors []error
for i := range process.importedDescriptors {
d := process.importedDescriptors[i]
if strings.HasPrefix(d.Type, prefix) {
process.Infof("Closing imported but unused descript... | [
"func",
"(",
"process",
"*",
"TeleportProcess",
")",
"closeImportedDescriptors",
"(",
"prefix",
"string",
")",
"error",
"{",
"process",
".",
"Lock",
"(",
")",
"\n",
"defer",
"process",
".",
"Unlock",
"(",
")",
"\n\n",
"var",
"errors",
"[",
"]",
"error",
... | // closeImportedDescriptors closes imported but unused file descriptors,
// what could happen if service has updated configuration | [
"closeImportedDescriptors",
"closes",
"imported",
"but",
"unused",
"file",
"descriptors",
"what",
"could",
"happen",
"if",
"service",
"has",
"updated",
"configuration"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/signals.go#L186-L199 | train |
gravitational/teleport | lib/service/signals.go | importListener | func (process *TeleportProcess) importListener(listenerType, address string) (net.Listener, error) {
process.Lock()
defer process.Unlock()
for i := range process.importedDescriptors {
d := process.importedDescriptors[i]
if d.Type == listenerType && d.Address == address {
l, err := d.ToListener()
if err !=... | go | func (process *TeleportProcess) importListener(listenerType, address string) (net.Listener, error) {
process.Lock()
defer process.Unlock()
for i := range process.importedDescriptors {
d := process.importedDescriptors[i]
if d.Type == listenerType && d.Address == address {
l, err := d.ToListener()
if err !=... | [
"func",
"(",
"process",
"*",
"TeleportProcess",
")",
"importListener",
"(",
"listenerType",
",",
"address",
"string",
")",
"(",
"net",
".",
"Listener",
",",
"error",
")",
"{",
"process",
".",
"Lock",
"(",
")",
"\n",
"defer",
"process",
".",
"Unlock",
"("... | // importListener imports listener passed by the parent process, if no listener is found
// returns NotFound, otherwise removes the file from the list | [
"importListener",
"imports",
"listener",
"passed",
"by",
"the",
"parent",
"process",
"if",
"no",
"listener",
"is",
"found",
"returns",
"NotFound",
"otherwise",
"removes",
"the",
"file",
"from",
"the",
"list"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/signals.go#L233-L251 | train |
gravitational/teleport | lib/service/signals.go | createListener | func (process *TeleportProcess) createListener(listenerType, address string) (net.Listener, error) {
listener, err := net.Listen("tcp", address)
if err != nil {
return nil, trace.Wrap(err)
}
process.Lock()
defer process.Unlock()
r := RegisteredListener{Type: listenerType, Address: address, Listener: listener}
... | go | func (process *TeleportProcess) createListener(listenerType, address string) (net.Listener, error) {
listener, err := net.Listen("tcp", address)
if err != nil {
return nil, trace.Wrap(err)
}
process.Lock()
defer process.Unlock()
r := RegisteredListener{Type: listenerType, Address: address, Listener: listener}
... | [
"func",
"(",
"process",
"*",
"TeleportProcess",
")",
"createListener",
"(",
"listenerType",
",",
"address",
"string",
")",
"(",
"net",
".",
"Listener",
",",
"error",
")",
"{",
"listener",
",",
"err",
":=",
"net",
".",
"Listen",
"(",
"\"",
"\"",
",",
"a... | // createListener creates listener and adds to a list of tracked listeners | [
"createListener",
"creates",
"listener",
"and",
"adds",
"to",
"a",
"list",
"of",
"tracked",
"listeners"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/signals.go#L254-L264 | train |
gravitational/teleport | lib/service/signals.go | ExportFileDescriptors | func (process *TeleportProcess) ExportFileDescriptors() ([]FileDescriptor, error) {
var out []FileDescriptor
process.Lock()
defer process.Unlock()
for _, r := range process.registeredListeners {
file, err := utils.GetListenerFile(r.Listener)
if err != nil {
return nil, trace.Wrap(err)
}
out = append(out,... | go | func (process *TeleportProcess) ExportFileDescriptors() ([]FileDescriptor, error) {
var out []FileDescriptor
process.Lock()
defer process.Unlock()
for _, r := range process.registeredListeners {
file, err := utils.GetListenerFile(r.Listener)
if err != nil {
return nil, trace.Wrap(err)
}
out = append(out,... | [
"func",
"(",
"process",
"*",
"TeleportProcess",
")",
"ExportFileDescriptors",
"(",
")",
"(",
"[",
"]",
"FileDescriptor",
",",
"error",
")",
"{",
"var",
"out",
"[",
"]",
"FileDescriptor",
"\n",
"process",
".",
"Lock",
"(",
")",
"\n",
"defer",
"process",
"... | // ExportFileDescriptors exports file descriptors to be passed to child process | [
"ExportFileDescriptors",
"exports",
"file",
"descriptors",
"to",
"be",
"passed",
"to",
"child",
"process"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/signals.go#L267-L279 | train |
gravitational/teleport | lib/service/signals.go | importFileDescriptors | func importFileDescriptors() ([]FileDescriptor, error) {
// These files may be passed in by the parent process
filesString := os.Getenv(teleportFilesEnvVar)
if filesString == "" {
return nil, nil
}
files, err := filesFromString(filesString)
if err != nil {
return nil, trace.BadParameter("child process has fa... | go | func importFileDescriptors() ([]FileDescriptor, error) {
// These files may be passed in by the parent process
filesString := os.Getenv(teleportFilesEnvVar)
if filesString == "" {
return nil, nil
}
files, err := filesFromString(filesString)
if err != nil {
return nil, trace.BadParameter("child process has fa... | [
"func",
"importFileDescriptors",
"(",
")",
"(",
"[",
"]",
"FileDescriptor",
",",
"error",
")",
"{",
"// These files may be passed in by the parent process",
"filesString",
":=",
"os",
".",
"Getenv",
"(",
"teleportFilesEnvVar",
")",
"\n",
"if",
"filesString",
"==",
"... | // importFileDescriptors imports file descriptors from environment if there are any | [
"importFileDescriptors",
"imports",
"file",
"descriptors",
"from",
"environment",
"if",
"there",
"are",
"any"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/signals.go#L282-L299 | train |
gravitational/teleport | lib/events/recorder.go | NewForwardRecorder | func NewForwardRecorder(cfg ForwardRecorderConfig) (*ForwardRecorder, error) {
if err := cfg.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
// Always write sessions to local disk first, then forward them to the Auth
// Server later.
auditLog, err := NewForwarder(ForwarderConfig{
SessionID: ... | go | func NewForwardRecorder(cfg ForwardRecorderConfig) (*ForwardRecorder, error) {
if err := cfg.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
// Always write sessions to local disk first, then forward them to the Auth
// Server later.
auditLog, err := NewForwarder(ForwarderConfig{
SessionID: ... | [
"func",
"NewForwardRecorder",
"(",
"cfg",
"ForwardRecorderConfig",
")",
"(",
"*",
"ForwardRecorder",
",",
"error",
")",
"{",
"if",
"err",
":=",
"cfg",
".",
"CheckAndSetDefaults",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"trace",
".",
... | // NewForwardRecorder returns a new instance of session recorder | [
"NewForwardRecorder",
"returns",
"a",
"new",
"instance",
"of",
"session",
"recorder"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/recorder.go#L112-L139 | train |
gravitational/teleport | lib/events/recorder.go | Write | func (r *ForwardRecorder) Write(data []byte) (int, error) {
// we are copying buffer to prevent data corruption:
// io.Copy allocates single buffer and calls multiple writes in a loop
// our PostSessionSlice is async and sends reader wrapping buffer
// to the channel. This can lead to cases when the buffer is re-us... | go | func (r *ForwardRecorder) Write(data []byte) (int, error) {
// we are copying buffer to prevent data corruption:
// io.Copy allocates single buffer and calls multiple writes in a loop
// our PostSessionSlice is async and sends reader wrapping buffer
// to the channel. This can lead to cases when the buffer is re-us... | [
"func",
"(",
"r",
"*",
"ForwardRecorder",
")",
"Write",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"// we are copying buffer to prevent data corruption:",
"// io.Copy allocates single buffer and calls multiple writes in a loop",
"// our PostSess... | // Write takes a chunk and writes it into the audit log | [
"Write",
"takes",
"a",
"chunk",
"and",
"writes",
"it",
"into",
"the",
"audit",
"log"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/recorder.go#L147-L169 | train |
gravitational/teleport | lib/events/recorder.go | Close | func (r *ForwardRecorder) Close() error {
var errors []error
err := r.AuditLog.Close()
errors = append(errors, err)
// wait until all events from recorder get flushed, it is important
// to do so before we send SessionEndEvent to advise the audit log
// to release resources associated with this session.
// not ... | go | func (r *ForwardRecorder) Close() error {
var errors []error
err := r.AuditLog.Close()
errors = append(errors, err)
// wait until all events from recorder get flushed, it is important
// to do so before we send SessionEndEvent to advise the audit log
// to release resources associated with this session.
// not ... | [
"func",
"(",
"r",
"*",
"ForwardRecorder",
")",
"Close",
"(",
")",
"error",
"{",
"var",
"errors",
"[",
"]",
"error",
"\n",
"err",
":=",
"r",
".",
"AuditLog",
".",
"Close",
"(",
")",
"\n",
"errors",
"=",
"append",
"(",
"errors",
",",
"err",
")",
"\... | // Close closes audit log session recorder | [
"Close",
"closes",
"audit",
"log",
"session",
"recorder"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/recorder.go#L172-L191 | train |
gravitational/teleport | lib/backend/helpers.go | AcquireLock | func AcquireLock(ctx context.Context, backend Backend, lockName string, ttl time.Duration) (err error) {
if lockName == "" {
return trace.BadParameter("missing parameter lock name")
}
key := []byte(filepath.Join(locksPrefix, lockName))
for {
// Get will clear TTL on a lock
backend.Get(ctx, key)
// CreateVa... | go | func AcquireLock(ctx context.Context, backend Backend, lockName string, ttl time.Duration) (err error) {
if lockName == "" {
return trace.BadParameter("missing parameter lock name")
}
key := []byte(filepath.Join(locksPrefix, lockName))
for {
// Get will clear TTL on a lock
backend.Get(ctx, key)
// CreateVa... | [
"func",
"AcquireLock",
"(",
"ctx",
"context",
".",
"Context",
",",
"backend",
"Backend",
",",
"lockName",
"string",
",",
"ttl",
"time",
".",
"Duration",
")",
"(",
"err",
"error",
")",
"{",
"if",
"lockName",
"==",
"\"",
"\"",
"{",
"return",
"trace",
"."... | // AcquireLock grabs a lock that will be released automatically in TTL | [
"AcquireLock",
"grabs",
"a",
"lock",
"that",
"will",
"be",
"released",
"automatically",
"in",
"TTL"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/helpers.go#L30-L51 | train |
gravitational/teleport | lib/backend/helpers.go | ReleaseLock | func ReleaseLock(ctx context.Context, backend Backend, lockName string) error {
if lockName == "" {
return trace.BadParameter("missing parameter lockName")
}
key := []byte(filepath.Join(locksPrefix, lockName))
if err := backend.Delete(ctx, key); err != nil {
return trace.Wrap(err)
}
return nil
} | go | func ReleaseLock(ctx context.Context, backend Backend, lockName string) error {
if lockName == "" {
return trace.BadParameter("missing parameter lockName")
}
key := []byte(filepath.Join(locksPrefix, lockName))
if err := backend.Delete(ctx, key); err != nil {
return trace.Wrap(err)
}
return nil
} | [
"func",
"ReleaseLock",
"(",
"ctx",
"context",
".",
"Context",
",",
"backend",
"Backend",
",",
"lockName",
"string",
")",
"error",
"{",
"if",
"lockName",
"==",
"\"",
"\"",
"{",
"return",
"trace",
".",
"BadParameter",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n... | // ReleaseLock forces lock release | [
"ReleaseLock",
"forces",
"lock",
"release"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/helpers.go#L54-L63 | train |
gravitational/teleport | lib/services/authority.go | Check | func (c *HostCertParams) Check() error {
if c.HostID == "" && len(c.Principals) == 0 {
return trace.BadParameter("HostID [%q] or Principals [%q] are required",
c.HostID, c.Principals)
}
if c.ClusterName == "" {
return trace.BadParameter("ClusterName [%q] is required", c.ClusterName)
}
if err := c.Roles.Che... | go | func (c *HostCertParams) Check() error {
if c.HostID == "" && len(c.Principals) == 0 {
return trace.BadParameter("HostID [%q] or Principals [%q] are required",
c.HostID, c.Principals)
}
if c.ClusterName == "" {
return trace.BadParameter("ClusterName [%q] is required", c.ClusterName)
}
if err := c.Roles.Che... | [
"func",
"(",
"c",
"*",
"HostCertParams",
")",
"Check",
"(",
")",
"error",
"{",
"if",
"c",
".",
"HostID",
"==",
"\"",
"\"",
"&&",
"len",
"(",
"c",
".",
"Principals",
")",
"==",
"0",
"{",
"return",
"trace",
".",
"BadParameter",
"(",
"\"",
"\"",
","... | // Check checks parameters for errors | [
"Check",
"checks",
"parameters",
"for",
"errors"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L57-L71 | train |
gravitational/teleport | lib/services/authority.go | MarshalCertRoles | func MarshalCertRoles(roles []string) (string, error) {
out, err := json.Marshal(CertRoles{Version: V1, Roles: roles})
if err != nil {
return "", trace.Wrap(err)
}
return string(out), err
} | go | func MarshalCertRoles(roles []string) (string, error) {
out, err := json.Marshal(CertRoles{Version: V1, Roles: roles})
if err != nil {
return "", trace.Wrap(err)
}
return string(out), err
} | [
"func",
"MarshalCertRoles",
"(",
"roles",
"[",
"]",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"out",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"CertRoles",
"{",
"Version",
":",
"V1",
",",
"Roles",
":",
"roles",
"}",
")",
"\n",
"if"... | // MarshalCertRoles marshal roles list to OpenSSH | [
"MarshalCertRoles",
"marshal",
"roles",
"list",
"to",
"OpenSSH"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L133-L139 | train |
gravitational/teleport | lib/services/authority.go | UnmarshalCertRoles | func UnmarshalCertRoles(data string) ([]string, error) {
var certRoles CertRoles
if err := utils.UnmarshalWithSchema(CertRolesSchema, &certRoles, []byte(data)); err != nil {
return nil, trace.BadParameter(err.Error())
}
return certRoles.Roles, nil
} | go | func UnmarshalCertRoles(data string) ([]string, error) {
var certRoles CertRoles
if err := utils.UnmarshalWithSchema(CertRolesSchema, &certRoles, []byte(data)); err != nil {
return nil, trace.BadParameter(err.Error())
}
return certRoles.Roles, nil
} | [
"func",
"UnmarshalCertRoles",
"(",
"data",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"var",
"certRoles",
"CertRoles",
"\n",
"if",
"err",
":=",
"utils",
".",
"UnmarshalWithSchema",
"(",
"CertRolesSchema",
",",
"&",
"certRoles",
",",
"[... | // UnmarshalCertRoles marshals roles list to OpenSSH | [
"UnmarshalCertRoles",
"marshals",
"roles",
"list",
"to",
"OpenSSH"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L142-L148 | train |
gravitational/teleport | lib/services/authority.go | CertPoolFromCertAuthorities | func CertPoolFromCertAuthorities(cas []CertAuthority) (*x509.CertPool, error) {
certPool := x509.NewCertPool()
for _, ca := range cas {
keyPairs := ca.GetTLSKeyPairs()
if len(keyPairs) == 0 {
continue
}
for _, keyPair := range keyPairs {
cert, err := tlsca.ParseCertificatePEM(keyPair.Cert)
if err != ... | go | func CertPoolFromCertAuthorities(cas []CertAuthority) (*x509.CertPool, error) {
certPool := x509.NewCertPool()
for _, ca := range cas {
keyPairs := ca.GetTLSKeyPairs()
if len(keyPairs) == 0 {
continue
}
for _, keyPair := range keyPairs {
cert, err := tlsca.ParseCertificatePEM(keyPair.Cert)
if err != ... | [
"func",
"CertPoolFromCertAuthorities",
"(",
"cas",
"[",
"]",
"CertAuthority",
")",
"(",
"*",
"x509",
".",
"CertPool",
",",
"error",
")",
"{",
"certPool",
":=",
"x509",
".",
"NewCertPool",
"(",
")",
"\n",
"for",
"_",
",",
"ca",
":=",
"range",
"cas",
"{"... | // CertPoolFromCertAuthorities returns certificate pools from TLS certificates
// set up in the certificate authorities list | [
"CertPoolFromCertAuthorities",
"returns",
"certificate",
"pools",
"from",
"TLS",
"certificates",
"set",
"up",
"in",
"the",
"certificate",
"authorities",
"list"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L217-L234 | train |
gravitational/teleport | lib/services/authority.go | TLSCerts | func TLSCerts(ca CertAuthority) [][]byte {
pairs := ca.GetTLSKeyPairs()
out := make([][]byte, len(pairs))
for i, pair := range pairs {
out[i] = append([]byte{}, pair.Cert...)
}
return out
} | go | func TLSCerts(ca CertAuthority) [][]byte {
pairs := ca.GetTLSKeyPairs()
out := make([][]byte, len(pairs))
for i, pair := range pairs {
out[i] = append([]byte{}, pair.Cert...)
}
return out
} | [
"func",
"TLSCerts",
"(",
"ca",
"CertAuthority",
")",
"[",
"]",
"[",
"]",
"byte",
"{",
"pairs",
":=",
"ca",
".",
"GetTLSKeyPairs",
"(",
")",
"\n",
"out",
":=",
"make",
"(",
"[",
"]",
"[",
"]",
"byte",
",",
"len",
"(",
"pairs",
")",
")",
"\n",
"f... | // TLSCerts returns TLS certificates from CA | [
"TLSCerts",
"returns",
"TLS",
"certificates",
"from",
"CA"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L255-L262 | train |
gravitational/teleport | lib/services/authority.go | NewCertAuthority | func NewCertAuthority(caType CertAuthType, clusterName string, signingKeys, checkingKeys [][]byte, roles []string) CertAuthority {
return &CertAuthorityV2{
Kind: KindCertAuthority,
Version: V2,
SubKind: string(caType),
Metadata: Metadata{
Name: clusterName,
Namespace: defaults.Namespace,
},
S... | go | func NewCertAuthority(caType CertAuthType, clusterName string, signingKeys, checkingKeys [][]byte, roles []string) CertAuthority {
return &CertAuthorityV2{
Kind: KindCertAuthority,
Version: V2,
SubKind: string(caType),
Metadata: Metadata{
Name: clusterName,
Namespace: defaults.Namespace,
},
S... | [
"func",
"NewCertAuthority",
"(",
"caType",
"CertAuthType",
",",
"clusterName",
"string",
",",
"signingKeys",
",",
"checkingKeys",
"[",
"]",
"[",
"]",
"byte",
",",
"roles",
"[",
"]",
"string",
")",
"CertAuthority",
"{",
"return",
"&",
"CertAuthorityV2",
"{",
... | // NewCertAuthority returns new cert authority | [
"NewCertAuthority",
"returns",
"new",
"cert",
"authority"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L265-L282 | train |
gravitational/teleport | lib/services/authority.go | CertAuthoritiesToV1 | func CertAuthoritiesToV1(in []CertAuthority) ([]CertAuthorityV1, error) {
out := make([]CertAuthorityV1, len(in))
type cav1 interface {
V1() *CertAuthorityV1
}
for i, ca := range in {
v1, ok := ca.(cav1)
if !ok {
return nil, trace.BadParameter("could not transform object to V1")
}
out[i] = *(v1.V1())
... | go | func CertAuthoritiesToV1(in []CertAuthority) ([]CertAuthorityV1, error) {
out := make([]CertAuthorityV1, len(in))
type cav1 interface {
V1() *CertAuthorityV1
}
for i, ca := range in {
v1, ok := ca.(cav1)
if !ok {
return nil, trace.BadParameter("could not transform object to V1")
}
out[i] = *(v1.V1())
... | [
"func",
"CertAuthoritiesToV1",
"(",
"in",
"[",
"]",
"CertAuthority",
")",
"(",
"[",
"]",
"CertAuthorityV1",
",",
"error",
")",
"{",
"out",
":=",
"make",
"(",
"[",
"]",
"CertAuthorityV1",
",",
"len",
"(",
"in",
")",
")",
"\n",
"type",
"cav1",
"interface... | // CertAuthoritiesToV1 converts list of cert authorities to V1 slice | [
"CertAuthoritiesToV1",
"converts",
"list",
"of",
"cert",
"authorities",
"to",
"V1",
"slice"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L285-L298 | train |
gravitational/teleport | lib/services/authority.go | Clone | func (c *CertAuthorityV2) Clone() CertAuthority {
out := *c
out.Spec.CheckingKeys = utils.CopyByteSlices(c.Spec.CheckingKeys)
out.Spec.SigningKeys = utils.CopyByteSlices(c.Spec.SigningKeys)
for i, kp := range c.Spec.TLSKeyPairs {
out.Spec.TLSKeyPairs[i] = TLSKeyPair{
Key: utils.CopyByteSlice(kp.Key),
Cert:... | go | func (c *CertAuthorityV2) Clone() CertAuthority {
out := *c
out.Spec.CheckingKeys = utils.CopyByteSlices(c.Spec.CheckingKeys)
out.Spec.SigningKeys = utils.CopyByteSlices(c.Spec.SigningKeys)
for i, kp := range c.Spec.TLSKeyPairs {
out.Spec.TLSKeyPairs[i] = TLSKeyPair{
Key: utils.CopyByteSlice(kp.Key),
Cert:... | [
"func",
"(",
"c",
"*",
"CertAuthorityV2",
")",
"Clone",
"(",
")",
"CertAuthority",
"{",
"out",
":=",
"*",
"c",
"\n",
"out",
".",
"Spec",
".",
"CheckingKeys",
"=",
"utils",
".",
"CopyByteSlices",
"(",
"c",
".",
"Spec",
".",
"CheckingKeys",
")",
"\n",
... | // Clone returns a copy of the cert authority object. | [
"Clone",
"returns",
"a",
"copy",
"of",
"the",
"cert",
"authority",
"object",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L321-L333 | train |
gravitational/teleport | lib/services/authority.go | GetRotation | func (c *CertAuthorityV2) GetRotation() Rotation {
if c.Spec.Rotation == nil {
return Rotation{}
}
return *c.Spec.Rotation
} | go | func (c *CertAuthorityV2) GetRotation() Rotation {
if c.Spec.Rotation == nil {
return Rotation{}
}
return *c.Spec.Rotation
} | [
"func",
"(",
"c",
"*",
"CertAuthorityV2",
")",
"GetRotation",
"(",
")",
"Rotation",
"{",
"if",
"c",
".",
"Spec",
".",
"Rotation",
"==",
"nil",
"{",
"return",
"Rotation",
"{",
"}",
"\n",
"}",
"\n",
"return",
"*",
"c",
".",
"Spec",
".",
"Rotation",
"... | // GetRotation returns rotation state. | [
"GetRotation",
"returns",
"rotation",
"state",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L336-L341 | train |
gravitational/teleport | lib/services/authority.go | TLSCA | func (c *CertAuthorityV2) TLSCA() (*tlsca.CertAuthority, error) {
if len(c.Spec.TLSKeyPairs) == 0 {
return nil, trace.BadParameter("no TLS key pairs found for certificate authority")
}
return tlsca.New(c.Spec.TLSKeyPairs[0].Cert, c.Spec.TLSKeyPairs[0].Key)
} | go | func (c *CertAuthorityV2) TLSCA() (*tlsca.CertAuthority, error) {
if len(c.Spec.TLSKeyPairs) == 0 {
return nil, trace.BadParameter("no TLS key pairs found for certificate authority")
}
return tlsca.New(c.Spec.TLSKeyPairs[0].Cert, c.Spec.TLSKeyPairs[0].Key)
} | [
"func",
"(",
"c",
"*",
"CertAuthorityV2",
")",
"TLSCA",
"(",
")",
"(",
"*",
"tlsca",
".",
"CertAuthority",
",",
"error",
")",
"{",
"if",
"len",
"(",
"c",
".",
"Spec",
".",
"TLSKeyPairs",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"trace",
".",
"B... | // TLSCA returns TLS certificate authority | [
"TLSCA",
"returns",
"TLS",
"certificate",
"authority"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L349-L354 | train |
gravitational/teleport | lib/services/authority.go | String | func (c *CertAuthorityV2) String() string {
return fmt.Sprintf("CA(name=%v, type=%v)", c.GetClusterName(), c.GetType())
} | go | func (c *CertAuthorityV2) String() string {
return fmt.Sprintf("CA(name=%v, type=%v)", c.GetClusterName(), c.GetType())
} | [
"func",
"(",
"c",
"*",
"CertAuthorityV2",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"c",
".",
"GetClusterName",
"(",
")",
",",
"c",
".",
"GetType",
"(",
")",
")",
"\n",
"}"
] | // String returns human readable version of the CertAuthorityV2. | [
"String",
"returns",
"human",
"readable",
"version",
"of",
"the",
"CertAuthorityV2",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L402-L404 | train |
gravitational/teleport | lib/services/authority.go | AddRole | func (ca *CertAuthorityV2) AddRole(name string) {
for _, r := range ca.Spec.Roles {
if r == name {
return
}
}
ca.Spec.Roles = append(ca.Spec.Roles, name)
} | go | func (ca *CertAuthorityV2) AddRole(name string) {
for _, r := range ca.Spec.Roles {
if r == name {
return
}
}
ca.Spec.Roles = append(ca.Spec.Roles, name)
} | [
"func",
"(",
"ca",
"*",
"CertAuthorityV2",
")",
"AddRole",
"(",
"name",
"string",
")",
"{",
"for",
"_",
",",
"r",
":=",
"range",
"ca",
".",
"Spec",
".",
"Roles",
"{",
"if",
"r",
"==",
"name",
"{",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"ca",
"."... | // AddRole adds a role to ca role list | [
"AddRole",
"adds",
"a",
"role",
"to",
"ca",
"role",
"list"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L417-L424 | train |
gravitational/teleport | lib/services/authority.go | SetSigningKeys | func (ca *CertAuthorityV2) SetSigningKeys(keys [][]byte) error {
ca.Spec.SigningKeys = keys
return nil
} | go | func (ca *CertAuthorityV2) SetSigningKeys(keys [][]byte) error {
ca.Spec.SigningKeys = keys
return nil
} | [
"func",
"(",
"ca",
"*",
"CertAuthorityV2",
")",
"SetSigningKeys",
"(",
"keys",
"[",
"]",
"[",
"]",
"byte",
")",
"error",
"{",
"ca",
".",
"Spec",
".",
"SigningKeys",
"=",
"keys",
"\n",
"return",
"nil",
"\n",
"}"
] | // SetSigningKeys sets signing keys | [
"SetSigningKeys",
"sets",
"signing",
"keys"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L432-L435 | train |
gravitational/teleport | lib/services/authority.go | SetCheckingKeys | func (ca *CertAuthorityV2) SetCheckingKeys(keys [][]byte) error {
ca.Spec.CheckingKeys = keys
return nil
} | go | func (ca *CertAuthorityV2) SetCheckingKeys(keys [][]byte) error {
ca.Spec.CheckingKeys = keys
return nil
} | [
"func",
"(",
"ca",
"*",
"CertAuthorityV2",
")",
"SetCheckingKeys",
"(",
"keys",
"[",
"]",
"[",
"]",
"byte",
")",
"error",
"{",
"ca",
".",
"Spec",
".",
"CheckingKeys",
"=",
"keys",
"\n",
"return",
"nil",
"\n",
"}"
] | // SetCheckingKeys sets SSH public keys | [
"SetCheckingKeys",
"sets",
"SSH",
"public",
"keys"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L438-L441 | train |
gravitational/teleport | lib/services/authority.go | GetID | func (ca *CertAuthorityV2) GetID() CertAuthID {
return CertAuthID{Type: ca.Spec.Type, DomainName: ca.Metadata.Name}
} | go | func (ca *CertAuthorityV2) GetID() CertAuthID {
return CertAuthID{Type: ca.Spec.Type, DomainName: ca.Metadata.Name}
} | [
"func",
"(",
"ca",
"*",
"CertAuthorityV2",
")",
"GetID",
"(",
")",
"CertAuthID",
"{",
"return",
"CertAuthID",
"{",
"Type",
":",
"ca",
".",
"Spec",
".",
"Type",
",",
"DomainName",
":",
"ca",
".",
"Metadata",
".",
"Name",
"}",
"\n",
"}"
] | // GetID returns certificate authority ID -
// combined type and name | [
"GetID",
"returns",
"certificate",
"authority",
"ID",
"-",
"combined",
"type",
"and",
"name"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L445-L447 | train |
gravitational/teleport | lib/services/authority.go | SetRoleMap | func (c *CertAuthorityV2) SetRoleMap(m RoleMap) {
c.Spec.RoleMap = []RoleMapping(m)
} | go | func (c *CertAuthorityV2) SetRoleMap(m RoleMap) {
c.Spec.RoleMap = []RoleMapping(m)
} | [
"func",
"(",
"c",
"*",
"CertAuthorityV2",
")",
"SetRoleMap",
"(",
"m",
"RoleMap",
")",
"{",
"c",
".",
"Spec",
".",
"RoleMap",
"=",
"[",
"]",
"RoleMapping",
"(",
"m",
")",
"\n",
"}"
] | // SetRoleMap sets role map | [
"SetRoleMap",
"sets",
"role",
"map"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L500-L502 | train |
gravitational/teleport | lib/services/authority.go | FirstSigningKey | func (ca *CertAuthorityV2) FirstSigningKey() ([]byte, error) {
if len(ca.Spec.SigningKeys) == 0 {
return nil, trace.NotFound("%v has no signing keys", ca.Metadata.Name)
}
return ca.Spec.SigningKeys[0], nil
} | go | func (ca *CertAuthorityV2) FirstSigningKey() ([]byte, error) {
if len(ca.Spec.SigningKeys) == 0 {
return nil, trace.NotFound("%v has no signing keys", ca.Metadata.Name)
}
return ca.Spec.SigningKeys[0], nil
} | [
"func",
"(",
"ca",
"*",
"CertAuthorityV2",
")",
"FirstSigningKey",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"len",
"(",
"ca",
".",
"Spec",
".",
"SigningKeys",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"trace",
".",
"NotFound"... | // FirstSigningKey returns first signing key or returns error if it's not here | [
"FirstSigningKey",
"returns",
"first",
"signing",
"key",
"or",
"returns",
"error",
"if",
"it",
"s",
"not",
"here"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L505-L510 | train |
gravitational/teleport | lib/services/authority.go | Checkers | func (ca *CertAuthorityV2) Checkers() ([]ssh.PublicKey, error) {
out := make([]ssh.PublicKey, 0, len(ca.Spec.CheckingKeys))
for _, keyBytes := range ca.Spec.CheckingKeys {
key, _, _, _, err := ssh.ParseAuthorizedKey(keyBytes)
if err != nil {
return nil, trace.BadParameter("invalid authority public key (len=%d)... | go | func (ca *CertAuthorityV2) Checkers() ([]ssh.PublicKey, error) {
out := make([]ssh.PublicKey, 0, len(ca.Spec.CheckingKeys))
for _, keyBytes := range ca.Spec.CheckingKeys {
key, _, _, _, err := ssh.ParseAuthorizedKey(keyBytes)
if err != nil {
return nil, trace.BadParameter("invalid authority public key (len=%d)... | [
"func",
"(",
"ca",
"*",
"CertAuthorityV2",
")",
"Checkers",
"(",
")",
"(",
"[",
"]",
"ssh",
".",
"PublicKey",
",",
"error",
")",
"{",
"out",
":=",
"make",
"(",
"[",
"]",
"ssh",
".",
"PublicKey",
",",
"0",
",",
"len",
"(",
"ca",
".",
"Spec",
"."... | // Checkers returns public keys that can be used to check cert authorities | [
"Checkers",
"returns",
"public",
"keys",
"that",
"can",
"be",
"used",
"to",
"check",
"cert",
"authorities"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L519-L529 | train |
gravitational/teleport | lib/services/authority.go | Signers | func (ca *CertAuthorityV2) Signers() ([]ssh.Signer, error) {
out := make([]ssh.Signer, 0, len(ca.Spec.SigningKeys))
for _, keyBytes := range ca.Spec.SigningKeys {
signer, err := ssh.ParsePrivateKey(keyBytes)
if err != nil {
return nil, trace.Wrap(err)
}
out = append(out, signer)
}
return out, nil
} | go | func (ca *CertAuthorityV2) Signers() ([]ssh.Signer, error) {
out := make([]ssh.Signer, 0, len(ca.Spec.SigningKeys))
for _, keyBytes := range ca.Spec.SigningKeys {
signer, err := ssh.ParsePrivateKey(keyBytes)
if err != nil {
return nil, trace.Wrap(err)
}
out = append(out, signer)
}
return out, nil
} | [
"func",
"(",
"ca",
"*",
"CertAuthorityV2",
")",
"Signers",
"(",
")",
"(",
"[",
"]",
"ssh",
".",
"Signer",
",",
"error",
")",
"{",
"out",
":=",
"make",
"(",
"[",
"]",
"ssh",
".",
"Signer",
",",
"0",
",",
"len",
"(",
"ca",
".",
"Spec",
".",
"Si... | // Signers returns a list of signers that could be used to sign keys | [
"Signers",
"returns",
"a",
"list",
"of",
"signers",
"that",
"could",
"be",
"used",
"to",
"sign",
"keys"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L532-L542 | train |
gravitational/teleport | lib/services/authority.go | Check | func (ca *CertAuthorityV2) Check() error {
err := ca.ID().Check()
if err != nil {
return trace.Wrap(err)
}
_, err = ca.Checkers()
if err != nil {
return trace.Wrap(err)
}
_, err = ca.Signers()
if err != nil {
return trace.Wrap(err)
}
// This is to force users to migrate
if len(ca.Spec.Roles) != 0 && le... | go | func (ca *CertAuthorityV2) Check() error {
err := ca.ID().Check()
if err != nil {
return trace.Wrap(err)
}
_, err = ca.Checkers()
if err != nil {
return trace.Wrap(err)
}
_, err = ca.Signers()
if err != nil {
return trace.Wrap(err)
}
// This is to force users to migrate
if len(ca.Spec.Roles) != 0 && le... | [
"func",
"(",
"ca",
"*",
"CertAuthorityV2",
")",
"Check",
"(",
")",
"error",
"{",
"err",
":=",
"ca",
".",
"ID",
"(",
")",
".",
"Check",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"trace",
".",
"Wrap",
"(",
"err",
")",
"\n",
"}",
... | // Check checks if all passed parameters are valid | [
"Check",
"checks",
"if",
"all",
"passed",
"parameters",
"are",
"valid"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L545-L566 | train |
gravitational/teleport | lib/services/authority.go | RemoveCASecrets | func RemoveCASecrets(ca CertAuthority) {
ca.SetSigningKeys(nil)
keyPairs := ca.GetTLSKeyPairs()
for i := range keyPairs {
keyPairs[i].Key = nil
}
ca.SetTLSKeyPairs(keyPairs)
} | go | func RemoveCASecrets(ca CertAuthority) {
ca.SetSigningKeys(nil)
keyPairs := ca.GetTLSKeyPairs()
for i := range keyPairs {
keyPairs[i].Key = nil
}
ca.SetTLSKeyPairs(keyPairs)
} | [
"func",
"RemoveCASecrets",
"(",
"ca",
"CertAuthority",
")",
"{",
"ca",
".",
"SetSigningKeys",
"(",
"nil",
")",
"\n",
"keyPairs",
":=",
"ca",
".",
"GetTLSKeyPairs",
"(",
")",
"\n",
"for",
"i",
":=",
"range",
"keyPairs",
"{",
"keyPairs",
"[",
"i",
"]",
"... | // RemoveCASecrets removes secret values and keys
// from the certificate authority | [
"RemoveCASecrets",
"removes",
"secret",
"values",
"and",
"keys",
"from",
"the",
"certificate",
"authority"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L585-L592 | train |
gravitational/teleport | lib/services/authority.go | Matches | func (s *Rotation) Matches(rotation Rotation) bool {
return s.CurrentID == rotation.CurrentID && s.State == rotation.State && s.Phase == rotation.Phase
} | go | func (s *Rotation) Matches(rotation Rotation) bool {
return s.CurrentID == rotation.CurrentID && s.State == rotation.State && s.Phase == rotation.Phase
} | [
"func",
"(",
"s",
"*",
"Rotation",
")",
"Matches",
"(",
"rotation",
"Rotation",
")",
"bool",
"{",
"return",
"s",
".",
"CurrentID",
"==",
"rotation",
".",
"CurrentID",
"&&",
"s",
".",
"State",
"==",
"rotation",
".",
"State",
"&&",
"s",
".",
"Phase",
"... | // Matches returns true if this state rotation matches
// external rotation state, phase and rotation ID should match,
// notice that matches does not behave like Equals because it does not require
// all fields to be the same. | [
"Matches",
"returns",
"true",
"if",
"this",
"state",
"rotation",
"matches",
"external",
"rotation",
"state",
"phase",
"and",
"rotation",
"ID",
"should",
"match",
"notice",
"that",
"matches",
"does",
"not",
"behave",
"like",
"Equals",
"because",
"it",
"does",
"... | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L641-L643 | train |
gravitational/teleport | lib/services/authority.go | LastRotatedDescription | func (r *Rotation) LastRotatedDescription() string {
if r.LastRotated.IsZero() {
return "never updated"
}
return fmt.Sprintf("last rotated %v", r.LastRotated.Format(teleport.HumanDateFormatSeconds))
} | go | func (r *Rotation) LastRotatedDescription() string {
if r.LastRotated.IsZero() {
return "never updated"
}
return fmt.Sprintf("last rotated %v", r.LastRotated.Format(teleport.HumanDateFormatSeconds))
} | [
"func",
"(",
"r",
"*",
"Rotation",
")",
"LastRotatedDescription",
"(",
")",
"string",
"{",
"if",
"r",
".",
"LastRotated",
".",
"IsZero",
"(",
")",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"r... | // LastRotatedDescription returns human friendly description. | [
"LastRotatedDescription",
"returns",
"human",
"friendly",
"description",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L646-L651 | train |
gravitational/teleport | lib/services/authority.go | PhaseDescription | func (r *Rotation) PhaseDescription() string {
switch r.Phase {
case RotationPhaseInit:
return "initialized"
case RotationPhaseStandby, "":
return "on standby"
case RotationPhaseUpdateClients:
return "rotating clients"
case RotationPhaseUpdateServers:
return "rotating servers"
case RotationPhaseRollback:
... | go | func (r *Rotation) PhaseDescription() string {
switch r.Phase {
case RotationPhaseInit:
return "initialized"
case RotationPhaseStandby, "":
return "on standby"
case RotationPhaseUpdateClients:
return "rotating clients"
case RotationPhaseUpdateServers:
return "rotating servers"
case RotationPhaseRollback:
... | [
"func",
"(",
"r",
"*",
"Rotation",
")",
"PhaseDescription",
"(",
")",
"string",
"{",
"switch",
"r",
".",
"Phase",
"{",
"case",
"RotationPhaseInit",
":",
"return",
"\"",
"\"",
"\n",
"case",
"RotationPhaseStandby",
",",
"\"",
"\"",
":",
"return",
"\"",
"\"... | // PhaseDescription returns human friendly description of a current rotation phase. | [
"PhaseDescription",
"returns",
"human",
"friendly",
"description",
"of",
"a",
"current",
"rotation",
"phase",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L654-L669 | train |
gravitational/teleport | lib/services/authority.go | String | func (r *Rotation) String() string {
switch r.State {
case "", RotationStateStandby:
if r.LastRotated.IsZero() {
return "never updated"
}
return fmt.Sprintf("rotated %v", r.LastRotated.Format(teleport.HumanDateFormatSeconds))
case RotationStateInProgress:
return fmt.Sprintf("%v (mode: %v, started: %v, end... | go | func (r *Rotation) String() string {
switch r.State {
case "", RotationStateStandby:
if r.LastRotated.IsZero() {
return "never updated"
}
return fmt.Sprintf("rotated %v", r.LastRotated.Format(teleport.HumanDateFormatSeconds))
case RotationStateInProgress:
return fmt.Sprintf("%v (mode: %v, started: %v, end... | [
"func",
"(",
"r",
"*",
"Rotation",
")",
"String",
"(",
")",
"string",
"{",
"switch",
"r",
".",
"State",
"{",
"case",
"\"",
"\"",
",",
"RotationStateStandby",
":",
"if",
"r",
".",
"LastRotated",
".",
"IsZero",
"(",
")",
"{",
"return",
"\"",
"\"",
"\... | // String returns user friendly information about certificate authority. | [
"String",
"returns",
"user",
"friendly",
"information",
"about",
"certificate",
"authority",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L672-L689 | train |
gravitational/teleport | lib/services/authority.go | CheckAndSetDefaults | func (r *Rotation) CheckAndSetDefaults(clock clockwork.Clock) error {
switch r.Phase {
case "", RotationPhaseRollback, RotationPhaseUpdateClients, RotationPhaseUpdateServers:
default:
return trace.BadParameter("unsupported phase: %q", r.Phase)
}
switch r.Mode {
case "", RotationModeAuto, RotationModeManual:
de... | go | func (r *Rotation) CheckAndSetDefaults(clock clockwork.Clock) error {
switch r.Phase {
case "", RotationPhaseRollback, RotationPhaseUpdateClients, RotationPhaseUpdateServers:
default:
return trace.BadParameter("unsupported phase: %q", r.Phase)
}
switch r.Mode {
case "", RotationModeAuto, RotationModeManual:
de... | [
"func",
"(",
"r",
"*",
"Rotation",
")",
"CheckAndSetDefaults",
"(",
"clock",
"clockwork",
".",
"Clock",
")",
"error",
"{",
"switch",
"r",
".",
"Phase",
"{",
"case",
"\"",
"\"",
",",
"RotationPhaseRollback",
",",
"RotationPhaseUpdateClients",
",",
"RotationPhas... | // CheckAndSetDefaults checks and sets default rotation parameters. | [
"CheckAndSetDefaults",
"checks",
"and",
"sets",
"default",
"rotation",
"parameters",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L692-L720 | train |
gravitational/teleport | lib/services/authority.go | GenerateSchedule | func GenerateSchedule(clock clockwork.Clock, gracePeriod time.Duration) (*RotationSchedule, error) {
if gracePeriod <= 0 {
return nil, trace.BadParameter("invalid grace period %q, provide value > 0", gracePeriod)
}
return &RotationSchedule{
UpdateClients: clock.Now().UTC().Add(gracePeriod / 3).UTC(),
UpdateSer... | go | func GenerateSchedule(clock clockwork.Clock, gracePeriod time.Duration) (*RotationSchedule, error) {
if gracePeriod <= 0 {
return nil, trace.BadParameter("invalid grace period %q, provide value > 0", gracePeriod)
}
return &RotationSchedule{
UpdateClients: clock.Now().UTC().Add(gracePeriod / 3).UTC(),
UpdateSer... | [
"func",
"GenerateSchedule",
"(",
"clock",
"clockwork",
".",
"Clock",
",",
"gracePeriod",
"time",
".",
"Duration",
")",
"(",
"*",
"RotationSchedule",
",",
"error",
")",
"{",
"if",
"gracePeriod",
"<=",
"0",
"{",
"return",
"nil",
",",
"trace",
".",
"BadParame... | // GenerateSchedule generates schedule based on the time period, using
// even time periods between rotation phases. | [
"GenerateSchedule",
"generates",
"schedule",
"based",
"on",
"the",
"time",
"period",
"using",
"even",
"time",
"periods",
"between",
"rotation",
"phases",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L724-L733 | train |
gravitational/teleport | lib/services/authority.go | CheckAndSetDefaults | func (s *RotationSchedule) CheckAndSetDefaults(clock clockwork.Clock) error {
if s.UpdateServers.IsZero() {
return trace.BadParameter("phase %q has no time switch scheduled", RotationPhaseUpdateServers)
}
if s.Standby.IsZero() {
return trace.BadParameter("phase %q has no time switch scheduled", RotationPhaseStan... | go | func (s *RotationSchedule) CheckAndSetDefaults(clock clockwork.Clock) error {
if s.UpdateServers.IsZero() {
return trace.BadParameter("phase %q has no time switch scheduled", RotationPhaseUpdateServers)
}
if s.Standby.IsZero() {
return trace.BadParameter("phase %q has no time switch scheduled", RotationPhaseStan... | [
"func",
"(",
"s",
"*",
"RotationSchedule",
")",
"CheckAndSetDefaults",
"(",
"clock",
"clockwork",
".",
"Clock",
")",
"error",
"{",
"if",
"s",
".",
"UpdateServers",
".",
"IsZero",
"(",
")",
"{",
"return",
"trace",
".",
"BadParameter",
"(",
"\"",
"\"",
","... | // CheckAndSetDefaults checks and sets default values of the rotation schedule. | [
"CheckAndSetDefaults",
"checks",
"and",
"sets",
"default",
"values",
"of",
"the",
"rotation",
"schedule",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L736-L753 | train |
gravitational/teleport | lib/services/authority.go | String | func (c *CertAuthorityV1) String() string {
return fmt.Sprintf("CA(name=%v, type=%v)", c.DomainName, c.Type)
} | go | func (c *CertAuthorityV1) String() string {
return fmt.Sprintf("CA(name=%v, type=%v)", c.DomainName, c.Type)
} | [
"func",
"(",
"c",
"*",
"CertAuthorityV1",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"c",
".",
"DomainName",
",",
"c",
".",
"Type",
")",
"\n",
"}"
] | // String returns human readable version of the CertAuthorityV1. | [
"String",
"returns",
"human",
"readable",
"version",
"of",
"the",
"CertAuthorityV1",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L878-L880 | train |
gravitational/teleport | lib/services/authority.go | GetCertAuthoritySchema | func GetCertAuthoritySchema() string {
return fmt.Sprintf(V2SchemaTemplate, MetadataSchema, fmt.Sprintf(CertAuthoritySpecV2Schema, RotationSchema, RoleMapSchema), DefaultDefinitions)
} | go | func GetCertAuthoritySchema() string {
return fmt.Sprintf(V2SchemaTemplate, MetadataSchema, fmt.Sprintf(CertAuthoritySpecV2Schema, RotationSchema, RoleMapSchema), DefaultDefinitions)
} | [
"func",
"GetCertAuthoritySchema",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"V2SchemaTemplate",
",",
"MetadataSchema",
",",
"fmt",
".",
"Sprintf",
"(",
"CertAuthoritySpecV2Schema",
",",
"RotationSchema",
",",
"RoleMapSchema",
")",
",",
"Defaul... | // GetCertAuthoritySchema returns JSON Schema for cert authorities | [
"GetCertAuthoritySchema",
"returns",
"JSON",
"Schema",
"for",
"cert",
"authorities"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L912-L914 | train |
gravitational/teleport | lib/services/authority.go | UnmarshalCertAuthority | func (*TeleportCertAuthorityMarshaler) UnmarshalCertAuthority(bytes []byte, opts ...MarshalOption) (CertAuthority, error) {
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
var h ResourceHeader
err = utils.FastUnmarshal(bytes, &h)
if err != nil {
return nil, trace.Wrap(err)
}
s... | go | func (*TeleportCertAuthorityMarshaler) UnmarshalCertAuthority(bytes []byte, opts ...MarshalOption) (CertAuthority, error) {
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
var h ResourceHeader
err = utils.FastUnmarshal(bytes, &h)
if err != nil {
return nil, trace.Wrap(err)
}
s... | [
"func",
"(",
"*",
"TeleportCertAuthorityMarshaler",
")",
"UnmarshalCertAuthority",
"(",
"bytes",
"[",
"]",
"byte",
",",
"opts",
"...",
"MarshalOption",
")",
"(",
"CertAuthority",
",",
"error",
")",
"{",
"cfg",
",",
"err",
":=",
"collectOptions",
"(",
"opts",
... | // UnmarshalCertAuthority unmarshals cert authority from JSON | [
"UnmarshalCertAuthority",
"unmarshals",
"cert",
"authority",
"from",
"JSON"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L926-L965 | train |
gravitational/teleport | lib/services/authority.go | MarshalCertAuthority | func (*TeleportCertAuthorityMarshaler) MarshalCertAuthority(ca CertAuthority, opts ...MarshalOption) ([]byte, error) {
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
type cav1 interface {
V1() *CertAuthorityV1
}
type cav2 interface {
V2() *CertAuthorityV2
}
version := cfg.... | go | func (*TeleportCertAuthorityMarshaler) MarshalCertAuthority(ca CertAuthority, opts ...MarshalOption) ([]byte, error) {
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
type cav1 interface {
V1() *CertAuthorityV1
}
type cav2 interface {
V2() *CertAuthorityV2
}
version := cfg.... | [
"func",
"(",
"*",
"TeleportCertAuthorityMarshaler",
")",
"MarshalCertAuthority",
"(",
"ca",
"CertAuthority",
",",
"opts",
"...",
"MarshalOption",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"cfg",
",",
"err",
":=",
"collectOptions",
"(",
"opts",
")",... | // MarshalCertAuthority marshalls cert authority into JSON | [
"MarshalCertAuthority",
"marshalls",
"cert",
"authority",
"into",
"JSON"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L968-L1005 | train |
gravitational/teleport | lib/events/fields.go | UpdateEventFields | func UpdateEventFields(event Event, fields EventFields, clock clockwork.Clock, uid utils.UID) (err error) {
additionalFields := make(map[string]interface{})
if fields.GetType() == "" {
additionalFields[EventType] = event.Name
}
if fields.GetID() == "" {
additionalFields[EventID] = uid.New()
}
if fields.GetTim... | go | func UpdateEventFields(event Event, fields EventFields, clock clockwork.Clock, uid utils.UID) (err error) {
additionalFields := make(map[string]interface{})
if fields.GetType() == "" {
additionalFields[EventType] = event.Name
}
if fields.GetID() == "" {
additionalFields[EventID] = uid.New()
}
if fields.GetTim... | [
"func",
"UpdateEventFields",
"(",
"event",
"Event",
",",
"fields",
"EventFields",
",",
"clock",
"clockwork",
".",
"Clock",
",",
"uid",
"utils",
".",
"UID",
")",
"(",
"err",
"error",
")",
"{",
"additionalFields",
":=",
"make",
"(",
"map",
"[",
"string",
"... | // UpdateEventFields updates passed event fields with additional information
// common for all event types such as unique IDs, timestamps, codes, etc.
//
// This method is a "final stop" for various audit log implementations for
// updating event fields before it gets persisted in the backend. | [
"UpdateEventFields",
"updates",
"passed",
"event",
"fields",
"with",
"additional",
"information",
"common",
"for",
"all",
"event",
"types",
"such",
"as",
"unique",
"IDs",
"timestamps",
"codes",
"etc",
".",
"This",
"method",
"is",
"a",
"final",
"stop",
"for",
"... | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/fields.go#L32-L50 | train |
gravitational/teleport | lib/reversetunnel/api.go | CheckAndSetDefaults | func (d *DialParams) CheckAndSetDefaults() error {
if d.From == nil {
return trace.BadParameter("parameter From required")
}
if d.To == nil {
return trace.BadParameter("parameter To required")
}
return nil
} | go | func (d *DialParams) CheckAndSetDefaults() error {
if d.From == nil {
return trace.BadParameter("parameter From required")
}
if d.To == nil {
return trace.BadParameter("parameter To required")
}
return nil
} | [
"func",
"(",
"d",
"*",
"DialParams",
")",
"CheckAndSetDefaults",
"(",
")",
"error",
"{",
"if",
"d",
".",
"From",
"==",
"nil",
"{",
"return",
"trace",
".",
"BadParameter",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"d",
".",
"To",
"==",
"nil",
"... | // CheckAndSetDefaults makes sure the minimal parameters are set. | [
"CheckAndSetDefaults",
"makes",
"sure",
"the",
"minimal",
"parameters",
"are",
"set",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/api.go#L54-L63 | train |
gravitational/teleport | lib/services/trustedcluster.go | NewTrustedCluster | func NewTrustedCluster(name string, spec TrustedClusterSpecV2) (TrustedCluster, error) {
return &TrustedClusterV2{
Kind: KindTrustedCluster,
Version: V2,
Metadata: Metadata{
Name: name,
Namespace: defaults.Namespace,
},
Spec: spec,
}, nil
} | go | func NewTrustedCluster(name string, spec TrustedClusterSpecV2) (TrustedCluster, error) {
return &TrustedClusterV2{
Kind: KindTrustedCluster,
Version: V2,
Metadata: Metadata{
Name: name,
Namespace: defaults.Namespace,
},
Spec: spec,
}, nil
} | [
"func",
"NewTrustedCluster",
"(",
"name",
"string",
",",
"spec",
"TrustedClusterSpecV2",
")",
"(",
"TrustedCluster",
",",
"error",
")",
"{",
"return",
"&",
"TrustedClusterV2",
"{",
"Kind",
":",
"KindTrustedCluster",
",",
"Version",
":",
"V2",
",",
"Metadata",
... | // NewTrustedCluster is a convenience wa to create a TrustedCluster resource. | [
"NewTrustedCluster",
"is",
"a",
"convenience",
"wa",
"to",
"create",
"a",
"TrustedCluster",
"resource",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trustedcluster.go#L71-L81 | train |
gravitational/teleport | lib/services/trustedcluster.go | Equals | func (r RoleMap) Equals(o RoleMap) bool {
if len(r) != len(o) {
return false
}
for i := range r {
if !r[i].Equals(o[i]) {
return false
}
}
return true
} | go | func (r RoleMap) Equals(o RoleMap) bool {
if len(r) != len(o) {
return false
}
for i := range r {
if !r[i].Equals(o[i]) {
return false
}
}
return true
} | [
"func",
"(",
"r",
"RoleMap",
")",
"Equals",
"(",
"o",
"RoleMap",
")",
"bool",
"{",
"if",
"len",
"(",
"r",
")",
"!=",
"len",
"(",
"o",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"for",
"i",
":=",
"range",
"r",
"{",
"if",
"!",
"r",
"[",
"i... | // Equals checks if the two role maps are equal. | [
"Equals",
"checks",
"if",
"the",
"two",
"role",
"maps",
"are",
"equal",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trustedcluster.go#L131-L141 | train |
gravitational/teleport | lib/services/trustedcluster.go | String | func (r RoleMap) String() string {
values, err := r.parse()
if err != nil {
return fmt.Sprintf("<failed to parse: %v", err)
}
if len(values) != 0 {
return fmt.Sprintf("%v", values)
}
return "<empty>"
} | go | func (r RoleMap) String() string {
values, err := r.parse()
if err != nil {
return fmt.Sprintf("<failed to parse: %v", err)
}
if len(values) != 0 {
return fmt.Sprintf("%v", values)
}
return "<empty>"
} | [
"func",
"(",
"r",
"RoleMap",
")",
"String",
"(",
")",
"string",
"{",
"values",
",",
"err",
":=",
"r",
".",
"parse",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"... | // String prints user friendly representation of role mapping | [
"String",
"prints",
"user",
"friendly",
"representation",
"of",
"role",
"mapping"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trustedcluster.go#L144-L153 | train |
gravitational/teleport | lib/services/trustedcluster.go | Map | func (r RoleMap) Map(remoteRoles []string) ([]string, error) {
_, err := r.parse()
if err != nil {
return nil, trace.Wrap(err)
}
var outRoles []string
// when no remote roles is specified, assume that
// there is a single empty remote role (that should match wildcards)
if len(remoteRoles) == 0 {
remoteRoles ... | go | func (r RoleMap) Map(remoteRoles []string) ([]string, error) {
_, err := r.parse()
if err != nil {
return nil, trace.Wrap(err)
}
var outRoles []string
// when no remote roles is specified, assume that
// there is a single empty remote role (that should match wildcards)
if len(remoteRoles) == 0 {
remoteRoles ... | [
"func",
"(",
"r",
"RoleMap",
")",
"Map",
"(",
"remoteRoles",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"_",
",",
"err",
":=",
"r",
".",
"parse",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
"... | // Map maps local roles to remote roles | [
"Map",
"maps",
"local",
"roles",
"to",
"remote",
"roles"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trustedcluster.go#L187-L224 | train |
gravitational/teleport | lib/services/trustedcluster.go | Check | func (r RoleMap) Check() error {
_, err := r.parse()
return trace.Wrap(err)
} | go | func (r RoleMap) Check() error {
_, err := r.parse()
return trace.Wrap(err)
} | [
"func",
"(",
"r",
"RoleMap",
")",
"Check",
"(",
")",
"error",
"{",
"_",
",",
"err",
":=",
"r",
".",
"parse",
"(",
")",
"\n",
"return",
"trace",
".",
"Wrap",
"(",
"err",
")",
"\n",
"}"
] | // Check checks RoleMap for errors | [
"Check",
"checks",
"RoleMap",
"for",
"errors"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trustedcluster.go#L227-L230 | train |
gravitational/teleport | lib/services/trustedcluster.go | Equals | func (r RoleMapping) Equals(o RoleMapping) bool {
if r.Remote != o.Remote {
return false
}
if !utils.StringSlicesEqual(r.Local, r.Local) {
return false
}
return true
} | go | func (r RoleMapping) Equals(o RoleMapping) bool {
if r.Remote != o.Remote {
return false
}
if !utils.StringSlicesEqual(r.Local, r.Local) {
return false
}
return true
} | [
"func",
"(",
"r",
"RoleMapping",
")",
"Equals",
"(",
"o",
"RoleMapping",
")",
"bool",
"{",
"if",
"r",
".",
"Remote",
"!=",
"o",
".",
"Remote",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"!",
"utils",
".",
"StringSlicesEqual",
"(",
"r",
".",
"Lo... | // Equals checks if the two role mappings are equal. | [
"Equals",
"checks",
"if",
"the",
"two",
"role",
"mappings",
"are",
"equal",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trustedcluster.go#L233-L241 | train |
gravitational/teleport | lib/services/trustedcluster.go | CanChangeStateTo | func (c *TrustedClusterV2) CanChangeStateTo(t TrustedCluster) error {
if c.GetToken() != t.GetToken() {
return trace.BadParameter("can not update token for existing trusted cluster")
}
if c.GetProxyAddress() != t.GetProxyAddress() {
return trace.BadParameter("can not update proxy address for existing trusted clu... | go | func (c *TrustedClusterV2) CanChangeStateTo(t TrustedCluster) error {
if c.GetToken() != t.GetToken() {
return trace.BadParameter("can not update token for existing trusted cluster")
}
if c.GetProxyAddress() != t.GetProxyAddress() {
return trace.BadParameter("can not update proxy address for existing trusted clu... | [
"func",
"(",
"c",
"*",
"TrustedClusterV2",
")",
"CanChangeStateTo",
"(",
"t",
"TrustedCluster",
")",
"error",
"{",
"if",
"c",
".",
"GetToken",
"(",
")",
"!=",
"t",
".",
"GetToken",
"(",
")",
"{",
"return",
"trace",
".",
"BadParameter",
"(",
"\"",
"\"",... | // CanChangeState checks if the state change is allowed or not. If not, returns
// an error explaining the reason. | [
"CanChangeState",
"checks",
"if",
"the",
"state",
"change",
"is",
"allowed",
"or",
"not",
".",
"If",
"not",
"returns",
"an",
"error",
"explaining",
"the",
"reason",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trustedcluster.go#L408-L433 | train |
gravitational/teleport | lib/services/trustedcluster.go | String | func (c *TrustedClusterV2) String() string {
return fmt.Sprintf("TrustedCluster(Enabled=%v,Roles=%v,Token=%v,ProxyAddress=%v,ReverseTunnelAddress=%v)",
c.Spec.Enabled, c.Spec.Roles, c.Spec.Token, c.Spec.ProxyAddress, c.Spec.ReverseTunnelAddress)
} | go | func (c *TrustedClusterV2) String() string {
return fmt.Sprintf("TrustedCluster(Enabled=%v,Roles=%v,Token=%v,ProxyAddress=%v,ReverseTunnelAddress=%v)",
c.Spec.Enabled, c.Spec.Roles, c.Spec.Token, c.Spec.ProxyAddress, c.Spec.ReverseTunnelAddress)
} | [
"func",
"(",
"c",
"*",
"TrustedClusterV2",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"c",
".",
"Spec",
".",
"Enabled",
",",
"c",
".",
"Spec",
".",
"Roles",
",",
"c",
".",
"Spec",
".",
"Token",
... | // String represents a human readable version of trusted cluster settings. | [
"String",
"represents",
"a",
"human",
"readable",
"version",
"of",
"trusted",
"cluster",
"settings",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trustedcluster.go#L436-L439 | train |
gravitational/teleport | lib/services/trustedcluster.go | GetTrustedClusterSchema | func GetTrustedClusterSchema(extensionSchema string) string {
var trustedClusterSchema string
if extensionSchema == "" {
trustedClusterSchema = fmt.Sprintf(TrustedClusterSpecSchemaTemplate, RoleMapSchema, "")
} else {
trustedClusterSchema = fmt.Sprintf(TrustedClusterSpecSchemaTemplate, RoleMapSchema, ","+extensi... | go | func GetTrustedClusterSchema(extensionSchema string) string {
var trustedClusterSchema string
if extensionSchema == "" {
trustedClusterSchema = fmt.Sprintf(TrustedClusterSpecSchemaTemplate, RoleMapSchema, "")
} else {
trustedClusterSchema = fmt.Sprintf(TrustedClusterSpecSchemaTemplate, RoleMapSchema, ","+extensi... | [
"func",
"GetTrustedClusterSchema",
"(",
"extensionSchema",
"string",
")",
"string",
"{",
"var",
"trustedClusterSchema",
"string",
"\n",
"if",
"extensionSchema",
"==",
"\"",
"\"",
"{",
"trustedClusterSchema",
"=",
"fmt",
".",
"Sprintf",
"(",
"TrustedClusterSpecSchemaTe... | // GetTrustedClusterSchema returns the schema with optionally injected
// schema for extensions. | [
"GetTrustedClusterSchema",
"returns",
"the",
"schema",
"with",
"optionally",
"injected",
"schema",
"for",
"extensions",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trustedcluster.go#L480-L488 | train |
gravitational/teleport | lib/services/trustedcluster.go | Less | func (s SortedTrustedCluster) Less(i, j int) bool {
return s[i].GetName() < s[j].GetName()
} | go | func (s SortedTrustedCluster) Less(i, j int) bool {
return s[i].GetName() < s[j].GetName()
} | [
"func",
"(",
"s",
"SortedTrustedCluster",
")",
"Less",
"(",
"i",
",",
"j",
"int",
")",
"bool",
"{",
"return",
"s",
"[",
"i",
"]",
".",
"GetName",
"(",
")",
"<",
"s",
"[",
"j",
"]",
".",
"GetName",
"(",
")",
"\n",
"}"
] | // Less compares items by name. | [
"Less",
"compares",
"items",
"by",
"name",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trustedcluster.go#L579-L581 | train |
gravitational/teleport | lib/services/trustedcluster.go | Swap | func (s SortedTrustedCluster) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
} | go | func (s SortedTrustedCluster) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
} | [
"func",
"(",
"s",
"SortedTrustedCluster",
")",
"Swap",
"(",
"i",
",",
"j",
"int",
")",
"{",
"s",
"[",
"i",
"]",
",",
"s",
"[",
"j",
"]",
"=",
"s",
"[",
"j",
"]",
",",
"s",
"[",
"i",
"]",
"\n",
"}"
] | // Swap swaps two items in a list. | [
"Swap",
"swaps",
"two",
"items",
"in",
"a",
"list",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trustedcluster.go#L584-L586 | train |
gravitational/teleport | lib/client/profile.go | Name | func (c *ClientProfile) Name() string {
if c.ProxyHost != "" {
return c.ProxyHost
}
addr, _, err := net.SplitHostPort(c.WebProxyAddr)
if err != nil {
return c.WebProxyAddr
}
return addr
} | go | func (c *ClientProfile) Name() string {
if c.ProxyHost != "" {
return c.ProxyHost
}
addr, _, err := net.SplitHostPort(c.WebProxyAddr)
if err != nil {
return c.WebProxyAddr
}
return addr
} | [
"func",
"(",
"c",
"*",
"ClientProfile",
")",
"Name",
"(",
")",
"string",
"{",
"if",
"c",
".",
"ProxyHost",
"!=",
"\"",
"\"",
"{",
"return",
"c",
".",
"ProxyHost",
"\n",
"}",
"\n\n",
"addr",
",",
"_",
",",
"err",
":=",
"net",
".",
"SplitHostPort",
... | // Name returns the name of the profile. | [
"Name",
"returns",
"the",
"name",
"of",
"the",
"profile",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/profile.go#L72-L83 | train |
gravitational/teleport | lib/client/profile.go | UnlinkCurrentProfile | func UnlinkCurrentProfile() error {
return trace.Wrap(os.Remove(filepath.Join(FullProfilePath(""), CurrentProfileSymlink)))
} | go | func UnlinkCurrentProfile() error {
return trace.Wrap(os.Remove(filepath.Join(FullProfilePath(""), CurrentProfileSymlink)))
} | [
"func",
"UnlinkCurrentProfile",
"(",
")",
"error",
"{",
"return",
"trace",
".",
"Wrap",
"(",
"os",
".",
"Remove",
"(",
"filepath",
".",
"Join",
"(",
"FullProfilePath",
"(",
"\"",
"\"",
")",
",",
"CurrentProfileSymlink",
")",
")",
")",
"\n",
"}"
] | // If there's a current profile symlink, remove it | [
"If",
"there",
"s",
"a",
"current",
"profile",
"symlink",
"remove",
"it"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/profile.go#L103-L105 | train |
gravitational/teleport | lib/client/profile.go | ProfileFromFile | func ProfileFromFile(filePath string) (*ClientProfile, error) {
bytes, err := ioutil.ReadFile(filePath)
if err != nil {
return nil, trace.Wrap(err)
}
var cp *ClientProfile
if err = yaml.Unmarshal(bytes, &cp); err != nil {
return nil, trace.Wrap(err)
}
return cp, nil
} | go | func ProfileFromFile(filePath string) (*ClientProfile, error) {
bytes, err := ioutil.ReadFile(filePath)
if err != nil {
return nil, trace.Wrap(err)
}
var cp *ClientProfile
if err = yaml.Unmarshal(bytes, &cp); err != nil {
return nil, trace.Wrap(err)
}
return cp, nil
} | [
"func",
"ProfileFromFile",
"(",
"filePath",
"string",
")",
"(",
"*",
"ClientProfile",
",",
"error",
")",
"{",
"bytes",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"filePath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"trace"... | // ProfileFromFile loads the profile from a YAML file | [
"ProfileFromFile",
"loads",
"the",
"profile",
"from",
"a",
"YAML",
"file"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/profile.go#L121-L131 | train |
gravitational/teleport | lib/client/profile.go | SaveTo | func (cp *ClientProfile) SaveTo(loc ProfileLocation) error {
bytes, err := yaml.Marshal(&cp)
if err != nil {
return trace.Wrap(err)
}
if err = ioutil.WriteFile(loc.Path, bytes, 0660); err != nil {
return trace.Wrap(err)
}
if loc.AliasPath != "" && filepath.Base(loc.AliasPath) != filepath.Base(loc.Path) {
if... | go | func (cp *ClientProfile) SaveTo(loc ProfileLocation) error {
bytes, err := yaml.Marshal(&cp)
if err != nil {
return trace.Wrap(err)
}
if err = ioutil.WriteFile(loc.Path, bytes, 0660); err != nil {
return trace.Wrap(err)
}
if loc.AliasPath != "" && filepath.Base(loc.AliasPath) != filepath.Base(loc.Path) {
if... | [
"func",
"(",
"cp",
"*",
"ClientProfile",
")",
"SaveTo",
"(",
"loc",
"ProfileLocation",
")",
"error",
"{",
"bytes",
",",
"err",
":=",
"yaml",
".",
"Marshal",
"(",
"&",
"cp",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"trace",
".",
"Wrap",
"... | // SaveTo saves the profile into a given filename, optionally overwriting it. | [
"SaveTo",
"saves",
"the",
"profile",
"into",
"a",
"given",
"filename",
"optionally",
"overwriting",
"it",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/profile.go#L145-L171 | train |
gravitational/teleport | lib/auth/helpers.go | CreateUploaderDir | func CreateUploaderDir(dir string) error {
err := os.MkdirAll(filepath.Join(dir, teleport.LogsDir, teleport.ComponentUpload,
events.SessionLogsDir, defaults.Namespace), teleport.SharedDirMode)
if err != nil {
return trace.ConvertSystemError(err)
}
return nil
} | go | func CreateUploaderDir(dir string) error {
err := os.MkdirAll(filepath.Join(dir, teleport.LogsDir, teleport.ComponentUpload,
events.SessionLogsDir, defaults.Namespace), teleport.SharedDirMode)
if err != nil {
return trace.ConvertSystemError(err)
}
return nil
} | [
"func",
"CreateUploaderDir",
"(",
"dir",
"string",
")",
"error",
"{",
"err",
":=",
"os",
".",
"MkdirAll",
"(",
"filepath",
".",
"Join",
"(",
"dir",
",",
"teleport",
".",
"LogsDir",
",",
"teleport",
".",
"ComponentUpload",
",",
"events",
".",
"SessionLogsDi... | // CreateUploaderDir creates directory for file uploader service | [
"CreateUploaderDir",
"creates",
"directory",
"for",
"file",
"uploader",
"service"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L78-L86 | train |
gravitational/teleport | lib/auth/helpers.go | GenerateCertificate | func GenerateCertificate(authServer *AuthServer, identity TestIdentity) ([]byte, []byte, error) {
switch id := identity.I.(type) {
case LocalUser:
user, err := authServer.GetUser(id.Username)
if err != nil {
return nil, nil, trace.Wrap(err)
}
roles, err := services.FetchRoles(user.GetRoles(), authServer, u... | go | func GenerateCertificate(authServer *AuthServer, identity TestIdentity) ([]byte, []byte, error) {
switch id := identity.I.(type) {
case LocalUser:
user, err := authServer.GetUser(id.Username)
if err != nil {
return nil, nil, trace.Wrap(err)
}
roles, err := services.FetchRoles(user.GetRoles(), authServer, u... | [
"func",
"GenerateCertificate",
"(",
"authServer",
"*",
"AuthServer",
",",
"identity",
"TestIdentity",
")",
"(",
"[",
"]",
"byte",
",",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"switch",
"id",
":=",
"identity",
".",
"I",
".",
"(",
"type",
")",
"{",
"... | // GenerateCertificate generates certificate for identity,
// returns private public key pair | [
"GenerateCertificate",
"generates",
"certificate",
"for",
"identity",
"returns",
"private",
"public",
"key",
"pair"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L251-L293 | train |
gravitational/teleport | lib/auth/helpers.go | NewCertificate | func (a *TestAuthServer) NewCertificate(identity TestIdentity) (*tls.Certificate, error) {
cert, key, err := GenerateCertificate(a.AuthServer, identity)
if err != nil {
return nil, trace.Wrap(err)
}
tlsCert, err := tls.X509KeyPair(cert, key)
if err != nil {
return nil, trace.Wrap(err)
}
return &tlsCert, nil
... | go | func (a *TestAuthServer) NewCertificate(identity TestIdentity) (*tls.Certificate, error) {
cert, key, err := GenerateCertificate(a.AuthServer, identity)
if err != nil {
return nil, trace.Wrap(err)
}
tlsCert, err := tls.X509KeyPair(cert, key)
if err != nil {
return nil, trace.Wrap(err)
}
return &tlsCert, nil
... | [
"func",
"(",
"a",
"*",
"TestAuthServer",
")",
"NewCertificate",
"(",
"identity",
"TestIdentity",
")",
"(",
"*",
"tls",
".",
"Certificate",
",",
"error",
")",
"{",
"cert",
",",
"key",
",",
"err",
":=",
"GenerateCertificate",
"(",
"a",
".",
"AuthServer",
"... | // NewCertificate returns new TLS credentials generated by test auth server | [
"NewCertificate",
"returns",
"new",
"TLS",
"credentials",
"generated",
"by",
"test",
"auth",
"server"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L296-L306 | train |
gravitational/teleport | lib/auth/helpers.go | Trust | func (a *TestAuthServer) Trust(remote *TestAuthServer, roleMap services.RoleMap) error {
remoteCA, err := remote.AuthServer.GetCertAuthority(services.CertAuthID{
Type: services.HostCA,
DomainName: remote.ClusterName,
}, false)
if err != nil {
return trace.Wrap(err)
}
err = a.AuthServer.UpsertCertAuthor... | go | func (a *TestAuthServer) Trust(remote *TestAuthServer, roleMap services.RoleMap) error {
remoteCA, err := remote.AuthServer.GetCertAuthority(services.CertAuthID{
Type: services.HostCA,
DomainName: remote.ClusterName,
}, false)
if err != nil {
return trace.Wrap(err)
}
err = a.AuthServer.UpsertCertAuthor... | [
"func",
"(",
"a",
"*",
"TestAuthServer",
")",
"Trust",
"(",
"remote",
"*",
"TestAuthServer",
",",
"roleMap",
"services",
".",
"RoleMap",
")",
"error",
"{",
"remoteCA",
",",
"err",
":=",
"remote",
".",
"AuthServer",
".",
"GetCertAuthority",
"(",
"services",
... | // Trust adds other server host certificate authority as trusted | [
"Trust",
"adds",
"other",
"server",
"host",
"certificate",
"authority",
"as",
"trusted"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L314-L339 | train |
gravitational/teleport | lib/auth/helpers.go | NewRemoteClient | func (a *TestAuthServer) NewRemoteClient(identity TestIdentity, addr net.Addr, pool *x509.CertPool) (*Client, error) {
tlsConfig := utils.TLSConfig(a.CipherSuites)
cert, err := a.NewCertificate(identity)
if err != nil {
return nil, trace.Wrap(err)
}
tlsConfig.Certificates = []tls.Certificate{*cert}
tlsConfig.Ro... | go | func (a *TestAuthServer) NewRemoteClient(identity TestIdentity, addr net.Addr, pool *x509.CertPool) (*Client, error) {
tlsConfig := utils.TLSConfig(a.CipherSuites)
cert, err := a.NewCertificate(identity)
if err != nil {
return nil, trace.Wrap(err)
}
tlsConfig.Certificates = []tls.Certificate{*cert}
tlsConfig.Ro... | [
"func",
"(",
"a",
"*",
"TestAuthServer",
")",
"NewRemoteClient",
"(",
"identity",
"TestIdentity",
",",
"addr",
"net",
".",
"Addr",
",",
"pool",
"*",
"x509",
".",
"CertPool",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"tlsConfig",
":=",
"utils",
"... | // NewRemoteClient creates new client to the remote server using identity
// generated for this certificate authority | [
"NewRemoteClient",
"creates",
"new",
"client",
"to",
"the",
"remote",
"server",
"using",
"identity",
"generated",
"for",
"this",
"certificate",
"authority"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L362-L374 | train |
gravitational/teleport | lib/auth/helpers.go | CheckAndSetDefaults | func (cfg *TestTLSServerConfig) CheckAndSetDefaults() error {
if cfg.APIConfig == nil {
return trace.BadParameter("missing parameter APIConfig")
}
if cfg.AuthServer == nil {
return trace.BadParameter("missing parameter AuthServer")
}
// use very permissive limiter configuration by default
if cfg.Limiter == ni... | go | func (cfg *TestTLSServerConfig) CheckAndSetDefaults() error {
if cfg.APIConfig == nil {
return trace.BadParameter("missing parameter APIConfig")
}
if cfg.AuthServer == nil {
return trace.BadParameter("missing parameter AuthServer")
}
// use very permissive limiter configuration by default
if cfg.Limiter == ni... | [
"func",
"(",
"cfg",
"*",
"TestTLSServerConfig",
")",
"CheckAndSetDefaults",
"(",
")",
"error",
"{",
"if",
"cfg",
".",
"APIConfig",
"==",
"nil",
"{",
"return",
"trace",
".",
"BadParameter",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"cfg",
".",
"AuthS... | // CheckAndSetDefaults checks and sets limiter defaults | [
"CheckAndSetDefaults",
"checks",
"and",
"sets",
"limiter",
"defaults"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L416-L431 | train |
gravitational/teleport | lib/auth/helpers.go | NewClientFromWebSession | func (t *TestTLSServer) NewClientFromWebSession(sess services.WebSession) (*Client, error) {
tlsConfig, err := t.Identity.TLSConfig(t.AuthServer.CipherSuites)
if err != nil {
return nil, trace.Wrap(err)
}
tlsCert, err := tls.X509KeyPair(sess.GetTLSCert(), sess.GetPriv())
if err != nil {
return nil, trace.Wrap(... | go | func (t *TestTLSServer) NewClientFromWebSession(sess services.WebSession) (*Client, error) {
tlsConfig, err := t.Identity.TLSConfig(t.AuthServer.CipherSuites)
if err != nil {
return nil, trace.Wrap(err)
}
tlsCert, err := tls.X509KeyPair(sess.GetTLSCert(), sess.GetPriv())
if err != nil {
return nil, trace.Wrap(... | [
"func",
"(",
"t",
"*",
"TestTLSServer",
")",
"NewClientFromWebSession",
"(",
"sess",
"services",
".",
"WebSession",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"tlsConfig",
",",
"err",
":=",
"t",
".",
"Identity",
".",
"TLSConfig",
"(",
"t",
".",
"... | // NewClientFromWebSession returns new authenticated client from web session | [
"NewClientFromWebSession",
"returns",
"new",
"authenticated",
"client",
"from",
"web",
"session"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L513-L525 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.