id
int32
0
167k
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
sequence
docstring
stringlengths
6
2.61k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
85
252
13,200
fabric8-services/fabric8-wit
account/identity.go
IdentityWithUser
func IdentityWithUser() func(db *gorm.DB) *gorm.DB { return func(db *gorm.DB) *gorm.DB { return db.Preload("User") } }
go
func IdentityWithUser() func(db *gorm.DB) *gorm.DB { return func(db *gorm.DB) *gorm.DB { return db.Preload("User") } }
[ "func", "IdentityWithUser", "(", ")", "func", "(", "db", "*", "gorm", ".", "DB", ")", "*", "gorm", ".", "DB", "{", "return", "func", "(", "db", "*", "gorm", ".", "DB", ")", "*", "gorm", ".", "DB", "{", "return", "db", ".", "Preload", "(", "\"", "\"", ")", "\n", "}", "\n", "}" ]
// IdentityWithUser is a gorm filter for preloading the User relationship.
[ "IdentityWithUser", "is", "a", "gorm", "filter", "for", "preloading", "the", "User", "relationship", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/account/identity.go#L273-L277
13,201
fabric8-services/fabric8-wit
account/identity.go
IdentityFilterByProviderType
func IdentityFilterByProviderType(providerType string) func(db *gorm.DB) *gorm.DB { return func(db *gorm.DB) *gorm.DB { return db.Where("provider_type = ?", providerType) } }
go
func IdentityFilterByProviderType(providerType string) func(db *gorm.DB) *gorm.DB { return func(db *gorm.DB) *gorm.DB { return db.Where("provider_type = ?", providerType) } }
[ "func", "IdentityFilterByProviderType", "(", "providerType", "string", ")", "func", "(", "db", "*", "gorm", ".", "DB", ")", "*", "gorm", ".", "DB", "{", "return", "func", "(", "db", "*", "gorm", ".", "DB", ")", "*", "gorm", ".", "DB", "{", "return", "db", ".", "Where", "(", "\"", "\"", ",", "providerType", ")", "\n", "}", "\n", "}" ]
// IdentityFilterByProviderType is a gorm filter by 'provider_type'
[ "IdentityFilterByProviderType", "is", "a", "gorm", "filter", "by", "provider_type" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/account/identity.go#L280-L284
13,202
fabric8-services/fabric8-wit
account/identity.go
IdentityFilterByRegistrationCompleted
func IdentityFilterByRegistrationCompleted(registrationCompleted bool) func(db *gorm.DB) *gorm.DB { return func(db *gorm.DB) *gorm.DB { return db.Where("registration_completed = ?", registrationCompleted) } }
go
func IdentityFilterByRegistrationCompleted(registrationCompleted bool) func(db *gorm.DB) *gorm.DB { return func(db *gorm.DB) *gorm.DB { return db.Where("registration_completed = ?", registrationCompleted) } }
[ "func", "IdentityFilterByRegistrationCompleted", "(", "registrationCompleted", "bool", ")", "func", "(", "db", "*", "gorm", ".", "DB", ")", "*", "gorm", ".", "DB", "{", "return", "func", "(", "db", "*", "gorm", ".", "DB", ")", "*", "gorm", ".", "DB", "{", "return", "db", ".", "Where", "(", "\"", "\"", ",", "registrationCompleted", ")", "\n", "}", "\n", "}" ]
// IdentityFilterByRegistrationCompleted is a gorm filter by 'registration_completed'
[ "IdentityFilterByRegistrationCompleted", "is", "a", "gorm", "filter", "by", "registration_completed" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/account/identity.go#L287-L291
13,203
fabric8-services/fabric8-wit
account/identity.go
List
func (m *GormIdentityRepository) List(ctx context.Context) ([]Identity, error) { defer goa.MeasureSince([]string{"goa", "db", "identity", "list"}, time.Now()) var rows []Identity err := m.db.Model(&Identity{}).Order("username").Find(&rows).Error if err != nil && err != gorm.ErrRecordNotFound { return nil, errs.WithStack(err) } log.Debug(ctx, map[string]interface{}{ "identity_list": &rows, }, "Identity List executed successfully!") return rows, nil }
go
func (m *GormIdentityRepository) List(ctx context.Context) ([]Identity, error) { defer goa.MeasureSince([]string{"goa", "db", "identity", "list"}, time.Now()) var rows []Identity err := m.db.Model(&Identity{}).Order("username").Find(&rows).Error if err != nil && err != gorm.ErrRecordNotFound { return nil, errs.WithStack(err) } log.Debug(ctx, map[string]interface{}{ "identity_list": &rows, }, "Identity List executed successfully!") return rows, nil }
[ "func", "(", "m", "*", "GormIdentityRepository", ")", "List", "(", "ctx", "context", ".", "Context", ")", "(", "[", "]", "Identity", ",", "error", ")", "{", "defer", "goa", ".", "MeasureSince", "(", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", ",", "time", ".", "Now", "(", ")", ")", "\n", "var", "rows", "[", "]", "Identity", "\n\n", "err", ":=", "m", ".", "db", ".", "Model", "(", "&", "Identity", "{", "}", ")", ".", "Order", "(", "\"", "\"", ")", ".", "Find", "(", "&", "rows", ")", ".", "Error", "\n", "if", "err", "!=", "nil", "&&", "err", "!=", "gorm", ".", "ErrRecordNotFound", "{", "return", "nil", ",", "errs", ".", "WithStack", "(", "err", ")", "\n", "}", "\n\n", "log", ".", "Debug", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "&", "rows", ",", "}", ",", "\"", "\"", ")", "\n\n", "return", "rows", ",", "nil", "\n", "}" ]
// List return all user identities
[ "List", "return", "all", "user", "identities" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/account/identity.go#L294-L308
13,204
fabric8-services/fabric8-wit
account/identity.go
Search
func (m *GormIdentityRepository) Search(ctx context.Context, q string, start int, limit int) ([]Identity, int, error) { db := m.db.Model(&Identity{}) db = db.Offset(start) db = db.Limit(limit) // FIXME : returning the identities.id just for the sake of consistency with the other User APIs. db = db.Select("count(*) over () as cnt2 ,identities.id as identity_id,identities.username,users.*") db = db.Joins("LEFT JOIN users ON identities.user_id = users.id") db = db.Where("LOWER(users.full_name) like ?", "%"+strings.ToLower(q)+"%") db = db.Or("users.email like ?", "%"+strings.ToLower(q)+"%") db = db.Or("lower(identities.username) like ?", "%"+strings.ToLower(q)+"%") db = db.Group("identities.id,identities.username,users.id") //db = db.Preload("user") rows, err := db.Rows() defer closeable.Close(ctx, rows) if err != nil { return nil, 0, err } result := []Identity{} value := Identity{} columns, err := rows.Columns() if err != nil { return nil, 0, errors.NewInternalError(ctx, err) } // need to set up a result for Scan() in order to extract total count. var count int var identityID string var identityUsername string var ignore interface{} columnValues := make([]interface{}, len(columns)) for index := range columnValues { columnValues[index] = &ignore } columnValues[0] = &count // FIXME When our User Profile endpoints start giving "user" response // instead of "identity" response, the identity.ID would be less relevant. for rows.Next() { columnValues[1] = &identityID columnValues[2] = &identityUsername db.ScanRows(rows, &value.User) if err = rows.Scan(columnValues...); err != nil { return nil, 0, errors.NewInternalError(ctx, err) } value.ID, err = uuid.FromString(identityID) if err != nil { return nil, 0, errors.NewInternalError(ctx, err) } value.Username = identityUsername result = append(result, value) } return result, count, nil }
go
func (m *GormIdentityRepository) Search(ctx context.Context, q string, start int, limit int) ([]Identity, int, error) { db := m.db.Model(&Identity{}) db = db.Offset(start) db = db.Limit(limit) // FIXME : returning the identities.id just for the sake of consistency with the other User APIs. db = db.Select("count(*) over () as cnt2 ,identities.id as identity_id,identities.username,users.*") db = db.Joins("LEFT JOIN users ON identities.user_id = users.id") db = db.Where("LOWER(users.full_name) like ?", "%"+strings.ToLower(q)+"%") db = db.Or("users.email like ?", "%"+strings.ToLower(q)+"%") db = db.Or("lower(identities.username) like ?", "%"+strings.ToLower(q)+"%") db = db.Group("identities.id,identities.username,users.id") //db = db.Preload("user") rows, err := db.Rows() defer closeable.Close(ctx, rows) if err != nil { return nil, 0, err } result := []Identity{} value := Identity{} columns, err := rows.Columns() if err != nil { return nil, 0, errors.NewInternalError(ctx, err) } // need to set up a result for Scan() in order to extract total count. var count int var identityID string var identityUsername string var ignore interface{} columnValues := make([]interface{}, len(columns)) for index := range columnValues { columnValues[index] = &ignore } columnValues[0] = &count // FIXME When our User Profile endpoints start giving "user" response // instead of "identity" response, the identity.ID would be less relevant. for rows.Next() { columnValues[1] = &identityID columnValues[2] = &identityUsername db.ScanRows(rows, &value.User) if err = rows.Scan(columnValues...); err != nil { return nil, 0, errors.NewInternalError(ctx, err) } value.ID, err = uuid.FromString(identityID) if err != nil { return nil, 0, errors.NewInternalError(ctx, err) } value.Username = identityUsername result = append(result, value) } return result, count, nil }
[ "func", "(", "m", "*", "GormIdentityRepository", ")", "Search", "(", "ctx", "context", ".", "Context", ",", "q", "string", ",", "start", "int", ",", "limit", "int", ")", "(", "[", "]", "Identity", ",", "int", ",", "error", ")", "{", "db", ":=", "m", ".", "db", ".", "Model", "(", "&", "Identity", "{", "}", ")", "\n", "db", "=", "db", ".", "Offset", "(", "start", ")", "\n", "db", "=", "db", ".", "Limit", "(", "limit", ")", "\n", "// FIXME : returning the identities.id just for the sake of consistency with the other User APIs.", "db", "=", "db", ".", "Select", "(", "\"", "\"", ")", "\n", "db", "=", "db", ".", "Joins", "(", "\"", "\"", ")", "\n", "db", "=", "db", ".", "Where", "(", "\"", "\"", ",", "\"", "\"", "+", "strings", ".", "ToLower", "(", "q", ")", "+", "\"", "\"", ")", "\n", "db", "=", "db", ".", "Or", "(", "\"", "\"", ",", "\"", "\"", "+", "strings", ".", "ToLower", "(", "q", ")", "+", "\"", "\"", ")", "\n", "db", "=", "db", ".", "Or", "(", "\"", "\"", ",", "\"", "\"", "+", "strings", ".", "ToLower", "(", "q", ")", "+", "\"", "\"", ")", "\n", "db", "=", "db", ".", "Group", "(", "\"", "\"", ")", "\n", "//db = db.Preload(\"user\")", "rows", ",", "err", ":=", "db", ".", "Rows", "(", ")", "\n", "defer", "closeable", ".", "Close", "(", "ctx", ",", "rows", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "0", ",", "err", "\n", "}", "\n\n", "result", ":=", "[", "]", "Identity", "{", "}", "\n", "value", ":=", "Identity", "{", "}", "\n", "columns", ",", "err", ":=", "rows", ".", "Columns", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "0", ",", "errors", ".", "NewInternalError", "(", "ctx", ",", "err", ")", "\n", "}", "\n\n", "// need to set up a result for Scan() in order to extract total count.", "var", "count", "int", "\n", "var", "identityID", "string", "\n", "var", "identityUsername", "string", "\n", "var", "ignore", "interface", "{", "}", "\n", "columnValues", ":=", "make", "(", "[", "]", "interface", "{", "}", ",", "len", "(", "columns", ")", ")", "\n\n", "for", "index", ":=", "range", "columnValues", "{", "columnValues", "[", "index", "]", "=", "&", "ignore", "\n", "}", "\n", "columnValues", "[", "0", "]", "=", "&", "count", "\n", "// FIXME When our User Profile endpoints start giving \"user\" response", "// instead of \"identity\" response, the identity.ID would be less relevant.", "for", "rows", ".", "Next", "(", ")", "{", "columnValues", "[", "1", "]", "=", "&", "identityID", "\n", "columnValues", "[", "2", "]", "=", "&", "identityUsername", "\n", "db", ".", "ScanRows", "(", "rows", ",", "&", "value", ".", "User", ")", "\n\n", "if", "err", "=", "rows", ".", "Scan", "(", "columnValues", "...", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "0", ",", "errors", ".", "NewInternalError", "(", "ctx", ",", "err", ")", "\n", "}", "\n\n", "value", ".", "ID", ",", "err", "=", "uuid", ".", "FromString", "(", "identityID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "0", ",", "errors", ".", "NewInternalError", "(", "ctx", ",", "err", ")", "\n", "}", "\n\n", "value", ".", "Username", "=", "identityUsername", "\n\n", "result", "=", "append", "(", "result", ",", "value", ")", "\n", "}", "\n\n", "return", "result", ",", "count", ",", "nil", "\n", "}" ]
// Search searches for Identites where FullName like %q% or users.email like %q% or users.username like %q%
[ "Search", "searches", "for", "Identites", "where", "FullName", "like", "%q%", "or", "users", ".", "email", "like", "%q%", "or", "users", ".", "username", "like", "%q%" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/account/identity.go#L316-L377
13,205
fabric8-services/fabric8-wit
design/jsonapi_helpers.go
JSONResourceObject
func JSONResourceObject(name string, attributes *d.UserTypeDefinition, relationships *d.UserTypeDefinition) *d.UserTypeDefinition { return a.Type(name, func() { a.Attribute("type", d.String, func() { a.Enum(strings.ToLower(name) + "s") }) a.Attribute("id", d.String, "ID of the "+name, func() { a.Example("42") }) a.Attribute("attributes", attributes) if relationships != nil { a.Attribute("relationships", relationships) } a.Required("type", "id", "attributes") }) }
go
func JSONResourceObject(name string, attributes *d.UserTypeDefinition, relationships *d.UserTypeDefinition) *d.UserTypeDefinition { return a.Type(name, func() { a.Attribute("type", d.String, func() { a.Enum(strings.ToLower(name) + "s") }) a.Attribute("id", d.String, "ID of the "+name, func() { a.Example("42") }) a.Attribute("attributes", attributes) if relationships != nil { a.Attribute("relationships", relationships) } a.Required("type", "id", "attributes") }) }
[ "func", "JSONResourceObject", "(", "name", "string", ",", "attributes", "*", "d", ".", "UserTypeDefinition", ",", "relationships", "*", "d", ".", "UserTypeDefinition", ")", "*", "d", ".", "UserTypeDefinition", "{", "return", "a", ".", "Type", "(", "name", ",", "func", "(", ")", "{", "a", ".", "Attribute", "(", "\"", "\"", ",", "d", ".", "String", ",", "func", "(", ")", "{", "a", ".", "Enum", "(", "strings", ".", "ToLower", "(", "name", ")", "+", "\"", "\"", ")", "\n", "}", ")", "\n", "a", ".", "Attribute", "(", "\"", "\"", ",", "d", ".", "String", ",", "\"", "\"", "+", "name", ",", "func", "(", ")", "{", "a", ".", "Example", "(", "\"", "\"", ")", "\n", "}", ")", "\n", "a", ".", "Attribute", "(", "\"", "\"", ",", "attributes", ")", "\n", "if", "relationships", "!=", "nil", "{", "a", ".", "Attribute", "(", "\"", "\"", ",", "relationships", ")", "\n", "}", "\n", "a", ".", "Required", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "}", ")", "\n", "}" ]
// JSONResourceObject creates a single resource object
[ "JSONResourceObject", "creates", "a", "single", "resource", "object" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/design/jsonapi_helpers.go#L115-L129
13,206
fabric8-services/fabric8-wit
design/jsonapi_helpers.go
JSONList
func JSONList(name, description string, data *d.UserTypeDefinition, links *d.UserTypeDefinition, meta *d.UserTypeDefinition) *d.MediaTypeDefinition { return a.MediaType("application/vnd."+strings.ToLower(name)+"list+json", func() { a.UseTrait("jsonapi-media-type") a.TypeName(name + "List") a.Description(description) if links != nil { a.Attribute("links", links) } if meta != nil { a.Attribute("meta", meta) } a.Attribute("data", a.ArrayOf(data)) a.Attribute("included", a.ArrayOf(d.Any), "An array of mixed types") a.Required("data") a.View("default", func() { if links != nil { a.Attribute("links") } if meta != nil { a.Attribute("meta") } a.Attribute("data") a.Attribute("included") a.Required("data") }) }) }
go
func JSONList(name, description string, data *d.UserTypeDefinition, links *d.UserTypeDefinition, meta *d.UserTypeDefinition) *d.MediaTypeDefinition { return a.MediaType("application/vnd."+strings.ToLower(name)+"list+json", func() { a.UseTrait("jsonapi-media-type") a.TypeName(name + "List") a.Description(description) if links != nil { a.Attribute("links", links) } if meta != nil { a.Attribute("meta", meta) } a.Attribute("data", a.ArrayOf(data)) a.Attribute("included", a.ArrayOf(d.Any), "An array of mixed types") a.Required("data") a.View("default", func() { if links != nil { a.Attribute("links") } if meta != nil { a.Attribute("meta") } a.Attribute("data") a.Attribute("included") a.Required("data") }) }) }
[ "func", "JSONList", "(", "name", ",", "description", "string", ",", "data", "*", "d", ".", "UserTypeDefinition", ",", "links", "*", "d", ".", "UserTypeDefinition", ",", "meta", "*", "d", ".", "UserTypeDefinition", ")", "*", "d", ".", "MediaTypeDefinition", "{", "return", "a", ".", "MediaType", "(", "\"", "\"", "+", "strings", ".", "ToLower", "(", "name", ")", "+", "\"", "\"", ",", "func", "(", ")", "{", "a", ".", "UseTrait", "(", "\"", "\"", ")", "\n", "a", ".", "TypeName", "(", "name", "+", "\"", "\"", ")", "\n", "a", ".", "Description", "(", "description", ")", "\n", "if", "links", "!=", "nil", "{", "a", ".", "Attribute", "(", "\"", "\"", ",", "links", ")", "\n", "}", "\n", "if", "meta", "!=", "nil", "{", "a", ".", "Attribute", "(", "\"", "\"", ",", "meta", ")", "\n", "}", "\n", "a", ".", "Attribute", "(", "\"", "\"", ",", "a", ".", "ArrayOf", "(", "data", ")", ")", "\n", "a", ".", "Attribute", "(", "\"", "\"", ",", "a", ".", "ArrayOf", "(", "d", ".", "Any", ")", ",", "\"", "\"", ")", "\n", "a", ".", "Required", "(", "\"", "\"", ")", "\n\n", "a", ".", "View", "(", "\"", "\"", ",", "func", "(", ")", "{", "if", "links", "!=", "nil", "{", "a", ".", "Attribute", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "meta", "!=", "nil", "{", "a", ".", "Attribute", "(", "\"", "\"", ")", "\n", "}", "\n", "a", ".", "Attribute", "(", "\"", "\"", ")", "\n", "a", ".", "Attribute", "(", "\"", "\"", ")", "\n", "a", ".", "Required", "(", "\"", "\"", ")", "\n", "}", ")", "\n", "}", ")", "\n\n", "}" ]
// JSONList creates a UserTypeDefinition
[ "JSONList", "creates", "a", "UserTypeDefinition" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/design/jsonapi_helpers.go#L132-L160
13,207
fabric8-services/fabric8-wit
workitem/link/type_repository.go
Create
func (r *GormWorkItemLinkTypeRepository) Create(ctx context.Context, linkType WorkItemLinkType) (*WorkItemLinkType, error) { defer goa.MeasureSince([]string{"goa", "db", "workitemlinktype", "create"}, time.Now()) if err := linkType.CheckValidForCreation(); err != nil { log.Error(ctx, map[string]interface{}{ "wilt_id": linkType.ID.String(), "err": err, }, "failed to validate link type") return nil, errs.WithStack(err) } db := r.db.Create(&linkType) if db.Error != nil { if gormsupport.IsUniqueViolation(db.Error, "work_item_link_types_name_idx") { log.Error(ctx, map[string]interface{}{ "err": db.Error, "space_template_id": linkType.SpaceTemplateID, "wilt_name": linkType.Name, }, "unable to create work item link type because a link already exists with the same space_template_id and name") return nil, errors.NewDataConflictError(fmt.Sprintf("work item link type already exists with the same space_template_id: %s; name: %s ", linkType.SpaceTemplateID, linkType.Name)) } log.Error(ctx, map[string]interface{}{ "wilt_id": linkType.ID.String(), "err": db.Error, }, "failed to create work item link type") return nil, errors.NewInternalError(ctx, errs.Wrap(db.Error, "failed to create link type")) } log.Info(ctx, map[string]interface{}{ "wilt_id": linkType.ID.String(), }, "created work item link type") return &linkType, nil }
go
func (r *GormWorkItemLinkTypeRepository) Create(ctx context.Context, linkType WorkItemLinkType) (*WorkItemLinkType, error) { defer goa.MeasureSince([]string{"goa", "db", "workitemlinktype", "create"}, time.Now()) if err := linkType.CheckValidForCreation(); err != nil { log.Error(ctx, map[string]interface{}{ "wilt_id": linkType.ID.String(), "err": err, }, "failed to validate link type") return nil, errs.WithStack(err) } db := r.db.Create(&linkType) if db.Error != nil { if gormsupport.IsUniqueViolation(db.Error, "work_item_link_types_name_idx") { log.Error(ctx, map[string]interface{}{ "err": db.Error, "space_template_id": linkType.SpaceTemplateID, "wilt_name": linkType.Name, }, "unable to create work item link type because a link already exists with the same space_template_id and name") return nil, errors.NewDataConflictError(fmt.Sprintf("work item link type already exists with the same space_template_id: %s; name: %s ", linkType.SpaceTemplateID, linkType.Name)) } log.Error(ctx, map[string]interface{}{ "wilt_id": linkType.ID.String(), "err": db.Error, }, "failed to create work item link type") return nil, errors.NewInternalError(ctx, errs.Wrap(db.Error, "failed to create link type")) } log.Info(ctx, map[string]interface{}{ "wilt_id": linkType.ID.String(), }, "created work item link type") return &linkType, nil }
[ "func", "(", "r", "*", "GormWorkItemLinkTypeRepository", ")", "Create", "(", "ctx", "context", ".", "Context", ",", "linkType", "WorkItemLinkType", ")", "(", "*", "WorkItemLinkType", ",", "error", ")", "{", "defer", "goa", ".", "MeasureSince", "(", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", ",", "time", ".", "Now", "(", ")", ")", "\n", "if", "err", ":=", "linkType", ".", "CheckValidForCreation", "(", ")", ";", "err", "!=", "nil", "{", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "linkType", ".", "ID", ".", "String", "(", ")", ",", "\"", "\"", ":", "err", ",", "}", ",", "\"", "\"", ")", "\n", "return", "nil", ",", "errs", ".", "WithStack", "(", "err", ")", "\n", "}", "\n", "db", ":=", "r", ".", "db", ".", "Create", "(", "&", "linkType", ")", "\n", "if", "db", ".", "Error", "!=", "nil", "{", "if", "gormsupport", ".", "IsUniqueViolation", "(", "db", ".", "Error", ",", "\"", "\"", ")", "{", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "db", ".", "Error", ",", "\"", "\"", ":", "linkType", ".", "SpaceTemplateID", ",", "\"", "\"", ":", "linkType", ".", "Name", ",", "}", ",", "\"", "\"", ")", "\n", "return", "nil", ",", "errors", ".", "NewDataConflictError", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "linkType", ".", "SpaceTemplateID", ",", "linkType", ".", "Name", ")", ")", "\n", "}", "\n", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "linkType", ".", "ID", ".", "String", "(", ")", ",", "\"", "\"", ":", "db", ".", "Error", ",", "}", ",", "\"", "\"", ")", "\n", "return", "nil", ",", "errors", ".", "NewInternalError", "(", "ctx", ",", "errs", ".", "Wrap", "(", "db", ".", "Error", ",", "\"", "\"", ")", ")", "\n", "}", "\n", "log", ".", "Info", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "linkType", ".", "ID", ".", "String", "(", ")", ",", "}", ",", "\"", "\"", ")", "\n", "return", "&", "linkType", ",", "nil", "\n", "}" ]
// Create creates a new work item link type in the repository. // Returns BadParameterError, ConversionError or InternalError
[ "Create", "creates", "a", "new", "work", "item", "link", "type", "in", "the", "repository", ".", "Returns", "BadParameterError", "ConversionError", "or", "InternalError" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/link/type_repository.go#L40-L69
13,208
fabric8-services/fabric8-wit
workitem/link/type_repository.go
Load
func (r *GormWorkItemLinkTypeRepository) Load(ctx context.Context, ID uuid.UUID) (*WorkItemLinkType, error) { defer goa.MeasureSince([]string{"goa", "db", "workitemlinktype", "load"}, time.Now()) log.Info(ctx, map[string]interface{}{ "wilt_id": ID, }, "loading work item link type") modelLinkType := WorkItemLinkType{} db := r.db.Model(&modelLinkType).Where("id=?", ID).First(&modelLinkType) if db.RecordNotFound() { log.Error(ctx, map[string]interface{}{ "wilt_id": ID, }, "work item link type not found") return nil, errors.NewNotFoundError("work item link type", ID.String()) } if db.Error != nil { log.Error(ctx, map[string]interface{}{ "wilt_id": ID, "err": db.Error, }, "failed to create work item link type") return nil, errors.NewInternalError(ctx, db.Error) } return &modelLinkType, nil }
go
func (r *GormWorkItemLinkTypeRepository) Load(ctx context.Context, ID uuid.UUID) (*WorkItemLinkType, error) { defer goa.MeasureSince([]string{"goa", "db", "workitemlinktype", "load"}, time.Now()) log.Info(ctx, map[string]interface{}{ "wilt_id": ID, }, "loading work item link type") modelLinkType := WorkItemLinkType{} db := r.db.Model(&modelLinkType).Where("id=?", ID).First(&modelLinkType) if db.RecordNotFound() { log.Error(ctx, map[string]interface{}{ "wilt_id": ID, }, "work item link type not found") return nil, errors.NewNotFoundError("work item link type", ID.String()) } if db.Error != nil { log.Error(ctx, map[string]interface{}{ "wilt_id": ID, "err": db.Error, }, "failed to create work item link type") return nil, errors.NewInternalError(ctx, db.Error) } return &modelLinkType, nil }
[ "func", "(", "r", "*", "GormWorkItemLinkTypeRepository", ")", "Load", "(", "ctx", "context", ".", "Context", ",", "ID", "uuid", ".", "UUID", ")", "(", "*", "WorkItemLinkType", ",", "error", ")", "{", "defer", "goa", ".", "MeasureSince", "(", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", ",", "time", ".", "Now", "(", ")", ")", "\n", "log", ".", "Info", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "ID", ",", "}", ",", "\"", "\"", ")", "\n", "modelLinkType", ":=", "WorkItemLinkType", "{", "}", "\n", "db", ":=", "r", ".", "db", ".", "Model", "(", "&", "modelLinkType", ")", ".", "Where", "(", "\"", "\"", ",", "ID", ")", ".", "First", "(", "&", "modelLinkType", ")", "\n", "if", "db", ".", "RecordNotFound", "(", ")", "{", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "ID", ",", "}", ",", "\"", "\"", ")", "\n", "return", "nil", ",", "errors", ".", "NewNotFoundError", "(", "\"", "\"", ",", "ID", ".", "String", "(", ")", ")", "\n", "}", "\n", "if", "db", ".", "Error", "!=", "nil", "{", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "ID", ",", "\"", "\"", ":", "db", ".", "Error", ",", "}", ",", "\"", "\"", ")", "\n", "return", "nil", ",", "errors", ".", "NewInternalError", "(", "ctx", ",", "db", ".", "Error", ")", "\n", "}", "\n", "return", "&", "modelLinkType", ",", "nil", "\n", "}" ]
// Load returns the work item link type for the given ID. // Returns NotFoundError, ConversionError or InternalError
[ "Load", "returns", "the", "work", "item", "link", "type", "for", "the", "given", "ID", ".", "Returns", "NotFoundError", "ConversionError", "or", "InternalError" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/link/type_repository.go#L73-L94
13,209
fabric8-services/fabric8-wit
workitem/link/type_repository.go
List
func (r *GormWorkItemLinkTypeRepository) List(ctx context.Context, spaceTemplateID uuid.UUID) ([]WorkItemLinkType, error) { defer goa.MeasureSince([]string{"goa", "db", "workitemlinktype", "list"}, time.Now()) log.Info(ctx, map[string]interface{}{ "space_template_id": spaceTemplateID, }, "Listing work item link types by space template ID %s", spaceTemplateID) // check space template exists if err := spacetemplate.NewRepository(r.db).CheckExists(ctx, spaceTemplateID); err != nil { return nil, errors.NewNotFoundError("space template", spaceTemplateID.String()) } // We don't have any where clause or paging at the moment. var modelLinkTypes []WorkItemLinkType db := r.db.Where("space_template_id IN (?, ?)", spaceTemplateID, spacetemplate.SystemBaseTemplateID).Order("name") if err := db.Find(&modelLinkTypes).Error; err != nil { log.Error(ctx, map[string]interface{}{ "err": err, "space_template_id": spaceTemplateID, }, "failed to list work item link types") return nil, errs.Wrapf(err, "failed to find link types") } return modelLinkTypes, nil }
go
func (r *GormWorkItemLinkTypeRepository) List(ctx context.Context, spaceTemplateID uuid.UUID) ([]WorkItemLinkType, error) { defer goa.MeasureSince([]string{"goa", "db", "workitemlinktype", "list"}, time.Now()) log.Info(ctx, map[string]interface{}{ "space_template_id": spaceTemplateID, }, "Listing work item link types by space template ID %s", spaceTemplateID) // check space template exists if err := spacetemplate.NewRepository(r.db).CheckExists(ctx, spaceTemplateID); err != nil { return nil, errors.NewNotFoundError("space template", spaceTemplateID.String()) } // We don't have any where clause or paging at the moment. var modelLinkTypes []WorkItemLinkType db := r.db.Where("space_template_id IN (?, ?)", spaceTemplateID, spacetemplate.SystemBaseTemplateID).Order("name") if err := db.Find(&modelLinkTypes).Error; err != nil { log.Error(ctx, map[string]interface{}{ "err": err, "space_template_id": spaceTemplateID, }, "failed to list work item link types") return nil, errs.Wrapf(err, "failed to find link types") } return modelLinkTypes, nil }
[ "func", "(", "r", "*", "GormWorkItemLinkTypeRepository", ")", "List", "(", "ctx", "context", ".", "Context", ",", "spaceTemplateID", "uuid", ".", "UUID", ")", "(", "[", "]", "WorkItemLinkType", ",", "error", ")", "{", "defer", "goa", ".", "MeasureSince", "(", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", ",", "time", ".", "Now", "(", ")", ")", "\n", "log", ".", "Info", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "spaceTemplateID", ",", "}", ",", "\"", "\"", ",", "spaceTemplateID", ")", "\n\n", "// check space template exists", "if", "err", ":=", "spacetemplate", ".", "NewRepository", "(", "r", ".", "db", ")", ".", "CheckExists", "(", "ctx", ",", "spaceTemplateID", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "NewNotFoundError", "(", "\"", "\"", ",", "spaceTemplateID", ".", "String", "(", ")", ")", "\n", "}", "\n\n", "// We don't have any where clause or paging at the moment.", "var", "modelLinkTypes", "[", "]", "WorkItemLinkType", "\n", "db", ":=", "r", ".", "db", ".", "Where", "(", "\"", "\"", ",", "spaceTemplateID", ",", "spacetemplate", ".", "SystemBaseTemplateID", ")", ".", "Order", "(", "\"", "\"", ")", "\n", "if", "err", ":=", "db", ".", "Find", "(", "&", "modelLinkTypes", ")", ".", "Error", ";", "err", "!=", "nil", "{", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "err", ",", "\"", "\"", ":", "spaceTemplateID", ",", "}", ",", "\"", "\"", ")", "\n", "return", "nil", ",", "errs", ".", "Wrapf", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "return", "modelLinkTypes", ",", "nil", "\n", "}" ]
// List returns all work item link types
[ "List", "returns", "all", "work", "item", "link", "types" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/link/type_repository.go#L103-L125
13,210
fabric8-services/fabric8-wit
auth/resource.go
CreateSpace
func (m *AuthzResourceManager) CreateSpace(ctx context.Context, request *http.Request, spaceID string) error { if !m.configuration.IsAuthorizationEnabled() { // Keycloak authorization is disabled by default in Developer Mode log.Warn(ctx, map[string]interface{}{ "space_id": spaceID, }, "Authorization is disabled. Keycloak space resource won't be created") return nil } c, err := CreateClient(ctx, m.configuration) if err != nil { return err } sUD, err := goauuid.FromString(spaceID) if err != nil { return err } res, err := c.CreateSpace(goasupport.ForwardContextRequestID(ctx), authservice.CreateSpacePath(sUD)) if err != nil { log.Error(ctx, map[string]interface{}{ "space_id": spaceID, "err": err.Error(), }, "unable to create a space resource via auth service") return errs.Wrap(err, "unable to create a space resource via auth service") } defer rest.CloseResponse(res) if res.StatusCode != http.StatusOK { responseBody := rest.ReadBody(res.Body) log.Error(ctx, map[string]interface{}{ "space_id": spaceID, "response_status": res.Status, "response_body": responseBody, }, "unable to create a space resource via auth service") // Proxy-back back the response as is - // WIT acts as a gateway to Auth, who would send the appropriate response. return proxy.ConvertHTTPErrorCode(res.StatusCode, responseBody) } return nil }
go
func (m *AuthzResourceManager) CreateSpace(ctx context.Context, request *http.Request, spaceID string) error { if !m.configuration.IsAuthorizationEnabled() { // Keycloak authorization is disabled by default in Developer Mode log.Warn(ctx, map[string]interface{}{ "space_id": spaceID, }, "Authorization is disabled. Keycloak space resource won't be created") return nil } c, err := CreateClient(ctx, m.configuration) if err != nil { return err } sUD, err := goauuid.FromString(spaceID) if err != nil { return err } res, err := c.CreateSpace(goasupport.ForwardContextRequestID(ctx), authservice.CreateSpacePath(sUD)) if err != nil { log.Error(ctx, map[string]interface{}{ "space_id": spaceID, "err": err.Error(), }, "unable to create a space resource via auth service") return errs.Wrap(err, "unable to create a space resource via auth service") } defer rest.CloseResponse(res) if res.StatusCode != http.StatusOK { responseBody := rest.ReadBody(res.Body) log.Error(ctx, map[string]interface{}{ "space_id": spaceID, "response_status": res.Status, "response_body": responseBody, }, "unable to create a space resource via auth service") // Proxy-back back the response as is - // WIT acts as a gateway to Auth, who would send the appropriate response. return proxy.ConvertHTTPErrorCode(res.StatusCode, responseBody) } return nil }
[ "func", "(", "m", "*", "AuthzResourceManager", ")", "CreateSpace", "(", "ctx", "context", ".", "Context", ",", "request", "*", "http", ".", "Request", ",", "spaceID", "string", ")", "error", "{", "if", "!", "m", ".", "configuration", ".", "IsAuthorizationEnabled", "(", ")", "{", "// Keycloak authorization is disabled by default in Developer Mode", "log", ".", "Warn", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "spaceID", ",", "}", ",", "\"", "\"", ")", "\n", "return", "nil", "\n", "}", "\n\n", "c", ",", "err", ":=", "CreateClient", "(", "ctx", ",", "m", ".", "configuration", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "sUD", ",", "err", ":=", "goauuid", ".", "FromString", "(", "spaceID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "res", ",", "err", ":=", "c", ".", "CreateSpace", "(", "goasupport", ".", "ForwardContextRequestID", "(", "ctx", ")", ",", "authservice", ".", "CreateSpacePath", "(", "sUD", ")", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "spaceID", ",", "\"", "\"", ":", "err", ".", "Error", "(", ")", ",", "}", ",", "\"", "\"", ")", "\n", "return", "errs", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "defer", "rest", ".", "CloseResponse", "(", "res", ")", "\n\n", "if", "res", ".", "StatusCode", "!=", "http", ".", "StatusOK", "{", "responseBody", ":=", "rest", ".", "ReadBody", "(", "res", ".", "Body", ")", "\n", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "spaceID", ",", "\"", "\"", ":", "res", ".", "Status", ",", "\"", "\"", ":", "responseBody", ",", "}", ",", "\"", "\"", ")", "\n", "// Proxy-back back the response as is -", "// WIT acts as a gateway to Auth, who would send the appropriate response.", "return", "proxy", ".", "ConvertHTTPErrorCode", "(", "res", ".", "StatusCode", ",", "responseBody", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// CreateSpace calls auth service to create a keycloak resource associated with the space
[ "CreateSpace", "calls", "auth", "service", "to", "create", "a", "keycloak", "resource", "associated", "with", "the", "space" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/auth/resource.go#L42-L82
13,211
fabric8-services/fabric8-wit
iteration/iteration.go
FullPath
func (m *Iteration) FullPath() string { return m.Path.String() + path.SepInService + m.ID.String() }
go
func (m *Iteration) FullPath() string { return m.Path.String() + path.SepInService + m.ID.String() }
[ "func", "(", "m", "*", "Iteration", ")", "FullPath", "(", ")", "string", "{", "return", "m", ".", "Path", ".", "String", "(", ")", "+", "path", ".", "SepInService", "+", "m", ".", "ID", ".", "String", "(", ")", "\n", "}" ]
// FullPath returns the Path by appending self ID to it.
[ "FullPath", "returns", "the", "Path", "by", "appending", "self", "ID", "to", "it", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/iteration/iteration.go#L58-L60
13,212
fabric8-services/fabric8-wit
iteration/iteration.go
IsRoot
func (m Iteration) IsRoot(spaceID uuid.UUID) bool { return m.SpaceID == spaceID && len(m.Path) == 1 && m.Path[0] == m.ID }
go
func (m Iteration) IsRoot(spaceID uuid.UUID) bool { return m.SpaceID == spaceID && len(m.Path) == 1 && m.Path[0] == m.ID }
[ "func", "(", "m", "Iteration", ")", "IsRoot", "(", "spaceID", "uuid", ".", "UUID", ")", "bool", "{", "return", "m", ".", "SpaceID", "==", "spaceID", "&&", "len", "(", "m", ".", "Path", ")", "==", "1", "&&", "m", ".", "Path", "[", "0", "]", "==", "m", ".", "ID", "\n", "}" ]
// IsRoot Checks if given iteration is a root iteration or not
[ "IsRoot", "Checks", "if", "given", "iteration", "is", "a", "root", "iteration", "or", "not" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/iteration/iteration.go#L81-L83
13,213
fabric8-services/fabric8-wit
iteration/iteration.go
List
func (m *GormIterationRepository) List(ctx context.Context, spaceID uuid.UUID) ([]Iteration, error) { defer goa.MeasureSince([]string{"goa", "db", "iteration", "query"}, time.Now()) var objs []Iteration err := m.db.Where("space_id = ?", spaceID).Find(&objs).Error if err != nil && err != gorm.ErrRecordNotFound { log.Error(ctx, map[string]interface{}{ "space_id": spaceID, "err": err, }, "unable to list the iterations") return nil, errs.WithStack(err) } return objs, nil }
go
func (m *GormIterationRepository) List(ctx context.Context, spaceID uuid.UUID) ([]Iteration, error) { defer goa.MeasureSince([]string{"goa", "db", "iteration", "query"}, time.Now()) var objs []Iteration err := m.db.Where("space_id = ?", spaceID).Find(&objs).Error if err != nil && err != gorm.ErrRecordNotFound { log.Error(ctx, map[string]interface{}{ "space_id": spaceID, "err": err, }, "unable to list the iterations") return nil, errs.WithStack(err) } return objs, nil }
[ "func", "(", "m", "*", "GormIterationRepository", ")", "List", "(", "ctx", "context", ".", "Context", ",", "spaceID", "uuid", ".", "UUID", ")", "(", "[", "]", "Iteration", ",", "error", ")", "{", "defer", "goa", ".", "MeasureSince", "(", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", ",", "time", ".", "Now", "(", ")", ")", "\n", "var", "objs", "[", "]", "Iteration", "\n\n", "err", ":=", "m", ".", "db", ".", "Where", "(", "\"", "\"", ",", "spaceID", ")", ".", "Find", "(", "&", "objs", ")", ".", "Error", "\n", "if", "err", "!=", "nil", "&&", "err", "!=", "gorm", ".", "ErrRecordNotFound", "{", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "spaceID", ",", "\"", "\"", ":", "err", ",", "}", ",", "\"", "\"", ")", "\n", "return", "nil", ",", "errs", ".", "WithStack", "(", "err", ")", "\n", "}", "\n", "return", "objs", ",", "nil", "\n", "}" ]
// List all Iterations related to a single item
[ "List", "all", "Iterations", "related", "to", "a", "single", "item" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/iteration/iteration.go#L183-L196
13,214
fabric8-services/fabric8-wit
iteration/iteration.go
Root
func (m *GormIterationRepository) Root(ctx context.Context, spaceID uuid.UUID) (*Iteration, error) { defer goa.MeasureSince([]string{"goa", "db", "iteration", "query"}, time.Now()) var itr Iteration tx := m.db.Where("space_id = ? AND nlevel(path)=1", spaceID).First(&itr) if tx.Error != nil { log.Error(ctx, map[string]interface{}{ "space_id": spaceID, "err": tx.Error, }, "unable to get the root iteration") if tx.Error == gorm.ErrRecordNotFound { return nil, errors.NewNotFoundError("root iteration for space", spaceID.String()) } return nil, errors.NewInternalError(ctx, tx.Error) } return &itr, nil }
go
func (m *GormIterationRepository) Root(ctx context.Context, spaceID uuid.UUID) (*Iteration, error) { defer goa.MeasureSince([]string{"goa", "db", "iteration", "query"}, time.Now()) var itr Iteration tx := m.db.Where("space_id = ? AND nlevel(path)=1", spaceID).First(&itr) if tx.Error != nil { log.Error(ctx, map[string]interface{}{ "space_id": spaceID, "err": tx.Error, }, "unable to get the root iteration") if tx.Error == gorm.ErrRecordNotFound { return nil, errors.NewNotFoundError("root iteration for space", spaceID.String()) } return nil, errors.NewInternalError(ctx, tx.Error) } return &itr, nil }
[ "func", "(", "m", "*", "GormIterationRepository", ")", "Root", "(", "ctx", "context", ".", "Context", ",", "spaceID", "uuid", ".", "UUID", ")", "(", "*", "Iteration", ",", "error", ")", "{", "defer", "goa", ".", "MeasureSince", "(", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", ",", "time", ".", "Now", "(", ")", ")", "\n", "var", "itr", "Iteration", "\n\n", "tx", ":=", "m", ".", "db", ".", "Where", "(", "\"", "\"", ",", "spaceID", ")", ".", "First", "(", "&", "itr", ")", "\n", "if", "tx", ".", "Error", "!=", "nil", "{", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "spaceID", ",", "\"", "\"", ":", "tx", ".", "Error", ",", "}", ",", "\"", "\"", ")", "\n", "if", "tx", ".", "Error", "==", "gorm", ".", "ErrRecordNotFound", "{", "return", "nil", ",", "errors", ".", "NewNotFoundError", "(", "\"", "\"", ",", "spaceID", ".", "String", "(", ")", ")", "\n", "}", "\n", "return", "nil", ",", "errors", ".", "NewInternalError", "(", "ctx", ",", "tx", ".", "Error", ")", "\n", "}", "\n", "return", "&", "itr", ",", "nil", "\n", "}" ]
// Root returns the Root Iteration for a space
[ "Root", "returns", "the", "Root", "Iteration", "for", "a", "space" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/iteration/iteration.go#L199-L215
13,215
fabric8-services/fabric8-wit
iteration/iteration.go
Load
func (m *GormIterationRepository) Load(ctx context.Context, id uuid.UUID) (*Iteration, error) { defer goa.MeasureSince([]string{"goa", "db", "iteration", "get"}, time.Now()) var obj Iteration tx := m.db.Where("id = ?", id).First(&obj) if tx.RecordNotFound() { log.Error(ctx, map[string]interface{}{ "iteration_id": id.String(), }, "iteration cannot be found") return nil, errors.NewNotFoundError("Iteration", id.String()) } if tx.Error != nil { log.Error(ctx, map[string]interface{}{ "iteration_id": id.String(), "err": tx.Error, }, "unable to load the iteration") return nil, errors.NewInternalError(ctx, tx.Error) } return &obj, nil }
go
func (m *GormIterationRepository) Load(ctx context.Context, id uuid.UUID) (*Iteration, error) { defer goa.MeasureSince([]string{"goa", "db", "iteration", "get"}, time.Now()) var obj Iteration tx := m.db.Where("id = ?", id).First(&obj) if tx.RecordNotFound() { log.Error(ctx, map[string]interface{}{ "iteration_id": id.String(), }, "iteration cannot be found") return nil, errors.NewNotFoundError("Iteration", id.String()) } if tx.Error != nil { log.Error(ctx, map[string]interface{}{ "iteration_id": id.String(), "err": tx.Error, }, "unable to load the iteration") return nil, errors.NewInternalError(ctx, tx.Error) } return &obj, nil }
[ "func", "(", "m", "*", "GormIterationRepository", ")", "Load", "(", "ctx", "context", ".", "Context", ",", "id", "uuid", ".", "UUID", ")", "(", "*", "Iteration", ",", "error", ")", "{", "defer", "goa", ".", "MeasureSince", "(", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", ",", "time", ".", "Now", "(", ")", ")", "\n", "var", "obj", "Iteration", "\n\n", "tx", ":=", "m", ".", "db", ".", "Where", "(", "\"", "\"", ",", "id", ")", ".", "First", "(", "&", "obj", ")", "\n", "if", "tx", ".", "RecordNotFound", "(", ")", "{", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "id", ".", "String", "(", ")", ",", "}", ",", "\"", "\"", ")", "\n", "return", "nil", ",", "errors", ".", "NewNotFoundError", "(", "\"", "\"", ",", "id", ".", "String", "(", ")", ")", "\n", "}", "\n", "if", "tx", ".", "Error", "!=", "nil", "{", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "id", ".", "String", "(", ")", ",", "\"", "\"", ":", "tx", ".", "Error", ",", "}", ",", "\"", "\"", ")", "\n", "return", "nil", ",", "errors", ".", "NewInternalError", "(", "ctx", ",", "tx", ".", "Error", ")", "\n", "}", "\n", "return", "&", "obj", ",", "nil", "\n", "}" ]
// Load a single Iteration regardless of parent
[ "Load", "a", "single", "Iteration", "regardless", "of", "parent" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/iteration/iteration.go#L218-L237
13,216
fabric8-services/fabric8-wit
iteration/iteration.go
Save
func (m *GormIterationRepository) Save(ctx context.Context, i Iteration) (*Iteration, error) { itr := Iteration{} tx := m.db.Where("id=?", i.ID).First(&itr) if tx.RecordNotFound() { log.Error(ctx, map[string]interface{}{ "iteration_id": i.ID, }, "iteration cannot be found") // treating this as a not found error: the fact that we're using number internal is implementation detail return nil, errors.NewNotFoundError("iteration", i.ID.String()) } if err := tx.Error; err != nil { log.Error(ctx, map[string]interface{}{ "iteration_id": i.ID, "err": err, }, "unknown error happened when searching the iteration") return nil, errors.NewInternalError(ctx, err) } tx = tx.Save(&i) if err := tx.Error; err != nil { log.Error(ctx, map[string]interface{}{ "iteration_id": i.ID, "err": err, }, "unable to save the iterations") return nil, errors.NewInternalError(ctx, err) } return &i, nil }
go
func (m *GormIterationRepository) Save(ctx context.Context, i Iteration) (*Iteration, error) { itr := Iteration{} tx := m.db.Where("id=?", i.ID).First(&itr) if tx.RecordNotFound() { log.Error(ctx, map[string]interface{}{ "iteration_id": i.ID, }, "iteration cannot be found") // treating this as a not found error: the fact that we're using number internal is implementation detail return nil, errors.NewNotFoundError("iteration", i.ID.String()) } if err := tx.Error; err != nil { log.Error(ctx, map[string]interface{}{ "iteration_id": i.ID, "err": err, }, "unknown error happened when searching the iteration") return nil, errors.NewInternalError(ctx, err) } tx = tx.Save(&i) if err := tx.Error; err != nil { log.Error(ctx, map[string]interface{}{ "iteration_id": i.ID, "err": err, }, "unable to save the iterations") return nil, errors.NewInternalError(ctx, err) } return &i, nil }
[ "func", "(", "m", "*", "GormIterationRepository", ")", "Save", "(", "ctx", "context", ".", "Context", ",", "i", "Iteration", ")", "(", "*", "Iteration", ",", "error", ")", "{", "itr", ":=", "Iteration", "{", "}", "\n", "tx", ":=", "m", ".", "db", ".", "Where", "(", "\"", "\"", ",", "i", ".", "ID", ")", ".", "First", "(", "&", "itr", ")", "\n", "if", "tx", ".", "RecordNotFound", "(", ")", "{", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "i", ".", "ID", ",", "}", ",", "\"", "\"", ")", "\n", "// treating this as a not found error: the fact that we're using number internal is implementation detail", "return", "nil", ",", "errors", ".", "NewNotFoundError", "(", "\"", "\"", ",", "i", ".", "ID", ".", "String", "(", ")", ")", "\n", "}", "\n", "if", "err", ":=", "tx", ".", "Error", ";", "err", "!=", "nil", "{", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "i", ".", "ID", ",", "\"", "\"", ":", "err", ",", "}", ",", "\"", "\"", ")", "\n", "return", "nil", ",", "errors", ".", "NewInternalError", "(", "ctx", ",", "err", ")", "\n", "}", "\n", "tx", "=", "tx", ".", "Save", "(", "&", "i", ")", "\n", "if", "err", ":=", "tx", ".", "Error", ";", "err", "!=", "nil", "{", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "i", ".", "ID", ",", "\"", "\"", ":", "err", ",", "}", ",", "\"", "\"", ")", "\n", "return", "nil", ",", "errors", ".", "NewInternalError", "(", "ctx", ",", "err", ")", "\n", "}", "\n", "return", "&", "i", ",", "nil", "\n", "}" ]
// Save updates the given iteration in the db. Version must be the same as the one in the stored version // returns NotFoundError, VersionConflictError or InternalError
[ "Save", "updates", "the", "given", "iteration", "in", "the", "db", ".", "Version", "must", "be", "the", "same", "as", "the", "one", "in", "the", "stored", "version", "returns", "NotFoundError", "VersionConflictError", "or", "InternalError" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/iteration/iteration.go#L247-L273
13,217
fabric8-services/fabric8-wit
iteration/iteration.go
Delete
func (m *GormIterationRepository) Delete(ctx context.Context, ID uuid.UUID) error { defer goa.MeasureSince([]string{"goa", "db", "iteration", "delete"}, time.Now()) if ID == uuid.Nil { log.Error(ctx, map[string]interface{}{ "iteration_id": ID.String(), }, "unable to find the iteration by ID") return errors.NewNotFoundError("iteration", ID.String()) } itr := Iteration{ID: ID} tx := m.db.Delete(itr) if err := tx.Error; err != nil { log.Error(ctx, map[string]interface{}{ "iteration_id": ID.String(), }, "unable to delete the iteration") return errors.NewInternalError(ctx, err) } if tx.RowsAffected == 0 { log.Error(ctx, map[string]interface{}{ "iteration_id": ID.String(), }, "none row was affected by the deletion operation") return errors.NewNotFoundError("iteration", ID.String()) } return nil }
go
func (m *GormIterationRepository) Delete(ctx context.Context, ID uuid.UUID) error { defer goa.MeasureSince([]string{"goa", "db", "iteration", "delete"}, time.Now()) if ID == uuid.Nil { log.Error(ctx, map[string]interface{}{ "iteration_id": ID.String(), }, "unable to find the iteration by ID") return errors.NewNotFoundError("iteration", ID.String()) } itr := Iteration{ID: ID} tx := m.db.Delete(itr) if err := tx.Error; err != nil { log.Error(ctx, map[string]interface{}{ "iteration_id": ID.String(), }, "unable to delete the iteration") return errors.NewInternalError(ctx, err) } if tx.RowsAffected == 0 { log.Error(ctx, map[string]interface{}{ "iteration_id": ID.String(), }, "none row was affected by the deletion operation") return errors.NewNotFoundError("iteration", ID.String()) } return nil }
[ "func", "(", "m", "*", "GormIterationRepository", ")", "Delete", "(", "ctx", "context", ".", "Context", ",", "ID", "uuid", ".", "UUID", ")", "error", "{", "defer", "goa", ".", "MeasureSince", "(", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", ",", "time", ".", "Now", "(", ")", ")", "\n", "if", "ID", "==", "uuid", ".", "Nil", "{", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "ID", ".", "String", "(", ")", ",", "}", ",", "\"", "\"", ")", "\n", "return", "errors", ".", "NewNotFoundError", "(", "\"", "\"", ",", "ID", ".", "String", "(", ")", ")", "\n", "}", "\n", "itr", ":=", "Iteration", "{", "ID", ":", "ID", "}", "\n", "tx", ":=", "m", ".", "db", ".", "Delete", "(", "itr", ")", "\n\n", "if", "err", ":=", "tx", ".", "Error", ";", "err", "!=", "nil", "{", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "ID", ".", "String", "(", ")", ",", "}", ",", "\"", "\"", ")", "\n", "return", "errors", ".", "NewInternalError", "(", "ctx", ",", "err", ")", "\n", "}", "\n", "if", "tx", ".", "RowsAffected", "==", "0", "{", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "ID", ".", "String", "(", ")", ",", "}", ",", "\"", "\"", ")", "\n", "return", "errors", ".", "NewNotFoundError", "(", "\"", "\"", ",", "ID", ".", "String", "(", ")", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Delete deletes the itertion with the given id // returns NotFoundError or InternalError
[ "Delete", "deletes", "the", "itertion", "with", "the", "given", "id", "returns", "NotFoundError", "or", "InternalError" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/iteration/iteration.go#L337-L361
13,218
fabric8-services/fabric8-wit
kubernetes/deployments_metrics.go
NewMetricsClient
func NewMetricsClient(config *MetricsClientConfig) (Metrics, error) { // Use default implementation if no HawkularGetter is specified if config.HawkularGetter == nil { config.HawkularGetter = &defaultGetter{} } helper, err := config.GetHawkularRESTAPI(config) if err != nil { return nil, err } mc := &metricsClient{ HawkularRESTAPI: helper, } return mc, nil }
go
func NewMetricsClient(config *MetricsClientConfig) (Metrics, error) { // Use default implementation if no HawkularGetter is specified if config.HawkularGetter == nil { config.HawkularGetter = &defaultGetter{} } helper, err := config.GetHawkularRESTAPI(config) if err != nil { return nil, err } mc := &metricsClient{ HawkularRESTAPI: helper, } return mc, nil }
[ "func", "NewMetricsClient", "(", "config", "*", "MetricsClientConfig", ")", "(", "Metrics", ",", "error", ")", "{", "// Use default implementation if no HawkularGetter is specified", "if", "config", ".", "HawkularGetter", "==", "nil", "{", "config", ".", "HawkularGetter", "=", "&", "defaultGetter", "{", "}", "\n", "}", "\n", "helper", ",", "err", ":=", "config", ".", "GetHawkularRESTAPI", "(", "config", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "mc", ":=", "&", "metricsClient", "{", "HawkularRESTAPI", ":", "helper", ",", "}", "\n\n", "return", "mc", ",", "nil", "\n", "}" ]
// NewMetricsClient creates a Metrics object given a configuration
[ "NewMetricsClient", "creates", "a", "Metrics", "object", "given", "a", "configuration" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/kubernetes/deployments_metrics.go#L86-L100
13,219
fabric8-services/fabric8-wit
login/service.go
NewKeycloakOAuthProvider
func NewKeycloakOAuthProvider(identities account.IdentityRepository, users account.UserRepository, tokenManager token.Manager, db application.DB) *KeycloakOAuthProvider { return &KeycloakOAuthProvider{ Identities: identities, Users: users, TokenManager: tokenManager, db: db, } }
go
func NewKeycloakOAuthProvider(identities account.IdentityRepository, users account.UserRepository, tokenManager token.Manager, db application.DB) *KeycloakOAuthProvider { return &KeycloakOAuthProvider{ Identities: identities, Users: users, TokenManager: tokenManager, db: db, } }
[ "func", "NewKeycloakOAuthProvider", "(", "identities", "account", ".", "IdentityRepository", ",", "users", "account", ".", "UserRepository", ",", "tokenManager", "token", ".", "Manager", ",", "db", "application", ".", "DB", ")", "*", "KeycloakOAuthProvider", "{", "return", "&", "KeycloakOAuthProvider", "{", "Identities", ":", "identities", ",", "Users", ":", "users", ",", "TokenManager", ":", "tokenManager", ",", "db", ":", "db", ",", "}", "\n", "}" ]
// NewKeycloakOAuthProvider creates a new login.Service capable of using keycloak for authorization
[ "NewKeycloakOAuthProvider", "creates", "a", "new", "login", ".", "Service", "capable", "of", "using", "keycloak", "for", "authorization" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/login/service.go#L25-L32
13,220
fabric8-services/fabric8-wit
login/service.go
ContextIdentity
func ContextIdentity(ctx context.Context) (*uuid.UUID, error) { tm := tokencontext.ReadTokenManagerFromContext(ctx) if tm == nil { log.Error(ctx, map[string]interface{}{ "token": tm, }, "missing token manager") return nil, errs.New("Missing token manager") } // As mentioned in token.go, we can now safely convert tm to a token.Manager manager := tm.(token.Manager) uuid, err := manager.Locate(ctx) if err != nil { // TODO : need a way to define user as Guest log.Error(ctx, map[string]interface{}{ "uuid": uuid, "token_manager": manager, "err": err, }, "identity belongs to a Guest User") return nil, errs.WithStack(err) } return &uuid, nil }
go
func ContextIdentity(ctx context.Context) (*uuid.UUID, error) { tm := tokencontext.ReadTokenManagerFromContext(ctx) if tm == nil { log.Error(ctx, map[string]interface{}{ "token": tm, }, "missing token manager") return nil, errs.New("Missing token manager") } // As mentioned in token.go, we can now safely convert tm to a token.Manager manager := tm.(token.Manager) uuid, err := manager.Locate(ctx) if err != nil { // TODO : need a way to define user as Guest log.Error(ctx, map[string]interface{}{ "uuid": uuid, "token_manager": manager, "err": err, }, "identity belongs to a Guest User") return nil, errs.WithStack(err) } return &uuid, nil }
[ "func", "ContextIdentity", "(", "ctx", "context", ".", "Context", ")", "(", "*", "uuid", ".", "UUID", ",", "error", ")", "{", "tm", ":=", "tokencontext", ".", "ReadTokenManagerFromContext", "(", "ctx", ")", "\n", "if", "tm", "==", "nil", "{", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "tm", ",", "}", ",", "\"", "\"", ")", "\n\n", "return", "nil", ",", "errs", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "// As mentioned in token.go, we can now safely convert tm to a token.Manager", "manager", ":=", "tm", ".", "(", "token", ".", "Manager", ")", "\n", "uuid", ",", "err", ":=", "manager", ".", "Locate", "(", "ctx", ")", "\n", "if", "err", "!=", "nil", "{", "// TODO : need a way to define user as Guest", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "uuid", ",", "\"", "\"", ":", "manager", ",", "\"", "\"", ":", "err", ",", "}", ",", "\"", "\"", ")", "\n\n", "return", "nil", ",", "errs", ".", "WithStack", "(", "err", ")", "\n", "}", "\n", "return", "&", "uuid", ",", "nil", "\n", "}" ]
// ContextIdentity returns the identity's ID found in given context // Uses tokenManager.Locate to fetch the identity of currently logged in user
[ "ContextIdentity", "returns", "the", "identity", "s", "ID", "found", "in", "given", "context", "Uses", "tokenManager", ".", "Locate", "to", "fetch", "the", "identity", "of", "currently", "logged", "in", "user" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/login/service.go#L215-L238
13,221
fabric8-services/fabric8-wit
login/service.go
InjectTokenManager
func InjectTokenManager(tokenManager token.Manager) goa.Middleware { return func(h goa.Handler) goa.Handler { return func(ctx context.Context, rw http.ResponseWriter, req *http.Request) error { ctxWithTM := tokencontext.ContextWithTokenManager(ctx, tokenManager) return h(ctxWithTM, rw, req) } } }
go
func InjectTokenManager(tokenManager token.Manager) goa.Middleware { return func(h goa.Handler) goa.Handler { return func(ctx context.Context, rw http.ResponseWriter, req *http.Request) error { ctxWithTM := tokencontext.ContextWithTokenManager(ctx, tokenManager) return h(ctxWithTM, rw, req) } } }
[ "func", "InjectTokenManager", "(", "tokenManager", "token", ".", "Manager", ")", "goa", ".", "Middleware", "{", "return", "func", "(", "h", "goa", ".", "Handler", ")", "goa", ".", "Handler", "{", "return", "func", "(", "ctx", "context", ".", "Context", ",", "rw", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "error", "{", "ctxWithTM", ":=", "tokencontext", ".", "ContextWithTokenManager", "(", "ctx", ",", "tokenManager", ")", "\n", "return", "h", "(", "ctxWithTM", ",", "rw", ",", "req", ")", "\n", "}", "\n", "}", "\n", "}" ]
// InjectTokenManager is a middleware responsible for setting up tokenManager in the context for every request.
[ "InjectTokenManager", "is", "a", "middleware", "responsible", "for", "setting", "up", "tokenManager", "in", "the", "context", "for", "every", "request", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/login/service.go#L241-L248
13,222
fabric8-services/fabric8-wit
kubernetes/deployments_access.go
isAuthorized
func (rulesMap accessRules) isAuthorized(reqs []*requestedAccess) bool { for _, req := range reqs { // Check rules for resource type and also check wildcard variations // see: https://github.com/openshift/origin-web-common/blob/v3.10.0/src/services/authorizationService.js#L156 res := req.resource allRes := &qualifiedResource{res.apiGroup, rulesReviewWildcard} allGroup := &qualifiedResource{rulesReviewWildcard, res.resourceType} // Check if all requested actions are permitted for _, verb := range req.verbs { if !containsVerb(rulesMap, res, verb) && !containsVerb(rulesMap, allResAllGroup, verb) && !containsVerb(rulesMap, allRes, verb) && !containsVerb(rulesMap, allGroup, verb) { return false } } } return true }
go
func (rulesMap accessRules) isAuthorized(reqs []*requestedAccess) bool { for _, req := range reqs { // Check rules for resource type and also check wildcard variations // see: https://github.com/openshift/origin-web-common/blob/v3.10.0/src/services/authorizationService.js#L156 res := req.resource allRes := &qualifiedResource{res.apiGroup, rulesReviewWildcard} allGroup := &qualifiedResource{rulesReviewWildcard, res.resourceType} // Check if all requested actions are permitted for _, verb := range req.verbs { if !containsVerb(rulesMap, res, verb) && !containsVerb(rulesMap, allResAllGroup, verb) && !containsVerb(rulesMap, allRes, verb) && !containsVerb(rulesMap, allGroup, verb) { return false } } } return true }
[ "func", "(", "rulesMap", "accessRules", ")", "isAuthorized", "(", "reqs", "[", "]", "*", "requestedAccess", ")", "bool", "{", "for", "_", ",", "req", ":=", "range", "reqs", "{", "// Check rules for resource type and also check wildcard variations", "// see: https://github.com/openshift/origin-web-common/blob/v3.10.0/src/services/authorizationService.js#L156", "res", ":=", "req", ".", "resource", "\n", "allRes", ":=", "&", "qualifiedResource", "{", "res", ".", "apiGroup", ",", "rulesReviewWildcard", "}", "\n", "allGroup", ":=", "&", "qualifiedResource", "{", "rulesReviewWildcard", ",", "res", ".", "resourceType", "}", "\n\n", "// Check if all requested actions are permitted", "for", "_", ",", "verb", ":=", "range", "req", ".", "verbs", "{", "if", "!", "containsVerb", "(", "rulesMap", ",", "res", ",", "verb", ")", "&&", "!", "containsVerb", "(", "rulesMap", ",", "allResAllGroup", ",", "verb", ")", "&&", "!", "containsVerb", "(", "rulesMap", ",", "allRes", ",", "verb", ")", "&&", "!", "containsVerb", "(", "rulesMap", ",", "allGroup", ",", "verb", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "true", "\n", "}" ]
// Checks the subject rules review for the desired actions on resources
[ "Checks", "the", "subject", "rules", "review", "for", "the", "desired", "actions", "on", "resources" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/kubernetes/deployments_access.go#L61-L80
13,223
fabric8-services/fabric8-wit
kubernetes/deployments_access.go
CanGetSpace
func (kc *kubeClient) CanGetSpace() (bool, error) { // Also need access to build configs and builds in user namespace ok, err := kc.checkAuthorizedInEnv(getBuildConfigsAndBuildsRules, environmentTypeUser) if err != nil { return false, err } else if !ok { return false, nil } for envName := range kc.envMap { if kc.CanDeploy(envName) { ok, err := kc.checkAuthorizedInEnv(getDeploymentRules, envName) if err != nil { return false, err } else if !ok { return false, nil } } } return true, nil }
go
func (kc *kubeClient) CanGetSpace() (bool, error) { // Also need access to build configs and builds in user namespace ok, err := kc.checkAuthorizedInEnv(getBuildConfigsAndBuildsRules, environmentTypeUser) if err != nil { return false, err } else if !ok { return false, nil } for envName := range kc.envMap { if kc.CanDeploy(envName) { ok, err := kc.checkAuthorizedInEnv(getDeploymentRules, envName) if err != nil { return false, err } else if !ok { return false, nil } } } return true, nil }
[ "func", "(", "kc", "*", "kubeClient", ")", "CanGetSpace", "(", ")", "(", "bool", ",", "error", ")", "{", "// Also need access to build configs and builds in user namespace", "ok", ",", "err", ":=", "kc", ".", "checkAuthorizedInEnv", "(", "getBuildConfigsAndBuildsRules", ",", "environmentTypeUser", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "else", "if", "!", "ok", "{", "return", "false", ",", "nil", "\n", "}", "\n\n", "for", "envName", ":=", "range", "kc", ".", "envMap", "{", "if", "kc", ".", "CanDeploy", "(", "envName", ")", "{", "ok", ",", "err", ":=", "kc", ".", "checkAuthorizedInEnv", "(", "getDeploymentRules", ",", "envName", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "else", "if", "!", "ok", "{", "return", "false", ",", "nil", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "true", ",", "nil", "\n", "}" ]
// CanGetSpace returns whether the user is authorized to call KubeClientInterface.GetSpace
[ "CanGetSpace", "returns", "whether", "the", "user", "is", "authorized", "to", "call", "KubeClientInterface", ".", "GetSpace" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/kubernetes/deployments_access.go#L90-L110
13,224
fabric8-services/fabric8-wit
kubernetes/deployments_access.go
CanGetApplication
func (kc *kubeClient) CanGetApplication() (bool, error) { // Also need access to builds in user namespace ok, err := kc.checkAuthorizedInEnv(getBuildsRules, environmentTypeUser) if err != nil { return false, err } else if !ok { return false, nil } for envName := range kc.envMap { if kc.CanDeploy(envName) { ok, err := kc.checkAuthorizedInEnv(getDeploymentRules, envName) if err != nil { return false, err } else if !ok { return false, nil } } } return true, nil }
go
func (kc *kubeClient) CanGetApplication() (bool, error) { // Also need access to builds in user namespace ok, err := kc.checkAuthorizedInEnv(getBuildsRules, environmentTypeUser) if err != nil { return false, err } else if !ok { return false, nil } for envName := range kc.envMap { if kc.CanDeploy(envName) { ok, err := kc.checkAuthorizedInEnv(getDeploymentRules, envName) if err != nil { return false, err } else if !ok { return false, nil } } } return true, nil }
[ "func", "(", "kc", "*", "kubeClient", ")", "CanGetApplication", "(", ")", "(", "bool", ",", "error", ")", "{", "// Also need access to builds in user namespace", "ok", ",", "err", ":=", "kc", ".", "checkAuthorizedInEnv", "(", "getBuildsRules", ",", "environmentTypeUser", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "else", "if", "!", "ok", "{", "return", "false", ",", "nil", "\n", "}", "\n\n", "for", "envName", ":=", "range", "kc", ".", "envMap", "{", "if", "kc", ".", "CanDeploy", "(", "envName", ")", "{", "ok", ",", "err", ":=", "kc", ".", "checkAuthorizedInEnv", "(", "getDeploymentRules", ",", "envName", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "else", "if", "!", "ok", "{", "return", "false", ",", "nil", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "true", ",", "nil", "\n", "}" ]
// CanGetApplication returns whether the user is authorized to call KubeClientInterface.GetApplication
[ "CanGetApplication", "returns", "whether", "the", "user", "is", "authorized", "to", "call", "KubeClientInterface", ".", "GetApplication" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/kubernetes/deployments_access.go#L113-L133
13,225
fabric8-services/fabric8-wit
kubernetes/deployments_access.go
CanGetDeployment
func (kc *kubeClient) CanGetDeployment(envName string) (bool, error) { return kc.checkAuthorizedWithBuilds(envName, getDeploymentRules) }
go
func (kc *kubeClient) CanGetDeployment(envName string) (bool, error) { return kc.checkAuthorizedWithBuilds(envName, getDeploymentRules) }
[ "func", "(", "kc", "*", "kubeClient", ")", "CanGetDeployment", "(", "envName", "string", ")", "(", "bool", ",", "error", ")", "{", "return", "kc", ".", "checkAuthorizedWithBuilds", "(", "envName", ",", "getDeploymentRules", ")", "\n", "}" ]
// CanGetDeployment returns whether the user is authorized to call KubeClientInterface.GetDeployment
[ "CanGetDeployment", "returns", "whether", "the", "user", "is", "authorized", "to", "call", "KubeClientInterface", ".", "GetDeployment" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/kubernetes/deployments_access.go#L144-L146
13,226
fabric8-services/fabric8-wit
kubernetes/deployments_access.go
CanScaleDeployment
func (kc *kubeClient) CanScaleDeployment(envName string) (bool, error) { return kc.checkAuthorizedWithBuilds(envName, scaleDeploymentRules) }
go
func (kc *kubeClient) CanScaleDeployment(envName string) (bool, error) { return kc.checkAuthorizedWithBuilds(envName, scaleDeploymentRules) }
[ "func", "(", "kc", "*", "kubeClient", ")", "CanScaleDeployment", "(", "envName", "string", ")", "(", "bool", ",", "error", ")", "{", "return", "kc", ".", "checkAuthorizedWithBuilds", "(", "envName", ",", "scaleDeploymentRules", ")", "\n", "}" ]
// CanScaleDeployment returns whether the user is authorized to call KubeClientInterface.ScaleDeployment
[ "CanScaleDeployment", "returns", "whether", "the", "user", "is", "authorized", "to", "call", "KubeClientInterface", ".", "ScaleDeployment" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/kubernetes/deployments_access.go#L155-L157
13,227
fabric8-services/fabric8-wit
kubernetes/deployments_access.go
CanDeleteDeployment
func (kc *kubeClient) CanDeleteDeployment(envName string) (bool, error) { return kc.checkAuthorizedWithBuilds(envName, deleteDeploymentRules) }
go
func (kc *kubeClient) CanDeleteDeployment(envName string) (bool, error) { return kc.checkAuthorizedWithBuilds(envName, deleteDeploymentRules) }
[ "func", "(", "kc", "*", "kubeClient", ")", "CanDeleteDeployment", "(", "envName", "string", ")", "(", "bool", ",", "error", ")", "{", "return", "kc", ".", "checkAuthorizedWithBuilds", "(", "envName", ",", "deleteDeploymentRules", ")", "\n", "}" ]
// CanDeleteDeployment returns whether the user is authorized to call KubeClientInterface.DeleteDeployment
[ "CanDeleteDeployment", "returns", "whether", "the", "user", "is", "authorized", "to", "call", "KubeClientInterface", ".", "DeleteDeployment" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/kubernetes/deployments_access.go#L166-L168
13,228
fabric8-services/fabric8-wit
kubernetes/deployments_access.go
CanGetDeploymentStats
func (kc *kubeClient) CanGetDeploymentStats(envName string) (bool, error) { return kc.checkAuthorizedWithBuilds(envName, getDeploymentStatsRules) }
go
func (kc *kubeClient) CanGetDeploymentStats(envName string) (bool, error) { return kc.checkAuthorizedWithBuilds(envName, getDeploymentStatsRules) }
[ "func", "(", "kc", "*", "kubeClient", ")", "CanGetDeploymentStats", "(", "envName", "string", ")", "(", "bool", ",", "error", ")", "{", "return", "kc", ".", "checkAuthorizedWithBuilds", "(", "envName", ",", "getDeploymentStatsRules", ")", "\n", "}" ]
// CanGetDeploymentStats returns whether the user is authorized to call KubeClientInterface.GetDeploymentStats
[ "CanGetDeploymentStats", "returns", "whether", "the", "user", "is", "authorized", "to", "call", "KubeClientInterface", ".", "GetDeploymentStats" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/kubernetes/deployments_access.go#L177-L179
13,229
fabric8-services/fabric8-wit
kubernetes/deployments_access.go
CanGetEnvironments
func (kc *kubeClient) CanGetEnvironments() (bool, error) { for envName := range kc.envMap { if kc.CanDeploy(envName) { ok, err := kc.CanGetEnvironment(envName) if err != nil { return false, err } else if !ok { return false, nil } } } return true, nil }
go
func (kc *kubeClient) CanGetEnvironments() (bool, error) { for envName := range kc.envMap { if kc.CanDeploy(envName) { ok, err := kc.CanGetEnvironment(envName) if err != nil { return false, err } else if !ok { return false, nil } } } return true, nil }
[ "func", "(", "kc", "*", "kubeClient", ")", "CanGetEnvironments", "(", ")", "(", "bool", ",", "error", ")", "{", "for", "envName", ":=", "range", "kc", ".", "envMap", "{", "if", "kc", ".", "CanDeploy", "(", "envName", ")", "{", "ok", ",", "err", ":=", "kc", ".", "CanGetEnvironment", "(", "envName", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "else", "if", "!", "ok", "{", "return", "false", ",", "nil", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "true", ",", "nil", "\n", "}" ]
// CanGetEnvironments returns whether the user is authorized to call KubeClientInterface.GetEnvironments
[ "CanGetEnvironments", "returns", "whether", "the", "user", "is", "authorized", "to", "call", "KubeClientInterface", ".", "GetEnvironments" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/kubernetes/deployments_access.go#L223-L235
13,230
fabric8-services/fabric8-wit
kubernetes/deployments_access.go
CanGetEnvironment
func (kc *kubeClient) CanGetEnvironment(envName string) (bool, error) { return kc.checkAuthorizedInEnv(getEnvironmentRules, envName) }
go
func (kc *kubeClient) CanGetEnvironment(envName string) (bool, error) { return kc.checkAuthorizedInEnv(getEnvironmentRules, envName) }
[ "func", "(", "kc", "*", "kubeClient", ")", "CanGetEnvironment", "(", "envName", "string", ")", "(", "bool", ",", "error", ")", "{", "return", "kc", ".", "checkAuthorizedInEnv", "(", "getEnvironmentRules", ",", "envName", ")", "\n", "}" ]
// CanGetEnvironment returns whether the user is authorized to call KubeClientInterface.GetEnvironment
[ "CanGetEnvironment", "returns", "whether", "the", "user", "is", "authorized", "to", "call", "KubeClientInterface", ".", "GetEnvironment" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/kubernetes/deployments_access.go#L238-L240
13,231
fabric8-services/fabric8-wit
kubernetes/deployments_access.go
getRulesForEnvironment
func (kc *kubeClient) getRulesForEnvironment(envName string) (*accessRules, error) { // Check if we have a cached copy rules, pres := kc.rulesMap[envName] if pres { return rules, nil } // Lookup authorization rules for this environment envNS, err := kc.getEnvironmentNamespace(envName) if err != nil { return nil, err } rules, err = kc.lookupAllRules(envNS) if err != nil { return nil, err } // Cache rules, so subsequent calls by this kubeClient don't // trigger lookup over network kc.rulesMap[envName] = rules return rules, nil }
go
func (kc *kubeClient) getRulesForEnvironment(envName string) (*accessRules, error) { // Check if we have a cached copy rules, pres := kc.rulesMap[envName] if pres { return rules, nil } // Lookup authorization rules for this environment envNS, err := kc.getEnvironmentNamespace(envName) if err != nil { return nil, err } rules, err = kc.lookupAllRules(envNS) if err != nil { return nil, err } // Cache rules, so subsequent calls by this kubeClient don't // trigger lookup over network kc.rulesMap[envName] = rules return rules, nil }
[ "func", "(", "kc", "*", "kubeClient", ")", "getRulesForEnvironment", "(", "envName", "string", ")", "(", "*", "accessRules", ",", "error", ")", "{", "// Check if we have a cached copy", "rules", ",", "pres", ":=", "kc", ".", "rulesMap", "[", "envName", "]", "\n", "if", "pres", "{", "return", "rules", ",", "nil", "\n", "}", "\n\n", "// Lookup authorization rules for this environment", "envNS", ",", "err", ":=", "kc", ".", "getEnvironmentNamespace", "(", "envName", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "rules", ",", "err", "=", "kc", ".", "lookupAllRules", "(", "envNS", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// Cache rules, so subsequent calls by this kubeClient don't", "// trigger lookup over network", "kc", ".", "rulesMap", "[", "envName", "]", "=", "rules", "\n", "return", "rules", ",", "nil", "\n", "}" ]
// Gets the authorization rules for the current user in a given environment
[ "Gets", "the", "authorization", "rules", "for", "the", "current", "user", "in", "a", "given", "environment" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/kubernetes/deployments_access.go#L243-L264
13,232
fabric8-services/fabric8-wit
rendering/markup_content.go
NewMarkupContentFromMap
func NewMarkupContentFromMap(value map[string]interface{}) MarkupContent { content := value[ContentKey].(string) markup := SystemMarkupDefault if m, ok := value[MarkupKey]; ok { markup = m.(string) // use default markup if the input is not supported if !IsMarkupSupported(markup) { markup = SystemMarkupDefault } } return MarkupContent{Content: content, Markup: markup} }
go
func NewMarkupContentFromMap(value map[string]interface{}) MarkupContent { content := value[ContentKey].(string) markup := SystemMarkupDefault if m, ok := value[MarkupKey]; ok { markup = m.(string) // use default markup if the input is not supported if !IsMarkupSupported(markup) { markup = SystemMarkupDefault } } return MarkupContent{Content: content, Markup: markup} }
[ "func", "NewMarkupContentFromMap", "(", "value", "map", "[", "string", "]", "interface", "{", "}", ")", "MarkupContent", "{", "content", ":=", "value", "[", "ContentKey", "]", ".", "(", "string", ")", "\n", "markup", ":=", "SystemMarkupDefault", "\n", "if", "m", ",", "ok", ":=", "value", "[", "MarkupKey", "]", ";", "ok", "{", "markup", "=", "m", ".", "(", "string", ")", "\n", "// use default markup if the input is not supported", "if", "!", "IsMarkupSupported", "(", "markup", ")", "{", "markup", "=", "SystemMarkupDefault", "\n", "}", "\n", "}", "\n", "return", "MarkupContent", "{", "Content", ":", "content", ",", "Markup", ":", "markup", "}", "\n", "}" ]
// NewMarkupContentFromMap creates a MarkupContent from the given Map, // filling the 'Markup' field with the default value if no entry was found in the input or if the given markup is not supported. // This avoids filling the DB with invalid markup types.
[ "NewMarkupContentFromMap", "creates", "a", "MarkupContent", "from", "the", "given", "Map", "filling", "the", "Markup", "field", "with", "the", "default", "value", "if", "no", "entry", "was", "found", "in", "the", "input", "or", "if", "the", "given", "markup", "is", "not", "supported", ".", "This", "avoids", "filling", "the", "DB", "with", "invalid", "markup", "types", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/rendering/markup_content.go#L30-L41
13,233
fabric8-services/fabric8-wit
rendering/markup_content.go
NewMarkupContent
func NewMarkupContent(content, markup string) MarkupContent { return MarkupContent{Content: content, Markup: markup} }
go
func NewMarkupContent(content, markup string) MarkupContent { return MarkupContent{Content: content, Markup: markup} }
[ "func", "NewMarkupContent", "(", "content", ",", "markup", "string", ")", "MarkupContent", "{", "return", "MarkupContent", "{", "Content", ":", "content", ",", "Markup", ":", "markup", "}", "\n", "}" ]
// NewMarkupContent creates a MarkupContent from the given content, using the default markup.
[ "NewMarkupContent", "creates", "a", "MarkupContent", "from", "the", "given", "content", "using", "the", "default", "markup", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/rendering/markup_content.go#L49-L51
13,234
fabric8-services/fabric8-wit
controller/search.go
getWorkItemsByFilterExpression
func getWorkItemsByFilterExpression(ctx context.Context, db application.DB, filterExpression string, filterParentexists *bool, offset *int, limit *int) ([]workitem.WorkItem, link.WorkItemLinkList, link.AncestorList, error) { var result []workitem.WorkItem var childLinks link.WorkItemLinkList var parents link.AncestorList err := application.Transactional(db, func(appl application.Application) error { var err error // add tree option to query if not already present var reqMap map[string]interface{} err = json.Unmarshal([]byte(filterExpression), &reqMap) if err != nil { return errs.Errorf("error unmarshalling query expression for CSV filtering: %s", filterExpression) } if _, ok := reqMap["$OPTS"]; !ok { reqMap["$OPTS"] = make(map[string]interface{}) } // Set "tree-view" to true. We always want tree-view to be enabled (reqMap["$OPTS"].(map[string]interface{}))["tree-view"] = true updatedFilterExpression, err := json.Marshal(reqMap) if err != nil { return errs.Errorf("error adding tree opt to query expression for CSV filtering: %s", filterExpression) } // execute query result, _, parents, childLinks, err = appl.SearchItems().Filter(ctx, string(updatedFilterExpression), filterParentexists, offset, limit) if err != nil { log.Error(ctx, map[string]interface{}{ "err": err, "filter_expression": filterExpression, }, "unable to list the work items") return errs.Wrapf(err, "error executing filter expression for CSV filtering: %s", filterExpression) } return nil }) return result, childLinks, parents, err }
go
func getWorkItemsByFilterExpression(ctx context.Context, db application.DB, filterExpression string, filterParentexists *bool, offset *int, limit *int) ([]workitem.WorkItem, link.WorkItemLinkList, link.AncestorList, error) { var result []workitem.WorkItem var childLinks link.WorkItemLinkList var parents link.AncestorList err := application.Transactional(db, func(appl application.Application) error { var err error // add tree option to query if not already present var reqMap map[string]interface{} err = json.Unmarshal([]byte(filterExpression), &reqMap) if err != nil { return errs.Errorf("error unmarshalling query expression for CSV filtering: %s", filterExpression) } if _, ok := reqMap["$OPTS"]; !ok { reqMap["$OPTS"] = make(map[string]interface{}) } // Set "tree-view" to true. We always want tree-view to be enabled (reqMap["$OPTS"].(map[string]interface{}))["tree-view"] = true updatedFilterExpression, err := json.Marshal(reqMap) if err != nil { return errs.Errorf("error adding tree opt to query expression for CSV filtering: %s", filterExpression) } // execute query result, _, parents, childLinks, err = appl.SearchItems().Filter(ctx, string(updatedFilterExpression), filterParentexists, offset, limit) if err != nil { log.Error(ctx, map[string]interface{}{ "err": err, "filter_expression": filterExpression, }, "unable to list the work items") return errs.Wrapf(err, "error executing filter expression for CSV filtering: %s", filterExpression) } return nil }) return result, childLinks, parents, err }
[ "func", "getWorkItemsByFilterExpression", "(", "ctx", "context", ".", "Context", ",", "db", "application", ".", "DB", ",", "filterExpression", "string", ",", "filterParentexists", "*", "bool", ",", "offset", "*", "int", ",", "limit", "*", "int", ")", "(", "[", "]", "workitem", ".", "WorkItem", ",", "link", ".", "WorkItemLinkList", ",", "link", ".", "AncestorList", ",", "error", ")", "{", "var", "result", "[", "]", "workitem", ".", "WorkItem", "\n", "var", "childLinks", "link", ".", "WorkItemLinkList", "\n", "var", "parents", "link", ".", "AncestorList", "\n", "err", ":=", "application", ".", "Transactional", "(", "db", ",", "func", "(", "appl", "application", ".", "Application", ")", "error", "{", "var", "err", "error", "\n", "// add tree option to query if not already present", "var", "reqMap", "map", "[", "string", "]", "interface", "{", "}", "\n", "err", "=", "json", ".", "Unmarshal", "(", "[", "]", "byte", "(", "filterExpression", ")", ",", "&", "reqMap", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errs", ".", "Errorf", "(", "\"", "\"", ",", "filterExpression", ")", "\n", "}", "\n", "if", "_", ",", "ok", ":=", "reqMap", "[", "\"", "\"", "]", ";", "!", "ok", "{", "reqMap", "[", "\"", "\"", "]", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "}", "\n", "// Set \"tree-view\" to true. We always want tree-view to be enabled", "(", "reqMap", "[", "\"", "\"", "]", ".", "(", "map", "[", "string", "]", "interface", "{", "}", ")", ")", "[", "\"", "\"", "]", "=", "true", "\n", "updatedFilterExpression", ",", "err", ":=", "json", ".", "Marshal", "(", "reqMap", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errs", ".", "Errorf", "(", "\"", "\"", ",", "filterExpression", ")", "\n", "}", "\n", "// execute query", "result", ",", "_", ",", "parents", ",", "childLinks", ",", "err", "=", "appl", ".", "SearchItems", "(", ")", ".", "Filter", "(", "ctx", ",", "string", "(", "updatedFilterExpression", ")", ",", "filterParentexists", ",", "offset", ",", "limit", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "err", ",", "\"", "\"", ":", "filterExpression", ",", "}", ",", "\"", "\"", ")", "\n", "return", "errs", ".", "Wrapf", "(", "err", ",", "\"", "\"", ",", "filterExpression", ")", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n", "return", "result", ",", "childLinks", ",", "parents", ",", "err", "\n", "}" ]
// getWorkItemsByFilterExpression retrieves Work Items, children and parents for a given expression and parameters
[ "getWorkItemsByFilterExpression", "retrieves", "Work", "Items", "children", "and", "parents", "for", "a", "given", "expression", "and", "parameters" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/controller/search.go#L257-L290
13,235
fabric8-services/fabric8-wit
controller/search.go
Spaces
func (c *SearchController) Spaces(ctx *app.SpacesSearchContext) error { q := ctx.Q if q == "" { return jsonapi.JSONErrorResponse(ctx, goa.ErrBadRequest("empty search query not allowed")) } else if q == "*" { q = "" // Allow empty query if * specified } var result []space.Space var count int var err error offset, limit := computePagingLimits(ctx.PageOffset, ctx.PageLimit) err = application.Transactional(c.db, func(appl application.Application) error { result, count, err = appl.Spaces().Search(ctx, &q, &offset, &limit) if err != nil { log.Error(ctx, map[string]interface{}{ "query": q, "offset": offset, "limit": limit, "err": err, }, "unable to list spaces") } return err }) if err != nil { return jsonapi.JSONErrorResponse(ctx, err) } spaceData, err := ConvertSpacesFromModel(ctx.Request, result, IncludeBacklogTotalCount(ctx.Context, c.db)) if err != nil { return jsonapi.JSONErrorResponse(ctx, err) } response := app.SearchSpaceList{ Links: &app.PagingLinks{}, Meta: &app.SpaceListMeta{TotalCount: count}, Data: spaceData, } setPagingLinks(response.Links, buildAbsoluteURL(ctx.Request), len(result), offset, limit, count, "q="+q) return ctx.OK(&response) }
go
func (c *SearchController) Spaces(ctx *app.SpacesSearchContext) error { q := ctx.Q if q == "" { return jsonapi.JSONErrorResponse(ctx, goa.ErrBadRequest("empty search query not allowed")) } else if q == "*" { q = "" // Allow empty query if * specified } var result []space.Space var count int var err error offset, limit := computePagingLimits(ctx.PageOffset, ctx.PageLimit) err = application.Transactional(c.db, func(appl application.Application) error { result, count, err = appl.Spaces().Search(ctx, &q, &offset, &limit) if err != nil { log.Error(ctx, map[string]interface{}{ "query": q, "offset": offset, "limit": limit, "err": err, }, "unable to list spaces") } return err }) if err != nil { return jsonapi.JSONErrorResponse(ctx, err) } spaceData, err := ConvertSpacesFromModel(ctx.Request, result, IncludeBacklogTotalCount(ctx.Context, c.db)) if err != nil { return jsonapi.JSONErrorResponse(ctx, err) } response := app.SearchSpaceList{ Links: &app.PagingLinks{}, Meta: &app.SpaceListMeta{TotalCount: count}, Data: spaceData, } setPagingLinks(response.Links, buildAbsoluteURL(ctx.Request), len(result), offset, limit, count, "q="+q) return ctx.OK(&response) }
[ "func", "(", "c", "*", "SearchController", ")", "Spaces", "(", "ctx", "*", "app", ".", "SpacesSearchContext", ")", "error", "{", "q", ":=", "ctx", ".", "Q", "\n", "if", "q", "==", "\"", "\"", "{", "return", "jsonapi", ".", "JSONErrorResponse", "(", "ctx", ",", "goa", ".", "ErrBadRequest", "(", "\"", "\"", ")", ")", "\n", "}", "else", "if", "q", "==", "\"", "\"", "{", "q", "=", "\"", "\"", "// Allow empty query if * specified", "\n", "}", "\n\n", "var", "result", "[", "]", "space", ".", "Space", "\n", "var", "count", "int", "\n", "var", "err", "error", "\n", "offset", ",", "limit", ":=", "computePagingLimits", "(", "ctx", ".", "PageOffset", ",", "ctx", ".", "PageLimit", ")", "\n", "err", "=", "application", ".", "Transactional", "(", "c", ".", "db", ",", "func", "(", "appl", "application", ".", "Application", ")", "error", "{", "result", ",", "count", ",", "err", "=", "appl", ".", "Spaces", "(", ")", ".", "Search", "(", "ctx", ",", "&", "q", ",", "&", "offset", ",", "&", "limit", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "q", ",", "\"", "\"", ":", "offset", ",", "\"", "\"", ":", "limit", ",", "\"", "\"", ":", "err", ",", "}", ",", "\"", "\"", ")", "\n", "}", "\n", "return", "err", "\n", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "jsonapi", ".", "JSONErrorResponse", "(", "ctx", ",", "err", ")", "\n", "}", "\n", "spaceData", ",", "err", ":=", "ConvertSpacesFromModel", "(", "ctx", ".", "Request", ",", "result", ",", "IncludeBacklogTotalCount", "(", "ctx", ".", "Context", ",", "c", ".", "db", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "jsonapi", ".", "JSONErrorResponse", "(", "ctx", ",", "err", ")", "\n", "}", "\n", "response", ":=", "app", ".", "SearchSpaceList", "{", "Links", ":", "&", "app", ".", "PagingLinks", "{", "}", ",", "Meta", ":", "&", "app", ".", "SpaceListMeta", "{", "TotalCount", ":", "count", "}", ",", "Data", ":", "spaceData", ",", "}", "\n", "setPagingLinks", "(", "response", ".", "Links", ",", "buildAbsoluteURL", "(", "ctx", ".", "Request", ")", ",", "len", "(", "result", ")", ",", "offset", ",", "limit", ",", "count", ",", "\"", "\"", "+", "q", ")", "\n", "return", "ctx", ".", "OK", "(", "&", "response", ")", "\n", "}" ]
// Spaces runs the space search action.
[ "Spaces", "runs", "the", "space", "search", "action", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/controller/search.go#L447-L485
13,236
fabric8-services/fabric8-wit
controller/search.go
enrichWorkItemList
func (c *SearchController) enrichWorkItemList(ctx *app.ShowSearchContext, ancestors link.AncestorList, matchingIDs id.Slice, childLinks link.WorkItemLinkList, res *app.SearchWorkItemList, hasChildren WorkItemConvertFunc) error { parentIDs := id.Slice{} for _, wi := range res.Data { if wi.Relationships != nil && wi.Relationships.Parent != nil && wi.Relationships.Parent.Data != nil { parentIDs = append(parentIDs, wi.Relationships.Parent.Data.ID) } } // Also append the ancestors not already included in the parent list fetchInBatch := parentIDs fetchInBatch.Add(ancestors.GetDistinctAncestorIDs().Diff(parentIDs)) // Append direct children of matching work items that have a child that is // also a match and are not yet in the list. nonMatchingChildItems := childLinks.GetDistinctListOfTargetIDs(link.SystemWorkItemLinkTypeParentChildID) fetchInBatch.Add(fetchInBatch.Diff(nonMatchingChildItems)) // Eliminate work items already in the search fetchInBatch = fetchInBatch.Sub(matchingIDs) wis := []*workitem.WorkItem{} err := application.Transactional(c.db, func(appl application.Application) error { var err error wis, err = appl.WorkItems().LoadBatchByID(ctx, fetchInBatch) return err }) if err != nil { log.Error(ctx, map[string]interface{}{ "wis": wis, "err": err, }, "unable to load parent work items in batch: %s", fetchInBatch) return errs.Wrapf(err, "unable to load work item items in batch: %s", fetchInBatch) } for _, ele := range wis { wit, err := c.db.WorkItemTypes().Load(ctx.Context, ele.Type) if err != nil { return errs.Wrapf(err, "failed to load work item type: %s", ele.Type) } convertedWI, err := ConvertWorkItem(ctx.Request, *wit, *ele, hasChildren, includeParentWorkItem(ctx, ancestors, childLinks)) if err != nil { return errs.WithStack(err) } res.Included = append(res.Included, *convertedWI) } return nil }
go
func (c *SearchController) enrichWorkItemList(ctx *app.ShowSearchContext, ancestors link.AncestorList, matchingIDs id.Slice, childLinks link.WorkItemLinkList, res *app.SearchWorkItemList, hasChildren WorkItemConvertFunc) error { parentIDs := id.Slice{} for _, wi := range res.Data { if wi.Relationships != nil && wi.Relationships.Parent != nil && wi.Relationships.Parent.Data != nil { parentIDs = append(parentIDs, wi.Relationships.Parent.Data.ID) } } // Also append the ancestors not already included in the parent list fetchInBatch := parentIDs fetchInBatch.Add(ancestors.GetDistinctAncestorIDs().Diff(parentIDs)) // Append direct children of matching work items that have a child that is // also a match and are not yet in the list. nonMatchingChildItems := childLinks.GetDistinctListOfTargetIDs(link.SystemWorkItemLinkTypeParentChildID) fetchInBatch.Add(fetchInBatch.Diff(nonMatchingChildItems)) // Eliminate work items already in the search fetchInBatch = fetchInBatch.Sub(matchingIDs) wis := []*workitem.WorkItem{} err := application.Transactional(c.db, func(appl application.Application) error { var err error wis, err = appl.WorkItems().LoadBatchByID(ctx, fetchInBatch) return err }) if err != nil { log.Error(ctx, map[string]interface{}{ "wis": wis, "err": err, }, "unable to load parent work items in batch: %s", fetchInBatch) return errs.Wrapf(err, "unable to load work item items in batch: %s", fetchInBatch) } for _, ele := range wis { wit, err := c.db.WorkItemTypes().Load(ctx.Context, ele.Type) if err != nil { return errs.Wrapf(err, "failed to load work item type: %s", ele.Type) } convertedWI, err := ConvertWorkItem(ctx.Request, *wit, *ele, hasChildren, includeParentWorkItem(ctx, ancestors, childLinks)) if err != nil { return errs.WithStack(err) } res.Included = append(res.Included, *convertedWI) } return nil }
[ "func", "(", "c", "*", "SearchController", ")", "enrichWorkItemList", "(", "ctx", "*", "app", ".", "ShowSearchContext", ",", "ancestors", "link", ".", "AncestorList", ",", "matchingIDs", "id", ".", "Slice", ",", "childLinks", "link", ".", "WorkItemLinkList", ",", "res", "*", "app", ".", "SearchWorkItemList", ",", "hasChildren", "WorkItemConvertFunc", ")", "error", "{", "parentIDs", ":=", "id", ".", "Slice", "{", "}", "\n", "for", "_", ",", "wi", ":=", "range", "res", ".", "Data", "{", "if", "wi", ".", "Relationships", "!=", "nil", "&&", "wi", ".", "Relationships", ".", "Parent", "!=", "nil", "&&", "wi", ".", "Relationships", ".", "Parent", ".", "Data", "!=", "nil", "{", "parentIDs", "=", "append", "(", "parentIDs", ",", "wi", ".", "Relationships", ".", "Parent", ".", "Data", ".", "ID", ")", "\n", "}", "\n", "}", "\n\n", "// Also append the ancestors not already included in the parent list", "fetchInBatch", ":=", "parentIDs", "\n", "fetchInBatch", ".", "Add", "(", "ancestors", ".", "GetDistinctAncestorIDs", "(", ")", ".", "Diff", "(", "parentIDs", ")", ")", "\n\n", "// Append direct children of matching work items that have a child that is", "// also a match and are not yet in the list.", "nonMatchingChildItems", ":=", "childLinks", ".", "GetDistinctListOfTargetIDs", "(", "link", ".", "SystemWorkItemLinkTypeParentChildID", ")", "\n", "fetchInBatch", ".", "Add", "(", "fetchInBatch", ".", "Diff", "(", "nonMatchingChildItems", ")", ")", "\n\n", "// Eliminate work items already in the search", "fetchInBatch", "=", "fetchInBatch", ".", "Sub", "(", "matchingIDs", ")", "\n\n", "wis", ":=", "[", "]", "*", "workitem", ".", "WorkItem", "{", "}", "\n", "err", ":=", "application", ".", "Transactional", "(", "c", ".", "db", ",", "func", "(", "appl", "application", ".", "Application", ")", "error", "{", "var", "err", "error", "\n", "wis", ",", "err", "=", "appl", ".", "WorkItems", "(", ")", ".", "LoadBatchByID", "(", "ctx", ",", "fetchInBatch", ")", "\n", "return", "err", "\n", "}", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "wis", ",", "\"", "\"", ":", "err", ",", "}", ",", "\"", "\"", ",", "fetchInBatch", ")", "\n", "return", "errs", ".", "Wrapf", "(", "err", ",", "\"", "\"", ",", "fetchInBatch", ")", "\n", "}", "\n\n", "for", "_", ",", "ele", ":=", "range", "wis", "{", "wit", ",", "err", ":=", "c", ".", "db", ".", "WorkItemTypes", "(", ")", ".", "Load", "(", "ctx", ".", "Context", ",", "ele", ".", "Type", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errs", ".", "Wrapf", "(", "err", ",", "\"", "\"", ",", "ele", ".", "Type", ")", "\n", "}", "\n", "convertedWI", ",", "err", ":=", "ConvertWorkItem", "(", "ctx", ".", "Request", ",", "*", "wit", ",", "*", "ele", ",", "hasChildren", ",", "includeParentWorkItem", "(", "ctx", ",", "ancestors", ",", "childLinks", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errs", ".", "WithStack", "(", "err", ")", "\n", "}", "\n", "res", ".", "Included", "=", "append", "(", "res", ".", "Included", ",", "*", "convertedWI", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Iterate over the WI list and read parent IDs // Fetch and load Parent WI in the included list
[ "Iterate", "over", "the", "WI", "list", "and", "read", "parent", "IDs", "Fetch", "and", "load", "Parent", "WI", "in", "the", "included", "list" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/controller/search.go#L494-L540
13,237
fabric8-services/fabric8-wit
controller/search.go
Codebases
func (c *SearchController) Codebases(ctx *app.CodebasesSearchContext) error { if ctx.URL == "" { return jsonapi.JSONErrorResponse(ctx, goa.ErrBadRequest("empty search query not allowed")) } offset, limit := computePagingLimits(ctx.PageOffset, ctx.PageLimit) var matchingCodebases []codebase.Codebase var relatedSpaces []space.Space var totalCount int err := application.Transactional(c.db, func(appl application.Application) error { var err error url, err := convertGithubURL(ctx.URL) if err != nil { return nil } matchingCodebases, totalCount, err = appl.Codebases().SearchByURL(ctx, url, &offset, &limit) if err != nil { log.Error(ctx, map[string]interface{}{ "url": ctx.URL, "offset": offset, "limit": limit, "err": err, }, "unable to search codebases by URL") return err } // look-up the spaces of the matching codebases spaceIDs := make([]uuid.UUID, len(matchingCodebases)) for i, c := range matchingCodebases { spaceIDs[i] = c.SpaceID } relatedSpaces, err = appl.Spaces().LoadMany(ctx, spaceIDs) return err }) if err != nil { return jsonapi.JSONErrorResponse(ctx, err) } // put all related spaces and associated owners in the `included` data includedData := make([]interface{}, len(relatedSpaces)) for i, relatedSpace := range relatedSpaces { appSpace, err := ConvertSpaceFromModel(ctx.Request, relatedSpace) if err != nil { return err } includedData[i] = *appSpace } codebasesData := ConvertCodebases(ctx.Request, matchingCodebases) response := app.CodebaseList{ Links: &app.PagingLinks{}, Meta: &app.CodebaseListMeta{TotalCount: totalCount}, Data: codebasesData, Included: includedData, } setPagingLinks(response.Links, buildAbsoluteURL(ctx.Request), len(matchingCodebases), offset, limit, totalCount, "url="+ctx.URL) return ctx.OK(&response) }
go
func (c *SearchController) Codebases(ctx *app.CodebasesSearchContext) error { if ctx.URL == "" { return jsonapi.JSONErrorResponse(ctx, goa.ErrBadRequest("empty search query not allowed")) } offset, limit := computePagingLimits(ctx.PageOffset, ctx.PageLimit) var matchingCodebases []codebase.Codebase var relatedSpaces []space.Space var totalCount int err := application.Transactional(c.db, func(appl application.Application) error { var err error url, err := convertGithubURL(ctx.URL) if err != nil { return nil } matchingCodebases, totalCount, err = appl.Codebases().SearchByURL(ctx, url, &offset, &limit) if err != nil { log.Error(ctx, map[string]interface{}{ "url": ctx.URL, "offset": offset, "limit": limit, "err": err, }, "unable to search codebases by URL") return err } // look-up the spaces of the matching codebases spaceIDs := make([]uuid.UUID, len(matchingCodebases)) for i, c := range matchingCodebases { spaceIDs[i] = c.SpaceID } relatedSpaces, err = appl.Spaces().LoadMany(ctx, spaceIDs) return err }) if err != nil { return jsonapi.JSONErrorResponse(ctx, err) } // put all related spaces and associated owners in the `included` data includedData := make([]interface{}, len(relatedSpaces)) for i, relatedSpace := range relatedSpaces { appSpace, err := ConvertSpaceFromModel(ctx.Request, relatedSpace) if err != nil { return err } includedData[i] = *appSpace } codebasesData := ConvertCodebases(ctx.Request, matchingCodebases) response := app.CodebaseList{ Links: &app.PagingLinks{}, Meta: &app.CodebaseListMeta{TotalCount: totalCount}, Data: codebasesData, Included: includedData, } setPagingLinks(response.Links, buildAbsoluteURL(ctx.Request), len(matchingCodebases), offset, limit, totalCount, "url="+ctx.URL) return ctx.OK(&response) }
[ "func", "(", "c", "*", "SearchController", ")", "Codebases", "(", "ctx", "*", "app", ".", "CodebasesSearchContext", ")", "error", "{", "if", "ctx", ".", "URL", "==", "\"", "\"", "{", "return", "jsonapi", ".", "JSONErrorResponse", "(", "ctx", ",", "goa", ".", "ErrBadRequest", "(", "\"", "\"", ")", ")", "\n", "}", "\n", "offset", ",", "limit", ":=", "computePagingLimits", "(", "ctx", ".", "PageOffset", ",", "ctx", ".", "PageLimit", ")", "\n", "var", "matchingCodebases", "[", "]", "codebase", ".", "Codebase", "\n", "var", "relatedSpaces", "[", "]", "space", ".", "Space", "\n", "var", "totalCount", "int", "\n", "err", ":=", "application", ".", "Transactional", "(", "c", ".", "db", ",", "func", "(", "appl", "application", ".", "Application", ")", "error", "{", "var", "err", "error", "\n", "url", ",", "err", ":=", "convertGithubURL", "(", "ctx", ".", "URL", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", "\n", "}", "\n", "matchingCodebases", ",", "totalCount", ",", "err", "=", "appl", ".", "Codebases", "(", ")", ".", "SearchByURL", "(", "ctx", ",", "url", ",", "&", "offset", ",", "&", "limit", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "ctx", ".", "URL", ",", "\"", "\"", ":", "offset", ",", "\"", "\"", ":", "limit", ",", "\"", "\"", ":", "err", ",", "}", ",", "\"", "\"", ")", "\n", "return", "err", "\n", "}", "\n", "// look-up the spaces of the matching codebases", "spaceIDs", ":=", "make", "(", "[", "]", "uuid", ".", "UUID", ",", "len", "(", "matchingCodebases", ")", ")", "\n", "for", "i", ",", "c", ":=", "range", "matchingCodebases", "{", "spaceIDs", "[", "i", "]", "=", "c", ".", "SpaceID", "\n", "}", "\n", "relatedSpaces", ",", "err", "=", "appl", ".", "Spaces", "(", ")", ".", "LoadMany", "(", "ctx", ",", "spaceIDs", ")", "\n", "return", "err", "\n", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "jsonapi", ".", "JSONErrorResponse", "(", "ctx", ",", "err", ")", "\n", "}", "\n", "// put all related spaces and associated owners in the `included` data", "includedData", ":=", "make", "(", "[", "]", "interface", "{", "}", ",", "len", "(", "relatedSpaces", ")", ")", "\n", "for", "i", ",", "relatedSpace", ":=", "range", "relatedSpaces", "{", "appSpace", ",", "err", ":=", "ConvertSpaceFromModel", "(", "ctx", ".", "Request", ",", "relatedSpace", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "includedData", "[", "i", "]", "=", "*", "appSpace", "\n", "}", "\n", "codebasesData", ":=", "ConvertCodebases", "(", "ctx", ".", "Request", ",", "matchingCodebases", ")", "\n", "response", ":=", "app", ".", "CodebaseList", "{", "Links", ":", "&", "app", ".", "PagingLinks", "{", "}", ",", "Meta", ":", "&", "app", ".", "CodebaseListMeta", "{", "TotalCount", ":", "totalCount", "}", ",", "Data", ":", "codebasesData", ",", "Included", ":", "includedData", ",", "}", "\n", "setPagingLinks", "(", "response", ".", "Links", ",", "buildAbsoluteURL", "(", "ctx", ".", "Request", ")", ",", "len", "(", "matchingCodebases", ")", ",", "offset", ",", "limit", ",", "totalCount", ",", "\"", "\"", "+", "ctx", ".", "URL", ")", "\n", "return", "ctx", ".", "OK", "(", "&", "response", ")", "\n", "}" ]
// Codebases runs the codebases search action.
[ "Codebases", "runs", "the", "codebases", "search", "action", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/controller/search.go#L543-L596
13,238
fabric8-services/fabric8-wit
workitem/simple_type.go
Validate
func (t SimpleType) Validate() error { if !t.Kind.IsSimpleType() { return errs.New("a simple type can only have a simple type (e.g. no list or enum)") } _, err := t.SetDefaultValue(t.DefaultValue) if err != nil { return errs.Wrapf(err, "failed to validate default value for kind %s: %+v (%[1]T)", t.Kind, t.DefaultValue) } return nil }
go
func (t SimpleType) Validate() error { if !t.Kind.IsSimpleType() { return errs.New("a simple type can only have a simple type (e.g. no list or enum)") } _, err := t.SetDefaultValue(t.DefaultValue) if err != nil { return errs.Wrapf(err, "failed to validate default value for kind %s: %+v (%[1]T)", t.Kind, t.DefaultValue) } return nil }
[ "func", "(", "t", "SimpleType", ")", "Validate", "(", ")", "error", "{", "if", "!", "t", ".", "Kind", ".", "IsSimpleType", "(", ")", "{", "return", "errs", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "_", ",", "err", ":=", "t", ".", "SetDefaultValue", "(", "t", ".", "DefaultValue", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errs", ".", "Wrapf", "(", "err", ",", "\"", "\"", ",", "t", ".", "Kind", ",", "t", ".", "DefaultValue", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Validate checks that the default value matches the Kind
[ "Validate", "checks", "that", "the", "default", "value", "matches", "the", "Kind" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/simple_type.go#L32-L41
13,239
fabric8-services/fabric8-wit
workitem/simple_type.go
Equal
func (t SimpleType) Equal(u convert.Equaler) bool { other, ok := u.(SimpleType) if !ok { return false } if t.DefaultValue != other.DefaultValue { return false } return t.Kind == other.Kind }
go
func (t SimpleType) Equal(u convert.Equaler) bool { other, ok := u.(SimpleType) if !ok { return false } if t.DefaultValue != other.DefaultValue { return false } return t.Kind == other.Kind }
[ "func", "(", "t", "SimpleType", ")", "Equal", "(", "u", "convert", ".", "Equaler", ")", "bool", "{", "other", ",", "ok", ":=", "u", ".", "(", "SimpleType", ")", "\n", "if", "!", "ok", "{", "return", "false", "\n", "}", "\n", "if", "t", ".", "DefaultValue", "!=", "other", ".", "DefaultValue", "{", "return", "false", "\n", "}", "\n", "return", "t", ".", "Kind", "==", "other", ".", "Kind", "\n", "}" ]
// Equal returns true if two SimpleType objects are equal; otherwise false is returned.
[ "Equal", "returns", "true", "if", "two", "SimpleType", "objects", "are", "equal", ";", "otherwise", "false", "is", "returned", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/simple_type.go#L63-L72
13,240
fabric8-services/fabric8-wit
workitem/simple_type.go
ConvertToModelWithType
func (t SimpleType) ConvertToModelWithType(newFieldType FieldType, v interface{}) (interface{}, error) { // Try to assign the old value to the new field newVal, err := newFieldType.ConvertToModel(v) if err == nil { return newVal, nil } // if the new type is a list, stuff the old value in a list and // try to assign it if newFieldType.GetKind() == KindList { newVal, err = newFieldType.ConvertToModel([]interface{}{v}) if err == nil { return newVal, nil } } // if the old type is a list but the new one isn't check that // the list contains only one element and assign that if t.GetKind() == KindList && newFieldType.GetKind() != KindList { ifArr, ok := v.([]interface{}) if !ok { return nil, errs.Errorf("failed to convert value to interface array: %+v", v) } if len(ifArr) == 1 { newVal, err = newFieldType.ConvertToModel(ifArr[0]) if err == nil { return newVal, nil } } } return nil, errs.Errorf("failed to convert value %+v (%[1]T) to field type %+v (%[2]T)", v, newFieldType) }
go
func (t SimpleType) ConvertToModelWithType(newFieldType FieldType, v interface{}) (interface{}, error) { // Try to assign the old value to the new field newVal, err := newFieldType.ConvertToModel(v) if err == nil { return newVal, nil } // if the new type is a list, stuff the old value in a list and // try to assign it if newFieldType.GetKind() == KindList { newVal, err = newFieldType.ConvertToModel([]interface{}{v}) if err == nil { return newVal, nil } } // if the old type is a list but the new one isn't check that // the list contains only one element and assign that if t.GetKind() == KindList && newFieldType.GetKind() != KindList { ifArr, ok := v.([]interface{}) if !ok { return nil, errs.Errorf("failed to convert value to interface array: %+v", v) } if len(ifArr) == 1 { newVal, err = newFieldType.ConvertToModel(ifArr[0]) if err == nil { return newVal, nil } } } return nil, errs.Errorf("failed to convert value %+v (%[1]T) to field type %+v (%[2]T)", v, newFieldType) }
[ "func", "(", "t", "SimpleType", ")", "ConvertToModelWithType", "(", "newFieldType", "FieldType", ",", "v", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "// Try to assign the old value to the new field", "newVal", ",", "err", ":=", "newFieldType", ".", "ConvertToModel", "(", "v", ")", "\n", "if", "err", "==", "nil", "{", "return", "newVal", ",", "nil", "\n", "}", "\n\n", "// if the new type is a list, stuff the old value in a list and", "// try to assign it", "if", "newFieldType", ".", "GetKind", "(", ")", "==", "KindList", "{", "newVal", ",", "err", "=", "newFieldType", ".", "ConvertToModel", "(", "[", "]", "interface", "{", "}", "{", "v", "}", ")", "\n", "if", "err", "==", "nil", "{", "return", "newVal", ",", "nil", "\n", "}", "\n", "}", "\n\n", "// if the old type is a list but the new one isn't check that", "// the list contains only one element and assign that", "if", "t", ".", "GetKind", "(", ")", "==", "KindList", "&&", "newFieldType", ".", "GetKind", "(", ")", "!=", "KindList", "{", "ifArr", ",", "ok", ":=", "v", ".", "(", "[", "]", "interface", "{", "}", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "errs", ".", "Errorf", "(", "\"", "\"", ",", "v", ")", "\n", "}", "\n", "if", "len", "(", "ifArr", ")", "==", "1", "{", "newVal", ",", "err", "=", "newFieldType", ".", "ConvertToModel", "(", "ifArr", "[", "0", "]", ")", "\n", "if", "err", "==", "nil", "{", "return", "newVal", ",", "nil", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "nil", ",", "errs", ".", "Errorf", "(", "\"", "\"", ",", "v", ",", "newFieldType", ")", "\n", "}" ]
// ConvertToModelWithType implements FieldType
[ "ConvertToModelWithType", "implements", "FieldType" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/simple_type.go#L349-L380
13,241
fabric8-services/fabric8-wit
workitem/simple_type.go
AnyToUUID
func AnyToUUID(value interface{}) (uuid.UUID, error) { switch v := value.(type) { case uuid.UUID: return v, nil case string: return uuid.FromString(v) } return uuid.Nil, errs.Errorf(`value %+v (%[1]T) should be "string" or "uuid"`, value) }
go
func AnyToUUID(value interface{}) (uuid.UUID, error) { switch v := value.(type) { case uuid.UUID: return v, nil case string: return uuid.FromString(v) } return uuid.Nil, errs.Errorf(`value %+v (%[1]T) should be "string" or "uuid"`, value) }
[ "func", "AnyToUUID", "(", "value", "interface", "{", "}", ")", "(", "uuid", ".", "UUID", ",", "error", ")", "{", "switch", "v", ":=", "value", ".", "(", "type", ")", "{", "case", "uuid", ".", "UUID", ":", "return", "v", ",", "nil", "\n", "case", "string", ":", "return", "uuid", ".", "FromString", "(", "v", ")", "\n", "}", "\n", "return", "uuid", ".", "Nil", ",", "errs", ".", "Errorf", "(", "`value %+v (%[1]T) should be \"string\" or \"uuid\"`", ",", "value", ")", "\n", "}" ]
// AnyToUUID will return a proper UUID if the given input value is either a // string or a uuid.UUID object; otherwise a Nil UUID with an error will be // returned. Note, that "00000000-0000-0000-0000-000000000000" and the uuid.Nil // object are legal input values that won't produce an error. An empty string // will produce an error and it does not translate to uuid.Nil.
[ "AnyToUUID", "will", "return", "a", "proper", "UUID", "if", "the", "given", "input", "value", "is", "either", "a", "string", "or", "a", "uuid", ".", "UUID", "object", ";", "otherwise", "a", "Nil", "UUID", "with", "an", "error", "will", "be", "returned", ".", "Note", "that", "00000000", "-", "0000", "-", "0000", "-", "0000", "-", "000000000000", "and", "the", "uuid", ".", "Nil", "object", "are", "legal", "input", "values", "that", "won", "t", "produce", "an", "error", ".", "An", "empty", "string", "will", "produce", "an", "error", "and", "it", "does", "not", "translate", "to", "uuid", ".", "Nil", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/simple_type.go#L387-L395
13,242
fabric8-services/fabric8-wit
criteria/expression_not.go
Not
func Not(left Expression, right Expression) Expression { return reparent(&NotExpression{binaryExpression{expression{}, left, right}}) }
go
func Not(left Expression, right Expression) Expression { return reparent(&NotExpression{binaryExpression{expression{}, left, right}}) }
[ "func", "Not", "(", "left", "Expression", ",", "right", "Expression", ")", "Expression", "{", "return", "reparent", "(", "&", "NotExpression", "{", "binaryExpression", "{", "expression", "{", "}", ",", "left", ",", "right", "}", "}", ")", "\n", "}" ]
// Not constructs a NotExpression
[ "Not", "constructs", "a", "NotExpression" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/criteria/expression_not.go#L18-L20
13,243
fabric8-services/fabric8-wit
workitem/field_definition.go
IsRelational
func (k Kind) IsRelational() bool { switch k { case KindIteration, KindUser, KindLabel, KindBoardColumn, KindArea, KindRemoteTracker, KindCodebase: return true } return false }
go
func (k Kind) IsRelational() bool { switch k { case KindIteration, KindUser, KindLabel, KindBoardColumn, KindArea, KindRemoteTracker, KindCodebase: return true } return false }
[ "func", "(", "k", "Kind", ")", "IsRelational", "(", ")", "bool", "{", "switch", "k", "{", "case", "KindIteration", ",", "KindUser", ",", "KindLabel", ",", "KindBoardColumn", ",", "KindArea", ",", "KindRemoteTracker", ",", "KindCodebase", ":", "return", "true", "\n", "}", "\n", "return", "false", "\n", "}" ]
// IsRelational returns 'true' if the kind must be represented with a // relationship.
[ "IsRelational", "returns", "true", "if", "the", "kind", "must", "be", "represented", "with", "a", "relationship", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/field_definition.go#L47-L59
13,244
fabric8-services/fabric8-wit
workitem/field_definition.go
Validate
func (f FieldDefinition) Validate() error { if strings.TrimSpace(f.Label) == "" { return errs.Errorf(`field label is empty "%s" when trimmed`, f.Label) } return f.Type.Validate() }
go
func (f FieldDefinition) Validate() error { if strings.TrimSpace(f.Label) == "" { return errs.Errorf(`field label is empty "%s" when trimmed`, f.Label) } return f.Type.Validate() }
[ "func", "(", "f", "FieldDefinition", ")", "Validate", "(", ")", "error", "{", "if", "strings", ".", "TrimSpace", "(", "f", ".", "Label", ")", "==", "\"", "\"", "{", "return", "errs", ".", "Errorf", "(", "`field label is empty \"%s\" when trimmed`", ",", "f", ".", "Label", ")", "\n", "}", "\n", "return", "f", ".", "Type", ".", "Validate", "(", ")", "\n", "}" ]
// Validate checks that a field has a proper setup
[ "Validate", "checks", "that", "a", "field", "has", "a", "proper", "setup" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/field_definition.go#L119-L124
13,245
fabric8-services/fabric8-wit
workitem/field_definition.go
Equal
func (f FieldDefinition) Equal(u convert.Equaler) bool { other, ok := u.(FieldDefinition) if !ok { return false } if f.Required != other.Required { return false } if f.ReadOnly != other.ReadOnly { return false } if f.Label != other.Label { return false } if f.Description != other.Description { return false } return convert.CascadeEqual(f.Type, other.Type) }
go
func (f FieldDefinition) Equal(u convert.Equaler) bool { other, ok := u.(FieldDefinition) if !ok { return false } if f.Required != other.Required { return false } if f.ReadOnly != other.ReadOnly { return false } if f.Label != other.Label { return false } if f.Description != other.Description { return false } return convert.CascadeEqual(f.Type, other.Type) }
[ "func", "(", "f", "FieldDefinition", ")", "Equal", "(", "u", "convert", ".", "Equaler", ")", "bool", "{", "other", ",", "ok", ":=", "u", ".", "(", "FieldDefinition", ")", "\n", "if", "!", "ok", "{", "return", "false", "\n", "}", "\n", "if", "f", ".", "Required", "!=", "other", ".", "Required", "{", "return", "false", "\n", "}", "\n", "if", "f", ".", "ReadOnly", "!=", "other", ".", "ReadOnly", "{", "return", "false", "\n", "}", "\n", "if", "f", ".", "Label", "!=", "other", ".", "Label", "{", "return", "false", "\n", "}", "\n", "if", "f", ".", "Description", "!=", "other", ".", "Description", "{", "return", "false", "\n", "}", "\n", "return", "convert", ".", "CascadeEqual", "(", "f", ".", "Type", ",", "other", ".", "Type", ")", "\n", "}" ]
// Equal returns true if two FieldDefinition objects are equal; otherwise false is returned.
[ "Equal", "returns", "true", "if", "two", "FieldDefinition", "objects", "are", "equal", ";", "otherwise", "false", "is", "returned", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/field_definition.go#L127-L145
13,246
fabric8-services/fabric8-wit
workitem/field_definition.go
ConvertToModel
func (f FieldDefinition) ConvertToModel(name string, value interface{}) (interface{}, error) { // Overwrite value if default value if none was provided if value == nil { value = f.Type.GetDefaultValue() } if f.Required { if value == nil { return nil, fmt.Errorf("value for field %q must not be nil", name) } if f.Type.GetKind() == KindString { sVal, ok := value.(string) if !ok { return nil, errs.Errorf("failed to convert '%+v' to string", spew.Sdump(value)) } if strings.TrimSpace(sVal) == "" { return nil, errs.Errorf("value for field %q must not be empty: \"%+v\"", name, value) } } } return f.Type.ConvertToModel(value) }
go
func (f FieldDefinition) ConvertToModel(name string, value interface{}) (interface{}, error) { // Overwrite value if default value if none was provided if value == nil { value = f.Type.GetDefaultValue() } if f.Required { if value == nil { return nil, fmt.Errorf("value for field %q must not be nil", name) } if f.Type.GetKind() == KindString { sVal, ok := value.(string) if !ok { return nil, errs.Errorf("failed to convert '%+v' to string", spew.Sdump(value)) } if strings.TrimSpace(sVal) == "" { return nil, errs.Errorf("value for field %q must not be empty: \"%+v\"", name, value) } } } return f.Type.ConvertToModel(value) }
[ "func", "(", "f", "FieldDefinition", ")", "ConvertToModel", "(", "name", "string", ",", "value", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "// Overwrite value if default value if none was provided", "if", "value", "==", "nil", "{", "value", "=", "f", ".", "Type", ".", "GetDefaultValue", "(", ")", "\n", "}", "\n\n", "if", "f", ".", "Required", "{", "if", "value", "==", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ")", "\n", "}", "\n", "if", "f", ".", "Type", ".", "GetKind", "(", ")", "==", "KindString", "{", "sVal", ",", "ok", ":=", "value", ".", "(", "string", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "errs", ".", "Errorf", "(", "\"", "\"", ",", "spew", ".", "Sdump", "(", "value", ")", ")", "\n", "}", "\n", "if", "strings", ".", "TrimSpace", "(", "sVal", ")", "==", "\"", "\"", "{", "return", "nil", ",", "errs", ".", "Errorf", "(", "\"", "\\\"", "\\\"", "\"", ",", "name", ",", "value", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "f", ".", "Type", ".", "ConvertToModel", "(", "value", ")", "\n", "}" ]
// ConvertToModel converts a field value for use in the persistence layer
[ "ConvertToModel", "converts", "a", "field", "value", "for", "use", "in", "the", "persistence", "layer" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/field_definition.go#L153-L174
13,247
fabric8-services/fabric8-wit
workitem/field_definition.go
ConvertFromModel
func (f FieldDefinition) ConvertFromModel(name string, value interface{}) (interface{}, error) { if f.Required && value == nil { return nil, fmt.Errorf("Value %s is required", name) } return f.Type.ConvertFromModel(value) }
go
func (f FieldDefinition) ConvertFromModel(name string, value interface{}) (interface{}, error) { if f.Required && value == nil { return nil, fmt.Errorf("Value %s is required", name) } return f.Type.ConvertFromModel(value) }
[ "func", "(", "f", "FieldDefinition", ")", "ConvertFromModel", "(", "name", "string", ",", "value", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "if", "f", ".", "Required", "&&", "value", "==", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ")", "\n", "}", "\n", "return", "f", ".", "Type", ".", "ConvertFromModel", "(", "value", ")", "\n", "}" ]
// ConvertFromModel converts a field value for use in the REST API layer
[ "ConvertFromModel", "converts", "a", "field", "value", "for", "use", "in", "the", "REST", "API", "layer" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/field_definition.go#L177-L182
13,248
fabric8-services/fabric8-wit
workitem/field_definition.go
Equal
func (f rawFieldDef) Equal(u convert.Equaler) bool { other, ok := u.(rawFieldDef) if !ok { return false } if f.Required != other.Required { return false } if f.ReadOnly != other.ReadOnly { return false } if f.Label != other.Label { return false } if f.Description != other.Description { return false } if !reflect.DeepEqual(f.Type, other.Type) { return false } return true }
go
func (f rawFieldDef) Equal(u convert.Equaler) bool { other, ok := u.(rawFieldDef) if !ok { return false } if f.Required != other.Required { return false } if f.ReadOnly != other.ReadOnly { return false } if f.Label != other.Label { return false } if f.Description != other.Description { return false } if !reflect.DeepEqual(f.Type, other.Type) { return false } return true }
[ "func", "(", "f", "rawFieldDef", ")", "Equal", "(", "u", "convert", ".", "Equaler", ")", "bool", "{", "other", ",", "ok", ":=", "u", ".", "(", "rawFieldDef", ")", "\n", "if", "!", "ok", "{", "return", "false", "\n", "}", "\n", "if", "f", ".", "Required", "!=", "other", ".", "Required", "{", "return", "false", "\n", "}", "\n", "if", "f", ".", "ReadOnly", "!=", "other", ".", "ReadOnly", "{", "return", "false", "\n", "}", "\n", "if", "f", ".", "Label", "!=", "other", ".", "Label", "{", "return", "false", "\n", "}", "\n", "if", "f", ".", "Description", "!=", "other", ".", "Description", "{", "return", "false", "\n", "}", "\n", "if", "!", "reflect", ".", "DeepEqual", "(", "f", ".", "Type", ",", "other", ".", "Type", ")", "{", "return", "false", "\n", "}", "\n", "return", "true", "\n", "}" ]
// Equal returns true if two rawFieldDef objects are equal; otherwise false is returned.
[ "Equal", "returns", "true", "if", "two", "rawFieldDef", "objects", "are", "equal", ";", "otherwise", "false", "is", "returned", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/field_definition.go#L197-L218
13,249
fabric8-services/fabric8-wit
workitem/field_definition.go
ConvertStringToKind
func ConvertStringToKind(k string) (*Kind, error) { kind := Kind(k) switch kind { case KindString, KindInteger, KindFloat, KindInstant, KindURL, KindUser, KindEnum, KindList, KindIteration, KindMarkup, KindArea, KindCodebase, KindLabel, KindBoardColumn, KindBoolean, KindRemoteTracker: return &kind, nil } return nil, errs.Errorf("kind '%s' is not a simple type", k) }
go
func ConvertStringToKind(k string) (*Kind, error) { kind := Kind(k) switch kind { case KindString, KindInteger, KindFloat, KindInstant, KindURL, KindUser, KindEnum, KindList, KindIteration, KindMarkup, KindArea, KindCodebase, KindLabel, KindBoardColumn, KindBoolean, KindRemoteTracker: return &kind, nil } return nil, errs.Errorf("kind '%s' is not a simple type", k) }
[ "func", "ConvertStringToKind", "(", "k", "string", ")", "(", "*", "Kind", ",", "error", ")", "{", "kind", ":=", "Kind", "(", "k", ")", "\n", "switch", "kind", "{", "case", "KindString", ",", "KindInteger", ",", "KindFloat", ",", "KindInstant", ",", "KindURL", ",", "KindUser", ",", "KindEnum", ",", "KindList", ",", "KindIteration", ",", "KindMarkup", ",", "KindArea", ",", "KindCodebase", ",", "KindLabel", ",", "KindBoardColumn", ",", "KindBoolean", ",", "KindRemoteTracker", ":", "return", "&", "kind", ",", "nil", "\n", "}", "\n", "return", "nil", ",", "errs", ".", "Errorf", "(", "\"", "\"", ",", "k", ")", "\n", "}" ]
// ConvertStringToKind returns the given string as a Kind object
[ "ConvertStringToKind", "returns", "the", "given", "string", "as", "a", "Kind", "object" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/field_definition.go#L290-L297
13,250
fabric8-services/fabric8-wit
workitem/field_definition.go
compatibleFields
func compatibleFields(existing FieldDefinition, new FieldDefinition) bool { if existing.Required != new.Required { return false } return existing.Type.Equal(new.Type) }
go
func compatibleFields(existing FieldDefinition, new FieldDefinition) bool { if existing.Required != new.Required { return false } return existing.Type.Equal(new.Type) }
[ "func", "compatibleFields", "(", "existing", "FieldDefinition", ",", "new", "FieldDefinition", ")", "bool", "{", "if", "existing", ".", "Required", "!=", "new", ".", "Required", "{", "return", "false", "\n", "}", "\n", "return", "existing", ".", "Type", ".", "Equal", "(", "new", ".", "Type", ")", "\n", "}" ]
// compatibleFields returns true if the existing and new field are compatible; // otherwise false is returned. It does so by comparing all members of the field // definition except for the label and description.
[ "compatibleFields", "returns", "true", "if", "the", "existing", "and", "new", "field", "are", "compatible", ";", "otherwise", "false", "is", "returned", ".", "It", "does", "so", "by", "comparing", "all", "members", "of", "the", "field", "definition", "except", "for", "the", "label", "and", "description", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/field_definition.go#L302-L307
13,251
fabric8-services/fabric8-wit
remoteworkitem/scheduler.go
NewScheduler
func NewScheduler(db *gorm.DB) *Scheduler { s := Scheduler{db: db} return &s }
go
func NewScheduler(db *gorm.DB) *Scheduler { s := Scheduler{db: db} return &s }
[ "func", "NewScheduler", "(", "db", "*", "gorm", ".", "DB", ")", "*", "Scheduler", "{", "s", ":=", "Scheduler", "{", "db", ":", "db", "}", "\n", "return", "&", "s", "\n", "}" ]
// NewScheduler creates a new Scheduler
[ "NewScheduler", "creates", "a", "new", "Scheduler" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/remoteworkitem/scheduler.go#L35-L38
13,252
fabric8-services/fabric8-wit
remoteworkitem/scheduler.go
ScheduleAllQueries
func (s *Scheduler) ScheduleAllQueries(ctx context.Context, accessTokens map[string]string) { cr.Stop() trackerQueries := fetchTrackerQueries(s.db) for _, tq := range trackerQueries { cr.AddFunc(tq.Schedule, func() { tr := lookupProvider(tq) authToken := accessTokens[tq.TrackerType] // In case of Jira, no auth token is needed hence the map wouldnt // return anything. So effectively the authToken is optional. for i := range tr.Fetch(authToken) { models.Transactional(s.db, func(tx *gorm.DB) error { // Save the remote items in a 'temporary' table. err := Upload(tx, tq.TrackerID, i) if err != nil { return errors.WithStack(err) } // Convert the remote item into a local work item and persist in the DB. _, err = ConvertToWorkItemModel(ctx, tx, i, tq) return errors.WithStack(err) }) } }) } cr.Start() }
go
func (s *Scheduler) ScheduleAllQueries(ctx context.Context, accessTokens map[string]string) { cr.Stop() trackerQueries := fetchTrackerQueries(s.db) for _, tq := range trackerQueries { cr.AddFunc(tq.Schedule, func() { tr := lookupProvider(tq) authToken := accessTokens[tq.TrackerType] // In case of Jira, no auth token is needed hence the map wouldnt // return anything. So effectively the authToken is optional. for i := range tr.Fetch(authToken) { models.Transactional(s.db, func(tx *gorm.DB) error { // Save the remote items in a 'temporary' table. err := Upload(tx, tq.TrackerID, i) if err != nil { return errors.WithStack(err) } // Convert the remote item into a local work item and persist in the DB. _, err = ConvertToWorkItemModel(ctx, tx, i, tq) return errors.WithStack(err) }) } }) } cr.Start() }
[ "func", "(", "s", "*", "Scheduler", ")", "ScheduleAllQueries", "(", "ctx", "context", ".", "Context", ",", "accessTokens", "map", "[", "string", "]", "string", ")", "{", "cr", ".", "Stop", "(", ")", "\n\n", "trackerQueries", ":=", "fetchTrackerQueries", "(", "s", ".", "db", ")", "\n", "for", "_", ",", "tq", ":=", "range", "trackerQueries", "{", "cr", ".", "AddFunc", "(", "tq", ".", "Schedule", ",", "func", "(", ")", "{", "tr", ":=", "lookupProvider", "(", "tq", ")", "\n", "authToken", ":=", "accessTokens", "[", "tq", ".", "TrackerType", "]", "\n\n", "// In case of Jira, no auth token is needed hence the map wouldnt", "// return anything. So effectively the authToken is optional.", "for", "i", ":=", "range", "tr", ".", "Fetch", "(", "authToken", ")", "{", "models", ".", "Transactional", "(", "s", ".", "db", ",", "func", "(", "tx", "*", "gorm", ".", "DB", ")", "error", "{", "// Save the remote items in a 'temporary' table.", "err", ":=", "Upload", "(", "tx", ",", "tq", ".", "TrackerID", ",", "i", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "WithStack", "(", "err", ")", "\n", "}", "\n", "// Convert the remote item into a local work item and persist in the DB.", "_", ",", "err", "=", "ConvertToWorkItemModel", "(", "ctx", ",", "tx", ",", "i", ",", "tq", ")", "\n", "return", "errors", ".", "WithStack", "(", "err", ")", "\n", "}", ")", "\n", "}", "\n", "}", ")", "\n", "}", "\n", "cr", ".", "Start", "(", ")", "\n", "}" ]
// ScheduleAllQueries fetch and import of remote tracker items
[ "ScheduleAllQueries", "fetch", "and", "import", "of", "remote", "tracker", "items" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/remoteworkitem/scheduler.go#L52-L79
13,253
fabric8-services/fabric8-wit
remoteworkitem/scheduler.go
lookupProvider
func lookupProvider(ts TrackerSchedule) TrackerProvider { switch ts.TrackerType { case ProviderGithub: return &GithubTracker{URL: ts.URL, Query: ts.Query} case ProviderJira: return &JiraTracker{URL: ts.URL, Query: ts.Query} } return nil }
go
func lookupProvider(ts TrackerSchedule) TrackerProvider { switch ts.TrackerType { case ProviderGithub: return &GithubTracker{URL: ts.URL, Query: ts.Query} case ProviderJira: return &JiraTracker{URL: ts.URL, Query: ts.Query} } return nil }
[ "func", "lookupProvider", "(", "ts", "TrackerSchedule", ")", "TrackerProvider", "{", "switch", "ts", ".", "TrackerType", "{", "case", "ProviderGithub", ":", "return", "&", "GithubTracker", "{", "URL", ":", "ts", ".", "URL", ",", "Query", ":", "ts", ".", "Query", "}", "\n", "case", "ProviderJira", ":", "return", "&", "JiraTracker", "{", "URL", ":", "ts", ".", "URL", ",", "Query", ":", "ts", ".", "Query", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// lookupProvider provides the respective tracker based on the type
[ "lookupProvider", "provides", "the", "respective", "tracker", "based", "on", "the", "type" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/remoteworkitem/scheduler.go#L93-L101
13,254
fabric8-services/fabric8-wit
workitem/link/link.go
Equal
func (l WorkItemLink) Equal(u convert.Equaler) bool { other, ok := u.(WorkItemLink) if !ok { return false } if l.ID != other.ID { return false } if l.Version != other.Version { return false } if !convert.CascadeEqual(l.Lifecycle, other.Lifecycle) { return false } if l.SourceID != other.SourceID { return false } if l.TargetID != other.TargetID { return false } if l.LinkTypeID != other.LinkTypeID { return false } return true }
go
func (l WorkItemLink) Equal(u convert.Equaler) bool { other, ok := u.(WorkItemLink) if !ok { return false } if l.ID != other.ID { return false } if l.Version != other.Version { return false } if !convert.CascadeEqual(l.Lifecycle, other.Lifecycle) { return false } if l.SourceID != other.SourceID { return false } if l.TargetID != other.TargetID { return false } if l.LinkTypeID != other.LinkTypeID { return false } return true }
[ "func", "(", "l", "WorkItemLink", ")", "Equal", "(", "u", "convert", ".", "Equaler", ")", "bool", "{", "other", ",", "ok", ":=", "u", ".", "(", "WorkItemLink", ")", "\n", "if", "!", "ok", "{", "return", "false", "\n", "}", "\n", "if", "l", ".", "ID", "!=", "other", ".", "ID", "{", "return", "false", "\n", "}", "\n", "if", "l", ".", "Version", "!=", "other", ".", "Version", "{", "return", "false", "\n", "}", "\n", "if", "!", "convert", ".", "CascadeEqual", "(", "l", ".", "Lifecycle", ",", "other", ".", "Lifecycle", ")", "{", "return", "false", "\n", "}", "\n", "if", "l", ".", "SourceID", "!=", "other", ".", "SourceID", "{", "return", "false", "\n", "}", "\n", "if", "l", ".", "TargetID", "!=", "other", ".", "TargetID", "{", "return", "false", "\n", "}", "\n", "if", "l", ".", "LinkTypeID", "!=", "other", ".", "LinkTypeID", "{", "return", "false", "\n", "}", "\n", "return", "true", "\n", "}" ]
// Equal returns true if two WorkItemLink objects are equal; otherwise false is returned.
[ "Equal", "returns", "true", "if", "two", "WorkItemLink", "objects", "are", "equal", ";", "otherwise", "false", "is", "returned", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/link/link.go#L30-L54
13,255
fabric8-services/fabric8-wit
workitem/link/link.go
CheckValidForCreation
func (l *WorkItemLink) CheckValidForCreation() error { if uuid.Equal(l.LinkTypeID, uuid.Nil) { return errors.NewBadParameterError("link_type_id", l.LinkTypeID) } return nil }
go
func (l *WorkItemLink) CheckValidForCreation() error { if uuid.Equal(l.LinkTypeID, uuid.Nil) { return errors.NewBadParameterError("link_type_id", l.LinkTypeID) } return nil }
[ "func", "(", "l", "*", "WorkItemLink", ")", "CheckValidForCreation", "(", ")", "error", "{", "if", "uuid", ".", "Equal", "(", "l", ".", "LinkTypeID", ",", "uuid", ".", "Nil", ")", "{", "return", "errors", ".", "NewBadParameterError", "(", "\"", "\"", ",", "l", ".", "LinkTypeID", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// CheckValidForCreation returns an error if the work item link // cannot be used for the creation of a new work item link.
[ "CheckValidForCreation", "returns", "an", "error", "if", "the", "work", "item", "link", "cannot", "be", "used", "for", "the", "creation", "of", "a", "new", "work", "item", "link", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/link/link.go#L69-L74
13,256
fabric8-services/fabric8-wit
workitem/link/link.go
GetDistinctListOfTargetIDs
func (list WorkItemLinkList) GetDistinctListOfTargetIDs(linkTypeID uuid.UUID) id.Slice { m := id.Map{} for _, l := range list { if l.LinkTypeID == linkTypeID { m[l.TargetID] = struct{}{} } } return m.ToSlice() }
go
func (list WorkItemLinkList) GetDistinctListOfTargetIDs(linkTypeID uuid.UUID) id.Slice { m := id.Map{} for _, l := range list { if l.LinkTypeID == linkTypeID { m[l.TargetID] = struct{}{} } } return m.ToSlice() }
[ "func", "(", "list", "WorkItemLinkList", ")", "GetDistinctListOfTargetIDs", "(", "linkTypeID", "uuid", ".", "UUID", ")", "id", ".", "Slice", "{", "m", ":=", "id", ".", "Map", "{", "}", "\n", "for", "_", ",", "l", ":=", "range", "list", "{", "if", "l", ".", "LinkTypeID", "==", "linkTypeID", "{", "m", "[", "l", ".", "TargetID", "]", "=", "struct", "{", "}", "{", "}", "\n", "}", "\n", "}", "\n", "return", "m", ".", "ToSlice", "(", ")", "\n", "}" ]
// GetDistinctListOfTargetIDs returns a list of distinct source IDs in the given // list.
[ "GetDistinctListOfTargetIDs", "returns", "a", "list", "of", "distinct", "source", "IDs", "in", "the", "given", "list", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/link/link.go#L108-L116
13,257
fabric8-services/fabric8-wit
application/repository/exister.go
CheckExists
func CheckExists(ctx context.Context, db *gorm.DB, tableName string, id uuid.UUID) error { _, err := Exists(ctx, db, tableName, id.String()) return err }
go
func CheckExists(ctx context.Context, db *gorm.DB, tableName string, id uuid.UUID) error { _, err := Exists(ctx, db, tableName, id.String()) return err }
[ "func", "CheckExists", "(", "ctx", "context", ".", "Context", ",", "db", "*", "gorm", ".", "DB", ",", "tableName", "string", ",", "id", "uuid", ".", "UUID", ")", "error", "{", "_", ",", "err", ":=", "Exists", "(", "ctx", ",", "db", ",", "tableName", ",", "id", ".", "String", "(", ")", ")", "\n", "return", "err", "\n", "}" ]
// CheckExists does the same as Exists but only returns the error value; thereby // being a handy convenience function.
[ "CheckExists", "does", "the", "same", "as", "Exists", "but", "only", "returns", "the", "error", "value", ";", "thereby", "being", "a", "handy", "convenience", "function", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/application/repository/exister.go#L44-L47
13,258
fabric8-services/fabric8-wit
workitem/workitemtype_cache.go
Put
func (c *WorkItemTypeCache) Put(wit WorkItemType) { c.mapLock.Lock() defer c.mapLock.Unlock() c.cache[wit.ID] = wit }
go
func (c *WorkItemTypeCache) Put(wit WorkItemType) { c.mapLock.Lock() defer c.mapLock.Unlock() c.cache[wit.ID] = wit }
[ "func", "(", "c", "*", "WorkItemTypeCache", ")", "Put", "(", "wit", "WorkItemType", ")", "{", "c", ".", "mapLock", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mapLock", ".", "Unlock", "(", ")", "\n", "c", ".", "cache", "[", "wit", ".", "ID", "]", "=", "wit", "\n", "}" ]
// Put puts a work item type to the cache
[ "Put", "puts", "a", "work", "item", "type", "to", "the", "cache" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/workitemtype_cache.go#L35-L39
13,259
fabric8-services/fabric8-wit
workitem/workitemtype_cache.go
Clear
func (c *WorkItemTypeCache) Clear() { c.mapLock.Lock() defer c.mapLock.Unlock() log.Info(nil, nil, "Clearing work item cache") c.cache = make(witCacheMap) }
go
func (c *WorkItemTypeCache) Clear() { c.mapLock.Lock() defer c.mapLock.Unlock() log.Info(nil, nil, "Clearing work item cache") c.cache = make(witCacheMap) }
[ "func", "(", "c", "*", "WorkItemTypeCache", ")", "Clear", "(", ")", "{", "c", ".", "mapLock", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mapLock", ".", "Unlock", "(", ")", "\n", "log", ".", "Info", "(", "nil", ",", "nil", ",", "\"", "\"", ")", "\n\n", "c", ".", "cache", "=", "make", "(", "witCacheMap", ")", "\n", "}" ]
// Clear clears the cache
[ "Clear", "clears", "the", "cache" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/workitemtype_cache.go#L42-L48
13,260
fabric8-services/fabric8-wit
workitem/expression_compiler.go
bubbleUpJSONContext
func bubbleUpJSONContext(c *expressionCompiler) func(exp criteria.Expression) bool { return func(exp criteria.Expression) bool { switch t := exp.(type) { case *criteria.FieldExpression: _, isJSONField := c.getFieldName(t.FieldName) if isJSONField { t.SetAnnotation(jsonAnnotation, true) } case *criteria.EqualsExpression: if t.Left().Annotation(jsonAnnotation) == true || t.Right().Annotation(jsonAnnotation) == true { t.SetAnnotation(jsonAnnotation, true) } case *criteria.SubstringExpression: if t.Left().Annotation(jsonAnnotation) == true || t.Right().Annotation(jsonAnnotation) == true { t.SetAnnotation(jsonAnnotation, true) } case *criteria.NotExpression: if t.Left().Annotation(jsonAnnotation) == true || t.Right().Annotation(jsonAnnotation) == true { t.SetAnnotation(jsonAnnotation, true) } } return true } }
go
func bubbleUpJSONContext(c *expressionCompiler) func(exp criteria.Expression) bool { return func(exp criteria.Expression) bool { switch t := exp.(type) { case *criteria.FieldExpression: _, isJSONField := c.getFieldName(t.FieldName) if isJSONField { t.SetAnnotation(jsonAnnotation, true) } case *criteria.EqualsExpression: if t.Left().Annotation(jsonAnnotation) == true || t.Right().Annotation(jsonAnnotation) == true { t.SetAnnotation(jsonAnnotation, true) } case *criteria.SubstringExpression: if t.Left().Annotation(jsonAnnotation) == true || t.Right().Annotation(jsonAnnotation) == true { t.SetAnnotation(jsonAnnotation, true) } case *criteria.NotExpression: if t.Left().Annotation(jsonAnnotation) == true || t.Right().Annotation(jsonAnnotation) == true { t.SetAnnotation(jsonAnnotation, true) } } return true } }
[ "func", "bubbleUpJSONContext", "(", "c", "*", "expressionCompiler", ")", "func", "(", "exp", "criteria", ".", "Expression", ")", "bool", "{", "return", "func", "(", "exp", "criteria", ".", "Expression", ")", "bool", "{", "switch", "t", ":=", "exp", ".", "(", "type", ")", "{", "case", "*", "criteria", ".", "FieldExpression", ":", "_", ",", "isJSONField", ":=", "c", ".", "getFieldName", "(", "t", ".", "FieldName", ")", "\n", "if", "isJSONField", "{", "t", ".", "SetAnnotation", "(", "jsonAnnotation", ",", "true", ")", "\n", "}", "\n", "case", "*", "criteria", ".", "EqualsExpression", ":", "if", "t", ".", "Left", "(", ")", ".", "Annotation", "(", "jsonAnnotation", ")", "==", "true", "||", "t", ".", "Right", "(", ")", ".", "Annotation", "(", "jsonAnnotation", ")", "==", "true", "{", "t", ".", "SetAnnotation", "(", "jsonAnnotation", ",", "true", ")", "\n", "}", "\n", "case", "*", "criteria", ".", "SubstringExpression", ":", "if", "t", ".", "Left", "(", ")", ".", "Annotation", "(", "jsonAnnotation", ")", "==", "true", "||", "t", ".", "Right", "(", ")", ".", "Annotation", "(", "jsonAnnotation", ")", "==", "true", "{", "t", ".", "SetAnnotation", "(", "jsonAnnotation", ",", "true", ")", "\n", "}", "\n", "case", "*", "criteria", ".", "NotExpression", ":", "if", "t", ".", "Left", "(", ")", ".", "Annotation", "(", "jsonAnnotation", ")", "==", "true", "||", "t", ".", "Right", "(", ")", ".", "Annotation", "(", "jsonAnnotation", ")", "==", "true", "{", "t", ".", "SetAnnotation", "(", "jsonAnnotation", ",", "true", ")", "\n", "}", "\n", "}", "\n", "return", "true", "\n", "}", "\n", "}" ]
// mark expression tree nodes that reference json fields
[ "mark", "expression", "tree", "nodes", "that", "reference", "json", "fields" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/expression_compiler.go#L54-L77
13,261
fabric8-services/fabric8-wit
workitem/expression_compiler.go
expressionRefersToJoinedData
func (c *expressionCompiler) expressionRefersToJoinedData(e criteria.Expression) (*TableJoin, bool) { switch t := e.(type) { case *criteria.FieldExpression: for _, j := range c.joins { if j.HandlesFieldName(t.FieldName) { j.Active = true return j, true } } } return nil, false }
go
func (c *expressionCompiler) expressionRefersToJoinedData(e criteria.Expression) (*TableJoin, bool) { switch t := e.(type) { case *criteria.FieldExpression: for _, j := range c.joins { if j.HandlesFieldName(t.FieldName) { j.Active = true return j, true } } } return nil, false }
[ "func", "(", "c", "*", "expressionCompiler", ")", "expressionRefersToJoinedData", "(", "e", "criteria", ".", "Expression", ")", "(", "*", "TableJoin", ",", "bool", ")", "{", "switch", "t", ":=", "e", ".", "(", "type", ")", "{", "case", "*", "criteria", ".", "FieldExpression", ":", "for", "_", ",", "j", ":=", "range", "c", ".", "joins", "{", "if", "j", ".", "HandlesFieldName", "(", "t", ".", "FieldName", ")", "{", "j", ".", "Active", "=", "true", "\n", "return", "j", ",", "true", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "nil", ",", "false", "\n", "}" ]
// expressionRefersToJoinedData returns true if the given field expression is a // field expression and refers to joined data; otherwise false is returned.
[ "expressionRefersToJoinedData", "returns", "true", "if", "the", "given", "field", "expression", "is", "a", "field", "expression", "and", "refers", "to", "joined", "data", ";", "otherwise", "false", "is", "returned", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/expression_compiler.go#L270-L281
13,262
fabric8-services/fabric8-wit
workitem/expression_compiler.go
Field
func (c *expressionCompiler) Field(f *criteria.FieldExpression) interface{} { if strings.Contains(f.FieldName, `"`) { c.err = append(c.err, errs.Errorf("field name must not contain double quotes: %s", f.FieldName)) return nil } if strings.Contains(f.FieldName, `'`) { c.err = append(c.err, errs.Errorf("field name must not contain single quotes: %s", f.FieldName)) return nil } mappedFieldName, isJSONField := c.getFieldName(f.FieldName) // Check if this field is referencing joinable data for _, j := range c.joins { if j.HandlesFieldName(mappedFieldName) { j.Active = true col, err := j.TranslateFieldName(mappedFieldName) if err != nil { c.err = append(c.err, errs.Wrapf(err, `failed to translate field "%s"`, mappedFieldName)) } return col // e.g. "iter.name" } } if !isJSONField { return mappedFieldName } if strings.Contains(mappedFieldName, "'") { // beware of injection, it's a reasonable restriction for field names, // make sure it's not allowed when creating wi types c.err = append(c.err, errs.Errorf("single quote not allowed in field name: %s", mappedFieldName)) return nil } // default to plain json field (e.g. for ID comparisons) return Column(WorkItemStorage{}.TableName(), "fields") + ` @> '{"` + mappedFieldName + `"` }
go
func (c *expressionCompiler) Field(f *criteria.FieldExpression) interface{} { if strings.Contains(f.FieldName, `"`) { c.err = append(c.err, errs.Errorf("field name must not contain double quotes: %s", f.FieldName)) return nil } if strings.Contains(f.FieldName, `'`) { c.err = append(c.err, errs.Errorf("field name must not contain single quotes: %s", f.FieldName)) return nil } mappedFieldName, isJSONField := c.getFieldName(f.FieldName) // Check if this field is referencing joinable data for _, j := range c.joins { if j.HandlesFieldName(mappedFieldName) { j.Active = true col, err := j.TranslateFieldName(mappedFieldName) if err != nil { c.err = append(c.err, errs.Wrapf(err, `failed to translate field "%s"`, mappedFieldName)) } return col // e.g. "iter.name" } } if !isJSONField { return mappedFieldName } if strings.Contains(mappedFieldName, "'") { // beware of injection, it's a reasonable restriction for field names, // make sure it's not allowed when creating wi types c.err = append(c.err, errs.Errorf("single quote not allowed in field name: %s", mappedFieldName)) return nil } // default to plain json field (e.g. for ID comparisons) return Column(WorkItemStorage{}.TableName(), "fields") + ` @> '{"` + mappedFieldName + `"` }
[ "func", "(", "c", "*", "expressionCompiler", ")", "Field", "(", "f", "*", "criteria", ".", "FieldExpression", ")", "interface", "{", "}", "{", "if", "strings", ".", "Contains", "(", "f", ".", "FieldName", ",", "`\"`", ")", "{", "c", ".", "err", "=", "append", "(", "c", ".", "err", ",", "errs", ".", "Errorf", "(", "\"", "\"", ",", "f", ".", "FieldName", ")", ")", "\n", "return", "nil", "\n", "}", "\n", "if", "strings", ".", "Contains", "(", "f", ".", "FieldName", ",", "`'`", ")", "{", "c", ".", "err", "=", "append", "(", "c", ".", "err", ",", "errs", ".", "Errorf", "(", "\"", "\"", ",", "f", ".", "FieldName", ")", ")", "\n", "return", "nil", "\n", "}", "\n\n", "mappedFieldName", ",", "isJSONField", ":=", "c", ".", "getFieldName", "(", "f", ".", "FieldName", ")", "\n\n", "// Check if this field is referencing joinable data", "for", "_", ",", "j", ":=", "range", "c", ".", "joins", "{", "if", "j", ".", "HandlesFieldName", "(", "mappedFieldName", ")", "{", "j", ".", "Active", "=", "true", "\n", "col", ",", "err", ":=", "j", ".", "TranslateFieldName", "(", "mappedFieldName", ")", "\n", "if", "err", "!=", "nil", "{", "c", ".", "err", "=", "append", "(", "c", ".", "err", ",", "errs", ".", "Wrapf", "(", "err", ",", "`failed to translate field \"%s\"`", ",", "mappedFieldName", ")", ")", "\n", "}", "\n", "return", "col", "// e.g. \"iter.name\"", "\n", "}", "\n", "}", "\n\n", "if", "!", "isJSONField", "{", "return", "mappedFieldName", "\n", "}", "\n", "if", "strings", ".", "Contains", "(", "mappedFieldName", ",", "\"", "\"", ")", "{", "// beware of injection, it's a reasonable restriction for field names,", "// make sure it's not allowed when creating wi types", "c", ".", "err", "=", "append", "(", "c", ".", "err", ",", "errs", ".", "Errorf", "(", "\"", "\"", ",", "mappedFieldName", ")", ")", "\n", "return", "nil", "\n", "}", "\n\n", "// default to plain json field (e.g. for ID comparisons)", "return", "Column", "(", "WorkItemStorage", "{", "}", ".", "TableName", "(", ")", ",", "\"", "\"", ")", "+", "` @> '{\"`", "+", "mappedFieldName", "+", "`\"`", "\n", "}" ]
// visitor implementation // the convention is to return nil when the expression cannot be compiled and to append an error to the err field
[ "visitor", "implementation", "the", "convention", "is", "to", "return", "nil", "when", "the", "expression", "cannot", "be", "compiled", "and", "to", "append", "an", "error", "to", "the", "err", "field" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/expression_compiler.go#L290-L326
13,263
fabric8-services/fabric8-wit
workitem/expression_compiler.go
isInJSONContext
func isInJSONContext(exp criteria.Expression) bool { result := false criteria.IterateParents(exp, func(exp criteria.Expression) bool { if exp.Annotation(jsonAnnotation) == true { result = true return false } return true }) return result }
go
func isInJSONContext(exp criteria.Expression) bool { result := false criteria.IterateParents(exp, func(exp criteria.Expression) bool { if exp.Annotation(jsonAnnotation) == true { result = true return false } return true }) return result }
[ "func", "isInJSONContext", "(", "exp", "criteria", ".", "Expression", ")", "bool", "{", "result", ":=", "false", "\n", "criteria", ".", "IterateParents", "(", "exp", ",", "func", "(", "exp", "criteria", ".", "Expression", ")", "bool", "{", "if", "exp", ".", "Annotation", "(", "jsonAnnotation", ")", "==", "true", "{", "result", "=", "true", "\n", "return", "false", "\n", "}", "\n", "return", "true", "\n", "}", ")", "\n", "return", "result", "\n", "}" ]
// iterate the parent chain to see if this expression references json fields
[ "iterate", "the", "parent", "chain", "to", "see", "if", "this", "expression", "references", "json", "fields" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/expression_compiler.go#L499-L509
13,264
fabric8-services/fabric8-wit
spacetemplate/repository.go
CheckExists
func (r *GormRepository) CheckExists(ctx context.Context, id uuid.UUID) error { return repository.CheckExists(ctx, r.db, SpaceTemplate{}.TableName(), id) }
go
func (r *GormRepository) CheckExists(ctx context.Context, id uuid.UUID) error { return repository.CheckExists(ctx, r.db, SpaceTemplate{}.TableName(), id) }
[ "func", "(", "r", "*", "GormRepository", ")", "CheckExists", "(", "ctx", "context", ".", "Context", ",", "id", "uuid", ".", "UUID", ")", "error", "{", "return", "repository", ".", "CheckExists", "(", "ctx", ",", "r", ".", "db", ",", "SpaceTemplate", "{", "}", ".", "TableName", "(", ")", ",", "id", ")", "\n", "}" ]
// CheckExists returns nil if a spacetemplate exists with a given ID
[ "CheckExists", "returns", "nil", "if", "a", "spacetemplate", "exists", "with", "a", "given", "ID" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/spacetemplate/repository.go#L39-L41
13,265
fabric8-services/fabric8-wit
spacetemplate/repository.go
List
func (r *GormRepository) List(ctx context.Context) ([]SpaceTemplate, error) { var objs []SpaceTemplate err := r.db.Find(&objs).Error if err != nil && err != gorm.ErrRecordNotFound { return nil, errs.Wrap(err, "failed to list space templates") } return objs, nil }
go
func (r *GormRepository) List(ctx context.Context) ([]SpaceTemplate, error) { var objs []SpaceTemplate err := r.db.Find(&objs).Error if err != nil && err != gorm.ErrRecordNotFound { return nil, errs.Wrap(err, "failed to list space templates") } return objs, nil }
[ "func", "(", "r", "*", "GormRepository", ")", "List", "(", "ctx", "context", ".", "Context", ")", "(", "[", "]", "SpaceTemplate", ",", "error", ")", "{", "var", "objs", "[", "]", "SpaceTemplate", "\n", "err", ":=", "r", ".", "db", ".", "Find", "(", "&", "objs", ")", ".", "Error", "\n", "if", "err", "!=", "nil", "&&", "err", "!=", "gorm", ".", "ErrRecordNotFound", "{", "return", "nil", ",", "errs", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "return", "objs", ",", "nil", "\n", "}" ]
// List returns an array with all space templates in it
[ "List", "returns", "an", "array", "with", "all", "space", "templates", "in", "it" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/spacetemplate/repository.go#L44-L51
13,266
fabric8-services/fabric8-wit
spacetemplate/repository.go
Load
func (r *GormRepository) Load(ctx context.Context, spaceTemplateID uuid.UUID) (*SpaceTemplate, error) { var s SpaceTemplate tx := r.db.Where("id = ?", spaceTemplateID).First(&s) if tx.RecordNotFound() { log.Info(ctx, map[string]interface{}{ "space_template_id": spaceTemplateID.String(), }, "space template not found") return nil, errors.NewNotFoundError("space_template", spaceTemplateID.String()) } if tx.Error != nil { log.Error(ctx, map[string]interface{}{ "space_template_id": spaceTemplateID.String(), "err": tx.Error, }, "failed to load space template") return nil, errors.NewInternalError(ctx, errs.Wrap(tx.Error, "failed to load space template")) } return &s, nil }
go
func (r *GormRepository) Load(ctx context.Context, spaceTemplateID uuid.UUID) (*SpaceTemplate, error) { var s SpaceTemplate tx := r.db.Where("id = ?", spaceTemplateID).First(&s) if tx.RecordNotFound() { log.Info(ctx, map[string]interface{}{ "space_template_id": spaceTemplateID.String(), }, "space template not found") return nil, errors.NewNotFoundError("space_template", spaceTemplateID.String()) } if tx.Error != nil { log.Error(ctx, map[string]interface{}{ "space_template_id": spaceTemplateID.String(), "err": tx.Error, }, "failed to load space template") return nil, errors.NewInternalError(ctx, errs.Wrap(tx.Error, "failed to load space template")) } return &s, nil }
[ "func", "(", "r", "*", "GormRepository", ")", "Load", "(", "ctx", "context", ".", "Context", ",", "spaceTemplateID", "uuid", ".", "UUID", ")", "(", "*", "SpaceTemplate", ",", "error", ")", "{", "var", "s", "SpaceTemplate", "\n", "tx", ":=", "r", ".", "db", ".", "Where", "(", "\"", "\"", ",", "spaceTemplateID", ")", ".", "First", "(", "&", "s", ")", "\n", "if", "tx", ".", "RecordNotFound", "(", ")", "{", "log", ".", "Info", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "spaceTemplateID", ".", "String", "(", ")", ",", "}", ",", "\"", "\"", ")", "\n", "return", "nil", ",", "errors", ".", "NewNotFoundError", "(", "\"", "\"", ",", "spaceTemplateID", ".", "String", "(", ")", ")", "\n", "}", "\n", "if", "tx", ".", "Error", "!=", "nil", "{", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "spaceTemplateID", ".", "String", "(", ")", ",", "\"", "\"", ":", "tx", ".", "Error", ",", "}", ",", "\"", "\"", ")", "\n", "return", "nil", ",", "errors", ".", "NewInternalError", "(", "ctx", ",", "errs", ".", "Wrap", "(", "tx", ".", "Error", ",", "\"", "\"", ")", ")", "\n", "}", "\n", "return", "&", "s", ",", "nil", "\n", "}" ]
// Load returns a single space template by a given ID
[ "Load", "returns", "a", "single", "space", "template", "by", "a", "given", "ID" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/spacetemplate/repository.go#L54-L71
13,267
fabric8-services/fabric8-wit
workitem/enum_type.go
GetDefaultValue
func (t EnumType) GetDefaultValue() interface{} { // manual default value has precedence over first value in list of allowed // values if t.DefaultValue != nil { return t.DefaultValue } // fallback to first permitted element if len(t.Values) > 0 { return t.Values[0] } return nil }
go
func (t EnumType) GetDefaultValue() interface{} { // manual default value has precedence over first value in list of allowed // values if t.DefaultValue != nil { return t.DefaultValue } // fallback to first permitted element if len(t.Values) > 0 { return t.Values[0] } return nil }
[ "func", "(", "t", "EnumType", ")", "GetDefaultValue", "(", ")", "interface", "{", "}", "{", "// manual default value has precedence over first value in list of allowed", "// values", "if", "t", ".", "DefaultValue", "!=", "nil", "{", "return", "t", ".", "DefaultValue", "\n", "}", "\n", "// fallback to first permitted element", "if", "len", "(", "t", ".", "Values", ")", ">", "0", "{", "return", "t", ".", "Values", "[", "0", "]", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// GetDefaultValue implements FieldType
[ "GetDefaultValue", "implements", "FieldType" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/enum_type.go#L74-L85
13,268
fabric8-services/fabric8-wit
workitem/enum_type.go
Equal
func (t EnumType) Equal(u convert.Equaler) bool { other, ok := u.(EnumType) if !ok { return false } if !convert.CascadeEqual(t.SimpleType, other.SimpleType) { return false } if !convert.CascadeEqual(t.BaseType, other.BaseType) { return false } if !t.RewritableValues { if !reflect.DeepEqual(t.Values, other.Values) { return false } } if !reflect.DeepEqual(t.DefaultValue, other.DefaultValue) { return false } return true }
go
func (t EnumType) Equal(u convert.Equaler) bool { other, ok := u.(EnumType) if !ok { return false } if !convert.CascadeEqual(t.SimpleType, other.SimpleType) { return false } if !convert.CascadeEqual(t.BaseType, other.BaseType) { return false } if !t.RewritableValues { if !reflect.DeepEqual(t.Values, other.Values) { return false } } if !reflect.DeepEqual(t.DefaultValue, other.DefaultValue) { return false } return true }
[ "func", "(", "t", "EnumType", ")", "Equal", "(", "u", "convert", ".", "Equaler", ")", "bool", "{", "other", ",", "ok", ":=", "u", ".", "(", "EnumType", ")", "\n", "if", "!", "ok", "{", "return", "false", "\n", "}", "\n", "if", "!", "convert", ".", "CascadeEqual", "(", "t", ".", "SimpleType", ",", "other", ".", "SimpleType", ")", "{", "return", "false", "\n", "}", "\n", "if", "!", "convert", ".", "CascadeEqual", "(", "t", ".", "BaseType", ",", "other", ".", "BaseType", ")", "{", "return", "false", "\n", "}", "\n", "if", "!", "t", ".", "RewritableValues", "{", "if", "!", "reflect", ".", "DeepEqual", "(", "t", ".", "Values", ",", "other", ".", "Values", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n", "if", "!", "reflect", ".", "DeepEqual", "(", "t", ".", "DefaultValue", ",", "other", ".", "DefaultValue", ")", "{", "return", "false", "\n", "}", "\n", "return", "true", "\n", "}" ]
// Equal returns true if two EnumType objects are equal; otherwise false is returned.
[ "Equal", "returns", "true", "if", "two", "EnumType", "objects", "are", "equal", ";", "otherwise", "false", "is", "returned", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/enum_type.go#L92-L112
13,269
fabric8-services/fabric8-wit
login/tokencontext/token_context.go
ContextWithTokenManager
func ContextWithTokenManager(ctx context.Context, tm interface{}) context.Context { return context.WithValue(ctx, contextTokenManagerKey, tm) }
go
func ContextWithTokenManager(ctx context.Context, tm interface{}) context.Context { return context.WithValue(ctx, contextTokenManagerKey, tm) }
[ "func", "ContextWithTokenManager", "(", "ctx", "context", ".", "Context", ",", "tm", "interface", "{", "}", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "contextTokenManagerKey", ",", "tm", ")", "\n", "}" ]
// ContextWithTokenManager injects tokenManager in the context for every incoming request // Accepts Token.Manager in order to make sure that correct object is set in the context. // Only other possible value is nil
[ "ContextWithTokenManager", "injects", "tokenManager", "in", "the", "context", "for", "every", "incoming", "request", "Accepts", "Token", ".", "Manager", "in", "order", "to", "make", "sure", "that", "correct", "object", "is", "set", "in", "the", "context", ".", "Only", "other", "possible", "value", "is", "nil" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/login/tokencontext/token_context.go#L36-L38
13,270
fabric8-services/fabric8-wit
login/tokencontext/token_context.go
ContextWithSpaceAuthzService
func ContextWithSpaceAuthzService(ctx context.Context, s interface{}) context.Context { return context.WithValue(ctx, autzSpaceServiceKey, s) }
go
func ContextWithSpaceAuthzService(ctx context.Context, s interface{}) context.Context { return context.WithValue(ctx, autzSpaceServiceKey, s) }
[ "func", "ContextWithSpaceAuthzService", "(", "ctx", "context", ".", "Context", ",", "s", "interface", "{", "}", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "autzSpaceServiceKey", ",", "s", ")", "\n", "}" ]
// ContextWithSpaceAuthzService injects AuthzServiceManager in the context for every incoming request // Accepts service.AuthzServiceManager in order to make sure that correct object is set in the context. // Only other possible value is nil
[ "ContextWithSpaceAuthzService", "injects", "AuthzServiceManager", "in", "the", "context", "for", "every", "incoming", "request", "Accepts", "service", ".", "AuthzServiceManager", "in", "order", "to", "make", "sure", "that", "correct", "object", "is", "set", "in", "the", "context", ".", "Only", "other", "possible", "value", "is", "nil" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/login/tokencontext/token_context.go#L43-L45
13,271
fabric8-services/fabric8-wit
actions/actions.go
ExecuteActionsByOldNew
func ExecuteActionsByOldNew(ctx context.Context, db application.DB, userID uuid.UUID, oldContext change.Detector, newContext change.Detector, actionConfigList map[string]string) (change.Detector, change.Set, error) { if oldContext == nil || newContext == nil { return nil, nil, errs.New("execute actions called with nil entities") } contextChanges, err := oldContext.ChangeSet(newContext) if err != nil { return nil, nil, err } return ExecuteActionsByChangeset(ctx, db, userID, newContext, contextChanges, actionConfigList) }
go
func ExecuteActionsByOldNew(ctx context.Context, db application.DB, userID uuid.UUID, oldContext change.Detector, newContext change.Detector, actionConfigList map[string]string) (change.Detector, change.Set, error) { if oldContext == nil || newContext == nil { return nil, nil, errs.New("execute actions called with nil entities") } contextChanges, err := oldContext.ChangeSet(newContext) if err != nil { return nil, nil, err } return ExecuteActionsByChangeset(ctx, db, userID, newContext, contextChanges, actionConfigList) }
[ "func", "ExecuteActionsByOldNew", "(", "ctx", "context", ".", "Context", ",", "db", "application", ".", "DB", ",", "userID", "uuid", ".", "UUID", ",", "oldContext", "change", ".", "Detector", ",", "newContext", "change", ".", "Detector", ",", "actionConfigList", "map", "[", "string", "]", "string", ")", "(", "change", ".", "Detector", ",", "change", ".", "Set", ",", "error", ")", "{", "if", "oldContext", "==", "nil", "||", "newContext", "==", "nil", "{", "return", "nil", ",", "nil", ",", "errs", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "contextChanges", ",", "err", ":=", "oldContext", ".", "ChangeSet", "(", "newContext", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "return", "ExecuteActionsByChangeset", "(", "ctx", ",", "db", ",", "userID", ",", "newContext", ",", "contextChanges", ",", "actionConfigList", ")", "\n", "}" ]
// ExecuteActionsByOldNew executes all actions given in the actionConfigList // using the mapped configuration strings and returns the new context entity. // It takes the old version and the new version of the context entity, comparing them.
[ "ExecuteActionsByOldNew", "executes", "all", "actions", "given", "in", "the", "actionConfigList", "using", "the", "mapped", "configuration", "strings", "and", "returns", "the", "new", "context", "entity", ".", "It", "takes", "the", "old", "version", "and", "the", "new", "version", "of", "the", "context", "entity", "comparing", "them", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/actions/actions.go#L47-L56
13,272
fabric8-services/fabric8-wit
workitem/board_repository.go
Load
func (r *GormBoardRepository) Load(ctx context.Context, boardID uuid.UUID) (*Board, error) { log.Debug(ctx, map[string]interface{}{"board_id": boardID}, "loading work item board ") res := Board{} db := r.db.Model(&res).Where("id=?", boardID).First(&res) if db.RecordNotFound() { log.Error(ctx, map[string]interface{}{"board_id": boardID}, "work item board not found") return nil, errors.NewNotFoundError("work item board", boardID.String()) } if err := db.Error; err != nil { return nil, errors.NewInternalError(ctx, err) } columns, err := r.loadColumns(ctx, res.ID) if err != nil { return nil, errs.Wrapf(err, "failed to load board columns for board with ID %s", res.ID) } res.Columns = columns return &res, nil }
go
func (r *GormBoardRepository) Load(ctx context.Context, boardID uuid.UUID) (*Board, error) { log.Debug(ctx, map[string]interface{}{"board_id": boardID}, "loading work item board ") res := Board{} db := r.db.Model(&res).Where("id=?", boardID).First(&res) if db.RecordNotFound() { log.Error(ctx, map[string]interface{}{"board_id": boardID}, "work item board not found") return nil, errors.NewNotFoundError("work item board", boardID.String()) } if err := db.Error; err != nil { return nil, errors.NewInternalError(ctx, err) } columns, err := r.loadColumns(ctx, res.ID) if err != nil { return nil, errs.Wrapf(err, "failed to load board columns for board with ID %s", res.ID) } res.Columns = columns return &res, nil }
[ "func", "(", "r", "*", "GormBoardRepository", ")", "Load", "(", "ctx", "context", ".", "Context", ",", "boardID", "uuid", ".", "UUID", ")", "(", "*", "Board", ",", "error", ")", "{", "log", ".", "Debug", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "boardID", "}", ",", "\"", "\"", ")", "\n", "res", ":=", "Board", "{", "}", "\n", "db", ":=", "r", ".", "db", ".", "Model", "(", "&", "res", ")", ".", "Where", "(", "\"", "\"", ",", "boardID", ")", ".", "First", "(", "&", "res", ")", "\n", "if", "db", ".", "RecordNotFound", "(", ")", "{", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "boardID", "}", ",", "\"", "\"", ")", "\n", "return", "nil", ",", "errors", ".", "NewNotFoundError", "(", "\"", "\"", ",", "boardID", ".", "String", "(", ")", ")", "\n", "}", "\n", "if", "err", ":=", "db", ".", "Error", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "NewInternalError", "(", "ctx", ",", "err", ")", "\n", "}", "\n", "columns", ",", "err", ":=", "r", ".", "loadColumns", "(", "ctx", ",", "res", ".", "ID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errs", ".", "Wrapf", "(", "err", ",", "\"", "\"", ",", "res", ".", "ID", ")", "\n", "}", "\n", "res", ".", "Columns", "=", "columns", "\n", "return", "&", "res", ",", "nil", "\n", "}" ]
// Load returns the board for the given id.
[ "Load", "returns", "the", "board", "for", "the", "given", "id", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/board_repository.go#L35-L52
13,273
fabric8-services/fabric8-wit
workitem/board_repository.go
loadColumns
func (r *GormBoardRepository) loadColumns(ctx context.Context, boardID uuid.UUID) ([]BoardColumn, error) { columns := []BoardColumn{} db := r.db.Model(&columns).Where("board_id=?", boardID).Order("column_order ASC").Find(&columns) if db.RecordNotFound() { log.Error(ctx, map[string]interface{}{"board_id": boardID}, "work item board columns not found") return nil, errors.NewNotFoundError("work item board columns of board", boardID.String()) } if err := db.Error; err != nil { return nil, errors.NewInternalError(ctx, err) } return columns, nil }
go
func (r *GormBoardRepository) loadColumns(ctx context.Context, boardID uuid.UUID) ([]BoardColumn, error) { columns := []BoardColumn{} db := r.db.Model(&columns).Where("board_id=?", boardID).Order("column_order ASC").Find(&columns) if db.RecordNotFound() { log.Error(ctx, map[string]interface{}{"board_id": boardID}, "work item board columns not found") return nil, errors.NewNotFoundError("work item board columns of board", boardID.String()) } if err := db.Error; err != nil { return nil, errors.NewInternalError(ctx, err) } return columns, nil }
[ "func", "(", "r", "*", "GormBoardRepository", ")", "loadColumns", "(", "ctx", "context", ".", "Context", ",", "boardID", "uuid", ".", "UUID", ")", "(", "[", "]", "BoardColumn", ",", "error", ")", "{", "columns", ":=", "[", "]", "BoardColumn", "{", "}", "\n", "db", ":=", "r", ".", "db", ".", "Model", "(", "&", "columns", ")", ".", "Where", "(", "\"", "\"", ",", "boardID", ")", ".", "Order", "(", "\"", "\"", ")", ".", "Find", "(", "&", "columns", ")", "\n", "if", "db", ".", "RecordNotFound", "(", ")", "{", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "boardID", "}", ",", "\"", "\"", ")", "\n", "return", "nil", ",", "errors", ".", "NewNotFoundError", "(", "\"", "\"", ",", "boardID", ".", "String", "(", ")", ")", "\n", "}", "\n", "if", "err", ":=", "db", ".", "Error", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "NewInternalError", "(", "ctx", ",", "err", ")", "\n", "}", "\n", "return", "columns", ",", "nil", "\n", "}" ]
// loadColumns loads all columns associated with the given board.
[ "loadColumns", "loads", "all", "columns", "associated", "with", "the", "given", "board", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/board_repository.go#L55-L66
13,274
fabric8-services/fabric8-wit
workitem/board_repository.go
List
func (r *GormBoardRepository) List(ctx context.Context, spaceTemplateID uuid.UUID) ([]*Board, error) { log.Debug(ctx, map[string]interface{}{"space_template_id": spaceTemplateID}, "loading work item boards for space template") // check space template exists if err := spacetemplate.NewRepository(r.db).CheckExists(ctx, spaceTemplateID); err != nil { return nil, errors.NewNotFoundError("space template", spaceTemplateID.String()) } res := []*Board{} db := r.db.Model(&res).Where("space_template_id=?", spaceTemplateID).Order("name ASC").Find(&res) if db.RecordNotFound() { log.Error(ctx, map[string]interface{}{"space_template_id": spaceTemplateID}, "work item boards not found") return nil, errors.NewNotFoundError("work item boards for space template", spaceTemplateID.String()) } if err := db.Error; err != nil { return nil, errors.NewInternalError(ctx, err) } for _, board := range res { columns, err := r.loadColumns(ctx, board.ID) if err != nil { return nil, errs.Wrapf(err, "failed to load columns for board with ID %s", board.ID) } board.Columns = columns } return res, nil }
go
func (r *GormBoardRepository) List(ctx context.Context, spaceTemplateID uuid.UUID) ([]*Board, error) { log.Debug(ctx, map[string]interface{}{"space_template_id": spaceTemplateID}, "loading work item boards for space template") // check space template exists if err := spacetemplate.NewRepository(r.db).CheckExists(ctx, spaceTemplateID); err != nil { return nil, errors.NewNotFoundError("space template", spaceTemplateID.String()) } res := []*Board{} db := r.db.Model(&res).Where("space_template_id=?", spaceTemplateID).Order("name ASC").Find(&res) if db.RecordNotFound() { log.Error(ctx, map[string]interface{}{"space_template_id": spaceTemplateID}, "work item boards not found") return nil, errors.NewNotFoundError("work item boards for space template", spaceTemplateID.String()) } if err := db.Error; err != nil { return nil, errors.NewInternalError(ctx, err) } for _, board := range res { columns, err := r.loadColumns(ctx, board.ID) if err != nil { return nil, errs.Wrapf(err, "failed to load columns for board with ID %s", board.ID) } board.Columns = columns } return res, nil }
[ "func", "(", "r", "*", "GormBoardRepository", ")", "List", "(", "ctx", "context", ".", "Context", ",", "spaceTemplateID", "uuid", ".", "UUID", ")", "(", "[", "]", "*", "Board", ",", "error", ")", "{", "log", ".", "Debug", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "spaceTemplateID", "}", ",", "\"", "\"", ")", "\n", "// check space template exists", "if", "err", ":=", "spacetemplate", ".", "NewRepository", "(", "r", ".", "db", ")", ".", "CheckExists", "(", "ctx", ",", "spaceTemplateID", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "NewNotFoundError", "(", "\"", "\"", ",", "spaceTemplateID", ".", "String", "(", ")", ")", "\n", "}", "\n", "res", ":=", "[", "]", "*", "Board", "{", "}", "\n", "db", ":=", "r", ".", "db", ".", "Model", "(", "&", "res", ")", ".", "Where", "(", "\"", "\"", ",", "spaceTemplateID", ")", ".", "Order", "(", "\"", "\"", ")", ".", "Find", "(", "&", "res", ")", "\n", "if", "db", ".", "RecordNotFound", "(", ")", "{", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "spaceTemplateID", "}", ",", "\"", "\"", ")", "\n", "return", "nil", ",", "errors", ".", "NewNotFoundError", "(", "\"", "\"", ",", "spaceTemplateID", ".", "String", "(", ")", ")", "\n", "}", "\n", "if", "err", ":=", "db", ".", "Error", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "NewInternalError", "(", "ctx", ",", "err", ")", "\n", "}", "\n", "for", "_", ",", "board", ":=", "range", "res", "{", "columns", ",", "err", ":=", "r", ".", "loadColumns", "(", "ctx", ",", "board", ".", "ID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errs", ".", "Wrapf", "(", "err", ",", "\"", "\"", ",", "board", ".", "ID", ")", "\n", "}", "\n", "board", ".", "Columns", "=", "columns", "\n", "}", "\n", "return", "res", ",", "nil", "\n", "}" ]
// List returns all boards for the given space template ID // ordered by their position value.
[ "List", "returns", "all", "boards", "for", "the", "given", "space", "template", "ID", "ordered", "by", "their", "position", "value", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/board_repository.go#L70-L93
13,275
fabric8-services/fabric8-wit
workitem/board_repository.go
Create
func (r *GormBoardRepository) Create(ctx context.Context, b Board) (*Board, error) { if len(b.Columns) <= 0 { return nil, errors.NewBadParameterError("columns", b.Columns).Expected("not empty") } if b.ID == uuid.Nil { b.ID = uuid.NewV4() } db := r.db.Create(&b) if db.Error != nil { return nil, errors.NewInternalError(ctx, db.Error) } log.Debug(ctx, map[string]interface{}{"board_id": b.ID}, "created work item board") // Create entries for each column in the column list for _, column := range b.Columns { if column.ID == uuid.Nil { column.ID = uuid.NewV4() } column.BoardID = b.ID db = db.Create(&column) if db.Error != nil { return nil, errors.NewInternalError(ctx, db.Error) } } return &b, nil }
go
func (r *GormBoardRepository) Create(ctx context.Context, b Board) (*Board, error) { if len(b.Columns) <= 0 { return nil, errors.NewBadParameterError("columns", b.Columns).Expected("not empty") } if b.ID == uuid.Nil { b.ID = uuid.NewV4() } db := r.db.Create(&b) if db.Error != nil { return nil, errors.NewInternalError(ctx, db.Error) } log.Debug(ctx, map[string]interface{}{"board_id": b.ID}, "created work item board") // Create entries for each column in the column list for _, column := range b.Columns { if column.ID == uuid.Nil { column.ID = uuid.NewV4() } column.BoardID = b.ID db = db.Create(&column) if db.Error != nil { return nil, errors.NewInternalError(ctx, db.Error) } } return &b, nil }
[ "func", "(", "r", "*", "GormBoardRepository", ")", "Create", "(", "ctx", "context", ".", "Context", ",", "b", "Board", ")", "(", "*", "Board", ",", "error", ")", "{", "if", "len", "(", "b", ".", "Columns", ")", "<=", "0", "{", "return", "nil", ",", "errors", ".", "NewBadParameterError", "(", "\"", "\"", ",", "b", ".", "Columns", ")", ".", "Expected", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "b", ".", "ID", "==", "uuid", ".", "Nil", "{", "b", ".", "ID", "=", "uuid", ".", "NewV4", "(", ")", "\n", "}", "\n", "db", ":=", "r", ".", "db", ".", "Create", "(", "&", "b", ")", "\n", "if", "db", ".", "Error", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "NewInternalError", "(", "ctx", ",", "db", ".", "Error", ")", "\n", "}", "\n", "log", ".", "Debug", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "b", ".", "ID", "}", ",", "\"", "\"", ")", "\n", "// Create entries for each column in the column list", "for", "_", ",", "column", ":=", "range", "b", ".", "Columns", "{", "if", "column", ".", "ID", "==", "uuid", ".", "Nil", "{", "column", ".", "ID", "=", "uuid", ".", "NewV4", "(", ")", "\n", "}", "\n", "column", ".", "BoardID", "=", "b", ".", "ID", "\n", "db", "=", "db", ".", "Create", "(", "&", "column", ")", "\n", "if", "db", ".", "Error", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "NewInternalError", "(", "ctx", ",", "db", ".", "Error", ")", "\n", "}", "\n", "}", "\n", "return", "&", "b", ",", "nil", "\n", "}" ]
// Create creates a new work item board in the repository
[ "Create", "creates", "a", "new", "work", "item", "board", "in", "the", "repository" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/workitem/board_repository.go#L102-L126
13,276
fabric8-services/fabric8-wit
codebase/codebase.go
IsRepoValidURL
func (c *Content) IsRepoValidURL() bool { r, err := regexp.Compile(`(?:git|ssh|https?|git@[-\w.]+):(\/\/)?(.*?)(\.git)(\/?|\#[-\d\w._]+?)$`) if err != nil { return false } return r.MatchString(c.Repository) }
go
func (c *Content) IsRepoValidURL() bool { r, err := regexp.Compile(`(?:git|ssh|https?|git@[-\w.]+):(\/\/)?(.*?)(\.git)(\/?|\#[-\d\w._]+?)$`) if err != nil { return false } return r.MatchString(c.Repository) }
[ "func", "(", "c", "*", "Content", ")", "IsRepoValidURL", "(", ")", "bool", "{", "r", ",", "err", ":=", "regexp", ".", "Compile", "(", "`(?:git|ssh|https?|git@[-\\w.]+):(\\/\\/)?(.*?)(\\.git)(\\/?|\\#[-\\d\\w._]+?)$`", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", "\n", "}", "\n", "return", "r", ".", "MatchString", "(", "c", ".", "Repository", ")", "\n", "}" ]
// IsRepoValidURL makes sure Repo is valid GIT URL
[ "IsRepoValidURL", "makes", "sure", "Repo", "is", "valid", "GIT", "URL" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/codebase/codebase.go#L51-L57
13,277
fabric8-services/fabric8-wit
codebase/codebase.go
IsValid
func (c *Content) IsValid() error { if c.Repository == "" { return errors.NewBadParameterError("system.codebase", RepositoryKey+" is mandatory") } if c.IsRepoValidURL() == false { return errors.NewBadParameterError("system.codebase", RepositoryKey+" is not valid git url") } return nil }
go
func (c *Content) IsValid() error { if c.Repository == "" { return errors.NewBadParameterError("system.codebase", RepositoryKey+" is mandatory") } if c.IsRepoValidURL() == false { return errors.NewBadParameterError("system.codebase", RepositoryKey+" is not valid git url") } return nil }
[ "func", "(", "c", "*", "Content", ")", "IsValid", "(", ")", "error", "{", "if", "c", ".", "Repository", "==", "\"", "\"", "{", "return", "errors", ".", "NewBadParameterError", "(", "\"", "\"", ",", "RepositoryKey", "+", "\"", "\"", ")", "\n", "}", "\n", "if", "c", ".", "IsRepoValidURL", "(", ")", "==", "false", "{", "return", "errors", ".", "NewBadParameterError", "(", "\"", "\"", ",", "RepositoryKey", "+", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// IsValid perform following checks // Repository value is mandatory
[ "IsValid", "perform", "following", "checks", "Repository", "value", "is", "mandatory" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/codebase/codebase.go#L61-L69
13,278
fabric8-services/fabric8-wit
codebase/codebase.go
NewCodebaseContent
func NewCodebaseContent(value map[string]interface{}) (Content, error) { cb := Content{} validKeys := []string{RepositoryKey, BranchKey, FileNameKey, LineNumberKey, CodebaseIDKey} for _, key := range validKeys { if v, ok := value[key]; ok { switch key { case RepositoryKey: cb.Repository = v.(string) case BranchKey: cb.Branch = v.(string) case FileNameKey: cb.FileName = v.(string) case CodebaseIDKey: cb.CodebaseID = v.(string) case LineNumberKey: switch v.(type) { case int: cb.LineNumber = v.(int) case float64: y := v.(float64) cb.LineNumber = int(y) } } } } err := cb.IsValid() return cb, err }
go
func NewCodebaseContent(value map[string]interface{}) (Content, error) { cb := Content{} validKeys := []string{RepositoryKey, BranchKey, FileNameKey, LineNumberKey, CodebaseIDKey} for _, key := range validKeys { if v, ok := value[key]; ok { switch key { case RepositoryKey: cb.Repository = v.(string) case BranchKey: cb.Branch = v.(string) case FileNameKey: cb.FileName = v.(string) case CodebaseIDKey: cb.CodebaseID = v.(string) case LineNumberKey: switch v.(type) { case int: cb.LineNumber = v.(int) case float64: y := v.(float64) cb.LineNumber = int(y) } } } } err := cb.IsValid() return cb, err }
[ "func", "NewCodebaseContent", "(", "value", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "Content", ",", "error", ")", "{", "cb", ":=", "Content", "{", "}", "\n", "validKeys", ":=", "[", "]", "string", "{", "RepositoryKey", ",", "BranchKey", ",", "FileNameKey", ",", "LineNumberKey", ",", "CodebaseIDKey", "}", "\n", "for", "_", ",", "key", ":=", "range", "validKeys", "{", "if", "v", ",", "ok", ":=", "value", "[", "key", "]", ";", "ok", "{", "switch", "key", "{", "case", "RepositoryKey", ":", "cb", ".", "Repository", "=", "v", ".", "(", "string", ")", "\n", "case", "BranchKey", ":", "cb", ".", "Branch", "=", "v", ".", "(", "string", ")", "\n", "case", "FileNameKey", ":", "cb", ".", "FileName", "=", "v", ".", "(", "string", ")", "\n", "case", "CodebaseIDKey", ":", "cb", ".", "CodebaseID", "=", "v", ".", "(", "string", ")", "\n", "case", "LineNumberKey", ":", "switch", "v", ".", "(", "type", ")", "{", "case", "int", ":", "cb", ".", "LineNumber", "=", "v", ".", "(", "int", ")", "\n", "case", "float64", ":", "y", ":=", "v", ".", "(", "float64", ")", "\n", "cb", ".", "LineNumber", "=", "int", "(", "y", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "\n", "err", ":=", "cb", ".", "IsValid", "(", ")", "\n\n", "return", "cb", ",", "err", "\n", "}" ]
// NewCodebaseContent builds Content instance from input Map.
[ "NewCodebaseContent", "builds", "Content", "instance", "from", "input", "Map", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/codebase/codebase.go#L72-L101
13,279
fabric8-services/fabric8-wit
codebase/codebase.go
Save
func (m *GormCodebaseRepository) Save(ctx context.Context, codebase *Codebase) (*Codebase, error) { c := Codebase{} tx := m.db.Where("id=?", codebase.ID).First(&c) if tx.RecordNotFound() { // treating this as a not found error: the fact that we're using number internal is implementation detail return nil, errors.NewNotFoundError("codebase", codebase.ID.String()) } if err := tx.Error; err != nil { return nil, errors.NewInternalError(ctx, err) } tx = tx.Save(codebase) if err := tx.Error; err != nil { return nil, errors.NewInternalError(ctx, err) } log.Debug(ctx, map[string]interface{}{"codebase_id": codebase.ID}, "codebase updated successfully") return codebase, nil }
go
func (m *GormCodebaseRepository) Save(ctx context.Context, codebase *Codebase) (*Codebase, error) { c := Codebase{} tx := m.db.Where("id=?", codebase.ID).First(&c) if tx.RecordNotFound() { // treating this as a not found error: the fact that we're using number internal is implementation detail return nil, errors.NewNotFoundError("codebase", codebase.ID.String()) } if err := tx.Error; err != nil { return nil, errors.NewInternalError(ctx, err) } tx = tx.Save(codebase) if err := tx.Error; err != nil { return nil, errors.NewInternalError(ctx, err) } log.Debug(ctx, map[string]interface{}{"codebase_id": codebase.ID}, "codebase updated successfully") return codebase, nil }
[ "func", "(", "m", "*", "GormCodebaseRepository", ")", "Save", "(", "ctx", "context", ".", "Context", ",", "codebase", "*", "Codebase", ")", "(", "*", "Codebase", ",", "error", ")", "{", "c", ":=", "Codebase", "{", "}", "\n", "tx", ":=", "m", ".", "db", ".", "Where", "(", "\"", "\"", ",", "codebase", ".", "ID", ")", ".", "First", "(", "&", "c", ")", "\n", "if", "tx", ".", "RecordNotFound", "(", ")", "{", "// treating this as a not found error: the fact that we're using number internal is implementation detail", "return", "nil", ",", "errors", ".", "NewNotFoundError", "(", "\"", "\"", ",", "codebase", ".", "ID", ".", "String", "(", ")", ")", "\n", "}", "\n", "if", "err", ":=", "tx", ".", "Error", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "NewInternalError", "(", "ctx", ",", "err", ")", "\n", "}", "\n\n", "tx", "=", "tx", ".", "Save", "(", "codebase", ")", "\n", "if", "err", ":=", "tx", ".", "Error", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "NewInternalError", "(", "ctx", ",", "err", ")", "\n", "}", "\n", "log", ".", "Debug", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "codebase", ".", "ID", "}", ",", "\"", "\"", ")", "\n", "return", "codebase", ",", "nil", "\n", "}" ]
// Save a single codebase
[ "Save", "a", "single", "codebase" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/codebase/codebase.go#L222-L239
13,280
fabric8-services/fabric8-wit
codebase/codebase.go
LoadByRepo
func (m *GormCodebaseRepository) LoadByRepo(ctx context.Context, spaceID uuid.UUID, repository string) (*Codebase, error) { defer goa.MeasureSince([]string{"goa", "db", "codebase", "loadbyrepository"}, time.Now()) var obj Codebase tx := m.db.Where("url=? and space_id=?", repository, spaceID.String()).First(&obj) if tx.RecordNotFound() { return nil, errors.NewNotFoundError("codebase url", repository) } if tx.Error != nil { return nil, errors.NewInternalError(ctx, tx.Error) } return &obj, nil }
go
func (m *GormCodebaseRepository) LoadByRepo(ctx context.Context, spaceID uuid.UUID, repository string) (*Codebase, error) { defer goa.MeasureSince([]string{"goa", "db", "codebase", "loadbyrepository"}, time.Now()) var obj Codebase tx := m.db.Where("url=? and space_id=?", repository, spaceID.String()).First(&obj) if tx.RecordNotFound() { return nil, errors.NewNotFoundError("codebase url", repository) } if tx.Error != nil { return nil, errors.NewInternalError(ctx, tx.Error) } return &obj, nil }
[ "func", "(", "m", "*", "GormCodebaseRepository", ")", "LoadByRepo", "(", "ctx", "context", ".", "Context", ",", "spaceID", "uuid", ".", "UUID", ",", "repository", "string", ")", "(", "*", "Codebase", ",", "error", ")", "{", "defer", "goa", ".", "MeasureSince", "(", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", ",", "time", ".", "Now", "(", ")", ")", "\n", "var", "obj", "Codebase", "\n\n", "tx", ":=", "m", ".", "db", ".", "Where", "(", "\"", "\"", ",", "repository", ",", "spaceID", ".", "String", "(", ")", ")", ".", "First", "(", "&", "obj", ")", "\n", "if", "tx", ".", "RecordNotFound", "(", ")", "{", "return", "nil", ",", "errors", ".", "NewNotFoundError", "(", "\"", "\"", ",", "repository", ")", "\n", "}", "\n", "if", "tx", ".", "Error", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "NewInternalError", "(", "ctx", ",", "tx", ".", "Error", ")", "\n", "}", "\n", "return", "&", "obj", ",", "nil", "\n", "}" ]
// LoadByRepo returns a single codebase found for input repository url
[ "LoadByRepo", "returns", "a", "single", "codebase", "found", "for", "input", "repository", "url" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/codebase/codebase.go#L333-L345
13,281
fabric8-services/fabric8-wit
controller/login.go
Authorize
func (c *LoginController) Authorize(ctx *app.AuthorizeLoginContext) error { return redirectWithParams(ctx, c.configuration, ctx.ResponseData.Header(), ctx.Params, authservice.LoginLoginPath()) }
go
func (c *LoginController) Authorize(ctx *app.AuthorizeLoginContext) error { return redirectWithParams(ctx, c.configuration, ctx.ResponseData.Header(), ctx.Params, authservice.LoginLoginPath()) }
[ "func", "(", "c", "*", "LoginController", ")", "Authorize", "(", "ctx", "*", "app", ".", "AuthorizeLoginContext", ")", "error", "{", "return", "redirectWithParams", "(", "ctx", ",", "c", ".", "configuration", ",", "ctx", ".", "ResponseData", ".", "Header", "(", ")", ",", "ctx", ".", "Params", ",", "authservice", ".", "LoginLoginPath", "(", ")", ")", "\n", "}" ]
// Authorize runs the authorize action.
[ "Authorize", "runs", "the", "authorize", "action", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/controller/login.go#L46-L48
13,282
fabric8-services/fabric8-wit
controller/login.go
Refresh
func (c *LoginController) Refresh(ctx *app.RefreshLoginContext) error { return proxy.RouteHTTPToPath(ctx, c.configuration.GetAuthShortServiceHostName(), authservice.RefreshTokenPath()) }
go
func (c *LoginController) Refresh(ctx *app.RefreshLoginContext) error { return proxy.RouteHTTPToPath(ctx, c.configuration.GetAuthShortServiceHostName(), authservice.RefreshTokenPath()) }
[ "func", "(", "c", "*", "LoginController", ")", "Refresh", "(", "ctx", "*", "app", ".", "RefreshLoginContext", ")", "error", "{", "return", "proxy", ".", "RouteHTTPToPath", "(", "ctx", ",", "c", ".", "configuration", ".", "GetAuthShortServiceHostName", "(", ")", ",", "authservice", ".", "RefreshTokenPath", "(", ")", ")", "\n", "}" ]
// Refresh obtain a new access token using the refresh token.
[ "Refresh", "obtain", "a", "new", "access", "token", "using", "the", "refresh", "token", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/controller/login.go#L51-L53
13,283
fabric8-services/fabric8-wit
controller/login.go
Generate
func (c *LoginController) Generate(ctx *app.GenerateLoginContext) error { return proxy.RouteHTTPToPath(ctx, c.configuration.GetAuthServiceURL(), authservice.GenerateTokenPath()) }
go
func (c *LoginController) Generate(ctx *app.GenerateLoginContext) error { return proxy.RouteHTTPToPath(ctx, c.configuration.GetAuthServiceURL(), authservice.GenerateTokenPath()) }
[ "func", "(", "c", "*", "LoginController", ")", "Generate", "(", "ctx", "*", "app", ".", "GenerateLoginContext", ")", "error", "{", "return", "proxy", ".", "RouteHTTPToPath", "(", "ctx", ",", "c", ".", "configuration", ".", "GetAuthServiceURL", "(", ")", ",", "authservice", ".", "GenerateTokenPath", "(", ")", ")", "\n", "}" ]
// Generate generates access tokens in Dev Mode
[ "Generate", "generates", "access", "tokens", "in", "Dev", "Mode" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/controller/login.go#L79-L81
13,284
fabric8-services/fabric8-wit
criteria/binary_expression.go
reparent
func reparent(parent BinaryExpression) Expression { parent.Left().setParent(parent) parent.Right().setParent(parent) return parent }
go
func reparent(parent BinaryExpression) Expression { parent.Left().setParent(parent) parent.Right().setParent(parent) return parent }
[ "func", "reparent", "(", "parent", "BinaryExpression", ")", "Expression", "{", "parent", ".", "Left", "(", ")", ".", "setParent", "(", "parent", ")", "\n", "parent", ".", "Right", "(", ")", ".", "setParent", "(", "parent", ")", "\n", "return", "parent", "\n", "}" ]
// make sure the children have the correct parent
[ "make", "sure", "the", "children", "have", "the", "correct", "parent" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/criteria/binary_expression.go#L31-L35
13,285
fabric8-services/fabric8-wit
controller/work_item_link_types.go
NewWorkItemLinkTypesController
func NewWorkItemLinkTypesController(service *goa.Service, db application.DB, config WorkItemLinkTypesControllerConfiguration) *WorkItemLinkTypesController { return &WorkItemLinkTypesController{ Controller: service.NewController("WorkItemLinkTypesController"), db: db, config: config, } }
go
func NewWorkItemLinkTypesController(service *goa.Service, db application.DB, config WorkItemLinkTypesControllerConfiguration) *WorkItemLinkTypesController { return &WorkItemLinkTypesController{ Controller: service.NewController("WorkItemLinkTypesController"), db: db, config: config, } }
[ "func", "NewWorkItemLinkTypesController", "(", "service", "*", "goa", ".", "Service", ",", "db", "application", ".", "DB", ",", "config", "WorkItemLinkTypesControllerConfiguration", ")", "*", "WorkItemLinkTypesController", "{", "return", "&", "WorkItemLinkTypesController", "{", "Controller", ":", "service", ".", "NewController", "(", "\"", "\"", ")", ",", "db", ":", "db", ",", "config", ":", "config", ",", "}", "\n", "}" ]
// NewWorkItemLinkTypesController creates a work-item-link-type controller.
[ "NewWorkItemLinkTypesController", "creates", "a", "work", "-", "item", "-", "link", "-", "type", "controller", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/controller/work_item_link_types.go#L29-L35
13,286
fabric8-services/fabric8-wit
remoteworkitem/trackerquery_repository.go
NewTrackerQueryRepository
func NewTrackerQueryRepository(db *gorm.DB) *GormTrackerQueryRepository { return &GormTrackerQueryRepository{ db: db, witr: workitem.NewWorkItemTypeRepository(db), wir: workitem.NewWorkItemRepository(db), } }
go
func NewTrackerQueryRepository(db *gorm.DB) *GormTrackerQueryRepository { return &GormTrackerQueryRepository{ db: db, witr: workitem.NewWorkItemTypeRepository(db), wir: workitem.NewWorkItemRepository(db), } }
[ "func", "NewTrackerQueryRepository", "(", "db", "*", "gorm", ".", "DB", ")", "*", "GormTrackerQueryRepository", "{", "return", "&", "GormTrackerQueryRepository", "{", "db", ":", "db", ",", "witr", ":", "workitem", ".", "NewWorkItemTypeRepository", "(", "db", ")", ",", "wir", ":", "workitem", ".", "NewWorkItemRepository", "(", "db", ")", ",", "}", "\n", "}" ]
// NewTrackerQueryRepository constructs a TrackerQueryRepository
[ "NewTrackerQueryRepository", "constructs", "a", "TrackerQueryRepository" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/remoteworkitem/trackerquery_repository.go#L32-L38
13,287
fabric8-services/fabric8-wit
remoteworkitem/trackerquery_repository.go
Create
func (r *GormTrackerQueryRepository) Create(ctx context.Context, tq TrackerQuery) (*TrackerQuery, error) { wiType, err := r.witr.Load(ctx, tq.WorkItemTypeID) if err != nil { return nil, errors.NewBadParameterError("WorkItemTypeID", tq.WorkItemTypeID) } allowedWIT, err := r.wir.CheckTypeAndSpaceShareTemplate(ctx, wiType, tq.SpaceID) if err != nil { return nil, err } if !allowedWIT { return nil, err } if err := r.db.Create(&tq).Error; err != nil { return nil, errors.NewInternalError(ctx, r.db.Error) } return &tq, nil }
go
func (r *GormTrackerQueryRepository) Create(ctx context.Context, tq TrackerQuery) (*TrackerQuery, error) { wiType, err := r.witr.Load(ctx, tq.WorkItemTypeID) if err != nil { return nil, errors.NewBadParameterError("WorkItemTypeID", tq.WorkItemTypeID) } allowedWIT, err := r.wir.CheckTypeAndSpaceShareTemplate(ctx, wiType, tq.SpaceID) if err != nil { return nil, err } if !allowedWIT { return nil, err } if err := r.db.Create(&tq).Error; err != nil { return nil, errors.NewInternalError(ctx, r.db.Error) } return &tq, nil }
[ "func", "(", "r", "*", "GormTrackerQueryRepository", ")", "Create", "(", "ctx", "context", ".", "Context", ",", "tq", "TrackerQuery", ")", "(", "*", "TrackerQuery", ",", "error", ")", "{", "wiType", ",", "err", ":=", "r", ".", "witr", ".", "Load", "(", "ctx", ",", "tq", ".", "WorkItemTypeID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "NewBadParameterError", "(", "\"", "\"", ",", "tq", ".", "WorkItemTypeID", ")", "\n", "}", "\n\n", "allowedWIT", ",", "err", ":=", "r", ".", "wir", ".", "CheckTypeAndSpaceShareTemplate", "(", "ctx", ",", "wiType", ",", "tq", ".", "SpaceID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n\n", "}", "\n", "if", "!", "allowedWIT", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "err", ":=", "r", ".", "db", ".", "Create", "(", "&", "tq", ")", ".", "Error", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "NewInternalError", "(", "ctx", ",", "r", ".", "db", ".", "Error", ")", "\n", "}", "\n", "return", "&", "tq", ",", "nil", "\n", "}" ]
// Create creates a new tracker query in the repository // returns BadParameterError, ConversionError or InternalError
[ "Create", "creates", "a", "new", "tracker", "query", "in", "the", "repository", "returns", "BadParameterError", "ConversionError", "or", "InternalError" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/remoteworkitem/trackerquery_repository.go#L62-L81
13,288
fabric8-services/fabric8-wit
remoteworkitem/trackerquery_repository.go
Load
func (r *GormTrackerQueryRepository) Load(ctx context.Context, ID uuid.UUID) (*TrackerQuery, error) { defer goa.MeasureSince([]string{"goa", "db", "trackerquery", "load"}, time.Now()) res := TrackerQuery{} tx := r.db.Where("id = ?", ID).Find(&res) if tx.RecordNotFound() { log.Error(ctx, map[string]interface{}{ "tracker_id": ID.String(), }, "tracker resource not found") return nil, errors.NewNotFoundError("tracker query", ID.String()) } if tx.Error != nil { log.Error(ctx, map[string]interface{}{ "err": tx.Error, "trackerquery_id": ID, }, "unable to load the trackerquery by ID") return nil, errors.NewInternalError(ctx, errs.Wrapf(tx.Error, "failed to load the trackerquery by ID: %s", ID)) } return &res, nil }
go
func (r *GormTrackerQueryRepository) Load(ctx context.Context, ID uuid.UUID) (*TrackerQuery, error) { defer goa.MeasureSince([]string{"goa", "db", "trackerquery", "load"}, time.Now()) res := TrackerQuery{} tx := r.db.Where("id = ?", ID).Find(&res) if tx.RecordNotFound() { log.Error(ctx, map[string]interface{}{ "tracker_id": ID.String(), }, "tracker resource not found") return nil, errors.NewNotFoundError("tracker query", ID.String()) } if tx.Error != nil { log.Error(ctx, map[string]interface{}{ "err": tx.Error, "trackerquery_id": ID, }, "unable to load the trackerquery by ID") return nil, errors.NewInternalError(ctx, errs.Wrapf(tx.Error, "failed to load the trackerquery by ID: %s", ID)) } return &res, nil }
[ "func", "(", "r", "*", "GormTrackerQueryRepository", ")", "Load", "(", "ctx", "context", ".", "Context", ",", "ID", "uuid", ".", "UUID", ")", "(", "*", "TrackerQuery", ",", "error", ")", "{", "defer", "goa", ".", "MeasureSince", "(", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", ",", "time", ".", "Now", "(", ")", ")", "\n", "res", ":=", "TrackerQuery", "{", "}", "\n", "tx", ":=", "r", ".", "db", ".", "Where", "(", "\"", "\"", ",", "ID", ")", ".", "Find", "(", "&", "res", ")", "\n", "if", "tx", ".", "RecordNotFound", "(", ")", "{", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "ID", ".", "String", "(", ")", ",", "}", ",", "\"", "\"", ")", "\n", "return", "nil", ",", "errors", ".", "NewNotFoundError", "(", "\"", "\"", ",", "ID", ".", "String", "(", ")", ")", "\n", "}", "\n", "if", "tx", ".", "Error", "!=", "nil", "{", "log", ".", "Error", "(", "ctx", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "tx", ".", "Error", ",", "\"", "\"", ":", "ID", ",", "}", ",", "\"", "\"", ")", "\n", "return", "nil", ",", "errors", ".", "NewInternalError", "(", "ctx", ",", "errs", ".", "Wrapf", "(", "tx", ".", "Error", ",", "\"", "\"", ",", "ID", ")", ")", "\n", "}", "\n", "return", "&", "res", ",", "nil", "\n", "}" ]
// Load returns the tracker query for the given id // returns NotFoundError, ConversionError or InternalError
[ "Load", "returns", "the", "tracker", "query", "for", "the", "given", "id", "returns", "NotFoundError", "ConversionError", "or", "InternalError" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/remoteworkitem/trackerquery_repository.go#L85-L103
13,289
fabric8-services/fabric8-wit
remoteworkitem/trackerquery_repository.go
List
func (r *GormTrackerQueryRepository) List(ctx context.Context, spaceID uuid.UUID) ([]TrackerQuery, error) { defer goa.MeasureSince([]string{"goa", "db", "trackerquery", "query"}, time.Now()) var objs []TrackerQuery err := r.db.Where("space_id = ?", spaceID).Find(&objs).Error if err != nil && err != gorm.ErrRecordNotFound { return nil, err } return objs, nil }
go
func (r *GormTrackerQueryRepository) List(ctx context.Context, spaceID uuid.UUID) ([]TrackerQuery, error) { defer goa.MeasureSince([]string{"goa", "db", "trackerquery", "query"}, time.Now()) var objs []TrackerQuery err := r.db.Where("space_id = ?", spaceID).Find(&objs).Error if err != nil && err != gorm.ErrRecordNotFound { return nil, err } return objs, nil }
[ "func", "(", "r", "*", "GormTrackerQueryRepository", ")", "List", "(", "ctx", "context", ".", "Context", ",", "spaceID", "uuid", ".", "UUID", ")", "(", "[", "]", "TrackerQuery", ",", "error", ")", "{", "defer", "goa", ".", "MeasureSince", "(", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", ",", "time", ".", "Now", "(", ")", ")", "\n", "var", "objs", "[", "]", "TrackerQuery", "\n", "err", ":=", "r", ".", "db", ".", "Where", "(", "\"", "\"", ",", "spaceID", ")", ".", "Find", "(", "&", "objs", ")", ".", "Error", "\n", "if", "err", "!=", "nil", "&&", "err", "!=", "gorm", ".", "ErrRecordNotFound", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "objs", ",", "nil", "\n", "}" ]
// List returns tracker queries that belong to a space
[ "List", "returns", "tracker", "queries", "that", "belong", "to", "a", "space" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/remoteworkitem/trackerquery_repository.go#L141-L149
13,290
fabric8-services/fabric8-wit
controller/work_item_link_type.go
NewWorkItemLinkTypeController
func NewWorkItemLinkTypeController(service *goa.Service, db application.DB, config WorkItemLinkTypeControllerConfiguration) *WorkItemLinkTypeController { return &WorkItemLinkTypeController{ Controller: service.NewController("WorkItemLinkTypeController"), db: db, config: config, } }
go
func NewWorkItemLinkTypeController(service *goa.Service, db application.DB, config WorkItemLinkTypeControllerConfiguration) *WorkItemLinkTypeController { return &WorkItemLinkTypeController{ Controller: service.NewController("WorkItemLinkTypeController"), db: db, config: config, } }
[ "func", "NewWorkItemLinkTypeController", "(", "service", "*", "goa", ".", "Service", ",", "db", "application", ".", "DB", ",", "config", "WorkItemLinkTypeControllerConfiguration", ")", "*", "WorkItemLinkTypeController", "{", "return", "&", "WorkItemLinkTypeController", "{", "Controller", ":", "service", ".", "NewController", "(", "\"", "\"", ")", ",", "db", ":", "db", ",", "config", ":", "config", ",", "}", "\n", "}" ]
// NewWorkItemLinkTypeController creates a work-item-link-type controller.
[ "NewWorkItemLinkTypeController", "creates", "a", "work", "-", "item", "-", "link", "-", "type", "controller", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/controller/work_item_link_type.go#L32-L38
13,291
fabric8-services/fabric8-wit
controller/work_item_link_type.go
ConvertWorkItemLinkTypeFromModel
func ConvertWorkItemLinkTypeFromModel(request *http.Request, modelLinkType link.WorkItemLinkType) app.WorkItemLinkTypeSingle { spaceTemplateRelatedURL := rest.AbsoluteURL(request, app.SpaceTemplateHref(modelLinkType.SpaceTemplateID.String())) spaceRelatedURL := rest.AbsoluteURL(request, app.SpaceHref(space.SystemSpace.String())) topologyStr := modelLinkType.Topology.String() var converted = app.WorkItemLinkTypeSingle{ Data: &app.WorkItemLinkTypeData{ Type: link.EndpointWorkItemLinkTypes, ID: &modelLinkType.ID, Attributes: &app.WorkItemLinkTypeAttributes{ Name: &modelLinkType.Name, Description: modelLinkType.Description, Version: &modelLinkType.Version, CreatedAt: &modelLinkType.CreatedAt, UpdatedAt: &modelLinkType.UpdatedAt, ForwardName: &modelLinkType.ForwardName, ForwardDescription: modelLinkType.ForwardDescription, ReverseName: &modelLinkType.ReverseName, ReverseDescription: modelLinkType.ReverseDescription, Topology: &topologyStr, }, Relationships: &app.WorkItemLinkTypeRelationships{ Space: app.NewSpaceRelation(space.SystemSpace, spaceRelatedURL), SpaceTemplate: app.NewSpaceTemplateRelation(modelLinkType.SpaceTemplateID, spaceTemplateRelatedURL), }, }, } return converted }
go
func ConvertWorkItemLinkTypeFromModel(request *http.Request, modelLinkType link.WorkItemLinkType) app.WorkItemLinkTypeSingle { spaceTemplateRelatedURL := rest.AbsoluteURL(request, app.SpaceTemplateHref(modelLinkType.SpaceTemplateID.String())) spaceRelatedURL := rest.AbsoluteURL(request, app.SpaceHref(space.SystemSpace.String())) topologyStr := modelLinkType.Topology.String() var converted = app.WorkItemLinkTypeSingle{ Data: &app.WorkItemLinkTypeData{ Type: link.EndpointWorkItemLinkTypes, ID: &modelLinkType.ID, Attributes: &app.WorkItemLinkTypeAttributes{ Name: &modelLinkType.Name, Description: modelLinkType.Description, Version: &modelLinkType.Version, CreatedAt: &modelLinkType.CreatedAt, UpdatedAt: &modelLinkType.UpdatedAt, ForwardName: &modelLinkType.ForwardName, ForwardDescription: modelLinkType.ForwardDescription, ReverseName: &modelLinkType.ReverseName, ReverseDescription: modelLinkType.ReverseDescription, Topology: &topologyStr, }, Relationships: &app.WorkItemLinkTypeRelationships{ Space: app.NewSpaceRelation(space.SystemSpace, spaceRelatedURL), SpaceTemplate: app.NewSpaceTemplateRelation(modelLinkType.SpaceTemplateID, spaceTemplateRelatedURL), }, }, } return converted }
[ "func", "ConvertWorkItemLinkTypeFromModel", "(", "request", "*", "http", ".", "Request", ",", "modelLinkType", "link", ".", "WorkItemLinkType", ")", "app", ".", "WorkItemLinkTypeSingle", "{", "spaceTemplateRelatedURL", ":=", "rest", ".", "AbsoluteURL", "(", "request", ",", "app", ".", "SpaceTemplateHref", "(", "modelLinkType", ".", "SpaceTemplateID", ".", "String", "(", ")", ")", ")", "\n", "spaceRelatedURL", ":=", "rest", ".", "AbsoluteURL", "(", "request", ",", "app", ".", "SpaceHref", "(", "space", ".", "SystemSpace", ".", "String", "(", ")", ")", ")", "\n\n", "topologyStr", ":=", "modelLinkType", ".", "Topology", ".", "String", "(", ")", "\n", "var", "converted", "=", "app", ".", "WorkItemLinkTypeSingle", "{", "Data", ":", "&", "app", ".", "WorkItemLinkTypeData", "{", "Type", ":", "link", ".", "EndpointWorkItemLinkTypes", ",", "ID", ":", "&", "modelLinkType", ".", "ID", ",", "Attributes", ":", "&", "app", ".", "WorkItemLinkTypeAttributes", "{", "Name", ":", "&", "modelLinkType", ".", "Name", ",", "Description", ":", "modelLinkType", ".", "Description", ",", "Version", ":", "&", "modelLinkType", ".", "Version", ",", "CreatedAt", ":", "&", "modelLinkType", ".", "CreatedAt", ",", "UpdatedAt", ":", "&", "modelLinkType", ".", "UpdatedAt", ",", "ForwardName", ":", "&", "modelLinkType", ".", "ForwardName", ",", "ForwardDescription", ":", "modelLinkType", ".", "ForwardDescription", ",", "ReverseName", ":", "&", "modelLinkType", ".", "ReverseName", ",", "ReverseDescription", ":", "modelLinkType", ".", "ReverseDescription", ",", "Topology", ":", "&", "topologyStr", ",", "}", ",", "Relationships", ":", "&", "app", ".", "WorkItemLinkTypeRelationships", "{", "Space", ":", "app", ".", "NewSpaceRelation", "(", "space", ".", "SystemSpace", ",", "spaceRelatedURL", ")", ",", "SpaceTemplate", ":", "app", ".", "NewSpaceTemplateRelation", "(", "modelLinkType", ".", "SpaceTemplateID", ",", "spaceTemplateRelatedURL", ")", ",", "}", ",", "}", ",", "}", "\n", "return", "converted", "\n", "}" ]
// ConvertWorkItemLinkTypeFromModel converts a work item link type from model to REST representation
[ "ConvertWorkItemLinkTypeFromModel", "converts", "a", "work", "item", "link", "type", "from", "model", "to", "REST", "representation" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/controller/work_item_link_type.go#L96-L124
13,292
fabric8-services/fabric8-wit
controller/work_item_link_type.go
ConvertWorkItemLinkTypeToModel
func ConvertWorkItemLinkTypeToModel(appLinkType app.WorkItemLinkTypeSingle) (*link.WorkItemLinkType, error) { modelLinkType := link.WorkItemLinkType{} if appLinkType.Data == nil { return nil, errors.NewBadParameterError("data", nil).Expected("not <nil>") } if appLinkType.Data.Attributes == nil { return nil, errors.NewBadParameterError("data.attributes", nil).Expected("not <nil>") } if appLinkType.Data.Relationships == nil { return nil, errors.NewBadParameterError("data.relationships", nil).Expected("not <nil>") } attrs := appLinkType.Data.Attributes rel := appLinkType.Data.Relationships if appLinkType.Data.ID != nil { modelLinkType.ID = *appLinkType.Data.ID } if attrs != nil { // If the name is not nil, it MUST NOT be empty if attrs.Name != nil { if *attrs.Name == "" { return nil, errors.NewBadParameterError("data.attributes.name", *attrs.Name) } modelLinkType.Name = *attrs.Name } modelLinkType.Description = attrs.Description modelLinkType.ForwardDescription = attrs.ForwardDescription modelLinkType.ReverseDescription = attrs.ReverseDescription if attrs.Version != nil { modelLinkType.Version = *attrs.Version } // If the forwardName is not nil, it MUST NOT be empty if attrs.ForwardName != nil { if *attrs.ForwardName == "" { return nil, errors.NewBadParameterError("data.attributes.forward_name", *attrs.ForwardName) } modelLinkType.ForwardName = *attrs.ForwardName } // If the ReverseName is not nil, it MUST NOT be empty if attrs.ReverseName != nil { if *attrs.ReverseName == "" { return nil, errors.NewBadParameterError("data.attributes.reverse_name", *attrs.ReverseName) } modelLinkType.ReverseName = *attrs.ReverseName } if attrs.Topology != nil { modelLinkType.Topology = link.Topology(*attrs.Topology) if err := modelLinkType.Topology.CheckValid(); err != nil { return nil, err } } } if rel != nil && rel.SpaceTemplate != nil && rel.SpaceTemplate.Data != nil { modelLinkType.SpaceTemplateID = rel.SpaceTemplate.Data.ID } return &modelLinkType, nil }
go
func ConvertWorkItemLinkTypeToModel(appLinkType app.WorkItemLinkTypeSingle) (*link.WorkItemLinkType, error) { modelLinkType := link.WorkItemLinkType{} if appLinkType.Data == nil { return nil, errors.NewBadParameterError("data", nil).Expected("not <nil>") } if appLinkType.Data.Attributes == nil { return nil, errors.NewBadParameterError("data.attributes", nil).Expected("not <nil>") } if appLinkType.Data.Relationships == nil { return nil, errors.NewBadParameterError("data.relationships", nil).Expected("not <nil>") } attrs := appLinkType.Data.Attributes rel := appLinkType.Data.Relationships if appLinkType.Data.ID != nil { modelLinkType.ID = *appLinkType.Data.ID } if attrs != nil { // If the name is not nil, it MUST NOT be empty if attrs.Name != nil { if *attrs.Name == "" { return nil, errors.NewBadParameterError("data.attributes.name", *attrs.Name) } modelLinkType.Name = *attrs.Name } modelLinkType.Description = attrs.Description modelLinkType.ForwardDescription = attrs.ForwardDescription modelLinkType.ReverseDescription = attrs.ReverseDescription if attrs.Version != nil { modelLinkType.Version = *attrs.Version } // If the forwardName is not nil, it MUST NOT be empty if attrs.ForwardName != nil { if *attrs.ForwardName == "" { return nil, errors.NewBadParameterError("data.attributes.forward_name", *attrs.ForwardName) } modelLinkType.ForwardName = *attrs.ForwardName } // If the ReverseName is not nil, it MUST NOT be empty if attrs.ReverseName != nil { if *attrs.ReverseName == "" { return nil, errors.NewBadParameterError("data.attributes.reverse_name", *attrs.ReverseName) } modelLinkType.ReverseName = *attrs.ReverseName } if attrs.Topology != nil { modelLinkType.Topology = link.Topology(*attrs.Topology) if err := modelLinkType.Topology.CheckValid(); err != nil { return nil, err } } } if rel != nil && rel.SpaceTemplate != nil && rel.SpaceTemplate.Data != nil { modelLinkType.SpaceTemplateID = rel.SpaceTemplate.Data.ID } return &modelLinkType, nil }
[ "func", "ConvertWorkItemLinkTypeToModel", "(", "appLinkType", "app", ".", "WorkItemLinkTypeSingle", ")", "(", "*", "link", ".", "WorkItemLinkType", ",", "error", ")", "{", "modelLinkType", ":=", "link", ".", "WorkItemLinkType", "{", "}", "\n", "if", "appLinkType", ".", "Data", "==", "nil", "{", "return", "nil", ",", "errors", ".", "NewBadParameterError", "(", "\"", "\"", ",", "nil", ")", ".", "Expected", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "appLinkType", ".", "Data", ".", "Attributes", "==", "nil", "{", "return", "nil", ",", "errors", ".", "NewBadParameterError", "(", "\"", "\"", ",", "nil", ")", ".", "Expected", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "appLinkType", ".", "Data", ".", "Relationships", "==", "nil", "{", "return", "nil", ",", "errors", ".", "NewBadParameterError", "(", "\"", "\"", ",", "nil", ")", ".", "Expected", "(", "\"", "\"", ")", "\n", "}", "\n\n", "attrs", ":=", "appLinkType", ".", "Data", ".", "Attributes", "\n", "rel", ":=", "appLinkType", ".", "Data", ".", "Relationships", "\n\n", "if", "appLinkType", ".", "Data", ".", "ID", "!=", "nil", "{", "modelLinkType", ".", "ID", "=", "*", "appLinkType", ".", "Data", ".", "ID", "\n", "}", "\n\n", "if", "attrs", "!=", "nil", "{", "// If the name is not nil, it MUST NOT be empty", "if", "attrs", ".", "Name", "!=", "nil", "{", "if", "*", "attrs", ".", "Name", "==", "\"", "\"", "{", "return", "nil", ",", "errors", ".", "NewBadParameterError", "(", "\"", "\"", ",", "*", "attrs", ".", "Name", ")", "\n", "}", "\n", "modelLinkType", ".", "Name", "=", "*", "attrs", ".", "Name", "\n", "}", "\n\n", "modelLinkType", ".", "Description", "=", "attrs", ".", "Description", "\n", "modelLinkType", ".", "ForwardDescription", "=", "attrs", ".", "ForwardDescription", "\n", "modelLinkType", ".", "ReverseDescription", "=", "attrs", ".", "ReverseDescription", "\n\n", "if", "attrs", ".", "Version", "!=", "nil", "{", "modelLinkType", ".", "Version", "=", "*", "attrs", ".", "Version", "\n", "}", "\n\n", "// If the forwardName is not nil, it MUST NOT be empty", "if", "attrs", ".", "ForwardName", "!=", "nil", "{", "if", "*", "attrs", ".", "ForwardName", "==", "\"", "\"", "{", "return", "nil", ",", "errors", ".", "NewBadParameterError", "(", "\"", "\"", ",", "*", "attrs", ".", "ForwardName", ")", "\n", "}", "\n", "modelLinkType", ".", "ForwardName", "=", "*", "attrs", ".", "ForwardName", "\n", "}", "\n\n", "// If the ReverseName is not nil, it MUST NOT be empty", "if", "attrs", ".", "ReverseName", "!=", "nil", "{", "if", "*", "attrs", ".", "ReverseName", "==", "\"", "\"", "{", "return", "nil", ",", "errors", ".", "NewBadParameterError", "(", "\"", "\"", ",", "*", "attrs", ".", "ReverseName", ")", "\n", "}", "\n", "modelLinkType", ".", "ReverseName", "=", "*", "attrs", ".", "ReverseName", "\n", "}", "\n\n", "if", "attrs", ".", "Topology", "!=", "nil", "{", "modelLinkType", ".", "Topology", "=", "link", ".", "Topology", "(", "*", "attrs", ".", "Topology", ")", "\n", "if", "err", ":=", "modelLinkType", ".", "Topology", ".", "CheckValid", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n", "}", "\n\n", "if", "rel", "!=", "nil", "&&", "rel", ".", "SpaceTemplate", "!=", "nil", "&&", "rel", ".", "SpaceTemplate", ".", "Data", "!=", "nil", "{", "modelLinkType", ".", "SpaceTemplateID", "=", "rel", ".", "SpaceTemplate", ".", "Data", ".", "ID", "\n", "}", "\n\n", "return", "&", "modelLinkType", ",", "nil", "\n", "}" ]
// ConvertWorkItemLinkTypeToModel converts the incoming app representation of a work item link type to the model layout. // Values are only overwrriten if they are set in "in", otherwise the values in "out" remain.
[ "ConvertWorkItemLinkTypeToModel", "converts", "the", "incoming", "app", "representation", "of", "a", "work", "item", "link", "type", "to", "the", "model", "layout", ".", "Values", "are", "only", "overwrriten", "if", "they", "are", "set", "in", "in", "otherwise", "the", "values", "in", "out", "remain", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/controller/work_item_link_type.go#L128-L193
13,293
fabric8-services/fabric8-wit
rendering/markup_render.go
IsMarkupSupported
func IsMarkupSupported(markup string) bool { if markup == SystemMarkupDefault || markup == SystemMarkupMarkdown { return true } return false }
go
func IsMarkupSupported(markup string) bool { if markup == SystemMarkupDefault || markup == SystemMarkupMarkdown { return true } return false }
[ "func", "IsMarkupSupported", "(", "markup", "string", ")", "bool", "{", "if", "markup", "==", "SystemMarkupDefault", "||", "markup", "==", "SystemMarkupMarkdown", "{", "return", "true", "\n", "}", "\n", "return", "false", "\n", "}" ]
// IsMarkupSupported indicates if the given markup is supported
[ "IsMarkupSupported", "indicates", "if", "the", "given", "markup", "is", "supported" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/rendering/markup_render.go#L11-L16
13,294
fabric8-services/fabric8-wit
rendering/markup_render.go
RenderMarkupToHTML
func RenderMarkupToHTML(content, markup string) string { switch markup { case SystemMarkupPlainText: return html.EscapeString(content) case SystemMarkupMarkdown: unsafe := MarkdownCommonHighlighter([]byte(content)) p := bluemonday.UGCPolicy() p.AllowAttrs("class").Matching(regexp.MustCompile("^language-[a-zA-Z0-9]+$|prettyprint")).OnElements("code") p.AllowAttrs("class").OnElements("span") p.AllowElements("input") p.AllowAttrs("type").OnElements("input") p.AllowAttrs("checked").OnElements("input") p.AllowAttrs("disabled").OnElements("input") p.AllowAttrs("data-checkbox-index").OnElements("input") p.AllowAttrs("class").OnElements("input") html := string(p.SanitizeBytes(unsafe)) return html default: return "" } }
go
func RenderMarkupToHTML(content, markup string) string { switch markup { case SystemMarkupPlainText: return html.EscapeString(content) case SystemMarkupMarkdown: unsafe := MarkdownCommonHighlighter([]byte(content)) p := bluemonday.UGCPolicy() p.AllowAttrs("class").Matching(regexp.MustCompile("^language-[a-zA-Z0-9]+$|prettyprint")).OnElements("code") p.AllowAttrs("class").OnElements("span") p.AllowElements("input") p.AllowAttrs("type").OnElements("input") p.AllowAttrs("checked").OnElements("input") p.AllowAttrs("disabled").OnElements("input") p.AllowAttrs("data-checkbox-index").OnElements("input") p.AllowAttrs("class").OnElements("input") html := string(p.SanitizeBytes(unsafe)) return html default: return "" } }
[ "func", "RenderMarkupToHTML", "(", "content", ",", "markup", "string", ")", "string", "{", "switch", "markup", "{", "case", "SystemMarkupPlainText", ":", "return", "html", ".", "EscapeString", "(", "content", ")", "\n", "case", "SystemMarkupMarkdown", ":", "unsafe", ":=", "MarkdownCommonHighlighter", "(", "[", "]", "byte", "(", "content", ")", ")", "\n", "p", ":=", "bluemonday", ".", "UGCPolicy", "(", ")", "\n", "p", ".", "AllowAttrs", "(", "\"", "\"", ")", ".", "Matching", "(", "regexp", ".", "MustCompile", "(", "\"", "\"", ")", ")", ".", "OnElements", "(", "\"", "\"", ")", "\n", "p", ".", "AllowAttrs", "(", "\"", "\"", ")", ".", "OnElements", "(", "\"", "\"", ")", "\n", "p", ".", "AllowElements", "(", "\"", "\"", ")", "\n", "p", ".", "AllowAttrs", "(", "\"", "\"", ")", ".", "OnElements", "(", "\"", "\"", ")", "\n", "p", ".", "AllowAttrs", "(", "\"", "\"", ")", ".", "OnElements", "(", "\"", "\"", ")", "\n", "p", ".", "AllowAttrs", "(", "\"", "\"", ")", ".", "OnElements", "(", "\"", "\"", ")", "\n", "p", ".", "AllowAttrs", "(", "\"", "\"", ")", ".", "OnElements", "(", "\"", "\"", ")", "\n", "p", ".", "AllowAttrs", "(", "\"", "\"", ")", ".", "OnElements", "(", "\"", "\"", ")", "\n", "html", ":=", "string", "(", "p", ".", "SanitizeBytes", "(", "unsafe", ")", ")", "\n", "return", "html", "\n", "default", ":", "return", "\"", "\"", "\n", "}", "\n", "}" ]
// RenderMarkupToHTML converts the given `content` in HTML using the markup tool corresponding to the given `markup` argument // or return nil if no tool for the given `markup` is available, or returns an `error` if the command was not found or failed.
[ "RenderMarkupToHTML", "converts", "the", "given", "content", "in", "HTML", "using", "the", "markup", "tool", "corresponding", "to", "the", "given", "markup", "argument", "or", "return", "nil", "if", "no", "tool", "for", "the", "given", "markup", "is", "available", "or", "returns", "an", "error", "if", "the", "command", "was", "not", "found", "or", "failed", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/rendering/markup_render.go#L20-L40
13,295
fabric8-services/fabric8-wit
rest/url.go
AbsoluteURL
func AbsoluteURL(req *http.Request, relative string) string { scheme := "http" if req.URL != nil && req.URL.Scheme == "https" { // isHTTPS scheme = "https" } xForwardProto := req.Header.Get("X-Forwarded-Proto") if xForwardProto != "" { scheme = xForwardProto } return fmt.Sprintf("%s://%s%s", scheme, req.Host, relative) }
go
func AbsoluteURL(req *http.Request, relative string) string { scheme := "http" if req.URL != nil && req.URL.Scheme == "https" { // isHTTPS scheme = "https" } xForwardProto := req.Header.Get("X-Forwarded-Proto") if xForwardProto != "" { scheme = xForwardProto } return fmt.Sprintf("%s://%s%s", scheme, req.Host, relative) }
[ "func", "AbsoluteURL", "(", "req", "*", "http", ".", "Request", ",", "relative", "string", ")", "string", "{", "scheme", ":=", "\"", "\"", "\n", "if", "req", ".", "URL", "!=", "nil", "&&", "req", ".", "URL", ".", "Scheme", "==", "\"", "\"", "{", "// isHTTPS", "scheme", "=", "\"", "\"", "\n", "}", "\n", "xForwardProto", ":=", "req", ".", "Header", ".", "Get", "(", "\"", "\"", ")", "\n", "if", "xForwardProto", "!=", "\"", "\"", "{", "scheme", "=", "xForwardProto", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "scheme", ",", "req", ".", "Host", ",", "relative", ")", "\n", "}" ]
// AbsoluteURL prefixes a relative URL with absolute address
[ "AbsoluteURL", "prefixes", "a", "relative", "URL", "with", "absolute", "address" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/rest/url.go#L16-L26
13,296
fabric8-services/fabric8-wit
rest/url.go
AbsoluteURLAsURL
func AbsoluteURLAsURL(req *http.Request, relative string) (*url.URL, error) { return url.Parse(AbsoluteURL(req, relative)) }
go
func AbsoluteURLAsURL(req *http.Request, relative string) (*url.URL, error) { return url.Parse(AbsoluteURL(req, relative)) }
[ "func", "AbsoluteURLAsURL", "(", "req", "*", "http", ".", "Request", ",", "relative", "string", ")", "(", "*", "url", ".", "URL", ",", "error", ")", "{", "return", "url", ".", "Parse", "(", "AbsoluteURL", "(", "req", ",", "relative", ")", ")", "\n", "}" ]
// AbsoluteURLAsURL returns the result of AbsoluteURL parsed into a URL // structure and a potential parsing error.
[ "AbsoluteURLAsURL", "returns", "the", "result", "of", "AbsoluteURL", "parsed", "into", "a", "URL", "structure", "and", "a", "potential", "parsing", "error", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/rest/url.go#L30-L32
13,297
fabric8-services/fabric8-wit
rest/url.go
ReadBody
func ReadBody(body io.ReadCloser) string { buf := new(bytes.Buffer) buf.ReadFrom(body) return buf.String() }
go
func ReadBody(body io.ReadCloser) string { buf := new(bytes.Buffer) buf.ReadFrom(body) return buf.String() }
[ "func", "ReadBody", "(", "body", "io", ".", "ReadCloser", ")", "string", "{", "buf", ":=", "new", "(", "bytes", ".", "Buffer", ")", "\n", "buf", ".", "ReadFrom", "(", "body", ")", "\n", "return", "buf", ".", "String", "(", ")", "\n", "}" ]
// ReadBody reads body from a ReadCloser and returns it as a string
[ "ReadBody", "reads", "body", "from", "a", "ReadCloser", "and", "returns", "it", "as", "a", "string" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/rest/url.go#L44-L48
13,298
fabric8-services/fabric8-wit
rest/url.go
CloseResponse
func CloseResponse(response *http.Response) { ioutil.ReadAll(response.Body) response.Body.Close() }
go
func CloseResponse(response *http.Response) { ioutil.ReadAll(response.Body) response.Body.Close() }
[ "func", "CloseResponse", "(", "response", "*", "http", ".", "Response", ")", "{", "ioutil", ".", "ReadAll", "(", "response", ".", "Body", ")", "\n", "response", ".", "Body", ".", "Close", "(", ")", "\n", "}" ]
// CloseResponse reads the body and close the response. To be used to prevent file descriptor leaks.
[ "CloseResponse", "reads", "the", "body", "and", "close", "the", "response", ".", "To", "be", "used", "to", "prevent", "file", "descriptor", "leaks", "." ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/rest/url.go#L51-L54
13,299
fabric8-services/fabric8-wit
remoteworkitem/github.go
listIssues
func (f *githubIssueFetcher) listIssues(query string, opts *github.SearchOptions) (*github.IssuesSearchResult, *github.Response, error) { return f.client.Search.Issues(query, opts) }
go
func (f *githubIssueFetcher) listIssues(query string, opts *github.SearchOptions) (*github.IssuesSearchResult, *github.Response, error) { return f.client.Search.Issues(query, opts) }
[ "func", "(", "f", "*", "githubIssueFetcher", ")", "listIssues", "(", "query", "string", ",", "opts", "*", "github", ".", "SearchOptions", ")", "(", "*", "github", ".", "IssuesSearchResult", ",", "*", "github", ".", "Response", ",", "error", ")", "{", "return", "f", ".", "client", ".", "Search", ".", "Issues", "(", "query", ",", "opts", ")", "\n", "}" ]
// ListIssues list all issues
[ "ListIssues", "list", "all", "issues" ]
54759c80c42ff2cf29b352e0f6c9330ce4ad7fce
https://github.com/fabric8-services/fabric8-wit/blob/54759c80c42ff2cf29b352e0f6c9330ce4ad7fce/remoteworkitem/github.go#L29-L31