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 list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
150,600 | tideland/golib | scroller/scroller.go | backendLoop | func (s *Scroller) backendLoop(l loop.Loop) error {
// Initial positioning.
if err := s.seekInitial(); err != nil {
return err
}
// Polling loop.
timer := time.NewTimer(0)
for {
select {
case <-l.ShallStop():
return nil
case <-timer.C:
for {
line, readErr := s.readLine()
_, writeErr := s.wri... | go | func (s *Scroller) backendLoop(l loop.Loop) error {
// Initial positioning.
if err := s.seekInitial(); err != nil {
return err
}
// Polling loop.
timer := time.NewTimer(0)
for {
select {
case <-l.ShallStop():
return nil
case <-timer.C:
for {
line, readErr := s.readLine()
_, writeErr := s.wri... | [
"func",
"(",
"s",
"*",
"Scroller",
")",
"backendLoop",
"(",
"l",
"loop",
".",
"Loop",
")",
"error",
"{",
"// Initial positioning.",
"if",
"err",
":=",
"s",
".",
"seekInitial",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
... | // backendLoop is the goroutine for reading, filtering and writing. | [
"backendLoop",
"is",
"the",
"goroutine",
"for",
"reading",
"filtering",
"and",
"writing",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/scroller/scroller.go#L156-L187 |
150,601 | tideland/golib | scroller/scroller.go | seekInitial | func (s *Scroller) seekInitial() error {
offset, err := s.source.Seek(0, os.SEEK_END)
if err != nil {
return err
}
if s.lines < 1 {
// Simple case, no initial lines wanted.
return nil
}
seekPos := int64(0)
found := 0
buffer := make([]byte, s.bufferSize)
SeekLoop:
for offset > 0 {
// bufferf partly fill... | go | func (s *Scroller) seekInitial() error {
offset, err := s.source.Seek(0, os.SEEK_END)
if err != nil {
return err
}
if s.lines < 1 {
// Simple case, no initial lines wanted.
return nil
}
seekPos := int64(0)
found := 0
buffer := make([]byte, s.bufferSize)
SeekLoop:
for offset > 0 {
// bufferf partly fill... | [
"func",
"(",
"s",
"*",
"Scroller",
")",
"seekInitial",
"(",
")",
"error",
"{",
"offset",
",",
"err",
":=",
"s",
".",
"source",
".",
"Seek",
"(",
"0",
",",
"os",
".",
"SEEK_END",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"... | // seekInitial sets the initial position to start reading. This
// position depends on the number lines and the filter st. | [
"seekInitial",
"sets",
"the",
"initial",
"position",
"to",
"start",
"reading",
".",
"This",
"position",
"depends",
"on",
"the",
"number",
"lines",
"and",
"the",
"filter",
"st",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/scroller/scroller.go#L191-L267 |
150,602 | tideland/golib | scroller/scroller.go | readLine | func (s *Scroller) readLine() ([]byte, error) {
for {
slice, err := s.reader.ReadSlice(delimiter)
if err == nil {
if s.isValid(slice) {
return slice, nil
}
continue
}
line := append([]byte(nil), slice...)
for err == bufio.ErrBufferFull {
slice, err = s.reader.ReadSlice(delimiter)
line = ap... | go | func (s *Scroller) readLine() ([]byte, error) {
for {
slice, err := s.reader.ReadSlice(delimiter)
if err == nil {
if s.isValid(slice) {
return slice, nil
}
continue
}
line := append([]byte(nil), slice...)
for err == bufio.ErrBufferFull {
slice, err = s.reader.ReadSlice(delimiter)
line = ap... | [
"func",
"(",
"s",
"*",
"Scroller",
")",
"readLine",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"for",
"{",
"slice",
",",
"err",
":=",
"s",
".",
"reader",
".",
"ReadSlice",
"(",
"delimiter",
")",
"\n",
"if",
"err",
"==",
"nil",
"{"... | // readLine reads the next valid line from the reader, even if it is
// larger than the reader buffer. | [
"readLine",
"reads",
"the",
"next",
"valid",
"line",
"from",
"the",
"reader",
"even",
"if",
"it",
"is",
"larger",
"than",
"the",
"reader",
"buffer",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/scroller/scroller.go#L271-L299 |
150,603 | tideland/golib | scroller/scroller.go | isValid | func (s *Scroller) isValid(line []byte) bool {
if s.filter == nil {
return true
}
return s.filter(line)
} | go | func (s *Scroller) isValid(line []byte) bool {
if s.filter == nil {
return true
}
return s.filter(line)
} | [
"func",
"(",
"s",
"*",
"Scroller",
")",
"isValid",
"(",
"line",
"[",
"]",
"byte",
")",
"bool",
"{",
"if",
"s",
".",
"filter",
"==",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n",
"return",
"s",
".",
"filter",
"(",
"line",
")",
"\n",
"}"
] | // isValid checks if the passed line is valid by using a
// possibly set filter. | [
"isValid",
"checks",
"if",
"the",
"passed",
"line",
"is",
"valid",
"by",
"using",
"a",
"possibly",
"set",
"filter",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/scroller/scroller.go#L303-L308 |
150,604 | tideland/golib | sort/sort.go | median | func median(data sort.Interface, lo, hi int) int {
m := (lo + hi) / 2
d := (hi - lo) / 8
// Move median into the middle.
mot := func(ml, mm, mh int) {
if data.Less(mm, ml) {
data.Swap(mm, ml)
}
if data.Less(mh, mm) {
data.Swap(mh, mm)
}
if data.Less(mm, ml) {
data.Swap(mm, ml)
}
}
// Get low,... | go | func median(data sort.Interface, lo, hi int) int {
m := (lo + hi) / 2
d := (hi - lo) / 8
// Move median into the middle.
mot := func(ml, mm, mh int) {
if data.Less(mm, ml) {
data.Swap(mm, ml)
}
if data.Less(mh, mm) {
data.Swap(mh, mm)
}
if data.Less(mm, ml) {
data.Swap(mm, ml)
}
}
// Get low,... | [
"func",
"median",
"(",
"data",
"sort",
".",
"Interface",
",",
"lo",
",",
"hi",
"int",
")",
"int",
"{",
"m",
":=",
"(",
"lo",
"+",
"hi",
")",
"/",
"2",
"\n",
"d",
":=",
"(",
"hi",
"-",
"lo",
")",
"/",
"8",
"\n",
"// Move median into the middle.",
... | // median to caclculate the median based on Tukey's ninther. | [
"median",
"to",
"caclculate",
"the",
"median",
"based",
"on",
"Tukey",
"s",
"ninther",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sort/sort.go#L43-L67 |
150,605 | tideland/golib | sort/sort.go | partition | func partition(data sort.Interface, lo, hi int) (int, int) {
med := median(data, lo, hi)
idx := lo
data.Swap(med, hi)
for i := lo; i < hi; i++ {
if data.Less(i, hi) {
data.Swap(i, idx)
idx++
}
}
data.Swap(idx, hi)
return idx - 1, idx + 1
} | go | func partition(data sort.Interface, lo, hi int) (int, int) {
med := median(data, lo, hi)
idx := lo
data.Swap(med, hi)
for i := lo; i < hi; i++ {
if data.Less(i, hi) {
data.Swap(i, idx)
idx++
}
}
data.Swap(idx, hi)
return idx - 1, idx + 1
} | [
"func",
"partition",
"(",
"data",
"sort",
".",
"Interface",
",",
"lo",
",",
"hi",
"int",
")",
"(",
"int",
",",
"int",
")",
"{",
"med",
":=",
"median",
"(",
"data",
",",
"lo",
",",
"hi",
")",
"\n",
"idx",
":=",
"lo",
"\n",
"data",
".",
"Swap",
... | // partition the data based on the median. | [
"partition",
"the",
"data",
"based",
"on",
"the",
"median",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sort/sort.go#L70-L82 |
150,606 | tideland/golib | sort/sort.go | sequentialQuickSort | func sequentialQuickSort(data sort.Interface, lo, hi int) {
if hi-lo > sequentialThreshold {
// Use sequential quicksort.
plo, phi := partition(data, lo, hi)
sequentialQuickSort(data, lo, plo)
sequentialQuickSort(data, phi, hi)
} else {
// Use insertion sort.
insertionSort(data, lo, hi)
}
} | go | func sequentialQuickSort(data sort.Interface, lo, hi int) {
if hi-lo > sequentialThreshold {
// Use sequential quicksort.
plo, phi := partition(data, lo, hi)
sequentialQuickSort(data, lo, plo)
sequentialQuickSort(data, phi, hi)
} else {
// Use insertion sort.
insertionSort(data, lo, hi)
}
} | [
"func",
"sequentialQuickSort",
"(",
"data",
"sort",
".",
"Interface",
",",
"lo",
",",
"hi",
"int",
")",
"{",
"if",
"hi",
"-",
"lo",
">",
"sequentialThreshold",
"{",
"// Use sequential quicksort.",
"plo",
",",
"phi",
":=",
"partition",
"(",
"data",
",",
"lo... | // sequentialQuickSort using itself recursively. | [
"sequentialQuickSort",
"using",
"itself",
"recursively",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sort/sort.go#L85-L95 |
150,607 | tideland/golib | sort/sort.go | parallelQuickSort | func parallelQuickSort(data sort.Interface, lo, hi int, done chan bool) {
if hi-lo > parallelThreshold {
// Parallel QuickSort.
plo, phi := partition(data, lo, hi)
partDone := make(chan bool)
go parallelQuickSort(data, lo, plo, partDone)
go parallelQuickSort(data, phi, hi, partDone)
// Wait for the end of ... | go | func parallelQuickSort(data sort.Interface, lo, hi int, done chan bool) {
if hi-lo > parallelThreshold {
// Parallel QuickSort.
plo, phi := partition(data, lo, hi)
partDone := make(chan bool)
go parallelQuickSort(data, lo, plo, partDone)
go parallelQuickSort(data, phi, hi, partDone)
// Wait for the end of ... | [
"func",
"parallelQuickSort",
"(",
"data",
"sort",
".",
"Interface",
",",
"lo",
",",
"hi",
"int",
",",
"done",
"chan",
"bool",
")",
"{",
"if",
"hi",
"-",
"lo",
">",
"parallelThreshold",
"{",
"// Parallel QuickSort.",
"plo",
",",
"phi",
":=",
"partition",
... | // parallelQuickSort using itself recursively and concurrent. | [
"parallelQuickSort",
"using",
"itself",
"recursively",
"and",
"concurrent",
"."
] | b56169c6bd620eeb7cfc4b9b4027fc10d2934c84 | https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sort/sort.go#L98-L114 |
150,608 | bahlo/goat | middleware.go | chain | func (r *Router) chain() http.Handler {
var final http.Handler
final = r.router
mw := r.allMiddleware()
for i := len(mw) - 1; i >= 0; i-- {
final = mw[i](final)
}
return final
} | go | func (r *Router) chain() http.Handler {
var final http.Handler
final = r.router
mw := r.allMiddleware()
for i := len(mw) - 1; i >= 0; i-- {
final = mw[i](final)
}
return final
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"chain",
"(",
")",
"http",
".",
"Handler",
"{",
"var",
"final",
"http",
".",
"Handler",
"\n\n",
"final",
"=",
"r",
".",
"router",
"\n",
"mw",
":=",
"r",
".",
"allMiddleware",
"(",
")",
"\n",
"for",
"i",
":=",... | // chain calls all middlewares and returns the final handler | [
"chain",
"calls",
"all",
"middlewares",
"and",
"returns",
"the",
"final",
"handler"
] | b22257573feec3b6df344c9cb5feec59098c8133 | https://github.com/bahlo/goat/blob/b22257573feec3b6df344c9cb5feec59098c8133/middleware.go#L9-L19 |
150,609 | bahlo/goat | middleware.go | allMiddleware | func (r *Router) allMiddleware() []Middleware {
mw := r.middleware
if r.parent != nil {
mw = append(mw, r.parent.allMiddleware()...)
}
return mw
} | go | func (r *Router) allMiddleware() []Middleware {
mw := r.middleware
if r.parent != nil {
mw = append(mw, r.parent.allMiddleware()...)
}
return mw
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"allMiddleware",
"(",
")",
"[",
"]",
"Middleware",
"{",
"mw",
":=",
"r",
".",
"middleware",
"\n\n",
"if",
"r",
".",
"parent",
"!=",
"nil",
"{",
"mw",
"=",
"append",
"(",
"mw",
",",
"r",
".",
"parent",
".",
... | // allMiddleware returns the middleware from this router and all parents | [
"allMiddleware",
"returns",
"the",
"middleware",
"from",
"this",
"router",
"and",
"all",
"parents"
] | b22257573feec3b6df344c9cb5feec59098c8133 | https://github.com/bahlo/goat/blob/b22257573feec3b6df344c9cb5feec59098c8133/middleware.go#L22-L30 |
150,610 | bahlo/goat | middleware.go | Use | func (r *Router) Use(middleware ...Middleware) {
if r.parent != nil {
panic("subrouters can't use middleware!")
}
r.middleware = append(r.middleware, middleware...)
} | go | func (r *Router) Use(middleware ...Middleware) {
if r.parent != nil {
panic("subrouters can't use middleware!")
}
r.middleware = append(r.middleware, middleware...)
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"Use",
"(",
"middleware",
"...",
"Middleware",
")",
"{",
"if",
"r",
".",
"parent",
"!=",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"r",
".",
"middleware",
"=",
"append",
"(",
"r",
".",
"mi... | // Use adds middleware to the router | [
"Use",
"adds",
"middleware",
"to",
"the",
"router"
] | b22257573feec3b6df344c9cb5feec59098c8133 | https://github.com/bahlo/goat/blob/b22257573feec3b6df344c9cb5feec59098c8133/middleware.go#L33-L38 |
150,611 | bahlo/goat | index.go | IndexHandler | func (r *Router) IndexHandler(w http.ResponseWriter, _ *http.Request, _ Params) {
WriteJSON(w, r.Index())
} | go | func (r *Router) IndexHandler(w http.ResponseWriter, _ *http.Request, _ Params) {
WriteJSON(w, r.Index())
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"IndexHandler",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"_",
"*",
"http",
".",
"Request",
",",
"_",
"Params",
")",
"{",
"WriteJSON",
"(",
"w",
",",
"r",
".",
"Index",
"(",
")",
")",
"\n",
"}"
] | // IndexHandler writes the index of all GET methods to the ResponseWriter | [
"IndexHandler",
"writes",
"the",
"index",
"of",
"all",
"GET",
"methods",
"to",
"the",
"ResponseWriter"
] | b22257573feec3b6df344c9cb5feec59098c8133 | https://github.com/bahlo/goat/blob/b22257573feec3b6df344c9cb5feec59098c8133/index.go#L9-L11 |
150,612 | bahlo/goat | index.go | Index | func (r *Router) Index() map[string]string {
index := r.index
// Recursion
for _, sr := range r.children {
si := sr.Index()
for k, v := range si {
index[k] = v
}
}
// Sort
sorted := make(map[string]string)
var keys []string
for k := range index {
keys = append(keys, k)
}
sort.Strings(keys)
for ... | go | func (r *Router) Index() map[string]string {
index := r.index
// Recursion
for _, sr := range r.children {
si := sr.Index()
for k, v := range si {
index[k] = v
}
}
// Sort
sorted := make(map[string]string)
var keys []string
for k := range index {
keys = append(keys, k)
}
sort.Strings(keys)
for ... | [
"func",
"(",
"r",
"*",
"Router",
")",
"Index",
"(",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"index",
":=",
"r",
".",
"index",
"\n\n",
"// Recursion",
"for",
"_",
",",
"sr",
":=",
"range",
"r",
".",
"children",
"{",
"si",
":=",
"sr",
".",
... | // Index returns a string map with the titles and urls of all GET routes | [
"Index",
"returns",
"a",
"string",
"map",
"with",
"the",
"titles",
"and",
"urls",
"of",
"all",
"GET",
"routes"
] | b22257573feec3b6df344c9cb5feec59098c8133 | https://github.com/bahlo/goat/blob/b22257573feec3b6df344c9cb5feec59098c8133/index.go#L14-L38 |
150,613 | bahlo/goat | params.go | paramsFromHTTPRouter | func paramsFromHTTPRouter(hrps httprouter.Params) Params {
var ps = Params{}
for _, p := range hrps {
ps[p.Key] = p.Value
}
return ps
} | go | func paramsFromHTTPRouter(hrps httprouter.Params) Params {
var ps = Params{}
for _, p := range hrps {
ps[p.Key] = p.Value
}
return ps
} | [
"func",
"paramsFromHTTPRouter",
"(",
"hrps",
"httprouter",
".",
"Params",
")",
"Params",
"{",
"var",
"ps",
"=",
"Params",
"{",
"}",
"\n\n",
"for",
"_",
",",
"p",
":=",
"range",
"hrps",
"{",
"ps",
"[",
"p",
".",
"Key",
"]",
"=",
"p",
".",
"Value",
... | // paramsFromHTTPRouter converts httprouter.Params to goat.Params | [
"paramsFromHTTPRouter",
"converts",
"httprouter",
".",
"Params",
"to",
"goat",
".",
"Params"
] | b22257573feec3b6df344c9cb5feec59098c8133 | https://github.com/bahlo/goat/blob/b22257573feec3b6df344c9cb5feec59098c8133/params.go#L9-L17 |
150,614 | bahlo/goat | goat.go | New | func New() *Router {
r := &Router{}
r.index = make(map[string]string)
r.prefix = "/"
r.router = httprouter.New()
r.router.NotFound = http.HandlerFunc(r.notFoundHandler)
return r
} | go | func New() *Router {
r := &Router{}
r.index = make(map[string]string)
r.prefix = "/"
r.router = httprouter.New()
r.router.NotFound = http.HandlerFunc(r.notFoundHandler)
return r
} | [
"func",
"New",
"(",
")",
"*",
"Router",
"{",
"r",
":=",
"&",
"Router",
"{",
"}",
"\n",
"r",
".",
"index",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"r",
".",
"prefix",
"=",
"\"",
"\"",
"\n",
"r",
".",
"router",
"=",
... | // New creates a new Router and returns it | [
"New",
"creates",
"a",
"new",
"Router",
"and",
"returns",
"it"
] | b22257573feec3b6df344c9cb5feec59098c8133 | https://github.com/bahlo/goat/blob/b22257573feec3b6df344c9cb5feec59098c8133/goat.go#L10-L18 |
150,615 | bahlo/goat | goat.go | Run | func (r *Router) Run(address string) error {
return http.ListenAndServe(address, r.chain())
} | go | func (r *Router) Run(address string) error {
return http.ListenAndServe(address, r.chain())
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"Run",
"(",
"address",
"string",
")",
"error",
"{",
"return",
"http",
".",
"ListenAndServe",
"(",
"address",
",",
"r",
".",
"chain",
"(",
")",
")",
"\n",
"}"
] | // Run starts the server | [
"Run",
"starts",
"the",
"server"
] | b22257573feec3b6df344c9cb5feec59098c8133 | https://github.com/bahlo/goat/blob/b22257573feec3b6df344c9cb5feec59098c8133/goat.go#L27-L29 |
150,616 | bahlo/goat | goat.go | RunTLS | func (r *Router) RunTLS(addr, certFile, keyFile string) error {
return http.ListenAndServeTLS(addr, certFile, keyFile, r.chain())
} | go | func (r *Router) RunTLS(addr, certFile, keyFile string) error {
return http.ListenAndServeTLS(addr, certFile, keyFile, r.chain())
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"RunTLS",
"(",
"addr",
",",
"certFile",
",",
"keyFile",
"string",
")",
"error",
"{",
"return",
"http",
".",
"ListenAndServeTLS",
"(",
"addr",
",",
"certFile",
",",
"keyFile",
",",
"r",
".",
"chain",
"(",
")",
")"... | // RunTLS starts the server, but expects HTTPS connections | [
"RunTLS",
"starts",
"the",
"server",
"but",
"expects",
"HTTPS",
"connections"
] | b22257573feec3b6df344c9cb5feec59098c8133 | https://github.com/bahlo/goat/blob/b22257573feec3b6df344c9cb5feec59098c8133/goat.go#L32-L34 |
150,617 | bahlo/goat | router.go | Subrouter | func (r *Router) Subrouter(path string) *Router {
sr := &Router{
index: make(map[string]string),
prefix: r.subPath(path),
router: r.router,
}
// Init relationships
r.children = append(r.children, sr)
sr.parent = r
return sr
} | go | func (r *Router) Subrouter(path string) *Router {
sr := &Router{
index: make(map[string]string),
prefix: r.subPath(path),
router: r.router,
}
// Init relationships
r.children = append(r.children, sr)
sr.parent = r
return sr
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"Subrouter",
"(",
"path",
"string",
")",
"*",
"Router",
"{",
"sr",
":=",
"&",
"Router",
"{",
"index",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
",",
"prefix",
":",
"r",
".",
"subPath",
"(",
... | // Subrouter creates and returns a subrouter | [
"Subrouter",
"creates",
"and",
"returns",
"a",
"subrouter"
] | b22257573feec3b6df344c9cb5feec59098c8133 | https://github.com/bahlo/goat/blob/b22257573feec3b6df344c9cb5feec59098c8133/router.go#L32-L44 |
150,618 | bahlo/goat | router.go | addRoute | func (r *Router) addRoute(m, p, t string, fn Handle) {
path := r.subPath(p)
// Add to index
if len(t) > 0 && m == "GET" {
// TODO: Display total path including host
r.index[t] = path
}
// Wrapper function to bypass the parameter problem
wf := func(w http.ResponseWriter, req *http.Request, p httprouter.Para... | go | func (r *Router) addRoute(m, p, t string, fn Handle) {
path := r.subPath(p)
// Add to index
if len(t) > 0 && m == "GET" {
// TODO: Display total path including host
r.index[t] = path
}
// Wrapper function to bypass the parameter problem
wf := func(w http.ResponseWriter, req *http.Request, p httprouter.Para... | [
"func",
"(",
"r",
"*",
"Router",
")",
"addRoute",
"(",
"m",
",",
"p",
",",
"t",
"string",
",",
"fn",
"Handle",
")",
"{",
"path",
":=",
"r",
".",
"subPath",
"(",
"p",
")",
"\n\n",
"// Add to index",
"if",
"len",
"(",
"t",
")",
">",
"0",
"&&",
... | // addRoute adds a route to the index and passes it over to the httprouter | [
"addRoute",
"adds",
"a",
"route",
"to",
"the",
"index",
"and",
"passes",
"it",
"over",
"to",
"the",
"httprouter"
] | b22257573feec3b6df344c9cb5feec59098c8133 | https://github.com/bahlo/goat/blob/b22257573feec3b6df344c9cb5feec59098c8133/router.go#L47-L63 |
150,619 | bahlo/goat | router.go | Get | func (r *Router) Get(path, title string, fn Handle) {
r.addRoute("GET", path, title, fn)
} | go | func (r *Router) Get(path, title string, fn Handle) {
r.addRoute("GET", path, title, fn)
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"Get",
"(",
"path",
",",
"title",
"string",
",",
"fn",
"Handle",
")",
"{",
"r",
".",
"addRoute",
"(",
"\"",
"\"",
",",
"path",
",",
"title",
",",
"fn",
")",
"\n",
"}"
] | // Get adds a GET route | [
"Get",
"adds",
"a",
"GET",
"route"
] | b22257573feec3b6df344c9cb5feec59098c8133 | https://github.com/bahlo/goat/blob/b22257573feec3b6df344c9cb5feec59098c8133/router.go#L66-L68 |
150,620 | bahlo/goat | router.go | subPath | func (r *Router) subPath(p string) string {
pre := r.prefix
if (pre == "/" || pre[:len(pre)-1] == "/") && p[:1] == "/" {
pre = pre[:len(pre)-1]
}
return pre + p
} | go | func (r *Router) subPath(p string) string {
pre := r.prefix
if (pre == "/" || pre[:len(pre)-1] == "/") && p[:1] == "/" {
pre = pre[:len(pre)-1]
}
return pre + p
} | [
"func",
"(",
"r",
"*",
"Router",
")",
"subPath",
"(",
"p",
"string",
")",
"string",
"{",
"pre",
":=",
"r",
".",
"prefix",
"\n\n",
"if",
"(",
"pre",
"==",
"\"",
"\"",
"||",
"pre",
"[",
":",
"len",
"(",
"pre",
")",
"-",
"1",
"]",
"==",
"\"",
... | // subPath returns the prefix of the router + the given path and eliminates
// duplicate slashes | [
"subPath",
"returns",
"the",
"prefix",
"of",
"the",
"router",
"+",
"the",
"given",
"path",
"and",
"eliminates",
"duplicate",
"slashes"
] | b22257573feec3b6df344c9cb5feec59098c8133 | https://github.com/bahlo/goat/blob/b22257573feec3b6df344c9cb5feec59098c8133/router.go#L97-L105 |
150,621 | bahlo/goat | json.go | WriteError | func WriteError(w http.ResponseWriter, code int, err string) {
w.WriteHeader(code)
WriteJSON(w, map[string]string{
"error": err,
})
} | go | func WriteError(w http.ResponseWriter, code int, err string) {
w.WriteHeader(code)
WriteJSON(w, map[string]string{
"error": err,
})
} | [
"func",
"WriteError",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"code",
"int",
",",
"err",
"string",
")",
"{",
"w",
".",
"WriteHeader",
"(",
"code",
")",
"\n\n",
"WriteJSON",
"(",
"w",
",",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
... | // WriteError writes a string as JSON encoded error | [
"WriteError",
"writes",
"a",
"string",
"as",
"JSON",
"encoded",
"error"
] | b22257573feec3b6df344c9cb5feec59098c8133 | https://github.com/bahlo/goat/blob/b22257573feec3b6df344c9cb5feec59098c8133/json.go#L9-L15 |
150,622 | bahlo/goat | json.go | WriteJSON | func WriteJSON(w http.ResponseWriter, v interface{}) error {
b, err := json.MarshalIndent(v, "", " ")
if err != nil {
return err
}
w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.Write(b)
return nil
} | go | func WriteJSON(w http.ResponseWriter, v interface{}) error {
b, err := json.MarshalIndent(v, "", " ")
if err != nil {
return err
}
w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.Write(b)
return nil
} | [
"func",
"WriteJSON",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"b",
",",
"err",
":=",
"json",
".",
"MarshalIndent",
"(",
"v",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil"... | // WriteJSON writes the given interface as JSON or returns an error | [
"WriteJSON",
"writes",
"the",
"given",
"interface",
"as",
"JSON",
"or",
"returns",
"an",
"error"
] | b22257573feec3b6df344c9cb5feec59098c8133 | https://github.com/bahlo/goat/blob/b22257573feec3b6df344c9cb5feec59098c8133/json.go#L18-L27 |
150,623 | bahlo/goat | json.go | WriteJSONWithStatus | func WriteJSONWithStatus(w http.ResponseWriter, code int, v interface{}) error {
w.WriteHeader(code)
return WriteJSON(w, v)
} | go | func WriteJSONWithStatus(w http.ResponseWriter, code int, v interface{}) error {
w.WriteHeader(code)
return WriteJSON(w, v)
} | [
"func",
"WriteJSONWithStatus",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"code",
"int",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"w",
".",
"WriteHeader",
"(",
"code",
")",
"\n\n",
"return",
"WriteJSON",
"(",
"w",
",",
"v",
")",
"\n",
"... | // WriteJSONWithStatus writes the given statuscode into the header and the
// given interface as JSON or returns an error | [
"WriteJSONWithStatus",
"writes",
"the",
"given",
"statuscode",
"into",
"the",
"header",
"and",
"the",
"given",
"interface",
"as",
"JSON",
"or",
"returns",
"an",
"error"
] | b22257573feec3b6df344c9cb5feec59098c8133 | https://github.com/bahlo/goat/blob/b22257573feec3b6df344c9cb5feec59098c8133/json.go#L31-L35 |
150,624 | fabric8-services/fabric8-auth | authorization/role/repository/role_scope.go | Create | func (m *GormRoleScopeRepository) Create(ctx context.Context, roleScope *RoleScope) error {
defer goa.MeasureSince([]string{"goa", "db", "role_scope", "create"}, time.Now())
err := m.db.Create(roleScope).Error
if err != nil {
log.Error(ctx, map[string]interface{}{
"resource_type_scope_id": roleScope.ResourceTyp... | go | func (m *GormRoleScopeRepository) Create(ctx context.Context, roleScope *RoleScope) error {
defer goa.MeasureSince([]string{"goa", "db", "role_scope", "create"}, time.Now())
err := m.db.Create(roleScope).Error
if err != nil {
log.Error(ctx, map[string]interface{}{
"resource_type_scope_id": roleScope.ResourceTyp... | [
"func",
"(",
"m",
"*",
"GormRoleScopeRepository",
")",
"Create",
"(",
"ctx",
"context",
".",
"Context",
",",
"roleScope",
"*",
"RoleScope",
")",
"error",
"{",
"defer",
"goa",
".",
"MeasureSince",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"... | // Create creates a new RoleScope | [
"Create",
"creates",
"a",
"new",
"RoleScope"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/authorization/role/repository/role_scope.go#L70-L86 |
150,625 | fabric8-services/fabric8-auth | authorization/role/repository/role_scope.go | LoadByScope | func (m *GormRoleScopeRepository) LoadByScope(ctx context.Context, ID uuid.UUID) ([]RoleScope, error) {
return m.Query(RoleScopeFilterByScope(ID))
} | go | func (m *GormRoleScopeRepository) LoadByScope(ctx context.Context, ID uuid.UUID) ([]RoleScope, error) {
return m.Query(RoleScopeFilterByScope(ID))
} | [
"func",
"(",
"m",
"*",
"GormRoleScopeRepository",
")",
"LoadByScope",
"(",
"ctx",
"context",
".",
"Context",
",",
"ID",
"uuid",
".",
"UUID",
")",
"(",
"[",
"]",
"RoleScope",
",",
"error",
")",
"{",
"return",
"m",
".",
"Query",
"(",
"RoleScopeFilterByScop... | //LoadByScope loads a 'role & scope assocation' by the scope ID | [
"LoadByScope",
"loads",
"a",
"role",
"&",
"scope",
"assocation",
"by",
"the",
"scope",
"ID"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/authorization/role/repository/role_scope.go#L89-L91 |
150,626 | fabric8-services/fabric8-auth | authorization/role/repository/role_scope.go | LoadByRole | func (m *GormRoleScopeRepository) LoadByRole(ctx context.Context, ID uuid.UUID) ([]RoleScope, error) {
return m.Query(RoleScopeFilterByRole(ID))
} | go | func (m *GormRoleScopeRepository) LoadByRole(ctx context.Context, ID uuid.UUID) ([]RoleScope, error) {
return m.Query(RoleScopeFilterByRole(ID))
} | [
"func",
"(",
"m",
"*",
"GormRoleScopeRepository",
")",
"LoadByRole",
"(",
"ctx",
"context",
".",
"Context",
",",
"ID",
"uuid",
".",
"UUID",
")",
"(",
"[",
"]",
"RoleScope",
",",
"error",
")",
"{",
"return",
"m",
".",
"Query",
"(",
"RoleScopeFilterByRole"... | //LoadByRole loads a 'role & scope assocation' by the role ID | [
"LoadByRole",
"loads",
"a",
"role",
"&",
"scope",
"assocation",
"by",
"the",
"role",
"ID"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/authorization/role/repository/role_scope.go#L94-L96 |
150,627 | fabric8-services/fabric8-auth | authorization/role/repository/role_scope.go | RoleScopeFilterByScope | func RoleScopeFilterByScope(id uuid.UUID) func(db *gorm.DB) *gorm.DB {
return func(db *gorm.DB) *gorm.DB {
return db.Where("scope_id = ?", id)
}
} | go | func RoleScopeFilterByScope(id uuid.UUID) func(db *gorm.DB) *gorm.DB {
return func(db *gorm.DB) *gorm.DB {
return db.Where("scope_id = ?", id)
}
} | [
"func",
"RoleScopeFilterByScope",
"(",
"id",
"uuid",
".",
"UUID",
")",
"func",
"(",
"db",
"*",
"gorm",
".",
"DB",
")",
"*",
"gorm",
".",
"DB",
"{",
"return",
"func",
"(",
"db",
"*",
"gorm",
".",
"DB",
")",
"*",
"gorm",
".",
"DB",
"{",
"return",
... | // RoleScopeFilterByScope is a gorm filter by 'scope_id' | [
"RoleScopeFilterByScope",
"is",
"a",
"gorm",
"filter",
"by",
"scope_id"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/authorization/role/repository/role_scope.go#L114-L118 |
150,628 | fabric8-services/fabric8-auth | authorization/role/repository/role_scope.go | RoleScopeFilterByRole | func RoleScopeFilterByRole(id uuid.UUID) func(db *gorm.DB) *gorm.DB {
return func(db *gorm.DB) *gorm.DB {
return db.Where("role_id = ?", id)
}
} | go | func RoleScopeFilterByRole(id uuid.UUID) func(db *gorm.DB) *gorm.DB {
return func(db *gorm.DB) *gorm.DB {
return db.Where("role_id = ?", id)
}
} | [
"func",
"RoleScopeFilterByRole",
"(",
"id",
"uuid",
".",
"UUID",
")",
"func",
"(",
"db",
"*",
"gorm",
".",
"DB",
")",
"*",
"gorm",
".",
"DB",
"{",
"return",
"func",
"(",
"db",
"*",
"gorm",
".",
"DB",
")",
"*",
"gorm",
".",
"DB",
"{",
"return",
... | // RoleScopeFilterByRole is a gorm filter by 'role' | [
"RoleScopeFilterByRole",
"is",
"a",
"gorm",
"filter",
"by",
"role"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/authorization/role/repository/role_scope.go#L121-L125 |
150,629 | fabric8-services/fabric8-auth | cluster/service/cluster.go | NewClusterService | func NewClusterService(context servicecontext.ServiceContext, config clusterServiceConfig) service.ClusterService {
return &clusterService{
BaseService: base.NewBaseService(context),
config: config,
}
} | go | func NewClusterService(context servicecontext.ServiceContext, config clusterServiceConfig) service.ClusterService {
return &clusterService{
BaseService: base.NewBaseService(context),
config: config,
}
} | [
"func",
"NewClusterService",
"(",
"context",
"servicecontext",
".",
"ServiceContext",
",",
"config",
"clusterServiceConfig",
")",
"service",
".",
"ClusterService",
"{",
"return",
"&",
"clusterService",
"{",
"BaseService",
":",
"base",
".",
"NewBaseService",
"(",
"co... | // NewClusterService creates a new cluster service | [
"NewClusterService",
"creates",
"a",
"new",
"cluster",
"service"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/cluster/service/cluster.go#L44-L49 |
150,630 | fabric8-services/fabric8-auth | cluster/service/cluster.go | ClusterByURL | func (s *clusterService) ClusterByURL(ctx context.Context, url string, options ...rest.HTTPClientOption) (*cluster.Cluster, error) {
_, err := Start(ctx, s.Factories().ClusterCacheFactory(), options...)
if err != nil {
return nil, err
}
clusterCache.RLock()
defer clusterCache.RUnlock()
return ClusterByURL(clus... | go | func (s *clusterService) ClusterByURL(ctx context.Context, url string, options ...rest.HTTPClientOption) (*cluster.Cluster, error) {
_, err := Start(ctx, s.Factories().ClusterCacheFactory(), options...)
if err != nil {
return nil, err
}
clusterCache.RLock()
defer clusterCache.RUnlock()
return ClusterByURL(clus... | [
"func",
"(",
"s",
"*",
"clusterService",
")",
"ClusterByURL",
"(",
"ctx",
"context",
".",
"Context",
",",
"url",
"string",
",",
"options",
"...",
"rest",
".",
"HTTPClientOption",
")",
"(",
"*",
"cluster",
".",
"Cluster",
",",
"error",
")",
"{",
"_",
",... | // ClusterByURL returns the cached cluster for the given cluster API URL | [
"ClusterByURL",
"returns",
"the",
"cached",
"cluster",
"for",
"the",
"given",
"cluster",
"API",
"URL"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/cluster/service/cluster.go#L64-L73 |
150,631 | fabric8-services/fabric8-auth | cluster/service/cluster.go | LinkIdentityToCluster | func (s *clusterService) LinkIdentityToCluster(ctx context.Context, identityID uuid.UUID, clusterURL string, options ...rest.HTTPClientOption) error {
signer := newJWTSASigner(ctx, s.config, options...)
remoteClusterService, err := signer.createSignedClient()
if err != nil {
return errors.Wrapf(err, "failed to cre... | go | func (s *clusterService) LinkIdentityToCluster(ctx context.Context, identityID uuid.UUID, clusterURL string, options ...rest.HTTPClientOption) error {
signer := newJWTSASigner(ctx, s.config, options...)
remoteClusterService, err := signer.createSignedClient()
if err != nil {
return errors.Wrapf(err, "failed to cre... | [
"func",
"(",
"s",
"*",
"clusterService",
")",
"LinkIdentityToCluster",
"(",
"ctx",
"context",
".",
"Context",
",",
"identityID",
"uuid",
".",
"UUID",
",",
"clusterURL",
"string",
",",
"options",
"...",
"rest",
".",
"HTTPClientOption",
")",
"error",
"{",
"sig... | // LinkIdentityToCluster links Identity To Cluster using Cluster URL | [
"LinkIdentityToCluster",
"links",
"Identity",
"To",
"Cluster",
"using",
"Cluster",
"URL"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/cluster/service/cluster.go#L89-L115 |
150,632 | fabric8-services/fabric8-auth | cluster/service/cluster.go | Start | func Start(ctx context.Context, factory service.ClusterCacheFactory, options ...rest.HTTPClientOption) (bool, error) {
if atomic.LoadUint32(&started) == 0 {
// Has not started yet.
startLock.Lock()
defer startLock.Unlock()
if started == 0 {
clusterCache = factory.NewClusterCache(ctx, options...)
err := c... | go | func Start(ctx context.Context, factory service.ClusterCacheFactory, options ...rest.HTTPClientOption) (bool, error) {
if atomic.LoadUint32(&started) == 0 {
// Has not started yet.
startLock.Lock()
defer startLock.Unlock()
if started == 0 {
clusterCache = factory.NewClusterCache(ctx, options...)
err := c... | [
"func",
"Start",
"(",
"ctx",
"context",
".",
"Context",
",",
"factory",
"service",
".",
"ClusterCacheFactory",
",",
"options",
"...",
"rest",
".",
"HTTPClientOption",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"atomic",
".",
"LoadUint32",
"(",
"&",
... | // Start initializes the default Cluster cache if it's not initialized already
// Cache initialization loads the list of clusters from the cluster management service and starts regular cache refresher | [
"Start",
"initializes",
"the",
"default",
"Cluster",
"cache",
"if",
"it",
"s",
"not",
"initialized",
"already",
"Cache",
"initialization",
"loads",
"the",
"list",
"of",
"clusters",
"from",
"the",
"cluster",
"management",
"service",
"and",
"starts",
"regular",
"c... | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/cluster/service/cluster.go#L148-L166 |
150,633 | fabric8-services/fabric8-auth | cluster/service/cluster.go | Clusters | func Clusters(clusters map[string]cluster.Cluster) []cluster.Cluster {
cs := make([]cluster.Cluster, 0, len(clusters))
for _, cls := range clusters {
cs = append(cs, cls)
}
return cs
} | go | func Clusters(clusters map[string]cluster.Cluster) []cluster.Cluster {
cs := make([]cluster.Cluster, 0, len(clusters))
for _, cls := range clusters {
cs = append(cs, cls)
}
return cs
} | [
"func",
"Clusters",
"(",
"clusters",
"map",
"[",
"string",
"]",
"cluster",
".",
"Cluster",
")",
"[",
"]",
"cluster",
".",
"Cluster",
"{",
"cs",
":=",
"make",
"(",
"[",
"]",
"cluster",
".",
"Cluster",
",",
"0",
",",
"len",
"(",
"clusters",
")",
")",... | // Clusters converts the given cluster map to an array slice | [
"Clusters",
"converts",
"the",
"given",
"cluster",
"map",
"to",
"an",
"array",
"slice"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/cluster/service/cluster.go#L169-L175 |
150,634 | fabric8-services/fabric8-auth | cluster/service/cluster.go | createSignedClient | func (c jwtSASigner) createSignedClient() (*clusterclient.Client, error) {
cln, err := c.createClient(c.ctx)
if err != nil {
return nil, err
}
m, err := manager.DefaultManager(c.config)
if err != nil {
return nil, err
}
signer := m.AuthServiceAccountSigner()
cln.SetJWTSigner(signer)
return cln, nil
} | go | func (c jwtSASigner) createSignedClient() (*clusterclient.Client, error) {
cln, err := c.createClient(c.ctx)
if err != nil {
return nil, err
}
m, err := manager.DefaultManager(c.config)
if err != nil {
return nil, err
}
signer := m.AuthServiceAccountSigner()
cln.SetJWTSigner(signer)
return cln, nil
} | [
"func",
"(",
"c",
"jwtSASigner",
")",
"createSignedClient",
"(",
")",
"(",
"*",
"clusterclient",
".",
"Client",
",",
"error",
")",
"{",
"cln",
",",
"err",
":=",
"c",
".",
"createClient",
"(",
"c",
".",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{... | // CreateSignedClient creates a client with a JWT signer which uses the Auth Service Account token | [
"CreateSignedClient",
"creates",
"a",
"client",
"with",
"a",
"JWT",
"signer",
"which",
"uses",
"the",
"Auth",
"Service",
"Account",
"token"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/cluster/service/cluster.go#L202-L214 |
150,635 | fabric8-services/fabric8-auth | configuration/configuration.go | DefaultConfigurationError | func (c *ConfigurationData) DefaultConfigurationError() error {
// Lock for reading because config file watcher can update config errors
c.mux.RLock()
defer c.mux.RUnlock()
return c.defaultConfigurationError
} | go | func (c *ConfigurationData) DefaultConfigurationError() error {
// Lock for reading because config file watcher can update config errors
c.mux.RLock()
defer c.mux.RUnlock()
return c.defaultConfigurationError
} | [
"func",
"(",
"c",
"*",
"ConfigurationData",
")",
"DefaultConfigurationError",
"(",
")",
"error",
"{",
"// Lock for reading because config file watcher can update config errors",
"c",
".",
"mux",
".",
"RLock",
"(",
")",
"\n",
"defer",
"c",
".",
"mux",
".",
"RUnlock",... | // DefaultConfigurationError returns an error if the default values is used
// for sensitive configuration like service account secrets or private keys.
// Error contains all the details.
// Returns nil if the default configuration is not used. | [
"DefaultConfigurationError",
"returns",
"an",
"error",
"if",
"the",
"default",
"values",
"is",
"used",
"for",
"sensitive",
"configuration",
"like",
"service",
"account",
"secrets",
"or",
"private",
"keys",
".",
"Error",
"contains",
"all",
"the",
"details",
".",
... | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/configuration/configuration.go#L480-L486 |
150,636 | fabric8-services/fabric8-auth | configuration/configuration.go | GetAuthServiceURL | func (c *ConfigurationData) GetAuthServiceURL() string {
if c.v.IsSet(varAuthURL) {
return c.v.GetString(varAuthURL)
}
switch c.GetEnvironment() {
case prodEnvironment:
return "https://auth.openshift.io"
case prodPreviewEnvironment:
return "https://auth.prod-preview.openshift.io"
default:
return "http://l... | go | func (c *ConfigurationData) GetAuthServiceURL() string {
if c.v.IsSet(varAuthURL) {
return c.v.GetString(varAuthURL)
}
switch c.GetEnvironment() {
case prodEnvironment:
return "https://auth.openshift.io"
case prodPreviewEnvironment:
return "https://auth.prod-preview.openshift.io"
default:
return "http://l... | [
"func",
"(",
"c",
"*",
"ConfigurationData",
")",
"GetAuthServiceURL",
"(",
")",
"string",
"{",
"if",
"c",
".",
"v",
".",
"IsSet",
"(",
"varAuthURL",
")",
"{",
"return",
"c",
".",
"v",
".",
"GetString",
"(",
"varAuthURL",
")",
"\n",
"}",
"\n",
"switch... | // GetAuthServiceUrl returns Auth Service URL | [
"GetAuthServiceUrl",
"returns",
"Auth",
"Service",
"URL"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/configuration/configuration.go#L489-L501 |
150,637 | fabric8-services/fabric8-auth | configuration/configuration.go | GetServiceAccountPrivateKey | func (c *ConfigurationData) GetServiceAccountPrivateKey() ([]byte, string) {
return []byte(c.v.GetString(varServiceAccountPrivateKey)), c.v.GetString(varServiceAccountPrivateKeyID)
} | go | func (c *ConfigurationData) GetServiceAccountPrivateKey() ([]byte, string) {
return []byte(c.v.GetString(varServiceAccountPrivateKey)), c.v.GetString(varServiceAccountPrivateKeyID)
} | [
"func",
"(",
"c",
"*",
"ConfigurationData",
")",
"GetServiceAccountPrivateKey",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"string",
")",
"{",
"return",
"[",
"]",
"byte",
"(",
"c",
".",
"v",
".",
"GetString",
"(",
"varServiceAccountPrivateKey",
")",
")",
",",... | // GetServiceAccountPrivateKey returns the service account private key and its ID
// that is used to sign service account authentication tokens. | [
"GetServiceAccountPrivateKey",
"returns",
"the",
"service",
"account",
"private",
"key",
"and",
"its",
"ID",
"that",
"is",
"used",
"to",
"sign",
"service",
"account",
"authentication",
"tokens",
"."
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/configuration/configuration.go#L838-L840 |
150,638 | fabric8-services/fabric8-auth | configuration/configuration.go | GetUserAccountPrivateKey | func (c *ConfigurationData) GetUserAccountPrivateKey() ([]byte, string) {
return []byte(c.v.GetString(varUserAccountPrivateKey)), c.v.GetString(varUserAccountPrivateKeyID)
} | go | func (c *ConfigurationData) GetUserAccountPrivateKey() ([]byte, string) {
return []byte(c.v.GetString(varUserAccountPrivateKey)), c.v.GetString(varUserAccountPrivateKeyID)
} | [
"func",
"(",
"c",
"*",
"ConfigurationData",
")",
"GetUserAccountPrivateKey",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"string",
")",
"{",
"return",
"[",
"]",
"byte",
"(",
"c",
".",
"v",
".",
"GetString",
"(",
"varUserAccountPrivateKey",
")",
")",
",",
"c"... | // GetUserAccountPrivateKey returns the user account private key and its ID
// that is used to sign user access and refresh tokens. | [
"GetUserAccountPrivateKey",
"returns",
"the",
"user",
"account",
"private",
"key",
"and",
"its",
"ID",
"that",
"is",
"used",
"to",
"sign",
"user",
"access",
"and",
"refresh",
"tokens",
"."
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/configuration/configuration.go#L850-L852 |
150,639 | fabric8-services/fabric8-auth | configuration/configuration.go | GetDevModePublicKey | func (c *ConfigurationData) GetDevModePublicKey() (bool, []byte, string) {
if c.IsPostgresDeveloperModeEnabled() {
return true, []byte(devModePublicKey), devModePublicKeyID
}
return false, nil, ""
} | go | func (c *ConfigurationData) GetDevModePublicKey() (bool, []byte, string) {
if c.IsPostgresDeveloperModeEnabled() {
return true, []byte(devModePublicKey), devModePublicKeyID
}
return false, nil, ""
} | [
"func",
"(",
"c",
"*",
"ConfigurationData",
")",
"GetDevModePublicKey",
"(",
")",
"(",
"bool",
",",
"[",
"]",
"byte",
",",
"string",
")",
"{",
"if",
"c",
".",
"IsPostgresDeveloperModeEnabled",
"(",
")",
"{",
"return",
"true",
",",
"[",
"]",
"byte",
"("... | // GetDevModePublicKey returns additional public key and its ID which should be used by the Auth service in Dev Mode
// For example a public key from Keycloak
// Returns false if in in Dev Mode | [
"GetDevModePublicKey",
"returns",
"additional",
"public",
"key",
"and",
"its",
"ID",
"which",
"should",
"be",
"used",
"by",
"the",
"Auth",
"service",
"in",
"Dev",
"Mode",
"For",
"example",
"a",
"public",
"key",
"from",
"Keycloak",
"Returns",
"false",
"if",
"... | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/configuration/configuration.go#L872-L877 |
150,640 | fabric8-services/fabric8-auth | configuration/configuration.go | GetWITURL | func (c *ConfigurationData) GetWITURL() (string, error) {
if c.v.IsSet(varWITURL) {
return c.v.GetString(varWITURL), nil
}
if c.IsPostgresDeveloperModeEnabled() {
return devModeWITURL, nil
}
return c.calculateWITURL()
} | go | func (c *ConfigurationData) GetWITURL() (string, error) {
if c.v.IsSet(varWITURL) {
return c.v.GetString(varWITURL), nil
}
if c.IsPostgresDeveloperModeEnabled() {
return devModeWITURL, nil
}
return c.calculateWITURL()
} | [
"func",
"(",
"c",
"*",
"ConfigurationData",
")",
"GetWITURL",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"c",
".",
"v",
".",
"IsSet",
"(",
"varWITURL",
")",
"{",
"return",
"c",
".",
"v",
".",
"GetString",
"(",
"varWITURL",
")",
",",
"... | // GetWITURL returns the WIT URL where WIT is running
// If AUTH_WIT_URL is not set and Auth in not in Dev Mode then we calculate the URL from the Auth Service URL domain | [
"GetWITURL",
"returns",
"the",
"WIT",
"URL",
"where",
"WIT",
"is",
"running",
"If",
"AUTH_WIT_URL",
"is",
"not",
"set",
"and",
"Auth",
"in",
"not",
"in",
"Dev",
"Mode",
"then",
"we",
"calculate",
"the",
"URL",
"from",
"the",
"Auth",
"Service",
"URL",
"do... | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/configuration/configuration.go#L980-L988 |
150,641 | fabric8-services/fabric8-auth | configuration/configuration.go | GetTenantServiceURL | func (c *ConfigurationData) GetTenantServiceURL() string {
if c.IsPostgresDeveloperModeEnabled() {
return devModeTenantServiceURL
}
return c.v.GetString(varTenantServiceURL)
} | go | func (c *ConfigurationData) GetTenantServiceURL() string {
if c.IsPostgresDeveloperModeEnabled() {
return devModeTenantServiceURL
}
return c.v.GetString(varTenantServiceURL)
} | [
"func",
"(",
"c",
"*",
"ConfigurationData",
")",
"GetTenantServiceURL",
"(",
")",
"string",
"{",
"if",
"c",
".",
"IsPostgresDeveloperModeEnabled",
"(",
")",
"{",
"return",
"devModeTenantServiceURL",
"\n",
"}",
"\n",
"return",
"c",
".",
"v",
".",
"GetString",
... | // GetTenantServiceURL returns the URL for the Tenant service used by login to initialize OSO tenant space | [
"GetTenantServiceURL",
"returns",
"the",
"URL",
"for",
"the",
"Tenant",
"service",
"used",
"by",
"login",
"to",
"initialize",
"OSO",
"tenant",
"space"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/configuration/configuration.go#L991-L996 |
150,642 | fabric8-services/fabric8-auth | configuration/configuration.go | GetCheServiceURL | func (c *ConfigurationData) GetCheServiceURL() string {
if c.IsPostgresDeveloperModeEnabled() {
return devModeCheServiceURL
}
return c.v.GetString(varCheServiceURL)
} | go | func (c *ConfigurationData) GetCheServiceURL() string {
if c.IsPostgresDeveloperModeEnabled() {
return devModeCheServiceURL
}
return c.v.GetString(varCheServiceURL)
} | [
"func",
"(",
"c",
"*",
"ConfigurationData",
")",
"GetCheServiceURL",
"(",
")",
"string",
"{",
"if",
"c",
".",
"IsPostgresDeveloperModeEnabled",
"(",
")",
"{",
"return",
"devModeCheServiceURL",
"\n",
"}",
"\n",
"return",
"c",
".",
"v",
".",
"GetString",
"(",
... | // GetCheServiceURL returns the URL for the Che service | [
"GetCheServiceURL",
"returns",
"the",
"URL",
"for",
"the",
"Che",
"service"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/configuration/configuration.go#L999-L1004 |
150,643 | fabric8-services/fabric8-auth | configuration/configuration.go | GetUserDeactivationInactivityNotificationPeriodDays | func (c *ConfigurationData) GetUserDeactivationInactivityNotificationPeriodDays() time.Duration {
return time.Duration(c.v.GetInt(varUserDeactivationInactivityNotificationPeriodDays)) * 24 * time.Hour
} | go | func (c *ConfigurationData) GetUserDeactivationInactivityNotificationPeriodDays() time.Duration {
return time.Duration(c.v.GetInt(varUserDeactivationInactivityNotificationPeriodDays)) * 24 * time.Hour
} | [
"func",
"(",
"c",
"*",
"ConfigurationData",
")",
"GetUserDeactivationInactivityNotificationPeriodDays",
"(",
")",
"time",
".",
"Duration",
"{",
"return",
"time",
".",
"Duration",
"(",
"c",
".",
"v",
".",
"GetInt",
"(",
"varUserDeactivationInactivityNotificationPeriodD... | // GetUserDeactivationInactivityNotificationPeriodDays returns the number of days of inactivity before notifying the user of the imminent account deactivation | [
"GetUserDeactivationInactivityNotificationPeriodDays",
"returns",
"the",
"number",
"of",
"days",
"of",
"inactivity",
"before",
"notifying",
"the",
"user",
"of",
"the",
"imminent",
"account",
"deactivation"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/configuration/configuration.go#L1117-L1119 |
150,644 | fabric8-services/fabric8-auth | configuration/configuration.go | GetUserDeactivationInactivityPeriodDays | func (c *ConfigurationData) GetUserDeactivationInactivityPeriodDays() time.Duration {
return time.Duration(c.v.GetInt(varUserDeactivationInactivityPeriodDays)) * 24 * time.Hour
} | go | func (c *ConfigurationData) GetUserDeactivationInactivityPeriodDays() time.Duration {
return time.Duration(c.v.GetInt(varUserDeactivationInactivityPeriodDays)) * 24 * time.Hour
} | [
"func",
"(",
"c",
"*",
"ConfigurationData",
")",
"GetUserDeactivationInactivityPeriodDays",
"(",
")",
"time",
".",
"Duration",
"{",
"return",
"time",
".",
"Duration",
"(",
"c",
".",
"v",
".",
"GetInt",
"(",
"varUserDeactivationInactivityPeriodDays",
")",
")",
"*... | // GetUserDeactivationInactivityPeriodDays returns the number of days of inactivity before a user account can be deactivated | [
"GetUserDeactivationInactivityPeriodDays",
"returns",
"the",
"number",
"of",
"days",
"of",
"inactivity",
"before",
"a",
"user",
"account",
"can",
"be",
"deactivated"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/configuration/configuration.go#L1122-L1124 |
150,645 | fabric8-services/fabric8-auth | configuration/configuration.go | GetUserDeactivationWorkerIntervalSeconds | func (c *ConfigurationData) GetUserDeactivationWorkerIntervalSeconds() time.Duration {
return time.Duration(c.v.GetInt(varUserDeactivationWorkerIntervalSeconds)) * time.Second
} | go | func (c *ConfigurationData) GetUserDeactivationWorkerIntervalSeconds() time.Duration {
return time.Duration(c.v.GetInt(varUserDeactivationWorkerIntervalSeconds)) * time.Second
} | [
"func",
"(",
"c",
"*",
"ConfigurationData",
")",
"GetUserDeactivationWorkerIntervalSeconds",
"(",
")",
"time",
".",
"Duration",
"{",
"return",
"time",
".",
"Duration",
"(",
"c",
".",
"v",
".",
"GetInt",
"(",
"varUserDeactivationWorkerIntervalSeconds",
")",
")",
... | // GetUserDeactivationWorkerIntervalSeconds returns the interval between 2 cycles of the user deactivation worker. | [
"GetUserDeactivationWorkerIntervalSeconds",
"returns",
"the",
"interval",
"between",
"2",
"cycles",
"of",
"the",
"user",
"deactivation",
"worker",
"."
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/configuration/configuration.go#L1134-L1136 |
150,646 | fabric8-services/fabric8-auth | configuration/configuration.go | GetUserDeactivationNotificationWorkerIntervalSeconds | func (c *ConfigurationData) GetUserDeactivationNotificationWorkerIntervalSeconds() time.Duration {
return time.Duration(c.v.GetInt(varUserDeactivationNotificationWorkerIntervalSeconds)) * time.Second
} | go | func (c *ConfigurationData) GetUserDeactivationNotificationWorkerIntervalSeconds() time.Duration {
return time.Duration(c.v.GetInt(varUserDeactivationNotificationWorkerIntervalSeconds)) * time.Second
} | [
"func",
"(",
"c",
"*",
"ConfigurationData",
")",
"GetUserDeactivationNotificationWorkerIntervalSeconds",
"(",
")",
"time",
".",
"Duration",
"{",
"return",
"time",
".",
"Duration",
"(",
"c",
".",
"v",
".",
"GetInt",
"(",
"varUserDeactivationNotificationWorkerIntervalSe... | // GetUserDeactivationNotificationWorkerIntervalSeconds returns the interval between 2 cycles of the user deactivation notification worker. | [
"GetUserDeactivationNotificationWorkerIntervalSeconds",
"returns",
"the",
"interval",
"between",
"2",
"cycles",
"of",
"the",
"user",
"deactivation",
"notification",
"worker",
"."
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/configuration/configuration.go#L1139-L1141 |
150,647 | fabric8-services/fabric8-auth | authentication/account/name.go | GenerateFullName | func GenerateFullName(nameComponents ...*string) string {
fullName := ""
for _, n := range nameComponents {
if n != nil {
if len(fullName) == 0 {
fullName = fmt.Sprintf("%s", *n)
} else {
fullName = fmt.Sprintf("%s %s", fullName, *n)
}
}
}
return fullName
} | go | func GenerateFullName(nameComponents ...*string) string {
fullName := ""
for _, n := range nameComponents {
if n != nil {
if len(fullName) == 0 {
fullName = fmt.Sprintf("%s", *n)
} else {
fullName = fmt.Sprintf("%s %s", fullName, *n)
}
}
}
return fullName
} | [
"func",
"GenerateFullName",
"(",
"nameComponents",
"...",
"*",
"string",
")",
"string",
"{",
"fullName",
":=",
"\"",
"\"",
"\n",
"for",
"_",
",",
"n",
":=",
"range",
"nameComponents",
"{",
"if",
"n",
"!=",
"nil",
"{",
"if",
"len",
"(",
"fullName",
")",... | // GenerateFullName generates the full name out of first name, middle name and last name. | [
"GenerateFullName",
"generates",
"the",
"full",
"name",
"out",
"of",
"first",
"name",
"middle",
"name",
"and",
"last",
"name",
"."
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/authentication/account/name.go#L9-L21 |
150,648 | fabric8-services/fabric8-auth | authentication/account/name.go | SplitFullName | func SplitFullName(fullName string) (string, string) {
nameComponents := strings.Split(fullName, " ")
firstName := nameComponents[0]
lastName := ""
if len(nameComponents) > 1 {
lastName = strings.Join(nameComponents[1:], " ")
}
return firstName, lastName
} | go | func SplitFullName(fullName string) (string, string) {
nameComponents := strings.Split(fullName, " ")
firstName := nameComponents[0]
lastName := ""
if len(nameComponents) > 1 {
lastName = strings.Join(nameComponents[1:], " ")
}
return firstName, lastName
} | [
"func",
"SplitFullName",
"(",
"fullName",
"string",
")",
"(",
"string",
",",
"string",
")",
"{",
"nameComponents",
":=",
"strings",
".",
"Split",
"(",
"fullName",
",",
"\"",
"\"",
")",
"\n",
"firstName",
":=",
"nameComponents",
"[",
"0",
"]",
"\n",
"last... | // SplitFullName splits a name and returns the firstname, lastname | [
"SplitFullName",
"splits",
"a",
"name",
"and",
"returns",
"the",
"firstname",
"lastname"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/authentication/account/name.go#L24-L32 |
150,649 | fabric8-services/fabric8-auth | authorization/token/token.go | IsValidTokenType | func IsValidTokenType(tokenType string) bool {
return tokenType == TOKEN_TYPE_RPT ||
tokenType == TOKEN_TYPE_ACCESS ||
tokenType == TOKEN_TYPE_REFRESH
} | go | func IsValidTokenType(tokenType string) bool {
return tokenType == TOKEN_TYPE_RPT ||
tokenType == TOKEN_TYPE_ACCESS ||
tokenType == TOKEN_TYPE_REFRESH
} | [
"func",
"IsValidTokenType",
"(",
"tokenType",
"string",
")",
"bool",
"{",
"return",
"tokenType",
"==",
"TOKEN_TYPE_RPT",
"||",
"tokenType",
"==",
"TOKEN_TYPE_ACCESS",
"||",
"tokenType",
"==",
"TOKEN_TYPE_REFRESH",
"\n",
"}"
] | // IsValidTokenType returns true if the specified token type is one of the known token types, otherwise returns false | [
"IsValidTokenType",
"returns",
"true",
"if",
"the",
"specified",
"token",
"type",
"is",
"one",
"of",
"the",
"known",
"token",
"types",
"otherwise",
"returns",
"false"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/authorization/token/token.go#L60-L64 |
150,650 | fabric8-services/fabric8-auth | authorization/token/token.go | IsSpecificServiceAccount | func IsSpecificServiceAccount(ctx context.Context, names ...string) bool {
accountName, ok := extractServiceAccountName(ctx)
if !ok {
return false
}
for _, name := range names {
if accountName == name {
return true
}
}
return false
} | go | func IsSpecificServiceAccount(ctx context.Context, names ...string) bool {
accountName, ok := extractServiceAccountName(ctx)
if !ok {
return false
}
for _, name := range names {
if accountName == name {
return true
}
}
return false
} | [
"func",
"IsSpecificServiceAccount",
"(",
"ctx",
"context",
".",
"Context",
",",
"names",
"...",
"string",
")",
"bool",
"{",
"accountName",
",",
"ok",
":=",
"extractServiceAccountName",
"(",
"ctx",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"false",
"\n",
"... | // IsSpecificServiceAccount checks if the request is done by a service account listed in the names param
// based on the JWT Token provided in context | [
"IsSpecificServiceAccount",
"checks",
"if",
"the",
"request",
"is",
"done",
"by",
"a",
"service",
"account",
"listed",
"in",
"the",
"names",
"param",
"based",
"on",
"the",
"JWT",
"Token",
"provided",
"in",
"context"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/authorization/token/token.go#L68-L79 |
150,651 | fabric8-services/fabric8-auth | authorization/token/token.go | IsServiceAccount | func IsServiceAccount(ctx context.Context) bool {
_, ok := extractServiceAccountName(ctx)
return ok
} | go | func IsServiceAccount(ctx context.Context) bool {
_, ok := extractServiceAccountName(ctx)
return ok
} | [
"func",
"IsServiceAccount",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"extractServiceAccountName",
"(",
"ctx",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // IsServiceAccount checks if the request is done by a
// Service account based on the JWT Token provided in context | [
"IsServiceAccount",
"checks",
"if",
"the",
"request",
"is",
"done",
"by",
"a",
"Service",
"account",
"based",
"on",
"the",
"JWT",
"Token",
"provided",
"in",
"context"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/authorization/token/token.go#L83-L86 |
150,652 | fabric8-services/fabric8-auth | authentication/provider/repository/state.go | Equal | func (r OauthStateReference) Equal(u convert.Equaler) bool {
other, ok := u.(OauthStateReference)
if !ok {
return false
}
if r.ID != other.ID {
return false
}
if r.State != other.State {
return false
}
if r.Referrer != other.Referrer {
return false
}
if r.ResponseMode == nil {
if other.ResponseMode... | go | func (r OauthStateReference) Equal(u convert.Equaler) bool {
other, ok := u.(OauthStateReference)
if !ok {
return false
}
if r.ID != other.ID {
return false
}
if r.State != other.State {
return false
}
if r.Referrer != other.Referrer {
return false
}
if r.ResponseMode == nil {
if other.ResponseMode... | [
"func",
"(",
"r",
"OauthStateReference",
")",
"Equal",
"(",
"u",
"convert",
".",
"Equaler",
")",
"bool",
"{",
"other",
",",
"ok",
":=",
"u",
".",
"(",
"OauthStateReference",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
... | // Equal returns true if two States objects are equal; otherwise false is returned. | [
"Equal",
"returns",
"true",
"if",
"two",
"States",
"objects",
"are",
"equal",
";",
"otherwise",
"false",
"is",
"returned",
"."
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/authentication/provider/repository/state.go#L34-L61 |
150,653 | fabric8-services/fabric8-auth | authentication/provider/repository/state.go | Delete | func (r *GormOauthStateReferenceRepository) Delete(ctx context.Context, ID uuid.UUID) error {
if ID == uuid.Nil {
log.Error(ctx, map[string]interface{}{
"oauth_state_reference_id": ID.String(),
}, "unable to find the oauth state reference by ID")
return errors.NewNotFoundError("oauth state reference", ID.Stri... | go | func (r *GormOauthStateReferenceRepository) Delete(ctx context.Context, ID uuid.UUID) error {
if ID == uuid.Nil {
log.Error(ctx, map[string]interface{}{
"oauth_state_reference_id": ID.String(),
}, "unable to find the oauth state reference by ID")
return errors.NewNotFoundError("oauth state reference", ID.Stri... | [
"func",
"(",
"r",
"*",
"GormOauthStateReferenceRepository",
")",
"Delete",
"(",
"ctx",
"context",
".",
"Context",
",",
"ID",
"uuid",
".",
"UUID",
")",
"error",
"{",
"if",
"ID",
"==",
"uuid",
".",
"Nil",
"{",
"log",
".",
"Error",
"(",
"ctx",
",",
"map... | // Delete deletes the reference with the given id
// returns NotFoundError or InternalError | [
"Delete",
"deletes",
"the",
"reference",
"with",
"the",
"given",
"id",
"returns",
"NotFoundError",
"or",
"InternalError"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/authentication/provider/repository/state.go#L82-L106 |
150,654 | fabric8-services/fabric8-auth | authentication/provider/repository/state.go | Create | func (r *GormOauthStateReferenceRepository) Create(ctx context.Context, reference *OauthStateReference) (*OauthStateReference, error) {
if reference.ID == uuid.Nil {
reference.ID = uuid.NewV4()
}
tx := r.db.Create(reference)
if err := tx.Error; err != nil {
return nil, errors.NewInternalError(ctx, err)
}
lo... | go | func (r *GormOauthStateReferenceRepository) Create(ctx context.Context, reference *OauthStateReference) (*OauthStateReference, error) {
if reference.ID == uuid.Nil {
reference.ID = uuid.NewV4()
}
tx := r.db.Create(reference)
if err := tx.Error; err != nil {
return nil, errors.NewInternalError(ctx, err)
}
lo... | [
"func",
"(",
"r",
"*",
"GormOauthStateReferenceRepository",
")",
"Create",
"(",
"ctx",
"context",
".",
"Context",
",",
"reference",
"*",
"OauthStateReference",
")",
"(",
"*",
"OauthStateReference",
",",
"error",
")",
"{",
"if",
"reference",
".",
"ID",
"==",
... | // Create creates a new oauth state reference in the DB
// returns InternalError | [
"Create",
"creates",
"a",
"new",
"oauth",
"state",
"reference",
"in",
"the",
"DB",
"returns",
"InternalError"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/authentication/provider/repository/state.go#L110-L124 |
150,655 | fabric8-services/fabric8-auth | authentication/provider/repository/state.go | Load | func (r *GormOauthStateReferenceRepository) Load(ctx context.Context, state string) (*OauthStateReference, error) {
ref := OauthStateReference{}
tx := r.db.Where("state=?", state).First(&ref)
if tx.RecordNotFound() {
log.Error(ctx, map[string]interface{}{
"state": state,
}, "Could not find oauth state refer... | go | func (r *GormOauthStateReferenceRepository) Load(ctx context.Context, state string) (*OauthStateReference, error) {
ref := OauthStateReference{}
tx := r.db.Where("state=?", state).First(&ref)
if tx.RecordNotFound() {
log.Error(ctx, map[string]interface{}{
"state": state,
}, "Could not find oauth state refer... | [
"func",
"(",
"r",
"*",
"GormOauthStateReferenceRepository",
")",
"Load",
"(",
"ctx",
"context",
".",
"Context",
",",
"state",
"string",
")",
"(",
"*",
"OauthStateReference",
",",
"error",
")",
"{",
"ref",
":=",
"OauthStateReference",
"{",
"}",
"\n\n",
"tx",
... | // Load loads state reference by state | [
"Load",
"loads",
"state",
"reference",
"by",
"state"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/authentication/provider/repository/state.go#L127-L142 |
150,656 | fabric8-services/fabric8-auth | controller/authorize.go | NewAuthorizeController | func NewAuthorizeController(service *goa.Service, app application.Application, config AuthorizeControllerConfiguration) *AuthorizeController {
return &AuthorizeController{Controller: service.NewController("AuthorizeController"), app: app, config: config}
} | go | func NewAuthorizeController(service *goa.Service, app application.Application, config AuthorizeControllerConfiguration) *AuthorizeController {
return &AuthorizeController{Controller: service.NewController("AuthorizeController"), app: app, config: config}
} | [
"func",
"NewAuthorizeController",
"(",
"service",
"*",
"goa",
".",
"Service",
",",
"app",
"application",
".",
"Application",
",",
"config",
"AuthorizeControllerConfiguration",
")",
"*",
"AuthorizeController",
"{",
"return",
"&",
"AuthorizeController",
"{",
"Controller... | // NewAuthorizeController returns a new AuthorizeController | [
"NewAuthorizeController",
"returns",
"a",
"new",
"AuthorizeController"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/controller/authorize.go#L27-L29 |
150,657 | fabric8-services/fabric8-auth | controller/authorize.go | Callback | func (c *AuthorizeController) Callback(ctx *app.CallbackAuthorizeContext) error {
redirectTo, err := c.app.AuthenticationProviderService().AuthorizeCallback(ctx, ctx.State, ctx.Code)
//redirectTo, err := c.Auth.AuthCodeCallback(ctx)
if err != nil {
return jsonapi.JSONErrorResponse(ctx, err)
}
ctx.ResponseData... | go | func (c *AuthorizeController) Callback(ctx *app.CallbackAuthorizeContext) error {
redirectTo, err := c.app.AuthenticationProviderService().AuthorizeCallback(ctx, ctx.State, ctx.Code)
//redirectTo, err := c.Auth.AuthCodeCallback(ctx)
if err != nil {
return jsonapi.JSONErrorResponse(ctx, err)
}
ctx.ResponseData... | [
"func",
"(",
"c",
"*",
"AuthorizeController",
")",
"Callback",
"(",
"ctx",
"*",
"app",
".",
"CallbackAuthorizeContext",
")",
"error",
"{",
"redirectTo",
",",
"err",
":=",
"c",
".",
"app",
".",
"AuthenticationProviderService",
"(",
")",
".",
"AuthorizeCallback"... | // Callback takes care of Authorize callback | [
"Callback",
"takes",
"care",
"of",
"Authorize",
"callback"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/controller/authorize.go#L63-L75 |
150,658 | fabric8-services/fabric8-auth | authentication/account/service/tenant.go | NewTenantService | func NewTenantService(config tenantConfig) service.TenantService {
return &tenantServiceImpl{config: config, doer: rest.DefaultHttpDoer()}
} | go | func NewTenantService(config tenantConfig) service.TenantService {
return &tenantServiceImpl{config: config, doer: rest.DefaultHttpDoer()}
} | [
"func",
"NewTenantService",
"(",
"config",
"tenantConfig",
")",
"service",
".",
"TenantService",
"{",
"return",
"&",
"tenantServiceImpl",
"{",
"config",
":",
"config",
",",
"doer",
":",
"rest",
".",
"DefaultHttpDoer",
"(",
")",
"}",
"\n",
"}"
] | // NewTenantService creates a new tenant service | [
"NewTenantService",
"creates",
"a",
"new",
"tenant",
"service"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/authentication/account/service/tenant.go#L32-L34 |
150,659 | fabric8-services/fabric8-auth | authentication/account/service/tenant.go | Init | func (t *tenantServiceImpl) Init(ctx context.Context) error {
c, err := t.createClientWithContextSigner(ctx)
if err != nil {
return err
}
// Ignore response for now
response, err := c.SetupTenant(goasupport.ForwardContextRequestID(ctx), tenant.SetupTenantPath())
if err == nil {
defer rest.CloseResponse(respo... | go | func (t *tenantServiceImpl) Init(ctx context.Context) error {
c, err := t.createClientWithContextSigner(ctx)
if err != nil {
return err
}
// Ignore response for now
response, err := c.SetupTenant(goasupport.ForwardContextRequestID(ctx), tenant.SetupTenantPath())
if err == nil {
defer rest.CloseResponse(respo... | [
"func",
"(",
"t",
"*",
"tenantServiceImpl",
")",
"Init",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"c",
",",
"err",
":=",
"t",
".",
"createClientWithContextSigner",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
... | // Init creates a new tenant in OSO | [
"Init",
"creates",
"a",
"new",
"tenant",
"in",
"OSO"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/authentication/account/service/tenant.go#L37-L50 |
150,660 | fabric8-services/fabric8-auth | authentication/account/service/tenant.go | Delete | func (t *tenantServiceImpl) Delete(ctx context.Context, identityID uuid.UUID) error {
log.Info(ctx, map[string]interface{}{"identity_id": identityID.String()}, "deleting user on Tenant service")
c, err := t.createClientWithServiceAccountSigner(ctx)
if err != nil {
return err
}
tenantID, err := goauuid.FromStrin... | go | func (t *tenantServiceImpl) Delete(ctx context.Context, identityID uuid.UUID) error {
log.Info(ctx, map[string]interface{}{"identity_id": identityID.String()}, "deleting user on Tenant service")
c, err := t.createClientWithServiceAccountSigner(ctx)
if err != nil {
return err
}
tenantID, err := goauuid.FromStrin... | [
"func",
"(",
"t",
"*",
"tenantServiceImpl",
")",
"Delete",
"(",
"ctx",
"context",
".",
"Context",
",",
"identityID",
"uuid",
".",
"UUID",
")",
"error",
"{",
"log",
".",
"Info",
"(",
"ctx",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
... | // Delete deletes tenants for the identity | [
"Delete",
"deletes",
"tenants",
"for",
"the",
"identity"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/authentication/account/service/tenant.go#L53-L93 |
150,661 | fabric8-services/fabric8-auth | authentication/account/service/tenant.go | createClientWithServiceAccountSigner | func (t *tenantServiceImpl) createClientWithServiceAccountSigner(ctx context.Context) (*tenant.Client, error) {
c, err := t.createClient(ctx)
if err != nil {
return nil, err
}
signer, err := manager.AuthServiceAccountSigner(ctx)
if err != nil {
return nil, err
}
c.SetJWTSigner(signer)
return c, nil
} | go | func (t *tenantServiceImpl) createClientWithServiceAccountSigner(ctx context.Context) (*tenant.Client, error) {
c, err := t.createClient(ctx)
if err != nil {
return nil, err
}
signer, err := manager.AuthServiceAccountSigner(ctx)
if err != nil {
return nil, err
}
c.SetJWTSigner(signer)
return c, nil
} | [
"func",
"(",
"t",
"*",
"tenantServiceImpl",
")",
"createClientWithServiceAccountSigner",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"tenant",
".",
"Client",
",",
"error",
")",
"{",
"c",
",",
"err",
":=",
"t",
".",
"createClient",
"(",
"ctx",
"... | // createClientWithSASigner creates a client with a JWT signer which uses the Auth Service Account token | [
"createClientWithSASigner",
"creates",
"a",
"client",
"with",
"a",
"JWT",
"signer",
"which",
"uses",
"the",
"Auth",
"Service",
"Account",
"token"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/authentication/account/service/tenant.go#L106-L117 |
150,662 | fabric8-services/fabric8-auth | application/service/factory/service_factory.go | WithAuthenticationProviderService | func WithAuthenticationProviderService(s service.AuthenticationProviderService) Option {
return func(f *ServiceFactory) {
f.authProviderServiceFunc = func() service.AuthenticationProviderService {
return s
}
}
} | go | func WithAuthenticationProviderService(s service.AuthenticationProviderService) Option {
return func(f *ServiceFactory) {
f.authProviderServiceFunc = func() service.AuthenticationProviderService {
return s
}
}
} | [
"func",
"WithAuthenticationProviderService",
"(",
"s",
"service",
".",
"AuthenticationProviderService",
")",
"Option",
"{",
"return",
"func",
"(",
"f",
"*",
"ServiceFactory",
")",
"{",
"f",
".",
"authProviderServiceFunc",
"=",
"func",
"(",
")",
"service",
".",
"... | // WithAuthenticationProviderService overrides the default function that returns the AuthenticationProviderService,
// so that instead, a mock implementation can be used | [
"WithAuthenticationProviderService",
"overrides",
"the",
"default",
"function",
"that",
"returns",
"the",
"AuthenticationProviderService",
"so",
"that",
"instead",
"a",
"mock",
"implementation",
"can",
"be",
"used"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/application/service/factory/service_factory.go#L184-L190 |
150,663 | fabric8-services/fabric8-auth | application/service/factory/service_factory.go | WithUserService | func WithUserService(s service.UserService) Option {
return func(f *ServiceFactory) {
f.userServiceFunc = func() service.UserService {
return s
}
}
} | go | func WithUserService(s service.UserService) Option {
return func(f *ServiceFactory) {
f.userServiceFunc = func() service.UserService {
return s
}
}
} | [
"func",
"WithUserService",
"(",
"s",
"service",
".",
"UserService",
")",
"Option",
"{",
"return",
"func",
"(",
"f",
"*",
"ServiceFactory",
")",
"{",
"f",
".",
"userServiceFunc",
"=",
"func",
"(",
")",
"service",
".",
"UserService",
"{",
"return",
"s",
"\... | // WithUserService overrides the default function that returns the UserService,
// so that instead, a mock implementation can be used | [
"WithUserService",
"overrides",
"the",
"default",
"function",
"that",
"returns",
"the",
"UserService",
"so",
"that",
"instead",
"a",
"mock",
"implementation",
"can",
"be",
"used"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/application/service/factory/service_factory.go#L194-L200 |
150,664 | fabric8-services/fabric8-auth | application/service/factory/service_factory.go | NewServiceFactory | func NewServiceFactory(producer servicecontext.ServiceContextProducer, config *configuration.ConfigurationData, options ...Option) *ServiceFactory {
f := &ServiceFactory{contextProducer: producer, config: config}
// default function to return an instance of WIT Service
f.witServiceFunc = func() service.WITService {
... | go | func NewServiceFactory(producer servicecontext.ServiceContextProducer, config *configuration.ConfigurationData, options ...Option) *ServiceFactory {
f := &ServiceFactory{contextProducer: producer, config: config}
// default function to return an instance of WIT Service
f.witServiceFunc = func() service.WITService {
... | [
"func",
"NewServiceFactory",
"(",
"producer",
"servicecontext",
".",
"ServiceContextProducer",
",",
"config",
"*",
"configuration",
".",
"ConfigurationData",
",",
"options",
"...",
"Option",
")",
"*",
"ServiceFactory",
"{",
"f",
":=",
"&",
"ServiceFactory",
"{",
"... | // NewServiceFactory returns a new ServiceFactory which can be configured with the options to replace the default implementations of some services | [
"NewServiceFactory",
"returns",
"a",
"new",
"ServiceFactory",
"which",
"can",
"be",
"configured",
"with",
"the",
"options",
"to",
"replace",
"the",
"default",
"implementations",
"of",
"some",
"services"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/application/service/factory/service_factory.go#L203-L235 |
150,665 | fabric8-services/fabric8-auth | authentication/subscription/service/oso_subscription_service.go | NewOSOSubscriptionService | func NewOSOSubscriptionService(context servicecontext.ServiceContext, config OSOSubscriptionServiceConfiguration) service.OSOSubscriptionService {
return &osoSubscriptionServiceImpl{
BaseService: base.NewBaseService(context),
config: config,
httpClient: http.DefaultClient,
}
} | go | func NewOSOSubscriptionService(context servicecontext.ServiceContext, config OSOSubscriptionServiceConfiguration) service.OSOSubscriptionService {
return &osoSubscriptionServiceImpl{
BaseService: base.NewBaseService(context),
config: config,
httpClient: http.DefaultClient,
}
} | [
"func",
"NewOSOSubscriptionService",
"(",
"context",
"servicecontext",
".",
"ServiceContext",
",",
"config",
"OSOSubscriptionServiceConfiguration",
")",
"service",
".",
"OSOSubscriptionService",
"{",
"return",
"&",
"osoSubscriptionServiceImpl",
"{",
"BaseService",
":",
"bas... | // NewOSOSubscriptionService returns a new OSOSubscriptionService implementation | [
"NewOSOSubscriptionService",
"returns",
"a",
"new",
"OSOSubscriptionService",
"implementation"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/authentication/subscription/service/oso_subscription_service.go#L39-L45 |
150,666 | fabric8-services/fabric8-auth | authentication/subscription/service/oso_subscription_service.go | LoadOSOSubscriptionStatus | func (s *osoSubscriptionServiceImpl) LoadOSOSubscriptionStatus(ctx context.Context, token oauth2.Token) (string, error) {
tm, err := manager.ReadTokenManagerFromContext(ctx)
if err != nil {
log.Error(nil, map[string]interface{}{
"err": err,
}, "failed to create token manager")
return "", autherrors.NewIntern... | go | func (s *osoSubscriptionServiceImpl) LoadOSOSubscriptionStatus(ctx context.Context, token oauth2.Token) (string, error) {
tm, err := manager.ReadTokenManagerFromContext(ctx)
if err != nil {
log.Error(nil, map[string]interface{}{
"err": err,
}, "failed to create token manager")
return "", autherrors.NewIntern... | [
"func",
"(",
"s",
"*",
"osoSubscriptionServiceImpl",
")",
"LoadOSOSubscriptionStatus",
"(",
"ctx",
"context",
".",
"Context",
",",
"token",
"oauth2",
".",
"Token",
")",
"(",
"string",
",",
"error",
")",
"{",
"tm",
",",
"err",
":=",
"manager",
".",
"ReadTok... | // LoadOSOSubscriptionStatus loads a subscription status from OpenShift Online Registration app | [
"LoadOSOSubscriptionStatus",
"loads",
"a",
"subscription",
"status",
"from",
"OpenShift",
"Online",
"Registration",
"app"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/authentication/subscription/service/oso_subscription_service.go#L48-L83 |
150,667 | fabric8-services/fabric8-auth | authentication/subscription/service/oso_subscription_service.go | DeactivateUser | func (s *osoSubscriptionServiceImpl) DeactivateUser(ctx context.Context, username string) error {
regAppURL := fmt.Sprintf("%s/api/accounts/%s/deprovision_osio?authorization_username=%s",
s.config.GetOSORegistrationAppURL(), username, s.config.GetOSORegistrationAppAdminUsername())
log.Info(ctx, map[string]interface... | go | func (s *osoSubscriptionServiceImpl) DeactivateUser(ctx context.Context, username string) error {
regAppURL := fmt.Sprintf("%s/api/accounts/%s/deprovision_osio?authorization_username=%s",
s.config.GetOSORegistrationAppURL(), username, s.config.GetOSORegistrationAppAdminUsername())
log.Info(ctx, map[string]interface... | [
"func",
"(",
"s",
"*",
"osoSubscriptionServiceImpl",
")",
"DeactivateUser",
"(",
"ctx",
"context",
".",
"Context",
",",
"username",
"string",
")",
"error",
"{",
"regAppURL",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"s",
".",
"config",
".",
"Get... | // DeactivateUser deactivates the user on OpenShift Online | [
"DeactivateUser",
"deactivates",
"the",
"user",
"on",
"OpenShift",
"Online"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/authentication/subscription/service/oso_subscription_service.go#L186-L222 |
150,668 | fabric8-services/fabric8-auth | controller/users.go | SendEmailVerificationCode | func (c *UsersController) SendEmailVerificationCode(ctx *app.SendEmailVerificationCodeUsersContext) error {
identity, err := c.app.UserService().LoadContextIdentityAndUser(ctx)
if err != nil {
log.Error(ctx, map[string]interface{}{"err": err}, "unable to load identity or user")
return jsonapi.JSONErrorResponse(ct... | go | func (c *UsersController) SendEmailVerificationCode(ctx *app.SendEmailVerificationCodeUsersContext) error {
identity, err := c.app.UserService().LoadContextIdentityAndUser(ctx)
if err != nil {
log.Error(ctx, map[string]interface{}{"err": err}, "unable to load identity or user")
return jsonapi.JSONErrorResponse(ct... | [
"func",
"(",
"c",
"*",
"UsersController",
")",
"SendEmailVerificationCode",
"(",
"ctx",
"*",
"app",
".",
"SendEmailVerificationCodeUsersContext",
")",
"error",
"{",
"identity",
",",
"err",
":=",
"c",
".",
"app",
".",
"UserService",
"(",
")",
".",
"LoadContextI... | // SendEmailVerificationCode sends out a verification code to the user's email address | [
"SendEmailVerificationCode",
"sends",
"out",
"a",
"verification",
"code",
"to",
"the",
"user",
"s",
"email",
"address"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/controller/users.go#L625-L643 |
150,669 | fabric8-services/fabric8-auth | controller/users.go | VerifyEmail | func (c *UsersController) VerifyEmail(ctx *app.VerifyEmailUsersContext) error {
verifiedCode, err := c.EmailVerificationService.VerifyCode(ctx, ctx.Code)
var errResponse string
isVerified := true
if err != nil {
errResponse = err.Error()
isVerified = false
} else if verifiedCode == nil {
errResponse = "unabl... | go | func (c *UsersController) VerifyEmail(ctx *app.VerifyEmailUsersContext) error {
verifiedCode, err := c.EmailVerificationService.VerifyCode(ctx, ctx.Code)
var errResponse string
isVerified := true
if err != nil {
errResponse = err.Error()
isVerified = false
} else if verifiedCode == nil {
errResponse = "unabl... | [
"func",
"(",
"c",
"*",
"UsersController",
")",
"VerifyEmail",
"(",
"ctx",
"*",
"app",
".",
"VerifyEmailUsersContext",
")",
"error",
"{",
"verifiedCode",
",",
"err",
":=",
"c",
".",
"EmailVerificationService",
".",
"VerifyCode",
"(",
"ctx",
",",
"ctx",
".",
... | // VerifyEmail verifies a user's email when updated. | [
"VerifyEmail",
"verifies",
"a",
"user",
"s",
"email",
"when",
"updated",
"."
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/controller/users.go#L646-L670 |
150,670 | fabric8-services/fabric8-auth | controller/users.go | ListTokens | func (c *UsersController) ListTokens(ctx *app.ListTokensUsersContext) error {
isSvcAccount := token.IsSpecificServiceAccount(ctx, token.Admin)
if !isSvcAccount {
log.Error(ctx, nil, "The account is not an authorized service account allowed to manage user tokens")
return jsonapi.JSONErrorResponse(ctx, errors.NewUn... | go | func (c *UsersController) ListTokens(ctx *app.ListTokensUsersContext) error {
isSvcAccount := token.IsSpecificServiceAccount(ctx, token.Admin)
if !isSvcAccount {
log.Error(ctx, nil, "The account is not an authorized service account allowed to manage user tokens")
return jsonapi.JSONErrorResponse(ctx, errors.NewUn... | [
"func",
"(",
"c",
"*",
"UsersController",
")",
"ListTokens",
"(",
"ctx",
"*",
"app",
".",
"ListTokensUsersContext",
")",
"error",
"{",
"isSvcAccount",
":=",
"token",
".",
"IsSpecificServiceAccount",
"(",
"ctx",
",",
"token",
".",
"Admin",
")",
"\n",
"if",
... | // ListTokens lists all of the tokens for the specified identity. This endpoint may only be invoked via the admin console
// service account | [
"ListTokens",
"lists",
"all",
"of",
"the",
"tokens",
"for",
"the",
"specified",
"identity",
".",
"This",
"endpoint",
"may",
"only",
"be",
"invoked",
"via",
"the",
"admin",
"console",
"service",
"account"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/controller/users.go#L674-L731 |
150,671 | fabric8-services/fabric8-auth | controller/userinfo.go | NewUserinfoController | func NewUserinfoController(service *goa.Service, app application.Application, tokenManager manager.TokenManager) *UserinfoController {
return &UserinfoController{
Controller: service.NewController("UserinfoController"),
app: app,
tokenManager: tokenManager,
}
} | go | func NewUserinfoController(service *goa.Service, app application.Application, tokenManager manager.TokenManager) *UserinfoController {
return &UserinfoController{
Controller: service.NewController("UserinfoController"),
app: app,
tokenManager: tokenManager,
}
} | [
"func",
"NewUserinfoController",
"(",
"service",
"*",
"goa",
".",
"Service",
",",
"app",
"application",
".",
"Application",
",",
"tokenManager",
"manager",
".",
"TokenManager",
")",
"*",
"UserinfoController",
"{",
"return",
"&",
"UserinfoController",
"{",
"Control... | // NewUserinfoController creates a userinfo controller. | [
"NewUserinfoController",
"creates",
"a",
"userinfo",
"controller",
"."
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/controller/userinfo.go#L23-L29 |
150,672 | fabric8-services/fabric8-auth | authorization/organization/service/organization_service.go | NewOrganizationService | func NewOrganizationService(context servicecontext.ServiceContext) service.OrganizationService {
return &organizationServiceImpl{base.NewBaseService(context)}
} | go | func NewOrganizationService(context servicecontext.ServiceContext) service.OrganizationService {
return &organizationServiceImpl{base.NewBaseService(context)}
} | [
"func",
"NewOrganizationService",
"(",
"context",
"servicecontext",
".",
"ServiceContext",
")",
"service",
".",
"OrganizationService",
"{",
"return",
"&",
"organizationServiceImpl",
"{",
"base",
".",
"NewBaseService",
"(",
"context",
")",
"}",
"\n",
"}"
] | // NewOrganizationService creates a new service. | [
"NewOrganizationService",
"creates",
"a",
"new",
"service",
"."
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/authorization/organization/service/organization_service.go#L28-L30 |
150,673 | fabric8-services/fabric8-auth | authorization/organization/service/organization_service.go | ListOrganizations | func (s *organizationServiceImpl) ListOrganizations(ctx context.Context, identityID uuid.UUID) ([]authorization.IdentityAssociation, error) {
resourceType := authorization.IdentityResourceTypeOrganization
// first find the identity's memberships
memberships, err := s.Repositories().Identities().FindIdentityMembersh... | go | func (s *organizationServiceImpl) ListOrganizations(ctx context.Context, identityID uuid.UUID) ([]authorization.IdentityAssociation, error) {
resourceType := authorization.IdentityResourceTypeOrganization
// first find the identity's memberships
memberships, err := s.Repositories().Identities().FindIdentityMembersh... | [
"func",
"(",
"s",
"*",
"organizationServiceImpl",
")",
"ListOrganizations",
"(",
"ctx",
"context",
".",
"Context",
",",
"identityID",
"uuid",
".",
"UUID",
")",
"(",
"[",
"]",
"authorization",
".",
"IdentityAssociation",
",",
"error",
")",
"{",
"resourceType",
... | // Returns an array of all organizations in which the specified identity is a member or is assigned a role | [
"Returns",
"an",
"array",
"of",
"all",
"organizations",
"in",
"which",
"the",
"specified",
"identity",
"is",
"a",
"member",
"or",
"is",
"assigned",
"a",
"role"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/authorization/organization/service/organization_service.go#L113-L131 |
150,674 | fabric8-services/fabric8-auth | controller/clusters.go | NewClustersController | func NewClustersController(service *goa.Service, config clusterConfiguration) *ClustersController {
return &ClustersController{
Controller: service.NewController("ClustersController"),
config: config,
}
} | go | func NewClustersController(service *goa.Service, config clusterConfiguration) *ClustersController {
return &ClustersController{
Controller: service.NewController("ClustersController"),
config: config,
}
} | [
"func",
"NewClustersController",
"(",
"service",
"*",
"goa",
".",
"Service",
",",
"config",
"clusterConfiguration",
")",
"*",
"ClustersController",
"{",
"return",
"&",
"ClustersController",
"{",
"Controller",
":",
"service",
".",
"NewController",
"(",
"\"",
"\"",
... | // NewClustersController creates a clusters controller. | [
"NewClustersController",
"creates",
"a",
"clusters",
"controller",
"."
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/controller/clusters.go#L24-L29 |
150,675 | fabric8-services/fabric8-auth | controller/clusters.go | Show | func (c *ClustersController) Show(ctx *app.ShowClustersContext) error {
err := httpsupport.RouteHTTP(ctx, c.config.GetClusterServiceURL())
if err != nil {
log.Error(ctx, map[string]interface{}{
"err": err,
}, "unable to proxy to cluster service")
return jsonapi.JSONErrorResponse(ctx, err)
}
return nil
} | go | func (c *ClustersController) Show(ctx *app.ShowClustersContext) error {
err := httpsupport.RouteHTTP(ctx, c.config.GetClusterServiceURL())
if err != nil {
log.Error(ctx, map[string]interface{}{
"err": err,
}, "unable to proxy to cluster service")
return jsonapi.JSONErrorResponse(ctx, err)
}
return nil
} | [
"func",
"(",
"c",
"*",
"ClustersController",
")",
"Show",
"(",
"ctx",
"*",
"app",
".",
"ShowClustersContext",
")",
"error",
"{",
"err",
":=",
"httpsupport",
".",
"RouteHTTP",
"(",
"ctx",
",",
"c",
".",
"config",
".",
"GetClusterServiceURL",
"(",
")",
")"... | // Show runs the list of available OSO clusters. | [
"Show",
"runs",
"the",
"list",
"of",
"available",
"OSO",
"clusters",
"."
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/controller/clusters.go#L32-L41 |
150,676 | fabric8-services/fabric8-auth | authorization/permission/repository/privilege_cache.go | ScopesAsArray | func (m PrivilegeCache) ScopesAsArray() []string {
if strings.TrimSpace(m.Scopes) == "" {
return []string{}
} else {
return strings.Split(m.Scopes, ",")
}
} | go | func (m PrivilegeCache) ScopesAsArray() []string {
if strings.TrimSpace(m.Scopes) == "" {
return []string{}
} else {
return strings.Split(m.Scopes, ",")
}
} | [
"func",
"(",
"m",
"PrivilegeCache",
")",
"ScopesAsArray",
"(",
")",
"[",
"]",
"string",
"{",
"if",
"strings",
".",
"TrimSpace",
"(",
"m",
".",
"Scopes",
")",
"==",
"\"",
"\"",
"{",
"return",
"[",
"]",
"string",
"{",
"}",
"\n",
"}",
"else",
"{",
"... | // Returns the scopes as a string array. If scopes is empty, returns an empty array | [
"Returns",
"the",
"scopes",
"as",
"a",
"string",
"array",
".",
"If",
"scopes",
"is",
"empty",
"returns",
"an",
"empty",
"array"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/authorization/permission/repository/privilege_cache.go#L43-L49 |
150,677 | fabric8-services/fabric8-auth | authorization/resourcetype/repository/resource_type.go | Lookup | func (m *GormResourceTypeRepository) Lookup(ctx context.Context, name string) (*ResourceType, error) {
defer goa.MeasureSince([]string{"goa", "db", "resource_type", "lookupOrCreate"}, time.Now())
var native ResourceType
err := m.db.Table(m.TableName()).Where("name = ?", name).First(&native).Error
if err == gorm.Er... | go | func (m *GormResourceTypeRepository) Lookup(ctx context.Context, name string) (*ResourceType, error) {
defer goa.MeasureSince([]string{"goa", "db", "resource_type", "lookupOrCreate"}, time.Now())
var native ResourceType
err := m.db.Table(m.TableName()).Where("name = ?", name).First(&native).Error
if err == gorm.Er... | [
"func",
"(",
"m",
"*",
"GormResourceTypeRepository",
")",
"Lookup",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"(",
"*",
"ResourceType",
",",
"error",
")",
"{",
"defer",
"goa",
".",
"MeasureSince",
"(",
"[",
"]",
"string",
"{",
... | // Query Functions
// Lookup looks up the ResourceType record with the specified name. If there is no such record, then
// a gorm.ErrRecordNotFound error will be returned. | [
"Query",
"Functions",
"Lookup",
"looks",
"up",
"the",
"ResourceType",
"record",
"with",
"the",
"specified",
"name",
".",
"If",
"there",
"is",
"no",
"such",
"record",
"then",
"a",
"gorm",
".",
"ErrRecordNotFound",
"error",
"will",
"be",
"returned",
"."
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/authorization/resourcetype/repository/resource_type.go#L68-L77 |
150,678 | fabric8-services/fabric8-auth | authentication/account/worker/user_deactivation_notification_worker.go | NewUserDeactivationNotificationWorker | func NewUserDeactivationNotificationWorker(ctx context.Context, app application.Application) UserDeactivationNotificationWorker {
w := &userDeactivationNotificationWorker{
worker.Worker{
Ctx: ctx,
App: app,
Owner: worker.GetLockOwner(ctx),
Name: UserDeactivationNotification,
},
}
w.Do = w.notify... | go | func NewUserDeactivationNotificationWorker(ctx context.Context, app application.Application) UserDeactivationNotificationWorker {
w := &userDeactivationNotificationWorker{
worker.Worker{
Ctx: ctx,
App: app,
Owner: worker.GetLockOwner(ctx),
Name: UserDeactivationNotification,
},
}
w.Do = w.notify... | [
"func",
"NewUserDeactivationNotificationWorker",
"(",
"ctx",
"context",
".",
"Context",
",",
"app",
"application",
".",
"Application",
")",
"UserDeactivationNotificationWorker",
"{",
"w",
":=",
"&",
"userDeactivationNotificationWorker",
"{",
"worker",
".",
"Worker",
"{"... | // NewUserDeactivationNotificationWorker returns a new UserDeactivationNotificationWorker | [
"NewUserDeactivationNotificationWorker",
"returns",
"a",
"new",
"UserDeactivationNotificationWorker"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/authentication/account/worker/user_deactivation_notification_worker.go#L26-L37 |
150,679 | fabric8-services/fabric8-auth | controller/namedusers.go | NewNamedusersController | func NewNamedusersController(service *goa.Service, app application.Application, config UsersControllerConfiguration, tenantService appservice.TenantService) *NamedusersController {
return &NamedusersController{
Controller: service.NewController("NamedusersController"),
app: app,
config: confi... | go | func NewNamedusersController(service *goa.Service, app application.Application, config UsersControllerConfiguration, tenantService appservice.TenantService) *NamedusersController {
return &NamedusersController{
Controller: service.NewController("NamedusersController"),
app: app,
config: confi... | [
"func",
"NewNamedusersController",
"(",
"service",
"*",
"goa",
".",
"Service",
",",
"app",
"application",
".",
"Application",
",",
"config",
"UsersControllerConfiguration",
",",
"tenantService",
"appservice",
".",
"TenantService",
")",
"*",
"NamedusersController",
"{"... | // NewNamedusersController creates a namedusers controller. | [
"NewNamedusersController",
"creates",
"a",
"namedusers",
"controller",
"."
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/controller/namedusers.go#L25-L32 |
150,680 | fabric8-services/fabric8-auth | controller/namedusers.go | Ban | func (c *NamedusersController) Ban(ctx *app.BanNamedusersContext) error {
isSvcAccount := token.IsSpecificServiceAccount(ctx, token.OnlineRegistration)
if !isSvcAccount {
log.Error(ctx, nil, "the account is not an authorized service account allowed to deprovision users")
return jsonapi.JSONErrorResponse(ctx, erro... | go | func (c *NamedusersController) Ban(ctx *app.BanNamedusersContext) error {
isSvcAccount := token.IsSpecificServiceAccount(ctx, token.OnlineRegistration)
if !isSvcAccount {
log.Error(ctx, nil, "the account is not an authorized service account allowed to deprovision users")
return jsonapi.JSONErrorResponse(ctx, erro... | [
"func",
"(",
"c",
"*",
"NamedusersController",
")",
"Ban",
"(",
"ctx",
"*",
"app",
".",
"BanNamedusersContext",
")",
"error",
"{",
"isSvcAccount",
":=",
"token",
".",
"IsSpecificServiceAccount",
"(",
"ctx",
",",
"token",
".",
"OnlineRegistration",
")",
"\n",
... | // Ban runs the "ban" action. | [
"Ban",
"runs",
"the",
"ban",
"action",
"."
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/controller/namedusers.go#L35-L69 |
150,681 | fabric8-services/fabric8-auth | controller/namedusers.go | Deactivate | func (c *NamedusersController) Deactivate(ctx *app.DeactivateNamedusersContext) error {
isSvcAccount := token.IsSpecificServiceAccount(ctx, token.OnlineRegistration)
if !isSvcAccount {
log.Error(ctx, nil, "the account is not an authorized service account allowed to deprovision users")
return jsonapi.JSONErrorResp... | go | func (c *NamedusersController) Deactivate(ctx *app.DeactivateNamedusersContext) error {
isSvcAccount := token.IsSpecificServiceAccount(ctx, token.OnlineRegistration)
if !isSvcAccount {
log.Error(ctx, nil, "the account is not an authorized service account allowed to deprovision users")
return jsonapi.JSONErrorResp... | [
"func",
"(",
"c",
"*",
"NamedusersController",
")",
"Deactivate",
"(",
"ctx",
"*",
"app",
".",
"DeactivateNamedusersContext",
")",
"error",
"{",
"isSvcAccount",
":=",
"token",
".",
"IsSpecificServiceAccount",
"(",
"ctx",
",",
"token",
".",
"OnlineRegistration",
... | // Deactivate runs the deactivate action. | [
"Deactivate",
"runs",
"the",
"deactivate",
"action",
"."
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/controller/namedusers.go#L84-L110 |
150,682 | fabric8-services/fabric8-auth | worker/worker.go | Start | func (w *Worker) Start(freq time.Duration) {
w.stopCh = make(chan bool, 1)
log.Info(w.Ctx, map[string]interface{}{
"owner": w.Owner,
"name": w.Name,
}, "starting worker")
w.ticker = time.NewTicker(freq)
go func() {
w.acquireLock() // will wait until succeed
for {
select {
case <-w.ticker.C:
w.ex... | go | func (w *Worker) Start(freq time.Duration) {
w.stopCh = make(chan bool, 1)
log.Info(w.Ctx, map[string]interface{}{
"owner": w.Owner,
"name": w.Name,
}, "starting worker")
w.ticker = time.NewTicker(freq)
go func() {
w.acquireLock() // will wait until succeed
for {
select {
case <-w.ticker.C:
w.ex... | [
"func",
"(",
"w",
"*",
"Worker",
")",
"Start",
"(",
"freq",
"time",
".",
"Duration",
")",
"{",
"w",
".",
"stopCh",
"=",
"make",
"(",
"chan",
"bool",
",",
"1",
")",
"\n",
"log",
".",
"Info",
"(",
"w",
".",
"Ctx",
",",
"map",
"[",
"string",
"]"... | // Start starts the worker with the given timer | [
"Start",
"starts",
"the",
"worker",
"with",
"the",
"given",
"timer"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/worker/worker.go#L28-L47 |
150,683 | fabric8-services/fabric8-auth | worker/worker.go | Stop | func (w *Worker) Stop() {
if w.stopCh != nil {
log.Debug(w.Ctx, map[string]interface{}{
"name": w.Name,
"owner": w.Owner,
}, "time to stop the worker")
w.stopCh <- true
}
} | go | func (w *Worker) Stop() {
if w.stopCh != nil {
log.Debug(w.Ctx, map[string]interface{}{
"name": w.Name,
"owner": w.Owner,
}, "time to stop the worker")
w.stopCh <- true
}
} | [
"func",
"(",
"w",
"*",
"Worker",
")",
"Stop",
"(",
")",
"{",
"if",
"w",
".",
"stopCh",
"!=",
"nil",
"{",
"log",
".",
"Debug",
"(",
"w",
".",
"Ctx",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"w",
".",
"Name... | // Stop stops the worker | [
"Stop",
"stops",
"the",
"worker"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/worker/worker.go#L97-L105 |
150,684 | fabric8-services/fabric8-auth | controller/roles.go | NewRolesController | func NewRolesController(service *goa.Service, app application.Application) *RolesController {
return &RolesController{
Controller: service.NewController("RolesController"),
app: app,
}
} | go | func NewRolesController(service *goa.Service, app application.Application) *RolesController {
return &RolesController{
Controller: service.NewController("RolesController"),
app: app,
}
} | [
"func",
"NewRolesController",
"(",
"service",
"*",
"goa",
".",
"Service",
",",
"app",
"application",
".",
"Application",
")",
"*",
"RolesController",
"{",
"return",
"&",
"RolesController",
"{",
"Controller",
":",
"service",
".",
"NewController",
"(",
"\"",
"\"... | // NewRolesController creates a roles controller. | [
"NewRolesController",
"creates",
"a",
"roles",
"controller",
"."
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/controller/roles.go#L21-L26 |
150,685 | fabric8-services/fabric8-auth | controller/space.go | ListTeams | func (c *SpaceController) ListTeams(ctx *app.ListTeamsSpaceContext) error {
currentUser, err := manager.ContextIdentity(ctx)
if err != nil {
return jsonapi.JSONErrorResponse(ctx, errors.NewUnauthorizedError(err.Error()))
}
if currentUser == nil {
return jsonapi.JSONErrorResponse(ctx, errors.NewUnauthorizedErro... | go | func (c *SpaceController) ListTeams(ctx *app.ListTeamsSpaceContext) error {
currentUser, err := manager.ContextIdentity(ctx)
if err != nil {
return jsonapi.JSONErrorResponse(ctx, errors.NewUnauthorizedError(err.Error()))
}
if currentUser == nil {
return jsonapi.JSONErrorResponse(ctx, errors.NewUnauthorizedErro... | [
"func",
"(",
"c",
"*",
"SpaceController",
")",
"ListTeams",
"(",
"ctx",
"*",
"app",
".",
"ListTeamsSpaceContext",
")",
"error",
"{",
"currentUser",
",",
"err",
":=",
"manager",
".",
"ContextIdentity",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",... | // ListTeams runs the listTeams action. | [
"ListTeams",
"runs",
"the",
"listTeams",
"action",
"."
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/controller/space.go#L68-L90 |
150,686 | fabric8-services/fabric8-auth | rest/rest.go | Host | func Host(req *goa.RequestData, config configuration) string {
if config != nil && config.IsPostgresDeveloperModeEnabled() {
return "auth.openshift.io"
}
return req.Host
} | go | func Host(req *goa.RequestData, config configuration) string {
if config != nil && config.IsPostgresDeveloperModeEnabled() {
return "auth.openshift.io"
}
return req.Host
} | [
"func",
"Host",
"(",
"req",
"*",
"goa",
".",
"RequestData",
",",
"config",
"configuration",
")",
"string",
"{",
"if",
"config",
"!=",
"nil",
"&&",
"config",
".",
"IsPostgresDeveloperModeEnabled",
"(",
")",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"ret... | // Host returns the host from the given request if run in prod mode or if config is nil
// and "auth.openshift.io" if run in dev mode | [
"Host",
"returns",
"the",
"host",
"from",
"the",
"given",
"request",
"if",
"run",
"in",
"prod",
"mode",
"or",
"if",
"config",
"is",
"nil",
"and",
"auth",
".",
"openshift",
".",
"io",
"if",
"run",
"in",
"dev",
"mode"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/rest/rest.go#L52-L57 |
150,687 | fabric8-services/fabric8-auth | rest/rest.go | AbsoluteURL | func AbsoluteURL(req *goa.RequestData, relative string, config configuration) string {
host := Host(req, config)
return absoluteURLForHost(req, host, relative)
} | go | func AbsoluteURL(req *goa.RequestData, relative string, config configuration) string {
host := Host(req, config)
return absoluteURLForHost(req, host, relative)
} | [
"func",
"AbsoluteURL",
"(",
"req",
"*",
"goa",
".",
"RequestData",
",",
"relative",
"string",
",",
"config",
"configuration",
")",
"string",
"{",
"host",
":=",
"Host",
"(",
"req",
",",
"config",
")",
"\n",
"return",
"absoluteURLForHost",
"(",
"req",
",",
... | // AbsoluteURL prefixes a relative URL with absolute address
// If config is not nil and run in dev mode then host is replaced by "auth.openshift.io" | [
"AbsoluteURL",
"prefixes",
"a",
"relative",
"URL",
"with",
"absolute",
"address",
"If",
"config",
"is",
"not",
"nil",
"and",
"run",
"in",
"dev",
"mode",
"then",
"host",
"is",
"replaced",
"by",
"auth",
".",
"openshift",
".",
"io"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/rest/rest.go#L61-L64 |
150,688 | fabric8-services/fabric8-auth | rest/rest.go | AddParam | func AddParam(urlString string, paramName string, paramValue string) (string, error) {
return AddParams(urlString, map[string]string{paramName: paramValue})
} | go | func AddParam(urlString string, paramName string, paramValue string) (string, error) {
return AddParams(urlString, map[string]string{paramName: paramValue})
} | [
"func",
"AddParam",
"(",
"urlString",
"string",
",",
"paramName",
"string",
",",
"paramValue",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"AddParams",
"(",
"urlString",
",",
"map",
"[",
"string",
"]",
"string",
"{",
"paramName",
":",
... | // AddParam adds a parameter to URL | [
"AddParam",
"adds",
"a",
"parameter",
"to",
"URL"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/rest/rest.go#L130-L132 |
150,689 | fabric8-services/fabric8-auth | rest/rest.go | AddParams | func AddParams(urlString string, params map[string]string) (string, error) {
parsedURL, err := url.Parse(urlString)
if err != nil {
return "", err
}
parameters := parsedURL.Query()
for k, v := range params {
parameters.Add(k, v)
}
parsedURL.RawQuery = parameters.Encode()
return parsedURL.String(), nil
} | go | func AddParams(urlString string, params map[string]string) (string, error) {
parsedURL, err := url.Parse(urlString)
if err != nil {
return "", err
}
parameters := parsedURL.Query()
for k, v := range params {
parameters.Add(k, v)
}
parsedURL.RawQuery = parameters.Encode()
return parsedURL.String(), nil
} | [
"func",
"AddParams",
"(",
"urlString",
"string",
",",
"params",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"parsedURL",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"urlString",
")",
"\n",
"if",
"err",
"!=",
"nil"... | // AddParams adds parameters to URL | [
"AddParams",
"adds",
"parameters",
"to",
"URL"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/rest/rest.go#L135-L148 |
150,690 | fabric8-services/fabric8-auth | rest/rest.go | AddTrailingSlashToURL | func AddTrailingSlashToURL(url string) string {
if url != "" && !strings.HasSuffix(url, "/") {
return url + "/"
}
return url
} | go | func AddTrailingSlashToURL(url string) string {
if url != "" && !strings.HasSuffix(url, "/") {
return url + "/"
}
return url
} | [
"func",
"AddTrailingSlashToURL",
"(",
"url",
"string",
")",
"string",
"{",
"if",
"url",
"!=",
"\"",
"\"",
"&&",
"!",
"strings",
".",
"HasSuffix",
"(",
"url",
",",
"\"",
"\"",
")",
"{",
"return",
"url",
"+",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"u... | // AddTrailingSlashToURL adds a trailing slash to the URL if it doesn't have it already
// If URL is an empty string the function returns an empty string too | [
"AddTrailingSlashToURL",
"adds",
"a",
"trailing",
"slash",
"to",
"the",
"URL",
"if",
"it",
"doesn",
"t",
"have",
"it",
"already",
"If",
"URL",
"is",
"an",
"empty",
"string",
"the",
"function",
"returns",
"an",
"empty",
"string",
"too"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/rest/rest.go#L152-L157 |
150,691 | fabric8-services/fabric8-auth | authorization/permission/service/privilege_cache_service.go | NewPrivilegeCacheService | func NewPrivilegeCacheService(context servicecontext.ServiceContext, config PrivilegeCacheServiceConfiguration) service.PrivilegeCacheService {
return &privilegeCacheServiceImpl{
BaseService: base.NewBaseService(context),
conf: config,
}
} | go | func NewPrivilegeCacheService(context servicecontext.ServiceContext, config PrivilegeCacheServiceConfiguration) service.PrivilegeCacheService {
return &privilegeCacheServiceImpl{
BaseService: base.NewBaseService(context),
conf: config,
}
} | [
"func",
"NewPrivilegeCacheService",
"(",
"context",
"servicecontext",
".",
"ServiceContext",
",",
"config",
"PrivilegeCacheServiceConfiguration",
")",
"service",
".",
"PrivilegeCacheService",
"{",
"return",
"&",
"privilegeCacheServiceImpl",
"{",
"BaseService",
":",
"base",
... | // NewPrivilegeCacheService creates a new service. | [
"NewPrivilegeCacheService",
"creates",
"a",
"new",
"service",
"."
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/authorization/permission/service/privilege_cache_service.go#L28-L33 |
150,692 | fabric8-services/fabric8-auth | authorization/permission/service/privilege_cache_service.go | CachedPrivileges | func (s *privilegeCacheServiceImpl) CachedPrivileges(ctx context.Context, identityID uuid.UUID, resourceID string) (*permission.PrivilegeCache, error) {
nowTime := time.Now()
// Attempt to load the privilege cache record from the database
privilegeCache, err := s.Repositories().PrivilegeCacheRepository().FindForIde... | go | func (s *privilegeCacheServiceImpl) CachedPrivileges(ctx context.Context, identityID uuid.UUID, resourceID string) (*permission.PrivilegeCache, error) {
nowTime := time.Now()
// Attempt to load the privilege cache record from the database
privilegeCache, err := s.Repositories().PrivilegeCacheRepository().FindForIde... | [
"func",
"(",
"s",
"*",
"privilegeCacheServiceImpl",
")",
"CachedPrivileges",
"(",
"ctx",
"context",
".",
"Context",
",",
"identityID",
"uuid",
".",
"UUID",
",",
"resourceID",
"string",
")",
"(",
"*",
"permission",
".",
"PrivilegeCache",
",",
"error",
")",
"{... | // CachedPrivileges returns the cached privileges that an identity has for a specified resource.
// If there are no privileges cached, or the cached value is stale, the privileges will be re-calculated and
// the cached value updated. | [
"CachedPrivileges",
"returns",
"the",
"cached",
"privileges",
"that",
"an",
"identity",
"has",
"for",
"a",
"specified",
"resource",
".",
"If",
"there",
"are",
"no",
"privileges",
"cached",
"or",
"the",
"cached",
"value",
"is",
"stale",
"the",
"privileges",
"wi... | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/authorization/permission/service/privilege_cache_service.go#L38-L95 |
150,693 | fabric8-services/fabric8-auth | controller/resource_roles.go | NewResourceRolesController | func NewResourceRolesController(service *goa.Service, app application.Application) *ResourceRolesController {
return &ResourceRolesController{
Controller: service.NewController("ResourceRolesController"),
app: app,
}
} | go | func NewResourceRolesController(service *goa.Service, app application.Application) *ResourceRolesController {
return &ResourceRolesController{
Controller: service.NewController("ResourceRolesController"),
app: app,
}
} | [
"func",
"NewResourceRolesController",
"(",
"service",
"*",
"goa",
".",
"Service",
",",
"app",
"application",
".",
"Application",
")",
"*",
"ResourceRolesController",
"{",
"return",
"&",
"ResourceRolesController",
"{",
"Controller",
":",
"service",
".",
"NewControlle... | // NewResourceRolesController creates a resource_roles controller. | [
"NewResourceRolesController",
"creates",
"a",
"resource_roles",
"controller",
"."
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/controller/resource_roles.go#L23-L28 |
150,694 | fabric8-services/fabric8-auth | controller/resource_roles.go | ListAssigned | func (c *ResourceRolesController) ListAssigned(ctx *app.ListAssignedResourceRolesContext) error {
currentIdentity, err := c.app.UserService().LoadContextIdentityIfNotBanned(ctx)
if err != nil {
return jsonapi.JSONErrorResponse(ctx, err)
}
var roles []rolerepository.IdentityRole
roles, err = c.app.RoleManagemen... | go | func (c *ResourceRolesController) ListAssigned(ctx *app.ListAssignedResourceRolesContext) error {
currentIdentity, err := c.app.UserService().LoadContextIdentityIfNotBanned(ctx)
if err != nil {
return jsonapi.JSONErrorResponse(ctx, err)
}
var roles []rolerepository.IdentityRole
roles, err = c.app.RoleManagemen... | [
"func",
"(",
"c",
"*",
"ResourceRolesController",
")",
"ListAssigned",
"(",
"ctx",
"*",
"app",
".",
"ListAssignedResourceRolesContext",
")",
"error",
"{",
"currentIdentity",
",",
"err",
":=",
"c",
".",
"app",
".",
"UserService",
"(",
")",
".",
"LoadContextIden... | // ListAssigned runs the list action. | [
"ListAssigned",
"runs",
"the",
"list",
"action",
"."
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/controller/resource_roles.go#L31-L52 |
150,695 | fabric8-services/fabric8-auth | controller/resource_roles.go | ListAssignedByRoleName | func (c *ResourceRolesController) ListAssignedByRoleName(ctx *app.ListAssignedByRoleNameResourceRolesContext) error {
currentIdentity, err := c.app.UserService().LoadContextIdentityIfNotBanned(ctx)
if err != nil {
return jsonapi.JSONErrorResponse(ctx, err)
}
var roles []rolerepository.IdentityRole
roles, err =... | go | func (c *ResourceRolesController) ListAssignedByRoleName(ctx *app.ListAssignedByRoleNameResourceRolesContext) error {
currentIdentity, err := c.app.UserService().LoadContextIdentityIfNotBanned(ctx)
if err != nil {
return jsonapi.JSONErrorResponse(ctx, err)
}
var roles []rolerepository.IdentityRole
roles, err =... | [
"func",
"(",
"c",
"*",
"ResourceRolesController",
")",
"ListAssignedByRoleName",
"(",
"ctx",
"*",
"app",
".",
"ListAssignedByRoleNameResourceRolesContext",
")",
"error",
"{",
"currentIdentity",
",",
"err",
":=",
"c",
".",
"app",
".",
"UserService",
"(",
")",
"."... | // ListAssignedByRoleName runs the list action. | [
"ListAssignedByRoleName",
"runs",
"the",
"list",
"action",
"."
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/controller/resource_roles.go#L55-L80 |
150,696 | fabric8-services/fabric8-auth | controller/resource_roles.go | AssignRole | func (c *ResourceRolesController) AssignRole(ctx *app.AssignRoleResourceRolesContext) error {
currentIdentity, err := manager.ContextIdentity(ctx)
if err != nil {
log.Error(ctx, map[string]interface{}{
"resource_id": ctx.ResourceID,
}, "error getting identity information from token")
return jsonapi.JSONError... | go | func (c *ResourceRolesController) AssignRole(ctx *app.AssignRoleResourceRolesContext) error {
currentIdentity, err := manager.ContextIdentity(ctx)
if err != nil {
log.Error(ctx, map[string]interface{}{
"resource_id": ctx.ResourceID,
}, "error getting identity information from token")
return jsonapi.JSONError... | [
"func",
"(",
"c",
"*",
"ResourceRolesController",
")",
"AssignRole",
"(",
"ctx",
"*",
"app",
".",
"AssignRoleResourceRolesContext",
")",
"error",
"{",
"currentIdentity",
",",
"err",
":=",
"manager",
".",
"ContextIdentity",
"(",
"ctx",
")",
"\n",
"if",
"err",
... | // AssignRole assigns a specific role for a resource, to one or more identities. | [
"AssignRole",
"assigns",
"a",
"specific",
"role",
"for",
"a",
"resource",
"to",
"one",
"or",
"more",
"identities",
"."
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/controller/resource_roles.go#L83-L117 |
150,697 | fabric8-services/fabric8-auth | controller/resource_roles.go | HasScope | func (c *ResourceRolesController) HasScope(ctx *app.HasScopeResourceRolesContext) error {
// retrieve the current user's identity from the request token
currentIdentity, err := manager.ContextIdentity(ctx)
if err != nil {
log.Error(ctx, map[string]interface{}{
"resource_id": ctx.ResourceID,
}, "error getting ... | go | func (c *ResourceRolesController) HasScope(ctx *app.HasScopeResourceRolesContext) error {
// retrieve the current user's identity from the request token
currentIdentity, err := manager.ContextIdentity(ctx)
if err != nil {
log.Error(ctx, map[string]interface{}{
"resource_id": ctx.ResourceID,
}, "error getting ... | [
"func",
"(",
"c",
"*",
"ResourceRolesController",
")",
"HasScope",
"(",
"ctx",
"*",
"app",
".",
"HasScopeResourceRolesContext",
")",
"error",
"{",
"// retrieve the current user's identity from the request token",
"currentIdentity",
",",
"err",
":=",
"manager",
".",
"Con... | // HasScope checks if the user has the given scope in the requested resource | [
"HasScope",
"checks",
"if",
"the",
"user",
"has",
"the",
"given",
"scope",
"in",
"the",
"requested",
"resource"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/controller/resource_roles.go#L120-L151 |
150,698 | fabric8-services/fabric8-auth | wit/service/wit_service.go | NewWITService | func NewWITService(context servicecontext.ServiceContext, config wit.Configuration) service.WITService {
return &witServiceImpl{base.NewBaseService(context), config, rest.DefaultHttpDoer()}
} | go | func NewWITService(context servicecontext.ServiceContext, config wit.Configuration) service.WITService {
return &witServiceImpl{base.NewBaseService(context), config, rest.DefaultHttpDoer()}
} | [
"func",
"NewWITService",
"(",
"context",
"servicecontext",
".",
"ServiceContext",
",",
"config",
"wit",
".",
"Configuration",
")",
"service",
".",
"WITService",
"{",
"return",
"&",
"witServiceImpl",
"{",
"base",
".",
"NewBaseService",
"(",
"context",
")",
",",
... | // NewWITService creates a new WIT service. | [
"NewWITService",
"creates",
"a",
"new",
"WIT",
"service",
"."
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/wit/service/wit_service.go#L33-L35 |
150,699 | fabric8-services/fabric8-auth | wit/service/wit_service.go | UpdateUser | func (s *witServiceImpl) UpdateUser(ctx context.Context, updatePayload *app.UpdateUsersPayload, identityID string) error {
// Using the UpdateUserPayload because it also describes which attribtues are being updated and which are not.
updateUserPayload := &witservice.UpdateUserAsServiceAccountUsersPayload{
Data: &wi... | go | func (s *witServiceImpl) UpdateUser(ctx context.Context, updatePayload *app.UpdateUsersPayload, identityID string) error {
// Using the UpdateUserPayload because it also describes which attribtues are being updated and which are not.
updateUserPayload := &witservice.UpdateUserAsServiceAccountUsersPayload{
Data: &wi... | [
"func",
"(",
"s",
"*",
"witServiceImpl",
")",
"UpdateUser",
"(",
"ctx",
"context",
".",
"Context",
",",
"updatePayload",
"*",
"app",
".",
"UpdateUsersPayload",
",",
"identityID",
"string",
")",
"error",
"{",
"// Using the UpdateUserPayload because it also describes wh... | // UpdateUser updates user in WIT | [
"UpdateUser",
"updates",
"user",
"in",
"WIT"
] | 2a60f45fcdf7456553025afca28e81115285cce6 | https://github.com/fabric8-services/fabric8-auth/blob/2a60f45fcdf7456553025afca28e81115285cce6/wit/service/wit_service.go#L38-L80 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.