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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
xo/xo | internal/loader.go | LoadForeignKeys | func (tl TypeLoader) LoadForeignKeys(args *ArgType, tableMap map[string]*Type) (map[string]*ForeignKey, error) {
var err error
fkMap := map[string]*ForeignKey{}
for _, t := range tableMap {
// load keys per table
err = tl.LoadTableForeignKeys(args, tableMap, t, fkMap)
if err != nil {
return nil, err
}
}... | go | func (tl TypeLoader) LoadForeignKeys(args *ArgType, tableMap map[string]*Type) (map[string]*ForeignKey, error) {
var err error
fkMap := map[string]*ForeignKey{}
for _, t := range tableMap {
// load keys per table
err = tl.LoadTableForeignKeys(args, tableMap, t, fkMap)
if err != nil {
return nil, err
}
}... | [
"func",
"(",
"tl",
"TypeLoader",
")",
"LoadForeignKeys",
"(",
"args",
"*",
"ArgType",
",",
"tableMap",
"map",
"[",
"string",
"]",
"*",
"Type",
")",
"(",
"map",
"[",
"string",
"]",
"*",
"ForeignKey",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\... | // LoadForeignKeys loads foreign keys. | [
"LoadForeignKeys",
"loads",
"foreign",
"keys",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/internal/loader.go#L553-L579 | train |
xo/xo | internal/loader.go | LoadTableForeignKeys | func (tl TypeLoader) LoadTableForeignKeys(args *ArgType, tableMap map[string]*Type, typeTpl *Type, fkMap map[string]*ForeignKey) error {
var err error
// load foreign keys
foreignKeyList, err := tl.ForeignKeyList(args.DB, args.Schema, typeTpl.Table.TableName)
if err != nil {
return err
}
// loop over foreign ... | go | func (tl TypeLoader) LoadTableForeignKeys(args *ArgType, tableMap map[string]*Type, typeTpl *Type, fkMap map[string]*ForeignKey) error {
var err error
// load foreign keys
foreignKeyList, err := tl.ForeignKeyList(args.DB, args.Schema, typeTpl.Table.TableName)
if err != nil {
return err
}
// loop over foreign ... | [
"func",
"(",
"tl",
"TypeLoader",
")",
"LoadTableForeignKeys",
"(",
"args",
"*",
"ArgType",
",",
"tableMap",
"map",
"[",
"string",
"]",
"*",
"Type",
",",
"typeTpl",
"*",
"Type",
",",
"fkMap",
"map",
"[",
"string",
"]",
"*",
"ForeignKey",
")",
"error",
"... | // LoadTableForeignKeys loads schema foreign key definitions per table. | [
"LoadTableForeignKeys",
"loads",
"schema",
"foreign",
"key",
"definitions",
"per",
"table",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/internal/loader.go#L582-L650 | train |
xo/xo | internal/loader.go | LoadIndexes | func (tl TypeLoader) LoadIndexes(args *ArgType, tableMap map[string]*Type) (map[string]*Index, error) {
var err error
ixMap := map[string]*Index{}
for _, t := range tableMap {
// load table indexes
err = tl.LoadTableIndexes(args, t, ixMap)
if err != nil {
return nil, err
}
}
// generate templates
for... | go | func (tl TypeLoader) LoadIndexes(args *ArgType, tableMap map[string]*Type) (map[string]*Index, error) {
var err error
ixMap := map[string]*Index{}
for _, t := range tableMap {
// load table indexes
err = tl.LoadTableIndexes(args, t, ixMap)
if err != nil {
return nil, err
}
}
// generate templates
for... | [
"func",
"(",
"tl",
"TypeLoader",
")",
"LoadIndexes",
"(",
"args",
"*",
"ArgType",
",",
"tableMap",
"map",
"[",
"string",
"]",
"*",
"Type",
")",
"(",
"map",
"[",
"string",
"]",
"*",
"Index",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"ix... | // LoadIndexes loads schema index definitions. | [
"LoadIndexes",
"loads",
"schema",
"index",
"definitions",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/internal/loader.go#L653-L674 | train |
xo/xo | internal/loader.go | LoadTableIndexes | func (tl TypeLoader) LoadTableIndexes(args *ArgType, typeTpl *Type, ixMap map[string]*Index) error {
var err error
var priIxLoaded bool
// load indexes
indexList, err := tl.IndexList(args.DB, args.Schema, typeTpl.Table.TableName)
if err != nil {
return err
}
// process indexes
for _, ix := range indexList {... | go | func (tl TypeLoader) LoadTableIndexes(args *ArgType, typeTpl *Type, ixMap map[string]*Index) error {
var err error
var priIxLoaded bool
// load indexes
indexList, err := tl.IndexList(args.DB, args.Schema, typeTpl.Table.TableName)
if err != nil {
return err
}
// process indexes
for _, ix := range indexList {... | [
"func",
"(",
"tl",
"TypeLoader",
")",
"LoadTableIndexes",
"(",
"args",
"*",
"ArgType",
",",
"typeTpl",
"*",
"Type",
",",
"ixMap",
"map",
"[",
"string",
"]",
"*",
"Index",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"var",
"priIxLoaded",
"bool",
"\n... | // LoadTableIndexes loads schema index definitions per table. | [
"LoadTableIndexes",
"loads",
"schema",
"index",
"definitions",
"per",
"table",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/internal/loader.go#L677-L742 | train |
xo/xo | internal/loader.go | LoadIndexColumns | func (tl TypeLoader) LoadIndexColumns(args *ArgType, ixTpl *Index) error {
var err error
// load index columns
indexCols, err := tl.IndexColumnList(args.DB, args.Schema, ixTpl.Type.Table.TableName, ixTpl.Index.IndexName)
if err != nil {
return err
}
// process index columns
for _, ic := range indexCols {
v... | go | func (tl TypeLoader) LoadIndexColumns(args *ArgType, ixTpl *Index) error {
var err error
// load index columns
indexCols, err := tl.IndexColumnList(args.DB, args.Schema, ixTpl.Type.Table.TableName, ixTpl.Index.IndexName)
if err != nil {
return err
}
// process index columns
for _, ic := range indexCols {
v... | [
"func",
"(",
"tl",
"TypeLoader",
")",
"LoadIndexColumns",
"(",
"args",
"*",
"ArgType",
",",
"ixTpl",
"*",
"Index",
")",
"error",
"{",
"var",
"err",
"error",
"\n\n",
"// load index columns",
"indexCols",
",",
"err",
":=",
"tl",
".",
"IndexColumnList",
"(",
... | // LoadIndexColumns loads the index column information. | [
"LoadIndexColumns",
"loads",
"the",
"index",
"column",
"information",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/internal/loader.go#L745-L775 | train |
xo/xo | examples/django/postgres/authpermission.xo.go | AuthPermissionByContentTypeIDCodename | func AuthPermissionByContentTypeIDCodename(db XODB, contentTypeID int, codename string) (*AuthPermission, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`id, name, content_type_id, codename ` +
`FROM public.auth_permission ` +
`WHERE content_type_id = $1 AND codename = $2`
// run query
XOLo... | go | func AuthPermissionByContentTypeIDCodename(db XODB, contentTypeID int, codename string) (*AuthPermission, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`id, name, content_type_id, codename ` +
`FROM public.auth_permission ` +
`WHERE content_type_id = $1 AND codename = $2`
// run query
XOLo... | [
"func",
"AuthPermissionByContentTypeIDCodename",
"(",
"db",
"XODB",
",",
"contentTypeID",
"int",
",",
"codename",
"string",
")",
"(",
"*",
"AuthPermission",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// sql query",
"const",
"sqlstr",
"=",
"`SELECT `... | // AuthPermissionByContentTypeIDCodename retrieves a row from 'public.auth_permission' as a AuthPermission.
//
// Generated from index 'auth_permission_content_type_id_01ab375a_uniq'. | [
"AuthPermissionByContentTypeIDCodename",
"retrieves",
"a",
"row",
"from",
"public",
".",
"auth_permission",
"as",
"a",
"AuthPermission",
".",
"Generated",
"from",
"index",
"auth_permission_content_type_id_01ab375a_uniq",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/postgres/authpermission.xo.go#L210-L231 | train |
xo/xo | examples/django/postgres/authpermission.xo.go | AuthPermissionByID | func AuthPermissionByID(db XODB, id int) (*AuthPermission, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`id, name, content_type_id, codename ` +
`FROM public.auth_permission ` +
`WHERE id = $1`
// run query
XOLog(sqlstr, id)
ap := AuthPermission{
_exists: true,
}
err = db.QueryRow(s... | go | func AuthPermissionByID(db XODB, id int) (*AuthPermission, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`id, name, content_type_id, codename ` +
`FROM public.auth_permission ` +
`WHERE id = $1`
// run query
XOLog(sqlstr, id)
ap := AuthPermission{
_exists: true,
}
err = db.QueryRow(s... | [
"func",
"AuthPermissionByID",
"(",
"db",
"XODB",
",",
"id",
"int",
")",
"(",
"*",
"AuthPermission",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// sql query",
"const",
"sqlstr",
"=",
"`SELECT `",
"+",
"`id, name, content_type_id, codename `",
"+",
... | // AuthPermissionByID retrieves a row from 'public.auth_permission' as a AuthPermission.
//
// Generated from index 'auth_permission_pkey'. | [
"AuthPermissionByID",
"retrieves",
"a",
"row",
"from",
"public",
".",
"auth_permission",
"as",
"a",
"AuthPermission",
".",
"Generated",
"from",
"index",
"auth_permission_pkey",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/postgres/authpermission.xo.go#L236-L257 | train |
xo/xo | models/sequence.xo.go | PgSequences | func PgSequences(db XODB, schema string) ([]*Sequence, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`t.relname ` + // ::varchar AS table_name
`FROM pg_class s ` +
`JOIN pg_depend d ON d.objid = s.oid ` +
`JOIN pg_class t ON d.objid = s.oid AND d.refobjid = t.oid ` +
`JOIN pg_namespace n ... | go | func PgSequences(db XODB, schema string) ([]*Sequence, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`t.relname ` + // ::varchar AS table_name
`FROM pg_class s ` +
`JOIN pg_depend d ON d.objid = s.oid ` +
`JOIN pg_class t ON d.objid = s.oid AND d.refobjid = t.oid ` +
`JOIN pg_namespace n ... | [
"func",
"PgSequences",
"(",
"db",
"XODB",
",",
"schema",
"string",
")",
"(",
"[",
"]",
"*",
"Sequence",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// sql query",
"const",
"sqlstr",
"=",
"`SELECT `",
"+",
"`t.relname `",
"+",
"// ::varchar AS t... | // PgSequences runs a custom query, returning results as Sequence. | [
"PgSequences",
"runs",
"a",
"custom",
"query",
"returning",
"results",
"as",
"Sequence",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/models/sequence.xo.go#L12-L47 | train |
xo/xo | models/sqcolumn.xo.go | SqTableColumns | func SqTableColumns(db XODB, table string) ([]*SqColumn, error) {
var err error
// sql query
var sqlstr = `PRAGMA table_info(` + table + `)`
// run query
XOLog(sqlstr)
q, err := db.Query(sqlstr, table)
if err != nil {
return nil, err
}
defer q.Close()
// load results
res := []*SqColumn{}
for q.Next() {... | go | func SqTableColumns(db XODB, table string) ([]*SqColumn, error) {
var err error
// sql query
var sqlstr = `PRAGMA table_info(` + table + `)`
// run query
XOLog(sqlstr)
q, err := db.Query(sqlstr, table)
if err != nil {
return nil, err
}
defer q.Close()
// load results
res := []*SqColumn{}
for q.Next() {... | [
"func",
"SqTableColumns",
"(",
"db",
"XODB",
",",
"table",
"string",
")",
"(",
"[",
"]",
"*",
"SqColumn",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// sql query",
"var",
"sqlstr",
"=",
"`PRAGMA table_info(`",
"+",
"table",
"+",
"`)`",
"\n\n... | // SqTableColumns runs a custom query, returning results as SqColumn. | [
"SqTableColumns",
"runs",
"a",
"custom",
"query",
"returning",
"results",
"as",
"SqColumn",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/models/sqcolumn.xo.go#L21-L50 | train |
xo/xo | examples/django/oracle/authuseruserpermission.xo.go | Save | func (auup *AuthUserUserPermission) Save(db XODB) error {
if auup.Exists() {
return auup.Update(db)
}
return auup.Insert(db)
} | go | func (auup *AuthUserUserPermission) Save(db XODB) error {
if auup.Exists() {
return auup.Update(db)
}
return auup.Insert(db)
} | [
"func",
"(",
"auup",
"*",
"AuthUserUserPermission",
")",
"Save",
"(",
"db",
"XODB",
")",
"error",
"{",
"if",
"auup",
".",
"Exists",
"(",
")",
"{",
"return",
"auup",
".",
"Update",
"(",
"db",
")",
"\n",
"}",
"\n\n",
"return",
"auup",
".",
"Insert",
... | // Save saves the AuthUserUserPermission to the database. | [
"Save",
"saves",
"the",
"AuthUserUserPermission",
"to",
"the",
"database",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/oracle/authuseruserpermission.xo.go#L90-L96 | train |
xo/xo | examples/django/oracle/authuseruserpermission.xo.go | AuthUserUserPermissionByUserIDPermissionID | func AuthUserUserPermissionByUserIDPermissionID(db XODB, userID float64, permissionID float64) (*AuthUserUserPermission, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`id, user_id, permission_id ` +
`FROM django.auth_user_user_permissions ` +
`WHERE user_id = :1 AND permission_id = :2`
// r... | go | func AuthUserUserPermissionByUserIDPermissionID(db XODB, userID float64, permissionID float64) (*AuthUserUserPermission, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`id, user_id, permission_id ` +
`FROM django.auth_user_user_permissions ` +
`WHERE user_id = :1 AND permission_id = :2`
// r... | [
"func",
"AuthUserUserPermissionByUserIDPermissionID",
"(",
"db",
"XODB",
",",
"userID",
"float64",
",",
"permissionID",
"float64",
")",
"(",
"*",
"AuthUserUserPermission",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// sql query",
"const",
"sqlstr",
"=... | // AuthUserUserPermissionByUserIDPermissionID retrieves a row from 'django.auth_user_user_permissions' as a AuthUserUserPermission.
//
// Generated from index 'auth_use_user_id_14a6b632_uniq'. | [
"AuthUserUserPermissionByUserIDPermissionID",
"retrieves",
"a",
"row",
"from",
"django",
".",
"auth_user_user_permissions",
"as",
"a",
"AuthUserUserPermission",
".",
"Generated",
"from",
"index",
"auth_use_user_id_14a6b632_uniq",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/oracle/authuseruserpermission.xo.go#L145-L166 | train |
xo/xo | examples/django/oracle/authuseruserpermission.xo.go | AuthUserUserPermissionsByUserID | func AuthUserUserPermissionsByUserID(db XODB, userID float64) ([]*AuthUserUserPermission, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`id, user_id, permission_id ` +
`FROM django.auth_user_user_permissions ` +
`WHERE user_id = :1`
// run query
XOLog(sqlstr, userID)
q, err := db.Query(sq... | go | func AuthUserUserPermissionsByUserID(db XODB, userID float64) ([]*AuthUserUserPermission, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`id, user_id, permission_id ` +
`FROM django.auth_user_user_permissions ` +
`WHERE user_id = :1`
// run query
XOLog(sqlstr, userID)
q, err := db.Query(sq... | [
"func",
"AuthUserUserPermissionsByUserID",
"(",
"db",
"XODB",
",",
"userID",
"float64",
")",
"(",
"[",
"]",
"*",
"AuthUserUserPermission",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// sql query",
"const",
"sqlstr",
"=",
"`SELECT `",
"+",
"`id, us... | // AuthUserUserPermissionsByUserID retrieves a row from 'django.auth_user_user_permissions' as a AuthUserUserPermission.
//
// Generated from index 'auth_user_user_permissions1cca'. | [
"AuthUserUserPermissionsByUserID",
"retrieves",
"a",
"row",
"from",
"django",
".",
"auth_user_user_permissions",
"as",
"a",
"AuthUserUserPermission",
".",
"Generated",
"from",
"index",
"auth_user_user_permissions1cca",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/oracle/authuseruserpermission.xo.go#L171-L205 | train |
xo/xo | examples/django/sqlite3/djangomigration.xo.go | Save | func (dm *DjangoMigration) Save(db XODB) error {
if dm.Exists() {
return dm.Update(db)
}
return dm.Insert(db)
} | go | func (dm *DjangoMigration) Save(db XODB) error {
if dm.Exists() {
return dm.Update(db)
}
return dm.Insert(db)
} | [
"func",
"(",
"dm",
"*",
"DjangoMigration",
")",
"Save",
"(",
"db",
"XODB",
")",
"error",
"{",
"if",
"dm",
".",
"Exists",
"(",
")",
"{",
"return",
"dm",
".",
"Update",
"(",
"db",
")",
"\n",
"}",
"\n\n",
"return",
"dm",
".",
"Insert",
"(",
"db",
... | // Save saves the DjangoMigration to the database. | [
"Save",
"saves",
"the",
"DjangoMigration",
"to",
"the",
"database",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/sqlite3/djangomigration.xo.go#L94-L100 | train |
xo/xo | loaders/mysql.go | MySchema | func MySchema(args *internal.ArgType) (string, error) {
var err error
// sql query
const sqlstr = `SELECT SCHEMA()`
var schema string
// run query
models.XOLog(sqlstr)
err = args.DB.QueryRow(sqlstr).Scan(&schema)
if err != nil {
return "", err
}
return schema, nil
} | go | func MySchema(args *internal.ArgType) (string, error) {
var err error
// sql query
const sqlstr = `SELECT SCHEMA()`
var schema string
// run query
models.XOLog(sqlstr)
err = args.DB.QueryRow(sqlstr).Scan(&schema)
if err != nil {
return "", err
}
return schema, nil
} | [
"func",
"MySchema",
"(",
"args",
"*",
"internal",
".",
"ArgType",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// sql query",
"const",
"sqlstr",
"=",
"`SELECT SCHEMA()`",
"\n\n",
"var",
"schema",
"string",
"\n\n",
"// run query... | // MySchema retrieves the name of the current schema. | [
"MySchema",
"retrieves",
"the",
"name",
"of",
"the",
"current",
"schema",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/loaders/mysql.go#L35-L51 | train |
xo/xo | loaders/mysql.go | MyEnumValues | func MyEnumValues(db models.XODB, schema string, enum string) ([]*models.EnumValue, error) {
var err error
// load enum vals
res, err := models.MyEnumValues(db, schema, enum)
if err != nil {
return nil, err
}
// process enum vals
enumVals := []*models.EnumValue{}
for i, ev := range strings.Split(res.EnumVal... | go | func MyEnumValues(db models.XODB, schema string, enum string) ([]*models.EnumValue, error) {
var err error
// load enum vals
res, err := models.MyEnumValues(db, schema, enum)
if err != nil {
return nil, err
}
// process enum vals
enumVals := []*models.EnumValue{}
for i, ev := range strings.Split(res.EnumVal... | [
"func",
"MyEnumValues",
"(",
"db",
"models",
".",
"XODB",
",",
"schema",
"string",
",",
"enum",
"string",
")",
"(",
"[",
"]",
"*",
"models",
".",
"EnumValue",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// load enum vals",
"res",
",",
"err"... | // MyEnumValues loads the enum values. | [
"MyEnumValues",
"loads",
"the",
"enum",
"values",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/loaders/mysql.go#L221-L240 | train |
xo/xo | loaders/mysql.go | MyTables | func MyTables(db models.XODB, schema string, relkind string) ([]*models.Table, error) {
var err error
// get the tables
rows, err := models.MyTables(db, schema, relkind)
if err != nil {
return nil, err
}
// get the tables that have Autoincrementing included
autoIncrements, err := models.MyAutoIncrements(db, ... | go | func MyTables(db models.XODB, schema string, relkind string) ([]*models.Table, error) {
var err error
// get the tables
rows, err := models.MyTables(db, schema, relkind)
if err != nil {
return nil, err
}
// get the tables that have Autoincrementing included
autoIncrements, err := models.MyAutoIncrements(db, ... | [
"func",
"MyTables",
"(",
"db",
"models",
".",
"XODB",
",",
"schema",
"string",
",",
"relkind",
"string",
")",
"(",
"[",
"]",
"*",
"models",
".",
"Table",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// get the tables",
"rows",
",",
"err",
... | // MyTables returns the MySql tables with the manual PK information added.
// ManualPk is true when the table's primary key is not autoincrement. | [
"MyTables",
"returns",
"the",
"MySql",
"tables",
"with",
"the",
"manual",
"PK",
"information",
"added",
".",
"ManualPk",
"is",
"true",
"when",
"the",
"table",
"s",
"primary",
"key",
"is",
"not",
"autoincrement",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/loaders/mysql.go#L244-L278 | train |
xo/xo | loaders/mysql.go | MyQueryColumns | func MyQueryColumns(args *internal.ArgType, inspect []string) ([]*models.Column, error) {
var err error
// create temporary view xoid
xoid := "_xo_" + internal.GenRandomID()
viewq := `CREATE VIEW ` + xoid + ` AS (` + strings.Join(inspect, "\n") + `)`
models.XOLog(viewq)
_, err = args.DB.Exec(viewq)
if err != ni... | go | func MyQueryColumns(args *internal.ArgType, inspect []string) ([]*models.Column, error) {
var err error
// create temporary view xoid
xoid := "_xo_" + internal.GenRandomID()
viewq := `CREATE VIEW ` + xoid + ` AS (` + strings.Join(inspect, "\n") + `)`
models.XOLog(viewq)
_, err = args.DB.Exec(viewq)
if err != ni... | [
"func",
"MyQueryColumns",
"(",
"args",
"*",
"internal",
".",
"ArgType",
",",
"inspect",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"*",
"models",
".",
"Column",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// create temporary view xoid",
"xoid",
... | // MyQueryColumns parses the query and generates a type for it. | [
"MyQueryColumns",
"parses",
"the",
"query",
"and",
"generates",
"a",
"type",
"for",
"it",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/loaders/mysql.go#L281-L303 | train |
xo/xo | internal/argtype.go | NewDefaultArgs | func NewDefaultArgs() *ArgType {
fkMode := FkModeSmart
return &ArgType{
Suffix: ".xo.go",
Int32Type: "int",
Uint32Type: "uint",
ForeignKeyMode: &fkMode,
QueryParamDelimiter: "%%",
NameConflictSuffix: "Val",
// KnownTypeMap is the collection of known Go types.
Kn... | go | func NewDefaultArgs() *ArgType {
fkMode := FkModeSmart
return &ArgType{
Suffix: ".xo.go",
Int32Type: "int",
Uint32Type: "uint",
ForeignKeyMode: &fkMode,
QueryParamDelimiter: "%%",
NameConflictSuffix: "Val",
// KnownTypeMap is the collection of known Go types.
Kn... | [
"func",
"NewDefaultArgs",
"(",
")",
"*",
"ArgType",
"{",
"fkMode",
":=",
"FkModeSmart",
"\n\n",
"return",
"&",
"ArgType",
"{",
"Suffix",
":",
"\"",
"\"",
",",
"Int32Type",
":",
"\"",
"\"",
",",
"Uint32Type",
":",
"\"",
"\"",
",",
"ForeignKeyMode",
":",
... | // NewDefaultArgs returns the default arguments. | [
"NewDefaultArgs",
"returns",
"the",
"default",
"arguments",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/internal/argtype.go#L156-L210 | train |
xo/xo | models/msidentity.xo.go | MsIdentities | func MsIdentities(db XODB, schema string) ([]*MsIdentity, error) {
var err error
// sql query
const sqlstr = `SELECT o.name as table_name ` +
`FROM sys.objects o inner join sys.columns c on o.object_id = c.object_id ` +
`WHERE c.is_identity = 1 ` +
`AND schema_name(o.schema_id) = $1 AND o.type = 'U'`
// run... | go | func MsIdentities(db XODB, schema string) ([]*MsIdentity, error) {
var err error
// sql query
const sqlstr = `SELECT o.name as table_name ` +
`FROM sys.objects o inner join sys.columns c on o.object_id = c.object_id ` +
`WHERE c.is_identity = 1 ` +
`AND schema_name(o.schema_id) = $1 AND o.type = 'U'`
// run... | [
"func",
"MsIdentities",
"(",
"db",
"XODB",
",",
"schema",
"string",
")",
"(",
"[",
"]",
"*",
"MsIdentity",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// sql query",
"const",
"sqlstr",
"=",
"`SELECT o.name as table_name `",
"+",
"`FROM sys.objects ... | // MsIdentities runs a custom query, returning results as MsIdentity. | [
"MsIdentities",
"runs",
"a",
"custom",
"query",
"returning",
"results",
"as",
"MsIdentity",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/models/msidentity.xo.go#L12-L44 | train |
xo/xo | loaders/postgres.go | PgRelkind | func PgRelkind(relType internal.RelType) string {
var s string
switch relType {
case internal.Table:
s = "r"
case internal.View:
s = "v"
default:
panic("unsupported RelType")
}
return s
} | go | func PgRelkind(relType internal.RelType) string {
var s string
switch relType {
case internal.Table:
s = "r"
case internal.View:
s = "v"
default:
panic("unsupported RelType")
}
return s
} | [
"func",
"PgRelkind",
"(",
"relType",
"internal",
".",
"RelType",
")",
"string",
"{",
"var",
"s",
"string",
"\n",
"switch",
"relType",
"{",
"case",
"internal",
".",
"Table",
":",
"s",
"=",
"\"",
"\"",
"\n",
"case",
"internal",
".",
"View",
":",
"s",
"... | // PgRelkind returns the postgres string representation for RelType. | [
"PgRelkind",
"returns",
"the",
"postgres",
"string",
"representation",
"for",
"RelType",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/loaders/postgres.go#L39-L50 | train |
xo/xo | loaders/postgres.go | PgQueryStrip | func PgQueryStrip(query []string, queryComments []string) {
for i, l := range query {
pos := pgQueryStripRE.FindStringIndex(l)
if pos != nil {
query[i] = l[:pos[0]] + l[pos[1]:]
queryComments[i+1] = l[pos[0]:pos[1]]
} else {
queryComments[i+1] = ""
}
}
} | go | func PgQueryStrip(query []string, queryComments []string) {
for i, l := range query {
pos := pgQueryStripRE.FindStringIndex(l)
if pos != nil {
query[i] = l[:pos[0]] + l[pos[1]:]
queryComments[i+1] = l[pos[0]:pos[1]]
} else {
queryComments[i+1] = ""
}
}
} | [
"func",
"PgQueryStrip",
"(",
"query",
"[",
"]",
"string",
",",
"queryComments",
"[",
"]",
"string",
")",
"{",
"for",
"i",
",",
"l",
":=",
"range",
"query",
"{",
"pos",
":=",
"pgQueryStripRE",
".",
"FindStringIndex",
"(",
"l",
")",
"\n",
"if",
"pos",
... | // PgQueryStrip strips stuff. | [
"PgQueryStrip",
"strips",
"stuff",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/loaders/postgres.go#L219-L229 | train |
xo/xo | loaders/postgres.go | PgTables | func PgTables(db models.XODB, schema string, relkind string) ([]*models.Table, error) {
var err error
// get the tables
rows, err := models.PgTables(db, schema, relkind)
if err != nil {
return nil, err
}
// Get the tables that have a sequence defined.
sequences, err := models.PgSequences(db, schema)
if err ... | go | func PgTables(db models.XODB, schema string, relkind string) ([]*models.Table, error) {
var err error
// get the tables
rows, err := models.PgTables(db, schema, relkind)
if err != nil {
return nil, err
}
// Get the tables that have a sequence defined.
sequences, err := models.PgSequences(db, schema)
if err ... | [
"func",
"PgTables",
"(",
"db",
"models",
".",
"XODB",
",",
"schema",
"string",
",",
"relkind",
"string",
")",
"(",
"[",
"]",
"*",
"models",
".",
"Table",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// get the tables",
"rows",
",",
"err",
... | // PgTables returns the Postgres tables with the manual PK information added.
// ManualPk is true when the table does not have a sequence defined. | [
"PgTables",
"returns",
"the",
"Postgres",
"tables",
"with",
"the",
"manual",
"PK",
"information",
"added",
".",
"ManualPk",
"is",
"true",
"when",
"the",
"table",
"does",
"not",
"have",
"a",
"sequence",
"defined",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/loaders/postgres.go#L233-L267 | train |
xo/xo | loaders/postgres.go | PgQueryColumns | func PgQueryColumns(args *internal.ArgType, inspect []string) ([]*models.Column, error) {
var err error
// create temporary view xoid
xoid := "_xo_" + internal.GenRandomID()
viewq := `CREATE TEMPORARY VIEW ` + xoid + ` AS (` + strings.Join(inspect, "\n") + `)`
models.XOLog(viewq)
_, err = args.DB.Exec(viewq)
if... | go | func PgQueryColumns(args *internal.ArgType, inspect []string) ([]*models.Column, error) {
var err error
// create temporary view xoid
xoid := "_xo_" + internal.GenRandomID()
viewq := `CREATE TEMPORARY VIEW ` + xoid + ` AS (` + strings.Join(inspect, "\n") + `)`
models.XOLog(viewq)
_, err = args.DB.Exec(viewq)
if... | [
"func",
"PgQueryColumns",
"(",
"args",
"*",
"internal",
".",
"ArgType",
",",
"inspect",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"*",
"models",
".",
"Column",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// create temporary view xoid",
"xoid",
... | // PgQueryColumns parses the query and generates a type for it. | [
"PgQueryColumns",
"parses",
"the",
"query",
"and",
"generates",
"a",
"type",
"for",
"it",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/loaders/postgres.go#L270-L298 | train |
xo/xo | loaders/postgres.go | PgIndexColumns | func PgIndexColumns(db models.XODB, schema string, table string, index string) ([]*models.IndexColumn, error) {
var err error
// load columns
cols, err := models.PgIndexColumns(db, schema, index)
if err != nil {
return nil, err
}
// load col order
colOrd, err := models.PgGetColOrder(db, schema, index)
if er... | go | func PgIndexColumns(db models.XODB, schema string, table string, index string) ([]*models.IndexColumn, error) {
var err error
// load columns
cols, err := models.PgIndexColumns(db, schema, index)
if err != nil {
return nil, err
}
// load col order
colOrd, err := models.PgGetColOrder(db, schema, index)
if er... | [
"func",
"PgIndexColumns",
"(",
"db",
"models",
".",
"XODB",
",",
"schema",
"string",
",",
"table",
"string",
",",
"index",
"string",
")",
"(",
"[",
"]",
"*",
"models",
".",
"IndexColumn",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// load ... | // PgIndexColumns returns the column list for an index. | [
"PgIndexColumns",
"returns",
"the",
"column",
"list",
"for",
"an",
"index",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/loaders/postgres.go#L301-L350 | train |
xo/xo | examples/django/postgres/djangocontenttype.xo.go | Update | func (dct *DjangoContentType) Update(db XODB) error {
var err error
// if doesn't exist, bail
if !dct._exists {
return errors.New("update failed: does not exist")
}
// if deleted, bail
if dct._deleted {
return errors.New("update failed: marked for deletion")
}
// sql query
const sqlstr = `UPDATE public.... | go | func (dct *DjangoContentType) Update(db XODB) error {
var err error
// if doesn't exist, bail
if !dct._exists {
return errors.New("update failed: does not exist")
}
// if deleted, bail
if dct._deleted {
return errors.New("update failed: marked for deletion")
}
// sql query
const sqlstr = `UPDATE public.... | [
"func",
"(",
"dct",
"*",
"DjangoContentType",
")",
"Update",
"(",
"db",
"XODB",
")",
"error",
"{",
"var",
"err",
"error",
"\n\n",
"// if doesn't exist, bail",
"if",
"!",
"dct",
".",
"_exists",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
... | // Update updates the DjangoContentType in the database. | [
"Update",
"updates",
"the",
"DjangoContentType",
"in",
"the",
"database",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/postgres/djangocontenttype.xo.go#L60-L84 | train |
xo/xo | examples/django/postgres/djangocontenttype.xo.go | Delete | func (dct *DjangoContentType) Delete(db XODB) error {
var err error
// if doesn't exist, bail
if !dct._exists {
return nil
}
// if deleted, bail
if dct._deleted {
return nil
}
// sql query
const sqlstr = `DELETE FROM public.django_content_type WHERE id = $1`
// run query
XOLog(sqlstr, dct.ID)
_, err... | go | func (dct *DjangoContentType) Delete(db XODB) error {
var err error
// if doesn't exist, bail
if !dct._exists {
return nil
}
// if deleted, bail
if dct._deleted {
return nil
}
// sql query
const sqlstr = `DELETE FROM public.django_content_type WHERE id = $1`
// run query
XOLog(sqlstr, dct.ID)
_, err... | [
"func",
"(",
"dct",
"*",
"DjangoContentType",
")",
"Delete",
"(",
"db",
"XODB",
")",
"error",
"{",
"var",
"err",
"error",
"\n\n",
"// if doesn't exist, bail",
"if",
"!",
"dct",
".",
"_exists",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// if deleted, bail",
... | // Delete deletes the DjangoContentType from the database. | [
"Delete",
"deletes",
"the",
"DjangoContentType",
"from",
"the",
"database",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/postgres/djangocontenttype.xo.go#L131-L158 | train |
xo/xo | examples/django/oracle/authgrouppermission.xo.go | AuthGroupPermissionByGroupIDPermissionID | func AuthGroupPermissionByGroupIDPermissionID(db XODB, groupID float64, permissionID float64) (*AuthGroupPermission, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`id, group_id, permission_id ` +
`FROM django.auth_group_permissions ` +
`WHERE group_id = :1 AND permission_id = :2`
// run que... | go | func AuthGroupPermissionByGroupIDPermissionID(db XODB, groupID float64, permissionID float64) (*AuthGroupPermission, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`id, group_id, permission_id ` +
`FROM django.auth_group_permissions ` +
`WHERE group_id = :1 AND permission_id = :2`
// run que... | [
"func",
"AuthGroupPermissionByGroupIDPermissionID",
"(",
"db",
"XODB",
",",
"groupID",
"float64",
",",
"permissionID",
"float64",
")",
"(",
"*",
"AuthGroupPermission",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// sql query",
"const",
"sqlstr",
"=",
... | // AuthGroupPermissionByGroupIDPermissionID retrieves a row from 'django.auth_group_permissions' as a AuthGroupPermission.
//
// Generated from index 'auth_gr_group_id_0cd325b0_uniq'. | [
"AuthGroupPermissionByGroupIDPermissionID",
"retrieves",
"a",
"row",
"from",
"django",
".",
"auth_group_permissions",
"as",
"a",
"AuthGroupPermission",
".",
"Generated",
"from",
"index",
"auth_gr_group_id_0cd325b0_uniq",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/oracle/authgrouppermission.xo.go#L145-L166 | train |
xo/xo | models/procparam.xo.go | PgProcParams | func PgProcParams(db XODB, schema string, proc string) ([]*ProcParam, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`UNNEST(STRING_TO_ARRAY(oidvectortypes(p.proargtypes), ', ')) ` + // ::varchar AS param_type
`FROM pg_proc p ` +
`JOIN ONLY pg_namespace n ON p.pronamespace = n.oid ` +
`WHERE... | go | func PgProcParams(db XODB, schema string, proc string) ([]*ProcParam, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`UNNEST(STRING_TO_ARRAY(oidvectortypes(p.proargtypes), ', ')) ` + // ::varchar AS param_type
`FROM pg_proc p ` +
`JOIN ONLY pg_namespace n ON p.pronamespace = n.oid ` +
`WHERE... | [
"func",
"PgProcParams",
"(",
"db",
"XODB",
",",
"schema",
"string",
",",
"proc",
"string",
")",
"(",
"[",
"]",
"*",
"ProcParam",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// sql query",
"const",
"sqlstr",
"=",
"`SELECT `",
"+",
"`UNNEST(STR... | // PgProcParams runs a custom query, returning results as ProcParam. | [
"PgProcParams",
"runs",
"a",
"custom",
"query",
"returning",
"results",
"as",
"ProcParam",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/models/procparam.xo.go#L12-L45 | train |
xo/xo | examples/django/mysql/authusergroup.xo.go | AuthUserGroupsByGroupID | func AuthUserGroupsByGroupID(db XODB, groupID int) ([]*AuthUserGroup, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`id, user_id, group_id ` +
`FROM django.auth_user_groups ` +
`WHERE group_id = ?`
// run query
XOLog(sqlstr, groupID)
q, err := db.Query(sqlstr, groupID)
if err != nil {
... | go | func AuthUserGroupsByGroupID(db XODB, groupID int) ([]*AuthUserGroup, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`id, user_id, group_id ` +
`FROM django.auth_user_groups ` +
`WHERE group_id = ?`
// run query
XOLog(sqlstr, groupID)
q, err := db.Query(sqlstr, groupID)
if err != nil {
... | [
"func",
"AuthUserGroupsByGroupID",
"(",
"db",
"XODB",
",",
"groupID",
"int",
")",
"(",
"[",
"]",
"*",
"AuthUserGroup",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// sql query",
"const",
"sqlstr",
"=",
"`SELECT `",
"+",
"`id, user_id, group_id `",
... | // AuthUserGroupsByGroupID retrieves a row from 'django.auth_user_groups' as a AuthUserGroup.
//
// Generated from index 'auth_user_groups_group_id_97559544_fk_auth_group_id'. | [
"AuthUserGroupsByGroupID",
"retrieves",
"a",
"row",
"from",
"django",
".",
"auth_user_groups",
"as",
"a",
"AuthUserGroup",
".",
"Generated",
"from",
"index",
"auth_user_groups_group_id_97559544_fk_auth_group_id",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/mysql/authusergroup.xo.go#L147-L181 | train |
xo/xo | examples/django/mysql/authusergroup.xo.go | AuthUserGroupByID | func AuthUserGroupByID(db XODB, id int) (*AuthUserGroup, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`id, user_id, group_id ` +
`FROM django.auth_user_groups ` +
`WHERE id = ?`
// run query
XOLog(sqlstr, id)
aug := AuthUserGroup{
_exists: true,
}
err = db.QueryRow(sqlstr, id).Scan(... | go | func AuthUserGroupByID(db XODB, id int) (*AuthUserGroup, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`id, user_id, group_id ` +
`FROM django.auth_user_groups ` +
`WHERE id = ?`
// run query
XOLog(sqlstr, id)
aug := AuthUserGroup{
_exists: true,
}
err = db.QueryRow(sqlstr, id).Scan(... | [
"func",
"AuthUserGroupByID",
"(",
"db",
"XODB",
",",
"id",
"int",
")",
"(",
"*",
"AuthUserGroup",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// sql query",
"const",
"sqlstr",
"=",
"`SELECT `",
"+",
"`id, user_id, group_id `",
"+",
"`FROM django.au... | // AuthUserGroupByID retrieves a row from 'django.auth_user_groups' as a AuthUserGroup.
//
// Generated from index 'auth_user_groups_id_pkey'. | [
"AuthUserGroupByID",
"retrieves",
"a",
"row",
"from",
"django",
".",
"auth_user_groups",
"as",
"a",
"AuthUserGroup",
".",
"Generated",
"from",
"index",
"auth_user_groups_id_pkey",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/mysql/authusergroup.xo.go#L186-L207 | train |
xo/xo | loaders/mssql.go | MsParseType | func MsParseType(args *internal.ArgType, dt string, nullable bool) (int, string, string) {
precision := 0
nilVal := "nil"
// extract precision
dt, precision, _ = args.ParsePrecision(dt)
var typ string
switch dt {
case "tinyint", "bit":
nilVal = "false"
typ = "bool"
if nullable {
nilVal = "sql.NullBool... | go | func MsParseType(args *internal.ArgType, dt string, nullable bool) (int, string, string) {
precision := 0
nilVal := "nil"
// extract precision
dt, precision, _ = args.ParsePrecision(dt)
var typ string
switch dt {
case "tinyint", "bit":
nilVal = "false"
typ = "bool"
if nullable {
nilVal = "sql.NullBool... | [
"func",
"MsParseType",
"(",
"args",
"*",
"internal",
".",
"ArgType",
",",
"dt",
"string",
",",
"nullable",
"bool",
")",
"(",
"int",
",",
"string",
",",
"string",
")",
"{",
"precision",
":=",
"0",
"\n",
"nilVal",
":=",
"\"",
"\"",
"\n\n",
"// extract pr... | // MsParseType parse a mssql type into a Go type based on the column
// definition. | [
"MsParseType",
"parse",
"a",
"mssql",
"type",
"into",
"a",
"Go",
"type",
"based",
"on",
"the",
"column",
"definition",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/loaders/mssql.go#L68-L182 | train |
xo/xo | loaders/mssql.go | MsQueryColumns | func MsQueryColumns(args *internal.ArgType, inspect []string) ([]*models.Column, error) {
var err error
// process inspect -- cannot have 'order by' in a CREATE VIEW
ins := []string{}
for _, l := range inspect {
if !strings.HasPrefix(strings.ToUpper(l), "ORDER BY ") {
ins = append(ins, l)
}
}
// create t... | go | func MsQueryColumns(args *internal.ArgType, inspect []string) ([]*models.Column, error) {
var err error
// process inspect -- cannot have 'order by' in a CREATE VIEW
ins := []string{}
for _, l := range inspect {
if !strings.HasPrefix(strings.ToUpper(l), "ORDER BY ") {
ins = append(ins, l)
}
}
// create t... | [
"func",
"MsQueryColumns",
"(",
"args",
"*",
"internal",
".",
"ArgType",
",",
"inspect",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"*",
"models",
".",
"Column",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// process inspect -- cannot have 'order by'... | // MsQueryColumns parses the query and generates a type for it. | [
"MsQueryColumns",
"parses",
"the",
"query",
"and",
"generates",
"a",
"type",
"for",
"it",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/loaders/mssql.go#L185-L215 | train |
xo/xo | loaders/mssql.go | MsTables | func MsTables(db models.XODB, schema string, relkind string) ([]*models.Table, error) {
var err error
// get the tables
rows, err := models.MsTables(db, schema, relkind)
if err != nil {
return nil, err
}
// get the tables that have Identity included
identities, err := models.MsIdentities(db, schema)
if err ... | go | func MsTables(db models.XODB, schema string, relkind string) ([]*models.Table, error) {
var err error
// get the tables
rows, err := models.MsTables(db, schema, relkind)
if err != nil {
return nil, err
}
// get the tables that have Identity included
identities, err := models.MsIdentities(db, schema)
if err ... | [
"func",
"MsTables",
"(",
"db",
"models",
".",
"XODB",
",",
"schema",
"string",
",",
"relkind",
"string",
")",
"(",
"[",
"]",
"*",
"models",
".",
"Table",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// get the tables",
"rows",
",",
"err",
... | // MsTables returns the MsSQL tables with the manual PK information added.
// ManualPk is true when the table's primary key is not an identity. | [
"MsTables",
"returns",
"the",
"MsSQL",
"tables",
"with",
"the",
"manual",
"PK",
"information",
"added",
".",
"ManualPk",
"is",
"true",
"when",
"the",
"table",
"s",
"primary",
"key",
"is",
"not",
"an",
"identity",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/loaders/mssql.go#L219-L253 | train |
xo/xo | examples/django/mysql/djangoadminlog.xo.go | Delete | func (dal *DjangoAdminLog) Delete(db XODB) error {
var err error
// if doesn't exist, bail
if !dal._exists {
return nil
}
// if deleted, bail
if dal._deleted {
return nil
}
// sql query
const sqlstr = `DELETE FROM django.django_admin_log WHERE id = ?`
// run query
XOLog(sqlstr, dal.ID)
_, err = db.E... | go | func (dal *DjangoAdminLog) Delete(db XODB) error {
var err error
// if doesn't exist, bail
if !dal._exists {
return nil
}
// if deleted, bail
if dal._deleted {
return nil
}
// sql query
const sqlstr = `DELETE FROM django.django_admin_log WHERE id = ?`
// run query
XOLog(sqlstr, dal.ID)
_, err = db.E... | [
"func",
"(",
"dal",
"*",
"DjangoAdminLog",
")",
"Delete",
"(",
"db",
"XODB",
")",
"error",
"{",
"var",
"err",
"error",
"\n\n",
"// if doesn't exist, bail",
"if",
"!",
"dal",
".",
"_exists",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// if deleted, bail",
"i... | // Delete deletes the DjangoAdminLog from the database. | [
"Delete",
"deletes",
"the",
"DjangoAdminLog",
"from",
"the",
"database",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/mysql/djangoadminlog.xo.go#L108-L135 | train |
xo/xo | examples/django/mysql/djangosession.xo.go | DjangoSessionsByExpireDate | func DjangoSessionsByExpireDate(db XODB, expireDate *time.Time) ([]*DjangoSession, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`session_key, session_data, expire_date ` +
`FROM django.django_session ` +
`WHERE expire_date = ?`
// run query
XOLog(sqlstr, expireDate)
q, err := db.Query(sq... | go | func DjangoSessionsByExpireDate(db XODB, expireDate *time.Time) ([]*DjangoSession, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`session_key, session_data, expire_date ` +
`FROM django.django_session ` +
`WHERE expire_date = ?`
// run query
XOLog(sqlstr, expireDate)
q, err := db.Query(sq... | [
"func",
"DjangoSessionsByExpireDate",
"(",
"db",
"XODB",
",",
"expireDate",
"*",
"time",
".",
"Time",
")",
"(",
"[",
"]",
"*",
"DjangoSession",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// sql query",
"const",
"sqlstr",
"=",
"`SELECT `",
"+",... | // DjangoSessionsByExpireDate retrieves a row from 'django.django_session' as a DjangoSession.
//
// Generated from index 'django_session_de54fa62'. | [
"DjangoSessionsByExpireDate",
"retrieves",
"a",
"row",
"from",
"django",
".",
"django_session",
"as",
"a",
"DjangoSession",
".",
"Generated",
"from",
"index",
"django_session_de54fa62",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/mysql/djangosession.xo.go#L127-L161 | train |
xo/xo | examples/django/mysql/djangosession.xo.go | DjangoSessionBySessionKey | func DjangoSessionBySessionKey(db XODB, sessionKey string) (*DjangoSession, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`session_key, session_data, expire_date ` +
`FROM django.django_session ` +
`WHERE session_key = ?`
// run query
XOLog(sqlstr, sessionKey)
ds := DjangoSession{
_exis... | go | func DjangoSessionBySessionKey(db XODB, sessionKey string) (*DjangoSession, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`session_key, session_data, expire_date ` +
`FROM django.django_session ` +
`WHERE session_key = ?`
// run query
XOLog(sqlstr, sessionKey)
ds := DjangoSession{
_exis... | [
"func",
"DjangoSessionBySessionKey",
"(",
"db",
"XODB",
",",
"sessionKey",
"string",
")",
"(",
"*",
"DjangoSession",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// sql query",
"const",
"sqlstr",
"=",
"`SELECT `",
"+",
"`session_key, session_data, expir... | // DjangoSessionBySessionKey retrieves a row from 'django.django_session' as a DjangoSession.
//
// Generated from index 'django_session_session_key_pkey'. | [
"DjangoSessionBySessionKey",
"retrieves",
"a",
"row",
"from",
"django",
".",
"django_session",
"as",
"a",
"DjangoSession",
".",
"Generated",
"from",
"index",
"django_session_session_key_pkey",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/mysql/djangosession.xo.go#L166-L187 | train |
xo/xo | examples/django/mysql/authuseruserpermission.xo.go | Update | func (auup *AuthUserUserPermission) Update(db XODB) error {
var err error
// if doesn't exist, bail
if !auup._exists {
return errors.New("update failed: does not exist")
}
// if deleted, bail
if auup._deleted {
return errors.New("update failed: marked for deletion")
}
// sql query
const sqlstr = `UPDATE... | go | func (auup *AuthUserUserPermission) Update(db XODB) error {
var err error
// if doesn't exist, bail
if !auup._exists {
return errors.New("update failed: does not exist")
}
// if deleted, bail
if auup._deleted {
return errors.New("update failed: marked for deletion")
}
// sql query
const sqlstr = `UPDATE... | [
"func",
"(",
"auup",
"*",
"AuthUserUserPermission",
")",
"Update",
"(",
"db",
"XODB",
")",
"error",
"{",
"var",
"err",
"error",
"\n\n",
"// if doesn't exist, bail",
"if",
"!",
"auup",
".",
"_exists",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
... | // Update updates the AuthUserUserPermission in the database. | [
"Update",
"updates",
"the",
"AuthUserUserPermission",
"in",
"the",
"database",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/mysql/authuseruserpermission.xo.go#L67-L89 | train |
xo/xo | examples/django/oracle/djangomigration.xo.go | Update | func (dm *DjangoMigration) Update(db XODB) error {
var err error
// if doesn't exist, bail
if !dm._exists {
return errors.New("update failed: does not exist")
}
// if deleted, bail
if dm._deleted {
return errors.New("update failed: marked for deletion")
}
// sql query
const sqlstr = `UPDATE django.djang... | go | func (dm *DjangoMigration) Update(db XODB) error {
var err error
// if doesn't exist, bail
if !dm._exists {
return errors.New("update failed: does not exist")
}
// if deleted, bail
if dm._deleted {
return errors.New("update failed: marked for deletion")
}
// sql query
const sqlstr = `UPDATE django.djang... | [
"func",
"(",
"dm",
"*",
"DjangoMigration",
")",
"Update",
"(",
"db",
"XODB",
")",
"error",
"{",
"var",
"err",
"error",
"\n\n",
"// if doesn't exist, bail",
"if",
"!",
"dm",
".",
"_exists",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n"... | // Update updates the DjangoMigration in the database. | [
"Update",
"updates",
"the",
"DjangoMigration",
"in",
"the",
"database",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/oracle/djangomigration.xo.go#L70-L92 | train |
xo/xo | examples/django/oracle/djangomigration.xo.go | Delete | func (dm *DjangoMigration) Delete(db XODB) error {
var err error
// if doesn't exist, bail
if !dm._exists {
return nil
}
// if deleted, bail
if dm._deleted {
return nil
}
// sql query
const sqlstr = `DELETE FROM django.django_migrations WHERE id = :1`
// run query
XOLog(sqlstr, dm.ID)
_, err = db.Ex... | go | func (dm *DjangoMigration) Delete(db XODB) error {
var err error
// if doesn't exist, bail
if !dm._exists {
return nil
}
// if deleted, bail
if dm._deleted {
return nil
}
// sql query
const sqlstr = `DELETE FROM django.django_migrations WHERE id = :1`
// run query
XOLog(sqlstr, dm.ID)
_, err = db.Ex... | [
"func",
"(",
"dm",
"*",
"DjangoMigration",
")",
"Delete",
"(",
"db",
"XODB",
")",
"error",
"{",
"var",
"err",
"error",
"\n\n",
"// if doesn't exist, bail",
"if",
"!",
"dm",
".",
"_exists",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// if deleted, bail",
"if... | // Delete deletes the DjangoMigration from the database. | [
"Delete",
"deletes",
"the",
"DjangoMigration",
"from",
"the",
"database",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/oracle/djangomigration.xo.go#L104-L131 | train |
xo/xo | examples/django/oracle/djangomigration.xo.go | DjangoMigrationByID | func DjangoMigrationByID(db XODB, id float64) (*DjangoMigration, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`id, app, name, applied ` +
`FROM django.django_migrations ` +
`WHERE id = :1`
// run query
XOLog(sqlstr, id)
dm := DjangoMigration{
_exists: true,
}
err = db.QueryRow(sqlst... | go | func DjangoMigrationByID(db XODB, id float64) (*DjangoMigration, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`id, app, name, applied ` +
`FROM django.django_migrations ` +
`WHERE id = :1`
// run query
XOLog(sqlstr, id)
dm := DjangoMigration{
_exists: true,
}
err = db.QueryRow(sqlst... | [
"func",
"DjangoMigrationByID",
"(",
"db",
"XODB",
",",
"id",
"float64",
")",
"(",
"*",
"DjangoMigration",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// sql query",
"const",
"sqlstr",
"=",
"`SELECT `",
"+",
"`id, app, name, applied `",
"+",
"`FROM ... | // DjangoMigrationByID retrieves a row from 'django.django_migrations' as a DjangoMigration.
//
// Generated from index 'sys_c004953'. | [
"DjangoMigrationByID",
"retrieves",
"a",
"row",
"from",
"django",
".",
"django_migrations",
"as",
"a",
"DjangoMigration",
".",
"Generated",
"from",
"index",
"sys_c004953",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/oracle/djangomigration.xo.go#L136-L157 | train |
xo/xo | examples/django/sqlite3/djangocontenttype.xo.go | DjangoContentTypeByID | func DjangoContentTypeByID(db XODB, id int) (*DjangoContentType, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`id, app_label, model ` +
`FROM django_content_type ` +
`WHERE id = ?`
// run query
XOLog(sqlstr, id)
dct := DjangoContentType{
_exists: true,
}
err = db.QueryRow(sqlstr, id... | go | func DjangoContentTypeByID(db XODB, id int) (*DjangoContentType, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`id, app_label, model ` +
`FROM django_content_type ` +
`WHERE id = ?`
// run query
XOLog(sqlstr, id)
dct := DjangoContentType{
_exists: true,
}
err = db.QueryRow(sqlstr, id... | [
"func",
"DjangoContentTypeByID",
"(",
"db",
"XODB",
",",
"id",
"int",
")",
"(",
"*",
"DjangoContentType",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// sql query",
"const",
"sqlstr",
"=",
"`SELECT `",
"+",
"`id, app_label, model `",
"+",
"`FROM dj... | // DjangoContentTypeByID retrieves a row from 'django_content_type' as a DjangoContentType.
//
// Generated from index 'django_content_type_id_pkey'. | [
"DjangoContentTypeByID",
"retrieves",
"a",
"row",
"from",
"django_content_type",
"as",
"a",
"DjangoContentType",
".",
"Generated",
"from",
"index",
"django_content_type_id_pkey",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/sqlite3/djangocontenttype.xo.go#L159-L180 | train |
xo/xo | examples/django/postgres/djangoadminlog.xo.go | Update | func (dal *DjangoAdminLog) Update(db XODB) error {
var err error
// if doesn't exist, bail
if !dal._exists {
return errors.New("update failed: does not exist")
}
// if deleted, bail
if dal._deleted {
return errors.New("update failed: marked for deletion")
}
// sql query
const sqlstr = `UPDATE public.dja... | go | func (dal *DjangoAdminLog) Update(db XODB) error {
var err error
// if doesn't exist, bail
if !dal._exists {
return errors.New("update failed: does not exist")
}
// if deleted, bail
if dal._deleted {
return errors.New("update failed: marked for deletion")
}
// sql query
const sqlstr = `UPDATE public.dja... | [
"func",
"(",
"dal",
"*",
"DjangoAdminLog",
")",
"Update",
"(",
"db",
"XODB",
")",
"error",
"{",
"var",
"err",
"error",
"\n\n",
"// if doesn't exist, bail",
"if",
"!",
"dal",
".",
"_exists",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n... | // Update updates the DjangoAdminLog in the database. | [
"Update",
"updates",
"the",
"DjangoAdminLog",
"in",
"the",
"database",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/postgres/djangoadminlog.xo.go#L67-L91 | train |
xo/xo | examples/django/postgres/djangoadminlog.xo.go | DjangoAdminLogsByContentTypeID | func DjangoAdminLogsByContentTypeID(db XODB, contentTypeID sql.NullInt64) ([]*DjangoAdminLog, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`id, action_time, object_id, object_repr, action_flag, change_message, content_type_id, user_id ` +
`FROM public.django_admin_log ` +
`WHERE content_type... | go | func DjangoAdminLogsByContentTypeID(db XODB, contentTypeID sql.NullInt64) ([]*DjangoAdminLog, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`id, action_time, object_id, object_repr, action_flag, change_message, content_type_id, user_id ` +
`FROM public.django_admin_log ` +
`WHERE content_type... | [
"func",
"DjangoAdminLogsByContentTypeID",
"(",
"db",
"XODB",
",",
"contentTypeID",
"sql",
".",
"NullInt64",
")",
"(",
"[",
"]",
"*",
"DjangoAdminLog",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// sql query",
"const",
"sqlstr",
"=",
"`SELECT `",
... | // DjangoAdminLogsByContentTypeID retrieves a row from 'public.django_admin_log' as a DjangoAdminLog.
//
// Generated from index 'django_admin_log_417f1b1c'. | [
"DjangoAdminLogsByContentTypeID",
"retrieves",
"a",
"row",
"from",
"public",
".",
"django_admin_log",
"as",
"a",
"DjangoAdminLog",
".",
"Generated",
"from",
"index",
"django_admin_log_417f1b1c",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/postgres/djangoadminlog.xo.go#L184-L218 | train |
xo/xo | models/proc.xo.go | PgProcs | func PgProcs(db XODB, schema string) ([]*Proc, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`p.proname, ` + // ::varchar AS proc_name
`pg_get_function_result(p.oid) ` + // ::varchar AS return_type
`FROM pg_proc p ` +
`JOIN ONLY pg_namespace n ON p.pronamespace = n.oid ` +
`WHERE n.nspnam... | go | func PgProcs(db XODB, schema string) ([]*Proc, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`p.proname, ` + // ::varchar AS proc_name
`pg_get_function_result(p.oid) ` + // ::varchar AS return_type
`FROM pg_proc p ` +
`JOIN ONLY pg_namespace n ON p.pronamespace = n.oid ` +
`WHERE n.nspnam... | [
"func",
"PgProcs",
"(",
"db",
"XODB",
",",
"schema",
"string",
")",
"(",
"[",
"]",
"*",
"Proc",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// sql query",
"const",
"sqlstr",
"=",
"`SELECT `",
"+",
"`p.proname, `",
"+",
"// ::varchar AS proc_nam... | // PgProcs runs a custom query, returning results as Proc. | [
"PgProcs",
"runs",
"a",
"custom",
"query",
"returning",
"results",
"as",
"Proc",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/models/proc.xo.go#L13-L47 | train |
xo/xo | examples/django/oracle/authgroup.xo.go | Delete | func (ag *AuthGroup) Delete(db XODB) error {
var err error
// if doesn't exist, bail
if !ag._exists {
return nil
}
// if deleted, bail
if ag._deleted {
return nil
}
// sql query
const sqlstr = `DELETE FROM django.auth_group WHERE id = :1`
// run query
XOLog(sqlstr, ag.ID)
_, err = db.Exec(sqlstr, ag... | go | func (ag *AuthGroup) Delete(db XODB) error {
var err error
// if doesn't exist, bail
if !ag._exists {
return nil
}
// if deleted, bail
if ag._deleted {
return nil
}
// sql query
const sqlstr = `DELETE FROM django.auth_group WHERE id = :1`
// run query
XOLog(sqlstr, ag.ID)
_, err = db.Exec(sqlstr, ag... | [
"func",
"(",
"ag",
"*",
"AuthGroup",
")",
"Delete",
"(",
"db",
"XODB",
")",
"error",
"{",
"var",
"err",
"error",
"\n\n",
"// if doesn't exist, bail",
"if",
"!",
"ag",
".",
"_exists",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// if deleted, bail",
"if",
"... | // Delete deletes the AuthGroup from the database. | [
"Delete",
"deletes",
"the",
"AuthGroup",
"from",
"the",
"database",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/oracle/authgroup.xo.go#L101-L128 | train |
xo/xo | examples/django/sqlite3/authgroup.xo.go | Update | func (ag *AuthGroup) Update(db XODB) error {
var err error
// if doesn't exist, bail
if !ag._exists {
return errors.New("update failed: does not exist")
}
// if deleted, bail
if ag._deleted {
return errors.New("update failed: marked for deletion")
}
// sql query
const sqlstr = `UPDATE auth_group SET ` +... | go | func (ag *AuthGroup) Update(db XODB) error {
var err error
// if doesn't exist, bail
if !ag._exists {
return errors.New("update failed: does not exist")
}
// if deleted, bail
if ag._deleted {
return errors.New("update failed: marked for deletion")
}
// sql query
const sqlstr = `UPDATE auth_group SET ` +... | [
"func",
"(",
"ag",
"*",
"AuthGroup",
")",
"Update",
"(",
"db",
"XODB",
")",
"error",
"{",
"var",
"err",
"error",
"\n\n",
"// if doesn't exist, bail",
"if",
"!",
"ag",
".",
"_exists",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}... | // Update updates the AuthGroup in the database. | [
"Update",
"updates",
"the",
"AuthGroup",
"in",
"the",
"database",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/sqlite3/authgroup.xo.go#L66-L88 | train |
xo/xo | examples/django/oracle/authuser.xo.go | Delete | func (au *AuthUser) Delete(db XODB) error {
var err error
// if doesn't exist, bail
if !au._exists {
return nil
}
// if deleted, bail
if au._deleted {
return nil
}
// sql query
const sqlstr = `DELETE FROM django.auth_user WHERE id = :1`
// run query
XOLog(sqlstr, au.ID)
_, err = db.Exec(sqlstr, au.I... | go | func (au *AuthUser) Delete(db XODB) error {
var err error
// if doesn't exist, bail
if !au._exists {
return nil
}
// if deleted, bail
if au._deleted {
return nil
}
// sql query
const sqlstr = `DELETE FROM django.auth_user WHERE id = :1`
// run query
XOLog(sqlstr, au.ID)
_, err = db.Exec(sqlstr, au.I... | [
"func",
"(",
"au",
"*",
"AuthUser",
")",
"Delete",
"(",
"db",
"XODB",
")",
"error",
"{",
"var",
"err",
"error",
"\n\n",
"// if doesn't exist, bail",
"if",
"!",
"au",
".",
"_exists",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// if deleted, bail",
"if",
"a... | // Delete deletes the AuthUser from the database. | [
"Delete",
"deletes",
"the",
"AuthUser",
"from",
"the",
"database",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/oracle/authuser.xo.go#L111-L138 | train |
xo/xo | examples/django/oracle/authuser.xo.go | AuthUserByUsername | func AuthUserByUsername(db XODB, username sql.NullString) (*AuthUser, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`id, password, last_login, is_superuser, username, first_name, last_name, email, is_staff, is_active, date_joined ` +
`FROM django.auth_user ` +
`WHERE username = :1`
// run q... | go | func AuthUserByUsername(db XODB, username sql.NullString) (*AuthUser, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`id, password, last_login, is_superuser, username, first_name, last_name, email, is_staff, is_active, date_joined ` +
`FROM django.auth_user ` +
`WHERE username = :1`
// run q... | [
"func",
"AuthUserByUsername",
"(",
"db",
"XODB",
",",
"username",
"sql",
".",
"NullString",
")",
"(",
"*",
"AuthUser",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// sql query",
"const",
"sqlstr",
"=",
"`SELECT `",
"+",
"`id, password, last_login, ... | // AuthUserByUsername retrieves a row from 'django.auth_user' as a AuthUser.
//
// Generated from index 'sys_c004977'. | [
"AuthUserByUsername",
"retrieves",
"a",
"row",
"from",
"django",
".",
"auth_user",
"as",
"a",
"AuthUser",
".",
"Generated",
"from",
"index",
"sys_c004977",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/oracle/authuser.xo.go#L169-L190 | train |
xo/xo | internal/fkmode.go | UnmarshalText | func (f *FkMode) UnmarshalText(text []byte) error {
switch strings.ToLower(string(text)) {
case "smart", "default":
*f = FkModeSmart
case "parent":
*f = FkModeParent
case "field":
*f = FkModeField
case "key":
*f = FkModeKey
default:
return errors.New("invalid FkMode")
}
return nil
} | go | func (f *FkMode) UnmarshalText(text []byte) error {
switch strings.ToLower(string(text)) {
case "smart", "default":
*f = FkModeSmart
case "parent":
*f = FkModeParent
case "field":
*f = FkModeField
case "key":
*f = FkModeKey
default:
return errors.New("invalid FkMode")
}
return nil
} | [
"func",
"(",
"f",
"*",
"FkMode",
")",
"UnmarshalText",
"(",
"text",
"[",
"]",
"byte",
")",
"error",
"{",
"switch",
"strings",
".",
"ToLower",
"(",
"string",
"(",
"text",
")",
")",
"{",
"case",
"\"",
"\"",
",",
"\"",
"\"",
":",
"*",
"f",
"=",
"F... | // UnmarshalText unmarshals FkMode from text. | [
"UnmarshalText",
"unmarshals",
"FkMode",
"from",
"text",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/internal/fkmode.go#L44-L60 | train |
xo/xo | internal/fkmode.go | fkName | func fkName(mode FkMode, fkMap map[string]*ForeignKey, fk *ForeignKey) string {
switch mode {
case FkModeParent:
return fk.RefType.Name
case FkModeField:
return fk.RefType.Name + "By" + fk.Field.Name
case FkModeKey:
return fk.RefType.Name + "By" + snaker.SnakeToCamelIdentifier(fk.ForeignKey.ForeignKeyName)
}... | go | func fkName(mode FkMode, fkMap map[string]*ForeignKey, fk *ForeignKey) string {
switch mode {
case FkModeParent:
return fk.RefType.Name
case FkModeField:
return fk.RefType.Name + "By" + fk.Field.Name
case FkModeKey:
return fk.RefType.Name + "By" + snaker.SnakeToCamelIdentifier(fk.ForeignKey.ForeignKeyName)
}... | [
"func",
"fkName",
"(",
"mode",
"FkMode",
",",
"fkMap",
"map",
"[",
"string",
"]",
"*",
"ForeignKey",
",",
"fk",
"*",
"ForeignKey",
")",
"string",
"{",
"switch",
"mode",
"{",
"case",
"FkModeParent",
":",
"return",
"fk",
".",
"RefType",
".",
"Name",
"\n"... | // fkName returns the name for the foreign key. | [
"fkName",
"returns",
"the",
"name",
"for",
"the",
"foreign",
"key",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/internal/fkmode.go#L79-L99 | train |
xo/xo | internal/fkmode.go | ForeignKeyName | func (a *ArgType) ForeignKeyName(fkMap map[string]*ForeignKey, fk *ForeignKey) string {
return fkName(*a.ForeignKeyMode, fkMap, fk)
} | go | func (a *ArgType) ForeignKeyName(fkMap map[string]*ForeignKey, fk *ForeignKey) string {
return fkName(*a.ForeignKeyMode, fkMap, fk)
} | [
"func",
"(",
"a",
"*",
"ArgType",
")",
"ForeignKeyName",
"(",
"fkMap",
"map",
"[",
"string",
"]",
"*",
"ForeignKey",
",",
"fk",
"*",
"ForeignKey",
")",
"string",
"{",
"return",
"fkName",
"(",
"*",
"a",
".",
"ForeignKeyMode",
",",
"fkMap",
",",
"fk",
... | // ForeignKeyName returns the foreign key name for the passed type. | [
"ForeignKeyName",
"returns",
"the",
"foreign",
"key",
"name",
"for",
"the",
"passed",
"type",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/internal/fkmode.go#L102-L104 | train |
xo/xo | examples/django/postgres/authuseruserpermission.xo.go | Delete | func (auup *AuthUserUserPermission) Delete(db XODB) error {
var err error
// if doesn't exist, bail
if !auup._exists {
return nil
}
// if deleted, bail
if auup._deleted {
return nil
}
// sql query
const sqlstr = `DELETE FROM public.auth_user_user_permissions WHERE id = $1`
// run query
XOLog(sqlstr, ... | go | func (auup *AuthUserUserPermission) Delete(db XODB) error {
var err error
// if doesn't exist, bail
if !auup._exists {
return nil
}
// if deleted, bail
if auup._deleted {
return nil
}
// sql query
const sqlstr = `DELETE FROM public.auth_user_user_permissions WHERE id = $1`
// run query
XOLog(sqlstr, ... | [
"func",
"(",
"auup",
"*",
"AuthUserUserPermission",
")",
"Delete",
"(",
"db",
"XODB",
")",
"error",
"{",
"var",
"err",
"error",
"\n\n",
"// if doesn't exist, bail",
"if",
"!",
"auup",
".",
"_exists",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// if deleted, b... | // Delete deletes the AuthUserUserPermission from the database. | [
"Delete",
"deletes",
"the",
"AuthUserUserPermission",
"from",
"the",
"database",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/postgres/authuseruserpermission.xo.go#L131-L158 | train |
xo/xo | examples/django/postgres/authuseruserpermission.xo.go | AuthUserUserPermissionByID | func AuthUserUserPermissionByID(db XODB, id int) (*AuthUserUserPermission, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`id, user_id, permission_id ` +
`FROM public.auth_user_user_permissions ` +
`WHERE id = $1`
// run query
XOLog(sqlstr, id)
auup := AuthUserUserPermission{
_exists: tr... | go | func AuthUserUserPermissionByID(db XODB, id int) (*AuthUserUserPermission, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`id, user_id, permission_id ` +
`FROM public.auth_user_user_permissions ` +
`WHERE id = $1`
// run query
XOLog(sqlstr, id)
auup := AuthUserUserPermission{
_exists: tr... | [
"func",
"AuthUserUserPermissionByID",
"(",
"db",
"XODB",
",",
"id",
"int",
")",
"(",
"*",
"AuthUserUserPermission",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// sql query",
"const",
"sqlstr",
"=",
"`SELECT `",
"+",
"`id, user_id, permission_id `",
... | // AuthUserUserPermissionByID retrieves a row from 'public.auth_user_user_permissions' as a AuthUserUserPermission.
//
// Generated from index 'auth_user_user_permissions_pkey'. | [
"AuthUserUserPermissionByID",
"retrieves",
"a",
"row",
"from",
"public",
".",
"auth_user_user_permissions",
"as",
"a",
"AuthUserUserPermission",
".",
"Generated",
"from",
"index",
"auth_user_user_permissions_pkey",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/postgres/authuseruserpermission.xo.go#L255-L276 | train |
xo/xo | examples/django/oracle/authusergroup.xo.go | Delete | func (aug *AuthUserGroup) Delete(db XODB) error {
var err error
// if doesn't exist, bail
if !aug._exists {
return nil
}
// if deleted, bail
if aug._deleted {
return nil
}
// sql query
const sqlstr = `DELETE FROM django.auth_user_groups WHERE id = :1`
// run query
XOLog(sqlstr, aug.ID)
_, err = db.E... | go | func (aug *AuthUserGroup) Delete(db XODB) error {
var err error
// if doesn't exist, bail
if !aug._exists {
return nil
}
// if deleted, bail
if aug._deleted {
return nil
}
// sql query
const sqlstr = `DELETE FROM django.auth_user_groups WHERE id = :1`
// run query
XOLog(sqlstr, aug.ID)
_, err = db.E... | [
"func",
"(",
"aug",
"*",
"AuthUserGroup",
")",
"Delete",
"(",
"db",
"XODB",
")",
"error",
"{",
"var",
"err",
"error",
"\n\n",
"// if doesn't exist, bail",
"if",
"!",
"aug",
".",
"_exists",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// if deleted, bail",
"if... | // Delete deletes the AuthUserGroup from the database. | [
"Delete",
"deletes",
"the",
"AuthUserGroup",
"from",
"the",
"database",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/oracle/authusergroup.xo.go#L99-L126 | train |
xo/xo | models/myenumvalue.xo.go | MyEnumValues | func MyEnumValues(db XODB, schema string, enum string) (*MyEnumValue, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`SUBSTRING(column_type, 6, CHAR_LENGTH(column_type) - 6) AS enum_values ` +
`FROM information_schema.columns ` +
`WHERE data_type = 'enum' AND table_schema = ? AND column_name =... | go | func MyEnumValues(db XODB, schema string, enum string) (*MyEnumValue, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`SUBSTRING(column_type, 6, CHAR_LENGTH(column_type) - 6) AS enum_values ` +
`FROM information_schema.columns ` +
`WHERE data_type = 'enum' AND table_schema = ? AND column_name =... | [
"func",
"MyEnumValues",
"(",
"db",
"XODB",
",",
"schema",
"string",
",",
"enum",
"string",
")",
"(",
"*",
"MyEnumValue",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// sql query",
"const",
"sqlstr",
"=",
"`SELECT `",
"+",
"`SUBSTRING(column_type,... | // MyEnumValues runs a custom query, returning results as MyEnumValue. | [
"MyEnumValues",
"runs",
"a",
"custom",
"query",
"returning",
"results",
"as",
"MyEnumValue",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/models/myenumvalue.xo.go#L12-L30 | train |
xo/xo | examples/django/postgres/authusergroup.xo.go | Update | func (aug *AuthUserGroup) Update(db XODB) error {
var err error
// if doesn't exist, bail
if !aug._exists {
return errors.New("update failed: does not exist")
}
// if deleted, bail
if aug._deleted {
return errors.New("update failed: marked for deletion")
}
// sql query
const sqlstr = `UPDATE public.auth... | go | func (aug *AuthUserGroup) Update(db XODB) error {
var err error
// if doesn't exist, bail
if !aug._exists {
return errors.New("update failed: does not exist")
}
// if deleted, bail
if aug._deleted {
return errors.New("update failed: marked for deletion")
}
// sql query
const sqlstr = `UPDATE public.auth... | [
"func",
"(",
"aug",
"*",
"AuthUserGroup",
")",
"Update",
"(",
"db",
"XODB",
")",
"error",
"{",
"var",
"err",
"error",
"\n\n",
"// if doesn't exist, bail",
"if",
"!",
"aug",
".",
"_exists",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n"... | // Update updates the AuthUserGroup in the database. | [
"Update",
"updates",
"the",
"AuthUserGroup",
"in",
"the",
"database",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/django/postgres/authusergroup.xo.go#L60-L84 | train |
xo/xo | models/column.xo.go | MyTableColumns | func MyTableColumns(db XODB, schema string, table string) ([]*Column, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`ordinal_position AS field_ordinal, ` +
`column_name, ` +
`IF(data_type = 'enum', column_name, column_type) AS data_type, ` +
`IF(is_nullable = 'YES', false, true) AS not_null... | go | func MyTableColumns(db XODB, schema string, table string) ([]*Column, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`ordinal_position AS field_ordinal, ` +
`column_name, ` +
`IF(data_type = 'enum', column_name, column_type) AS data_type, ` +
`IF(is_nullable = 'YES', false, true) AS not_null... | [
"func",
"MyTableColumns",
"(",
"db",
"XODB",
",",
"schema",
"string",
",",
"table",
"string",
")",
"(",
"[",
"]",
"*",
"Column",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// sql query",
"const",
"sqlstr",
"=",
"`SELECT `",
"+",
"`ordinal_po... | // MyTableColumns runs a custom query, returning results as Column. | [
"MyTableColumns",
"runs",
"a",
"custom",
"query",
"returning",
"results",
"as",
"Column",
"."
] | 1a94fa516029cb306cce6d379d086e4d5b5bb232 | https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/models/column.xo.go#L66-L104 | train |
gravitational/teleport | lib/auth/methods.go | AuthenticateUser | func (s *AuthServer) AuthenticateUser(req AuthenticateUserRequest) error {
err := s.authenticateUser(req)
if err != nil {
s.EmitAuditEvent(events.UserLocalLoginFailure, events.EventFields{
events.EventUser: req.Username,
events.LoginMethod: events.LoginMethodLocal,
events.AuthAttemptSuccess... | go | func (s *AuthServer) AuthenticateUser(req AuthenticateUserRequest) error {
err := s.authenticateUser(req)
if err != nil {
s.EmitAuditEvent(events.UserLocalLoginFailure, events.EventFields{
events.EventUser: req.Username,
events.LoginMethod: events.LoginMethodLocal,
events.AuthAttemptSuccess... | [
"func",
"(",
"s",
"*",
"AuthServer",
")",
"AuthenticateUser",
"(",
"req",
"AuthenticateUserRequest",
")",
"error",
"{",
"err",
":=",
"s",
".",
"authenticateUser",
"(",
"req",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"s",
".",
"EmitAuditEvent",
"(",
"eve... | // AuthenticateUser authenticates user based on the request type | [
"AuthenticateUser",
"authenticates",
"user",
"based",
"on",
"the",
"request",
"type"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/methods.go#L85-L102 | train |
gravitational/teleport | lib/auth/methods.go | AuthenticateWebUser | func (s *AuthServer) AuthenticateWebUser(req AuthenticateUserRequest) (services.WebSession, error) {
if req.Session != nil {
session, err := s.GetWebSession(req.Username, req.Session.ID)
if err != nil {
return nil, trace.AccessDenied("session is invalid or has expired")
}
return session, nil
}
if err := s... | go | func (s *AuthServer) AuthenticateWebUser(req AuthenticateUserRequest) (services.WebSession, error) {
if req.Session != nil {
session, err := s.GetWebSession(req.Username, req.Session.ID)
if err != nil {
return nil, trace.AccessDenied("session is invalid or has expired")
}
return session, nil
}
if err := s... | [
"func",
"(",
"s",
"*",
"AuthServer",
")",
"AuthenticateWebUser",
"(",
"req",
"AuthenticateUserRequest",
")",
"(",
"services",
".",
"WebSession",
",",
"error",
")",
"{",
"if",
"req",
".",
"Session",
"!=",
"nil",
"{",
"session",
",",
"err",
":=",
"s",
".",... | // AuthenticateWebUser authenticates web user, creates and returns web session
// in case if authentication is successful. In case if existing session id
// is used to authenticate, returns session associated with the existing session id
// instead of creating the new one | [
"AuthenticateWebUser",
"authenticates",
"web",
"user",
"creates",
"and",
"returns",
"web",
"session",
"in",
"case",
"if",
"authentication",
"is",
"successful",
".",
"In",
"case",
"if",
"existing",
"session",
"id",
"is",
"used",
"to",
"authenticate",
"returns",
"... | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/methods.go#L165-L188 | train |
gravitational/teleport | lib/auth/methods.go | CheckAndSetDefaults | func (a *AuthenticateSSHRequest) CheckAndSetDefaults() error {
if err := a.AuthenticateUserRequest.CheckAndSetDefaults(); err != nil {
return trace.Wrap(err)
}
if len(a.PublicKey) == 0 {
return trace.BadParameter("missing parameter 'public_key'")
}
certificateFormat, err := utils.CheckCertificateFormatFlag(a.C... | go | func (a *AuthenticateSSHRequest) CheckAndSetDefaults() error {
if err := a.AuthenticateUserRequest.CheckAndSetDefaults(); err != nil {
return trace.Wrap(err)
}
if len(a.PublicKey) == 0 {
return trace.BadParameter("missing parameter 'public_key'")
}
certificateFormat, err := utils.CheckCertificateFormatFlag(a.C... | [
"func",
"(",
"a",
"*",
"AuthenticateSSHRequest",
")",
"CheckAndSetDefaults",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"a",
".",
"AuthenticateUserRequest",
".",
"CheckAndSetDefaults",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"trace",
".",
"Wrap",
... | // CheckAndSetDefaults checks and sets default certificate values | [
"CheckAndSetDefaults",
"checks",
"and",
"sets",
"default",
"certificate",
"values"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/methods.go#L203-L216 | train |
gravitational/teleport | lib/auth/methods.go | SSHCertPublicKeys | func (c *TrustedCerts) SSHCertPublicKeys() ([]ssh.PublicKey, error) {
out := make([]ssh.PublicKey, 0, len(c.HostCertificates))
for _, keyBytes := range c.HostCertificates {
publicKey, _, _, _, err := ssh.ParseAuthorizedKey(keyBytes)
if err != nil {
return nil, trace.Wrap(err)
}
out = append(out, publicKey)... | go | func (c *TrustedCerts) SSHCertPublicKeys() ([]ssh.PublicKey, error) {
out := make([]ssh.PublicKey, 0, len(c.HostCertificates))
for _, keyBytes := range c.HostCertificates {
publicKey, _, _, _, err := ssh.ParseAuthorizedKey(keyBytes)
if err != nil {
return nil, trace.Wrap(err)
}
out = append(out, publicKey)... | [
"func",
"(",
"c",
"*",
"TrustedCerts",
")",
"SSHCertPublicKeys",
"(",
")",
"(",
"[",
"]",
"ssh",
".",
"PublicKey",
",",
"error",
")",
"{",
"out",
":=",
"make",
"(",
"[",
"]",
"ssh",
".",
"PublicKey",
",",
"0",
",",
"len",
"(",
"c",
".",
"HostCert... | // SSHCertPublicKeys returns a list of trusted host SSH certificate authority public keys | [
"SSHCertPublicKeys",
"returns",
"a",
"list",
"of",
"trusted",
"host",
"SSH",
"certificate",
"authority",
"public",
"keys"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/methods.go#L247-L257 | train |
gravitational/teleport | lib/auth/methods.go | AuthoritiesToTrustedCerts | func AuthoritiesToTrustedCerts(authorities []services.CertAuthority) []TrustedCerts {
out := make([]TrustedCerts, len(authorities))
for i, ca := range authorities {
out[i] = TrustedCerts{
ClusterName: ca.GetClusterName(),
HostCertificates: ca.GetCheckingKeys(),
TLSCertificates: services.TLSCerts(ca),... | go | func AuthoritiesToTrustedCerts(authorities []services.CertAuthority) []TrustedCerts {
out := make([]TrustedCerts, len(authorities))
for i, ca := range authorities {
out[i] = TrustedCerts{
ClusterName: ca.GetClusterName(),
HostCertificates: ca.GetCheckingKeys(),
TLSCertificates: services.TLSCerts(ca),... | [
"func",
"AuthoritiesToTrustedCerts",
"(",
"authorities",
"[",
"]",
"services",
".",
"CertAuthority",
")",
"[",
"]",
"TrustedCerts",
"{",
"out",
":=",
"make",
"(",
"[",
"]",
"TrustedCerts",
",",
"len",
"(",
"authorities",
")",
")",
"\n",
"for",
"i",
",",
... | // AuthoritiesToTrustedCerts serializes authorities to TrustedCerts data structure | [
"AuthoritiesToTrustedCerts",
"serializes",
"authorities",
"to",
"TrustedCerts",
"data",
"structure"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/methods.go#L260-L270 | train |
gravitational/teleport | lib/auth/methods.go | AuthenticateSSHUser | func (s *AuthServer) AuthenticateSSHUser(req AuthenticateSSHRequest) (*SSHLoginResponse, error) {
clusterName, err := s.GetClusterName()
if err != nil {
return nil, trace.Wrap(err)
}
if err := s.AuthenticateUser(req.AuthenticateUserRequest); err != nil {
return nil, trace.Wrap(err)
}
user, err := s.GetUser(r... | go | func (s *AuthServer) AuthenticateSSHUser(req AuthenticateSSHRequest) (*SSHLoginResponse, error) {
clusterName, err := s.GetClusterName()
if err != nil {
return nil, trace.Wrap(err)
}
if err := s.AuthenticateUser(req.AuthenticateUserRequest); err != nil {
return nil, trace.Wrap(err)
}
user, err := s.GetUser(r... | [
"func",
"(",
"s",
"*",
"AuthServer",
")",
"AuthenticateSSHUser",
"(",
"req",
"AuthenticateSSHRequest",
")",
"(",
"*",
"SSHLoginResponse",
",",
"error",
")",
"{",
"clusterName",
",",
"err",
":=",
"s",
".",
"GetClusterName",
"(",
")",
"\n",
"if",
"err",
"!="... | // AuthenticateSSHUser authenticates web user, creates and returns web session
// in case if authentication is successful | [
"AuthenticateSSHUser",
"authenticates",
"web",
"user",
"creates",
"and",
"returns",
"web",
"session",
"in",
"case",
"if",
"authentication",
"is",
"successful"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/methods.go#L274-L320 | train |
gravitational/teleport | lib/pam/pam.go | unregisterHandler | func unregisterHandler(handlerIndex int) {
handlerMu.Lock()
defer handlerMu.Unlock()
delete(handlers, handlerIndex)
} | go | func unregisterHandler(handlerIndex int) {
handlerMu.Lock()
defer handlerMu.Unlock()
delete(handlers, handlerIndex)
} | [
"func",
"unregisterHandler",
"(",
"handlerIndex",
"int",
")",
"{",
"handlerMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"handlerMu",
".",
"Unlock",
"(",
")",
"\n\n",
"delete",
"(",
"handlers",
",",
"handlerIndex",
")",
"\n",
"}"
] | // unregisterHandler will remove the PAM handle from the package level map
// once no more C callbacks can come back. | [
"unregisterHandler",
"will",
"remove",
"the",
"PAM",
"handle",
"from",
"the",
"package",
"level",
"map",
"once",
"no",
"more",
"C",
"callbacks",
"can",
"come",
"back",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/pam/pam.go#L140-L145 | train |
gravitational/teleport | lib/pam/pam.go | lookupHandler | func lookupHandler(handlerIndex int) (handler, error) {
handlerMu.Lock()
defer handlerMu.Unlock()
handle, ok := handlers[handlerIndex]
if !ok {
return nil, trace.BadParameter("handler with index %v not registered", handlerIndex)
}
return handle, nil
} | go | func lookupHandler(handlerIndex int) (handler, error) {
handlerMu.Lock()
defer handlerMu.Unlock()
handle, ok := handlers[handlerIndex]
if !ok {
return nil, trace.BadParameter("handler with index %v not registered", handlerIndex)
}
return handle, nil
} | [
"func",
"lookupHandler",
"(",
"handlerIndex",
"int",
")",
"(",
"handler",
",",
"error",
")",
"{",
"handlerMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"handlerMu",
".",
"Unlock",
"(",
")",
"\n\n",
"handle",
",",
"ok",
":=",
"handlers",
"[",
"handlerIndex",... | // lookupHandler returns a particular handler from the package level map. | [
"lookupHandler",
"returns",
"a",
"particular",
"handler",
"from",
"the",
"package",
"level",
"map",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/pam/pam.go#L148-L158 | train |
gravitational/teleport | lib/pam/pam.go | Open | func Open(config *Config) (*PAM, error) {
if config == nil {
return nil, trace.BadParameter("PAM configuration is required.")
}
err := config.CheckDefaults()
if err != nil {
return nil, trace.Wrap(err)
}
p := &PAM{
pamh: nil,
stdin: config.Stdin,
stdout: config.Stdout,
stderr: config.Stderr,
}
... | go | func Open(config *Config) (*PAM, error) {
if config == nil {
return nil, trace.BadParameter("PAM configuration is required.")
}
err := config.CheckDefaults()
if err != nil {
return nil, trace.Wrap(err)
}
p := &PAM{
pamh: nil,
stdin: config.Stdin,
stdout: config.Stdout,
stderr: config.Stderr,
}
... | [
"func",
"Open",
"(",
"config",
"*",
"Config",
")",
"(",
"*",
"PAM",
",",
"error",
")",
"{",
"if",
"config",
"==",
"nil",
"{",
"return",
"nil",
",",
"trace",
".",
"BadParameter",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"err",
":=",
"config",
".",
... | // Open creates a PAM context and initiates a PAM transaction to check the
// account and then opens a session. | [
"Open",
"creates",
"a",
"PAM",
"context",
"and",
"initiates",
"a",
"PAM",
"transaction",
"to",
"check",
"the",
"account",
"and",
"then",
"opens",
"a",
"session",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/pam/pam.go#L215-L271 | train |
gravitational/teleport | lib/pam/pam.go | Close | func (p *PAM) Close() error {
// Close the PAM session. Closing a session can entail anything from
// unmounting a home directory and updating auth.log.
p.retval = C._pam_close_session(pamHandle, p.pamh, 0)
if p.retval != C.PAM_SUCCESS {
return p.codeToError(p.retval)
}
// Terminate the PAM transaction.
retva... | go | func (p *PAM) Close() error {
// Close the PAM session. Closing a session can entail anything from
// unmounting a home directory and updating auth.log.
p.retval = C._pam_close_session(pamHandle, p.pamh, 0)
if p.retval != C.PAM_SUCCESS {
return p.codeToError(p.retval)
}
// Terminate the PAM transaction.
retva... | [
"func",
"(",
"p",
"*",
"PAM",
")",
"Close",
"(",
")",
"error",
"{",
"// Close the PAM session. Closing a session can entail anything from",
"// unmounting a home directory and updating auth.log.",
"p",
".",
"retval",
"=",
"C",
".",
"_pam_close_session",
"(",
"pamHandle",
... | // Close will close the session, the PAM context, and release any allocated
// memory. | [
"Close",
"will",
"close",
"the",
"session",
"the",
"PAM",
"context",
"and",
"release",
"any",
"allocated",
"memory",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/pam/pam.go#L275-L300 | train |
gravitational/teleport | lib/pam/pam.go | codeToError | func (p *PAM) codeToError(returnValue C.int) error {
// Error strings are not allocated on the heap, so memory does not need
// released.
err := C._pam_strerror(pamHandle, p.pamh, returnValue)
if err != nil {
return trace.BadParameter(C.GoString(err))
}
return nil
} | go | func (p *PAM) codeToError(returnValue C.int) error {
// Error strings are not allocated on the heap, so memory does not need
// released.
err := C._pam_strerror(pamHandle, p.pamh, returnValue)
if err != nil {
return trace.BadParameter(C.GoString(err))
}
return nil
} | [
"func",
"(",
"p",
"*",
"PAM",
")",
"codeToError",
"(",
"returnValue",
"C",
".",
"int",
")",
"error",
"{",
"// Error strings are not allocated on the heap, so memory does not need",
"// released.",
"err",
":=",
"C",
".",
"_pam_strerror",
"(",
"pamHandle",
",",
"p",
... | // codeToError returns a human readable string from the PAM error. | [
"codeToError",
"returns",
"a",
"human",
"readable",
"string",
"from",
"the",
"PAM",
"error",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/pam/pam.go#L334-L343 | train |
gravitational/teleport | lib/utils/fakeconn.go | DualPipeNetConn | func DualPipeNetConn(srcAddr net.Addr, dstAddr net.Addr) (*PipeNetConn, *PipeNetConn) {
server, client := net.Pipe()
serverConn := NewPipeNetConn(server, server, server, dstAddr, srcAddr)
clientConn := NewPipeNetConn(client, client, client, srcAddr, dstAddr)
return serverConn, clientConn
} | go | func DualPipeNetConn(srcAddr net.Addr, dstAddr net.Addr) (*PipeNetConn, *PipeNetConn) {
server, client := net.Pipe()
serverConn := NewPipeNetConn(server, server, server, dstAddr, srcAddr)
clientConn := NewPipeNetConn(client, client, client, srcAddr, dstAddr)
return serverConn, clientConn
} | [
"func",
"DualPipeNetConn",
"(",
"srcAddr",
"net",
".",
"Addr",
",",
"dstAddr",
"net",
".",
"Addr",
")",
"(",
"*",
"PipeNetConn",
",",
"*",
"PipeNetConn",
")",
"{",
"server",
",",
"client",
":=",
"net",
".",
"Pipe",
"(",
")",
"\n\n",
"serverConn",
":=",... | // DualPipeAddrConn creates a net.Pipe to connect a client and a server. The
// two net.Conn instances are wrapped in an addrConn which holds the source and
// destination addresses. | [
"DualPipeAddrConn",
"creates",
"a",
"net",
".",
"Pipe",
"to",
"connect",
"a",
"client",
"and",
"a",
"server",
".",
"The",
"two",
"net",
".",
"Conn",
"instances",
"are",
"wrapped",
"in",
"an",
"addrConn",
"which",
"holds",
"the",
"source",
"and",
"destinati... | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/fakeconn.go#L89-L96 | train |
gravitational/teleport | lib/services/clustername.go | NewClusterName | func NewClusterName(spec ClusterNameSpecV2) (ClusterName, error) {
cn := ClusterNameV2{
Kind: KindClusterName,
Version: V2,
Metadata: Metadata{
Name: MetaNameClusterName,
Namespace: defaults.Namespace,
},
Spec: spec,
}
if err := cn.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(... | go | func NewClusterName(spec ClusterNameSpecV2) (ClusterName, error) {
cn := ClusterNameV2{
Kind: KindClusterName,
Version: V2,
Metadata: Metadata{
Name: MetaNameClusterName,
Namespace: defaults.Namespace,
},
Spec: spec,
}
if err := cn.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(... | [
"func",
"NewClusterName",
"(",
"spec",
"ClusterNameSpecV2",
")",
"(",
"ClusterName",
",",
"error",
")",
"{",
"cn",
":=",
"ClusterNameV2",
"{",
"Kind",
":",
"KindClusterName",
",",
"Version",
":",
"V2",
",",
"Metadata",
":",
"Metadata",
"{",
"Name",
":",
"M... | // NewClusterName is a convenience wrapper to create a ClusterName resource. | [
"NewClusterName",
"is",
"a",
"convenience",
"wrapper",
"to",
"create",
"a",
"ClusterName",
"resource",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/clustername.go#L46-L61 | train |
gravitational/teleport | lib/services/clustername.go | GetClusterNameSchema | func GetClusterNameSchema(extensionSchema string) string {
var clusterNameSchema string
if clusterNameSchema == "" {
clusterNameSchema = fmt.Sprintf(ClusterNameSpecSchemaTemplate, "")
} else {
clusterNameSchema = fmt.Sprintf(ClusterNameSpecSchemaTemplate, ","+extensionSchema)
}
return fmt.Sprintf(V2SchemaTempl... | go | func GetClusterNameSchema(extensionSchema string) string {
var clusterNameSchema string
if clusterNameSchema == "" {
clusterNameSchema = fmt.Sprintf(ClusterNameSpecSchemaTemplate, "")
} else {
clusterNameSchema = fmt.Sprintf(ClusterNameSpecSchemaTemplate, ","+extensionSchema)
}
return fmt.Sprintf(V2SchemaTempl... | [
"func",
"GetClusterNameSchema",
"(",
"extensionSchema",
"string",
")",
"string",
"{",
"var",
"clusterNameSchema",
"string",
"\n",
"if",
"clusterNameSchema",
"==",
"\"",
"\"",
"{",
"clusterNameSchema",
"=",
"fmt",
".",
"Sprintf",
"(",
"ClusterNameSpecSchemaTemplate",
... | // GetClusterNameSchema returns the schema with optionally injected
// schema for extensions. | [
"GetClusterNameSchema",
"returns",
"the",
"schema",
"with",
"optionally",
"injected",
"schema",
"for",
"extensions",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/clustername.go#L166-L174 | train |
gravitational/teleport | lib/services/clustername.go | Unmarshal | func (t *TeleportClusterNameMarshaler) Unmarshal(bytes []byte, opts ...MarshalOption) (ClusterName, error) {
var clusterName ClusterNameV2
if len(bytes) == 0 {
return nil, trace.BadParameter("missing resource data")
}
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
if cfg.Sk... | go | func (t *TeleportClusterNameMarshaler) Unmarshal(bytes []byte, opts ...MarshalOption) (ClusterName, error) {
var clusterName ClusterNameV2
if len(bytes) == 0 {
return nil, trace.BadParameter("missing resource data")
}
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
if cfg.Sk... | [
"func",
"(",
"t",
"*",
"TeleportClusterNameMarshaler",
")",
"Unmarshal",
"(",
"bytes",
"[",
"]",
"byte",
",",
"opts",
"...",
"MarshalOption",
")",
"(",
"ClusterName",
",",
"error",
")",
"{",
"var",
"clusterName",
"ClusterNameV2",
"\n\n",
"if",
"len",
"(",
... | // Unmarshal unmarshals ClusterName from JSON. | [
"Unmarshal",
"unmarshals",
"ClusterName",
"from",
"JSON",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/clustername.go#L203-L239 | train |
gravitational/teleport | lib/services/clustername.go | Marshal | func (t *TeleportClusterNameMarshaler) Marshal(c ClusterName, opts ...MarshalOption) ([]byte, error) {
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
switch resource := c.(type) {
case *ClusterNameV2:
if !cfg.PreserveResourceID {
// avoid modifying the original object
// t... | go | func (t *TeleportClusterNameMarshaler) Marshal(c ClusterName, opts ...MarshalOption) ([]byte, error) {
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
switch resource := c.(type) {
case *ClusterNameV2:
if !cfg.PreserveResourceID {
// avoid modifying the original object
// t... | [
"func",
"(",
"t",
"*",
"TeleportClusterNameMarshaler",
")",
"Marshal",
"(",
"c",
"ClusterName",
",",
"opts",
"...",
"MarshalOption",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"cfg",
",",
"err",
":=",
"collectOptions",
"(",
"opts",
")",
"\n",
... | // Marshal marshals ClusterName to JSON. | [
"Marshal",
"marshals",
"ClusterName",
"to",
"JSON",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/clustername.go#L242-L260 | train |
gravitational/teleport | lib/services/trust.go | Check | func (c CertAuthType) Check() error {
if c != HostCA && c != UserCA {
return trace.BadParameter("'%v' authority type is not supported", c)
}
return nil
} | go | func (c CertAuthType) Check() error {
if c != HostCA && c != UserCA {
return trace.BadParameter("'%v' authority type is not supported", c)
}
return nil
} | [
"func",
"(",
"c",
"CertAuthType",
")",
"Check",
"(",
")",
"error",
"{",
"if",
"c",
"!=",
"HostCA",
"&&",
"c",
"!=",
"UserCA",
"{",
"return",
"trace",
".",
"BadParameter",
"(",
"\"",
"\"",
",",
"c",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"... | // Check checks if certificate authority type value is correct | [
"Check",
"checks",
"if",
"certificate",
"authority",
"type",
"value",
"is",
"correct"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trust.go#L81-L86 | train |
gravitational/teleport | lib/services/trust.go | Check | func (c *CertAuthID) Check() error {
if err := c.Type.Check(); err != nil {
return trace.Wrap(err)
}
if strings.TrimSpace(c.DomainName) == "" {
return trace.BadParameter("identity validation error: empty domain name")
}
return nil
} | go | func (c *CertAuthID) Check() error {
if err := c.Type.Check(); err != nil {
return trace.Wrap(err)
}
if strings.TrimSpace(c.DomainName) == "" {
return trace.BadParameter("identity validation error: empty domain name")
}
return nil
} | [
"func",
"(",
"c",
"*",
"CertAuthID",
")",
"Check",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"c",
".",
"Type",
".",
"Check",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"trace",
".",
"Wrap",
"(",
"err",
")",
"\n",
"}",
"\n",
"if",
"str... | // Check returns error if any of the id parameters are bad, nil otherwise | [
"Check",
"returns",
"error",
"if",
"any",
"of",
"the",
"id",
"parameters",
"are",
"bad",
"nil",
"otherwise"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trust.go#L99-L107 | train |
gravitational/teleport | lib/services/tunnel.go | NewReverseTunnel | func NewReverseTunnel(clusterName string, dialAddrs []string) ReverseTunnel {
return &ReverseTunnelV2{
Kind: KindReverseTunnel,
Version: V2,
Metadata: Metadata{
Name: clusterName,
Namespace: defaults.Namespace,
},
Spec: ReverseTunnelSpecV2{
ClusterName: clusterName,
DialAddrs: dialAddrs... | go | func NewReverseTunnel(clusterName string, dialAddrs []string) ReverseTunnel {
return &ReverseTunnelV2{
Kind: KindReverseTunnel,
Version: V2,
Metadata: Metadata{
Name: clusterName,
Namespace: defaults.Namespace,
},
Spec: ReverseTunnelSpecV2{
ClusterName: clusterName,
DialAddrs: dialAddrs... | [
"func",
"NewReverseTunnel",
"(",
"clusterName",
"string",
",",
"dialAddrs",
"[",
"]",
"string",
")",
"ReverseTunnel",
"{",
"return",
"&",
"ReverseTunnelV2",
"{",
"Kind",
":",
"KindReverseTunnel",
",",
"Version",
":",
"V2",
",",
"Metadata",
":",
"Metadata",
"{"... | // NewReverseTunnel returns new version of reverse tunnel | [
"NewReverseTunnel",
"returns",
"new",
"version",
"of",
"reverse",
"tunnel"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnel.go#L55-L68 | train |
gravitational/teleport | lib/services/tunnel.go | V2 | func (r *ReverseTunnelV1) V2() *ReverseTunnelV2 {
return &ReverseTunnelV2{
Kind: KindReverseTunnel,
Version: V2,
Metadata: Metadata{
Name: r.DomainName,
Namespace: defaults.Namespace,
},
Spec: ReverseTunnelSpecV2{
ClusterName: r.DomainName,
Type: ProxyTunnel,
DialAddrs: r.Dial... | go | func (r *ReverseTunnelV1) V2() *ReverseTunnelV2 {
return &ReverseTunnelV2{
Kind: KindReverseTunnel,
Version: V2,
Metadata: Metadata{
Name: r.DomainName,
Namespace: defaults.Namespace,
},
Spec: ReverseTunnelSpecV2{
ClusterName: r.DomainName,
Type: ProxyTunnel,
DialAddrs: r.Dial... | [
"func",
"(",
"r",
"*",
"ReverseTunnelV1",
")",
"V2",
"(",
")",
"*",
"ReverseTunnelV2",
"{",
"return",
"&",
"ReverseTunnelV2",
"{",
"Kind",
":",
"KindReverseTunnel",
",",
"Version",
":",
"V2",
",",
"Metadata",
":",
"Metadata",
"{",
"Name",
":",
"r",
".",
... | // V2 returns V2 version of reverse tunnel | [
"V2",
"returns",
"V2",
"version",
"of",
"reverse",
"tunnel"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnel.go#L240-L254 | train |
gravitational/teleport | lib/services/tunnel.go | UnmarshalReverseTunnel | func UnmarshalReverseTunnel(data []byte, opts ...MarshalOption) (ReverseTunnel, error) {
if len(data) == 0 {
return nil, trace.BadParameter("missing tunnel data")
}
var h ResourceHeader
err := json.Unmarshal(data, &h)
if err != nil {
return nil, trace.Wrap(err)
}
cfg, err := collectOptions(opts)
if err != n... | go | func UnmarshalReverseTunnel(data []byte, opts ...MarshalOption) (ReverseTunnel, error) {
if len(data) == 0 {
return nil, trace.BadParameter("missing tunnel data")
}
var h ResourceHeader
err := json.Unmarshal(data, &h)
if err != nil {
return nil, trace.Wrap(err)
}
cfg, err := collectOptions(opts)
if err != n... | [
"func",
"UnmarshalReverseTunnel",
"(",
"data",
"[",
"]",
"byte",
",",
"opts",
"...",
"MarshalOption",
")",
"(",
"ReverseTunnel",
",",
"error",
")",
"{",
"if",
"len",
"(",
"data",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"trace",
".",
"BadParameter",
... | // UnmarshalReverseTunnel unmarshals reverse tunnel from JSON or YAML,
// sets defaults and checks the schema | [
"UnmarshalReverseTunnel",
"unmarshals",
"reverse",
"tunnel",
"from",
"JSON",
"or",
"YAML",
"sets",
"defaults",
"and",
"checks",
"the",
"schema"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnel.go#L264-L313 | train |
gravitational/teleport | lib/services/tunnel.go | UnmarshalReverseTunnel | func (*TeleportTunnelMarshaler) UnmarshalReverseTunnel(bytes []byte, opts ...MarshalOption) (ReverseTunnel, error) {
return UnmarshalReverseTunnel(bytes, opts...)
} | go | func (*TeleportTunnelMarshaler) UnmarshalReverseTunnel(bytes []byte, opts ...MarshalOption) (ReverseTunnel, error) {
return UnmarshalReverseTunnel(bytes, opts...)
} | [
"func",
"(",
"*",
"TeleportTunnelMarshaler",
")",
"UnmarshalReverseTunnel",
"(",
"bytes",
"[",
"]",
"byte",
",",
"opts",
"...",
"MarshalOption",
")",
"(",
"ReverseTunnel",
",",
"error",
")",
"{",
"return",
"UnmarshalReverseTunnel",
"(",
"bytes",
",",
"opts",
"... | // UnmarshalReverseTunnel unmarshals reverse tunnel from JSON or YAML | [
"UnmarshalReverseTunnel",
"unmarshals",
"reverse",
"tunnel",
"from",
"JSON",
"or",
"YAML"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnel.go#L340-L342 | train |
gravitational/teleport | lib/services/tunnel.go | MarshalReverseTunnel | func (*TeleportTunnelMarshaler) MarshalReverseTunnel(rt ReverseTunnel, opts ...MarshalOption) ([]byte, error) {
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
type tunv1 interface {
V1() *ReverseTunnelV1
}
type tunv2 interface {
V2() *ReverseTunnelV2
}
version := cfg.GetVer... | go | func (*TeleportTunnelMarshaler) MarshalReverseTunnel(rt ReverseTunnel, opts ...MarshalOption) ([]byte, error) {
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
type tunv1 interface {
V1() *ReverseTunnelV1
}
type tunv2 interface {
V2() *ReverseTunnelV2
}
version := cfg.GetVer... | [
"func",
"(",
"*",
"TeleportTunnelMarshaler",
")",
"MarshalReverseTunnel",
"(",
"rt",
"ReverseTunnel",
",",
"opts",
"...",
"MarshalOption",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"cfg",
",",
"err",
":=",
"collectOptions",
"(",
"opts",
")",
"\n"... | // MarshalRole marshalls role into JSON | [
"MarshalRole",
"marshalls",
"role",
"into",
"JSON"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnel.go#L345-L381 | train |
gravitational/teleport | lib/utils/syslog.go | SwitchLoggingtoSyslog | func SwitchLoggingtoSyslog() error {
log.StandardLogger().SetHooks(make(log.LevelHooks))
hook, err := logrusSyslog.NewSyslogHook("", "", syslog.LOG_WARNING, "")
if err != nil {
// syslog is not available
log.SetOutput(os.Stderr)
return trace.Wrap(err)
}
log.AddHook(hook)
// ... and disable stderr:
log.SetO... | go | func SwitchLoggingtoSyslog() error {
log.StandardLogger().SetHooks(make(log.LevelHooks))
hook, err := logrusSyslog.NewSyslogHook("", "", syslog.LOG_WARNING, "")
if err != nil {
// syslog is not available
log.SetOutput(os.Stderr)
return trace.Wrap(err)
}
log.AddHook(hook)
// ... and disable stderr:
log.SetO... | [
"func",
"SwitchLoggingtoSyslog",
"(",
")",
"error",
"{",
"log",
".",
"StandardLogger",
"(",
")",
".",
"SetHooks",
"(",
"make",
"(",
"log",
".",
"LevelHooks",
")",
")",
"\n",
"hook",
",",
"err",
":=",
"logrusSyslog",
".",
"NewSyslogHook",
"(",
"\"",
"\"",... | // SwitchLoggingtoSyslog tells the logger to send the output to syslog. This
// code is behind a build flag because Windows does not support syslog. | [
"SwitchLoggingtoSyslog",
"tells",
"the",
"logger",
"to",
"send",
"the",
"output",
"to",
"syslog",
".",
"This",
"code",
"is",
"behind",
"a",
"build",
"flag",
"because",
"Windows",
"does",
"not",
"support",
"syslog",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/syslog.go#L33-L45 | train |
gravitational/teleport | lib/auth/rotate.go | Types | func (r *RotateRequest) Types() []services.CertAuthType {
switch r.Type {
case "":
return []services.CertAuthType{services.HostCA, services.UserCA}
case services.HostCA:
return []services.CertAuthType{services.HostCA}
case services.UserCA:
return []services.CertAuthType{services.UserCA}
}
return nil
} | go | func (r *RotateRequest) Types() []services.CertAuthType {
switch r.Type {
case "":
return []services.CertAuthType{services.HostCA, services.UserCA}
case services.HostCA:
return []services.CertAuthType{services.HostCA}
case services.UserCA:
return []services.CertAuthType{services.UserCA}
}
return nil
} | [
"func",
"(",
"r",
"*",
"RotateRequest",
")",
"Types",
"(",
")",
"[",
"]",
"services",
".",
"CertAuthType",
"{",
"switch",
"r",
".",
"Type",
"{",
"case",
"\"",
"\"",
":",
"return",
"[",
"]",
"services",
".",
"CertAuthType",
"{",
"services",
".",
"Host... | // Types returns cert authority types requested to be rotated. | [
"Types",
"returns",
"cert",
"authority",
"types",
"requested",
"to",
"be",
"rotated",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/rotate.go#L61-L71 | train |
gravitational/teleport | lib/auth/rotate.go | CheckAndSetDefaults | func (r *RotateRequest) CheckAndSetDefaults(clock clockwork.Clock) error {
if r.TargetPhase == "" {
// if phase if not set, imply that the first meaningful phase
// is set as a target phase
r.TargetPhase = services.RotationPhaseInit
}
// if mode is not set, default to manual (as it's safer)
if r.Mode == "" {
... | go | func (r *RotateRequest) CheckAndSetDefaults(clock clockwork.Clock) error {
if r.TargetPhase == "" {
// if phase if not set, imply that the first meaningful phase
// is set as a target phase
r.TargetPhase = services.RotationPhaseInit
}
// if mode is not set, default to manual (as it's safer)
if r.Mode == "" {
... | [
"func",
"(",
"r",
"*",
"RotateRequest",
")",
"CheckAndSetDefaults",
"(",
"clock",
"clockwork",
".",
"Clock",
")",
"error",
"{",
"if",
"r",
".",
"TargetPhase",
"==",
"\"",
"\"",
"{",
"// if phase if not set, imply that the first meaningful phase",
"// is set as a targe... | // CheckAndSetDefaults checks and sets default values. | [
"CheckAndSetDefaults",
"checks",
"and",
"sets",
"default",
"values",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/rotate.go#L74-L105 | train |
gravitational/teleport | lib/auth/rotate.go | RotateExternalCertAuthority | func (a *AuthServer) RotateExternalCertAuthority(ca services.CertAuthority) error {
if ca == nil {
return trace.BadParameter("missing certificate authority")
}
clusterName, err := a.GetClusterName()
if err != nil {
return trace.Wrap(err)
}
// this is just an extra precaution against local admins,
// because... | go | func (a *AuthServer) RotateExternalCertAuthority(ca services.CertAuthority) error {
if ca == nil {
return trace.BadParameter("missing certificate authority")
}
clusterName, err := a.GetClusterName()
if err != nil {
return trace.Wrap(err)
}
// this is just an extra precaution against local admins,
// because... | [
"func",
"(",
"a",
"*",
"AuthServer",
")",
"RotateExternalCertAuthority",
"(",
"ca",
"services",
".",
"CertAuthority",
")",
"error",
"{",
"if",
"ca",
"==",
"nil",
"{",
"return",
"trace",
".",
"BadParameter",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"cluster... | // RotateExternalCertAuthority rotates external certificate authority,
// this method is called by remote trusted cluster and is used to update
// only public keys and certificates of the certificate authority. | [
"RotateExternalCertAuthority",
"rotates",
"external",
"certificate",
"authority",
"this",
"method",
"is",
"called",
"by",
"remote",
"trusted",
"cluster",
"and",
"is",
"used",
"to",
"update",
"only",
"public",
"keys",
"and",
"certificates",
"of",
"the",
"certificate"... | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/rotate.go#L245-L280 | train |
gravitational/teleport | lib/auth/rotate.go | autoRotateCertAuthorities | func (a *AuthServer) autoRotateCertAuthorities() error {
clusterName, err := a.GetClusterName()
if err != nil {
return trace.Wrap(err)
}
for _, caType := range []services.CertAuthType{services.HostCA, services.UserCA} {
ca, err := a.Trust.GetCertAuthority(services.CertAuthID{
Type: caType,
DomainNam... | go | func (a *AuthServer) autoRotateCertAuthorities() error {
clusterName, err := a.GetClusterName()
if err != nil {
return trace.Wrap(err)
}
for _, caType := range []services.CertAuthType{services.HostCA, services.UserCA} {
ca, err := a.Trust.GetCertAuthority(services.CertAuthID{
Type: caType,
DomainNam... | [
"func",
"(",
"a",
"*",
"AuthServer",
")",
"autoRotateCertAuthorities",
"(",
")",
"error",
"{",
"clusterName",
",",
"err",
":=",
"a",
".",
"GetClusterName",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"trace",
".",
"Wrap",
"(",
"err",
")",
... | // autoRotateCertAuthorities automatically rotates cert authorities,
// does nothing if no rotation parameters were set up
// or it is too early to rotate per schedule | [
"autoRotateCertAuthorities",
"automatically",
"rotates",
"cert",
"authorities",
"does",
"nothing",
"if",
"no",
"rotation",
"parameters",
"were",
"set",
"up",
"or",
"it",
"is",
"too",
"early",
"to",
"rotate",
"per",
"schedule"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/rotate.go#L285-L303 | train |
gravitational/teleport | lib/auth/rotate.go | processRotationRequest | func processRotationRequest(req rotationReq) (services.CertAuthority, error) {
rotation := req.ca.GetRotation()
ca := req.ca.Clone()
switch req.targetPhase {
case services.RotationPhaseInit:
// This is the first stage of the rotation - new certificate authorities
// are being generated, but no components are u... | go | func processRotationRequest(req rotationReq) (services.CertAuthority, error) {
rotation := req.ca.GetRotation()
ca := req.ca.Clone()
switch req.targetPhase {
case services.RotationPhaseInit:
// This is the first stage of the rotation - new certificate authorities
// are being generated, but no components are u... | [
"func",
"processRotationRequest",
"(",
"req",
"rotationReq",
")",
"(",
"services",
".",
"CertAuthority",
",",
"error",
")",
"{",
"rotation",
":=",
"req",
".",
"ca",
".",
"GetRotation",
"(",
")",
"\n",
"ca",
":=",
"req",
".",
"ca",
".",
"Clone",
"(",
")... | // processRotationRequest processes rotation request based on the target and
// current phase and state. | [
"processRotationRequest",
"processes",
"rotation",
"request",
"based",
"on",
"the",
"target",
"and",
"current",
"phase",
"and",
"state",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/rotate.go#L371-L450 | train |
gravitational/teleport | lib/auth/rotate.go | startRollingBackRotation | func startRollingBackRotation(ca services.CertAuthority) error {
rotation := ca.GetRotation()
// Rollback always sets rotation to manual mode.
rotation.Mode = services.RotationModeManual
signingKeys := ca.GetSigningKeys()
checkingKeys := ca.GetCheckingKeys()
keyPairs := ca.GetTLSKeyPairs()
// Rotation sets th... | go | func startRollingBackRotation(ca services.CertAuthority) error {
rotation := ca.GetRotation()
// Rollback always sets rotation to manual mode.
rotation.Mode = services.RotationModeManual
signingKeys := ca.GetSigningKeys()
checkingKeys := ca.GetCheckingKeys()
keyPairs := ca.GetTLSKeyPairs()
// Rotation sets th... | [
"func",
"startRollingBackRotation",
"(",
"ca",
"services",
".",
"CertAuthority",
")",
"error",
"{",
"rotation",
":=",
"ca",
".",
"GetRotation",
"(",
")",
"\n\n",
"// Rollback always sets rotation to manual mode.",
"rotation",
".",
"Mode",
"=",
"services",
".",
"Rota... | // startRollingBackRotation starts roll back to the original state. | [
"startRollingBackRotation",
"starts",
"roll",
"back",
"to",
"the",
"original",
"state",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/rotate.go#L575-L601 | train |
gravitational/teleport | lib/auth/rotate.go | completeRollingBackRotation | func completeRollingBackRotation(clock clockwork.Clock, ca services.CertAuthority) error {
rotation := ca.GetRotation()
// clean up the state
rotation.Started = time.Time{}
rotation.State = services.RotationStateStandby
rotation.Phase = services.RotationPhaseStandby
rotation.Mode = ""
rotation.Schedule = servic... | go | func completeRollingBackRotation(clock clockwork.Clock, ca services.CertAuthority) error {
rotation := ca.GetRotation()
// clean up the state
rotation.Started = time.Time{}
rotation.State = services.RotationStateStandby
rotation.Phase = services.RotationPhaseStandby
rotation.Mode = ""
rotation.Schedule = servic... | [
"func",
"completeRollingBackRotation",
"(",
"clock",
"clockwork",
".",
"Clock",
",",
"ca",
"services",
".",
"CertAuthority",
")",
"error",
"{",
"rotation",
":=",
"ca",
".",
"GetRotation",
"(",
")",
"\n\n",
"// clean up the state",
"rotation",
".",
"Started",
"="... | // completeRollingBackRotation completes rollback of the rotation and sets it to the standby state | [
"completeRollingBackRotation",
"completes",
"rollback",
"of",
"the",
"rotation",
"and",
"sets",
"it",
"to",
"the",
"standby",
"state"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/rotate.go#L604-L622 | train |
gravitational/teleport | lib/auth/rotate.go | completeRotation | func completeRotation(clock clockwork.Clock, ca services.CertAuthority) error {
rotation := ca.GetRotation()
signingKeys := ca.GetSigningKeys()
checkingKeys := ca.GetCheckingKeys()
keyPairs := ca.GetTLSKeyPairs()
signingKeys = signingKeys[:1]
checkingKeys = checkingKeys[:1]
keyPairs = keyPairs[:1]
rotation.St... | go | func completeRotation(clock clockwork.Clock, ca services.CertAuthority) error {
rotation := ca.GetRotation()
signingKeys := ca.GetSigningKeys()
checkingKeys := ca.GetCheckingKeys()
keyPairs := ca.GetTLSKeyPairs()
signingKeys = signingKeys[:1]
checkingKeys = checkingKeys[:1]
keyPairs = keyPairs[:1]
rotation.St... | [
"func",
"completeRotation",
"(",
"clock",
"clockwork",
".",
"Clock",
",",
"ca",
"services",
".",
"CertAuthority",
")",
"error",
"{",
"rotation",
":=",
"ca",
".",
"GetRotation",
"(",
")",
"\n",
"signingKeys",
":=",
"ca",
".",
"GetSigningKeys",
"(",
")",
"\n... | // completeRotation completes the certificate authority rotation. | [
"completeRotation",
"completes",
"the",
"certificate",
"authority",
"rotation",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/rotate.go#L625-L647 | train |
gravitational/teleport | lib/utils/unpack.go | Extract | func Extract(r io.Reader, dir string) error {
tarball := tar.NewReader(r)
for {
header, err := tarball.Next()
if err == io.EOF {
break
} else if err != nil {
return trace.Wrap(err)
}
if err := extractFile(tarball, header, dir); err != nil {
return trace.Wrap(err)
}
}
return nil
} | go | func Extract(r io.Reader, dir string) error {
tarball := tar.NewReader(r)
for {
header, err := tarball.Next()
if err == io.EOF {
break
} else if err != nil {
return trace.Wrap(err)
}
if err := extractFile(tarball, header, dir); err != nil {
return trace.Wrap(err)
}
}
return nil
} | [
"func",
"Extract",
"(",
"r",
"io",
".",
"Reader",
",",
"dir",
"string",
")",
"error",
"{",
"tarball",
":=",
"tar",
".",
"NewReader",
"(",
"r",
")",
"\n\n",
"for",
"{",
"header",
",",
"err",
":=",
"tarball",
".",
"Next",
"(",
")",
"\n",
"if",
"err... | // Extract extracts the contents of the specified tarball under dir.
// The resulting files and directories are created using the current user context. | [
"Extract",
"extracts",
"the",
"contents",
"of",
"the",
"specified",
"tarball",
"under",
"dir",
".",
"The",
"resulting",
"files",
"and",
"directories",
"are",
"created",
"using",
"the",
"current",
"user",
"context",
"."
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/unpack.go#L33-L49 | train |
gravitational/teleport | lib/utils/rand.go | CryptoRandomHex | func CryptoRandomHex(len int) (string, error) {
randomBytes := make([]byte, len)
if _, err := rand.Reader.Read(randomBytes); err != nil {
return "", trace.Wrap(err)
}
return hex.EncodeToString(randomBytes), nil
} | go | func CryptoRandomHex(len int) (string, error) {
randomBytes := make([]byte, len)
if _, err := rand.Reader.Read(randomBytes); err != nil {
return "", trace.Wrap(err)
}
return hex.EncodeToString(randomBytes), nil
} | [
"func",
"CryptoRandomHex",
"(",
"len",
"int",
")",
"(",
"string",
",",
"error",
")",
"{",
"randomBytes",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"len",
")",
"\n",
"if",
"_",
",",
"err",
":=",
"rand",
".",
"Reader",
".",
"Read",
"(",
"randomBytes"... | // CryptoRandomHex returns hex encoded random string generated with crypto-strong
// pseudo random generator of the given bytes | [
"CryptoRandomHex",
"returns",
"hex",
"encoded",
"random",
"string",
"generated",
"with",
"crypto",
"-",
"strong",
"pseudo",
"random",
"generator",
"of",
"the",
"given",
"bytes"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/rand.go#L30-L36 | train |
gravitational/teleport | lib/utils/rand.go | RandomDuration | func RandomDuration(max time.Duration) time.Duration {
randomVal, err := rand.Int(rand.Reader, big.NewInt(int64(max)))
if err != nil {
return max / 2
}
return time.Duration(randomVal.Int64())
} | go | func RandomDuration(max time.Duration) time.Duration {
randomVal, err := rand.Int(rand.Reader, big.NewInt(int64(max)))
if err != nil {
return max / 2
}
return time.Duration(randomVal.Int64())
} | [
"func",
"RandomDuration",
"(",
"max",
"time",
".",
"Duration",
")",
"time",
".",
"Duration",
"{",
"randomVal",
",",
"err",
":=",
"rand",
".",
"Int",
"(",
"rand",
".",
"Reader",
",",
"big",
".",
"NewInt",
"(",
"int64",
"(",
"max",
")",
")",
")",
"\n... | // RandomDuration returns a duration in a range [0, max) | [
"RandomDuration",
"returns",
"a",
"duration",
"in",
"a",
"range",
"[",
"0",
"max",
")"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/rand.go#L39-L45 | train |
gravitational/teleport | lib/services/suite/suite.go | NewServer | func NewServer(kind, name, addr, namespace string) *services.ServerV2 {
return &services.ServerV2{
Kind: kind,
Version: services.V2,
Metadata: services.Metadata{
Name: name,
Namespace: namespace,
},
Spec: services.ServerSpecV2{
Addr: addr,
PublicAddr: addr,
},
}
} | go | func NewServer(kind, name, addr, namespace string) *services.ServerV2 {
return &services.ServerV2{
Kind: kind,
Version: services.V2,
Metadata: services.Metadata{
Name: name,
Namespace: namespace,
},
Spec: services.ServerSpecV2{
Addr: addr,
PublicAddr: addr,
},
}
} | [
"func",
"NewServer",
"(",
"kind",
",",
"name",
",",
"addr",
",",
"namespace",
"string",
")",
"*",
"services",
".",
"ServerV2",
"{",
"return",
"&",
"services",
".",
"ServerV2",
"{",
"Kind",
":",
"kind",
",",
"Version",
":",
"services",
".",
"V2",
",",
... | // NewServer creates a new server resource | [
"NewServer",
"creates",
"a",
"new",
"server",
"resource"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/suite/suite.go#L302-L315 | train |
gravitational/teleport | lib/services/suite/suite.go | AuthPreference | func (s *ServicesTestSuite) AuthPreference(c *check.C) {
ap, err := services.NewAuthPreference(services.AuthPreferenceSpecV2{
Type: "local",
SecondFactor: "otp",
})
c.Assert(err, check.IsNil)
err = s.ConfigS.SetAuthPreference(ap)
c.Assert(err, check.IsNil)
gotAP, err := s.ConfigS.GetAuthPreference()... | go | func (s *ServicesTestSuite) AuthPreference(c *check.C) {
ap, err := services.NewAuthPreference(services.AuthPreferenceSpecV2{
Type: "local",
SecondFactor: "otp",
})
c.Assert(err, check.IsNil)
err = s.ConfigS.SetAuthPreference(ap)
c.Assert(err, check.IsNil)
gotAP, err := s.ConfigS.GetAuthPreference()... | [
"func",
"(",
"s",
"*",
"ServicesTestSuite",
")",
"AuthPreference",
"(",
"c",
"*",
"check",
".",
"C",
")",
"{",
"ap",
",",
"err",
":=",
"services",
".",
"NewAuthPreference",
"(",
"services",
".",
"AuthPreferenceSpecV2",
"{",
"Type",
":",
"\"",
"\"",
",",
... | // AuthPreference tests authentication preference service | [
"AuthPreference",
"tests",
"authentication",
"preference",
"service"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/suite/suite.go#L890-L905 | train |
gravitational/teleport | lib/services/suite/suite.go | CollectOptions | func CollectOptions(opts ...SuiteOption) SuiteOptions {
var suiteOpts SuiteOptions
for _, o := range opts {
o(&suiteOpts)
}
return suiteOpts
} | go | func CollectOptions(opts ...SuiteOption) SuiteOptions {
var suiteOpts SuiteOptions
for _, o := range opts {
o(&suiteOpts)
}
return suiteOpts
} | [
"func",
"CollectOptions",
"(",
"opts",
"...",
"SuiteOption",
")",
"SuiteOptions",
"{",
"var",
"suiteOpts",
"SuiteOptions",
"\n",
"for",
"_",
",",
"o",
":=",
"range",
"opts",
"{",
"o",
"(",
"&",
"suiteOpts",
")",
"\n",
"}",
"\n",
"return",
"suiteOpts",
"\... | // CollectOptions collects suite options | [
"CollectOptions",
"collects",
"suite",
"options"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/suite/suite.go#L953-L959 | train |
gravitational/teleport | lib/services/suite/suite.go | ClusterConfig | func (s *ServicesTestSuite) ClusterConfig(c *check.C, opts ...SuiteOption) {
config, err := services.NewClusterConfig(services.ClusterConfigSpecV3{
ClientIdleTimeout: services.NewDuration(17 * time.Second),
DisconnectExpiredCert: services.NewBool(true),
ClusterID: "27",
SessionRecording: s... | go | func (s *ServicesTestSuite) ClusterConfig(c *check.C, opts ...SuiteOption) {
config, err := services.NewClusterConfig(services.ClusterConfigSpecV3{
ClientIdleTimeout: services.NewDuration(17 * time.Second),
DisconnectExpiredCert: services.NewBool(true),
ClusterID: "27",
SessionRecording: s... | [
"func",
"(",
"s",
"*",
"ServicesTestSuite",
")",
"ClusterConfig",
"(",
"c",
"*",
"check",
".",
"C",
",",
"opts",
"...",
"SuiteOption",
")",
"{",
"config",
",",
"err",
":=",
"services",
".",
"NewClusterConfig",
"(",
"services",
".",
"ClusterConfigSpecV3",
"... | // ClusterConfig tests cluster configuration | [
"ClusterConfig",
"tests",
"cluster",
"configuration"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/suite/suite.go#L962-L1023 | train |
gravitational/teleport | lib/services/suite/suite.go | EventsClusterConfig | func (s *ServicesTestSuite) EventsClusterConfig(c *check.C) {
testCases := []eventTest{
{
name: "Cluster config",
kind: services.WatchKind{
Kind: services.KindClusterConfig,
},
crud: func() services.Resource {
config, err := services.NewClusterConfig(services.ClusterConfigSpecV3{})
c.Assert(e... | go | func (s *ServicesTestSuite) EventsClusterConfig(c *check.C) {
testCases := []eventTest{
{
name: "Cluster config",
kind: services.WatchKind{
Kind: services.KindClusterConfig,
},
crud: func() services.Resource {
config, err := services.NewClusterConfig(services.ClusterConfigSpecV3{})
c.Assert(e... | [
"func",
"(",
"s",
"*",
"ServicesTestSuite",
")",
"EventsClusterConfig",
"(",
"c",
"*",
"check",
".",
"C",
")",
"{",
"testCases",
":=",
"[",
"]",
"eventTest",
"{",
"{",
"name",
":",
"\"",
"\"",
",",
"kind",
":",
"services",
".",
"WatchKind",
"{",
"Kin... | // EventsClusterConfig tests cluster config resource events | [
"EventsClusterConfig",
"tests",
"cluster",
"config",
"resource",
"events"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/suite/suite.go#L1310-L1357 | train |
gravitational/teleport | lib/services/tunnelconn.go | TunnelConnectionStatus | func TunnelConnectionStatus(clock clockwork.Clock, conn TunnelConnection) string {
diff := clock.Now().Sub(conn.GetLastHeartbeat())
if diff < defaults.ReverseTunnelOfflineThreshold {
return teleport.RemoteClusterStatusOnline
}
return teleport.RemoteClusterStatusOffline
} | go | func TunnelConnectionStatus(clock clockwork.Clock, conn TunnelConnection) string {
diff := clock.Now().Sub(conn.GetLastHeartbeat())
if diff < defaults.ReverseTunnelOfflineThreshold {
return teleport.RemoteClusterStatusOnline
}
return teleport.RemoteClusterStatusOffline
} | [
"func",
"TunnelConnectionStatus",
"(",
"clock",
"clockwork",
".",
"Clock",
",",
"conn",
"TunnelConnection",
")",
"string",
"{",
"diff",
":=",
"clock",
".",
"Now",
"(",
")",
".",
"Sub",
"(",
"conn",
".",
"GetLastHeartbeat",
"(",
")",
")",
"\n",
"if",
"dif... | // IsTunnelConnectionStatus returns tunnel connection status based on the last
// heartbeat time recorded for a connection | [
"IsTunnelConnectionStatus",
"returns",
"tunnel",
"connection",
"status",
"based",
"on",
"the",
"last",
"heartbeat",
"time",
"recorded",
"for",
"a",
"connection"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnelconn.go#L78-L84 | train |
gravitational/teleport | lib/services/tunnelconn.go | MustCreateTunnelConnection | func MustCreateTunnelConnection(name string, spec TunnelConnectionSpecV2) TunnelConnection {
conn, err := NewTunnelConnection(name, spec)
if err != nil {
panic(err)
}
return conn
} | go | func MustCreateTunnelConnection(name string, spec TunnelConnectionSpecV2) TunnelConnection {
conn, err := NewTunnelConnection(name, spec)
if err != nil {
panic(err)
}
return conn
} | [
"func",
"MustCreateTunnelConnection",
"(",
"name",
"string",
",",
"spec",
"TunnelConnectionSpecV2",
")",
"TunnelConnection",
"{",
"conn",
",",
"err",
":=",
"NewTunnelConnection",
"(",
"name",
",",
"spec",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",... | // MustCreateTunnelConnection returns new connection from V2 spec or panics if
// parameters are incorrect | [
"MustCreateTunnelConnection",
"returns",
"new",
"connection",
"from",
"V2",
"spec",
"or",
"panics",
"if",
"parameters",
"are",
"incorrect"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnelconn.go#L88-L94 | train |
gravitational/teleport | lib/services/tunnelconn.go | NewTunnelConnection | func NewTunnelConnection(name string, spec TunnelConnectionSpecV2) (TunnelConnection, error) {
conn := &TunnelConnectionV2{
Kind: KindTunnelConnection,
SubKind: spec.ClusterName,
Version: V2,
Metadata: Metadata{
Name: name,
Namespace: defaults.Namespace,
},
Spec: spec,
}
if err := conn.Chec... | go | func NewTunnelConnection(name string, spec TunnelConnectionSpecV2) (TunnelConnection, error) {
conn := &TunnelConnectionV2{
Kind: KindTunnelConnection,
SubKind: spec.ClusterName,
Version: V2,
Metadata: Metadata{
Name: name,
Namespace: defaults.Namespace,
},
Spec: spec,
}
if err := conn.Chec... | [
"func",
"NewTunnelConnection",
"(",
"name",
"string",
",",
"spec",
"TunnelConnectionSpecV2",
")",
"(",
"TunnelConnection",
",",
"error",
")",
"{",
"conn",
":=",
"&",
"TunnelConnectionV2",
"{",
"Kind",
":",
"KindTunnelConnection",
",",
"SubKind",
":",
"spec",
"."... | // NewTunnelConnection returns new connection from V2 spec | [
"NewTunnelConnection",
"returns",
"new",
"connection",
"from",
"V2",
"spec"
] | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnelconn.go#L97-L112 | 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.