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 listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
125,000 | apcera/util | iprange/allocator.go | IPRange | func (a *IPRangeAllocator) IPRange() *IPRange {
a.mutex.Lock()
defer a.mutex.Unlock()
return &IPRange{
Start: a.ipRange.Start,
End: a.ipRange.End,
Mask: a.ipRange.Mask,
}
} | go | func (a *IPRangeAllocator) IPRange() *IPRange {
a.mutex.Lock()
defer a.mutex.Unlock()
return &IPRange{
Start: a.ipRange.Start,
End: a.ipRange.End,
Mask: a.ipRange.Mask,
}
} | [
"func",
"(",
"a",
"*",
"IPRangeAllocator",
")",
"IPRange",
"(",
")",
"*",
"IPRange",
"{",
"a",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"a",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
"&",
"IPRange",
"{",
"Start",
":",
"a... | // IPRange returns a copy of the IPRange provided to the allocator. | [
"IPRange",
"returns",
"a",
"copy",
"of",
"the",
"IPRange",
"provided",
"to",
"the",
"allocator",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/iprange/allocator.go#L143-L152 |
125,001 | apcera/util | iprange/allocator.go | Size | func (a *IPRangeAllocator) Size() int64 {
a.mutex.Lock()
defer a.mutex.Unlock()
return a.size
} | go | func (a *IPRangeAllocator) Size() int64 {
a.mutex.Lock()
defer a.mutex.Unlock()
return a.size
} | [
"func",
"(",
"a",
"*",
"IPRangeAllocator",
")",
"Size",
"(",
")",
"int64",
"{",
"a",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"a",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"return",
"a",
".",
"size",
"\n",
"}"
] | // Size returns the size of the allowable IP addresses specified by the range. | [
"Size",
"returns",
"the",
"size",
"of",
"the",
"allowable",
"IP",
"addresses",
"specified",
"by",
"the",
"range",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/iprange/allocator.go#L155-L159 |
125,002 | apcera/util | iprange/allocator.go | Remaining | func (a *IPRangeAllocator) Remaining() int64 {
a.mutex.Lock()
defer a.mutex.Unlock()
return a.remaining
} | go | func (a *IPRangeAllocator) Remaining() int64 {
a.mutex.Lock()
defer a.mutex.Unlock()
return a.remaining
} | [
"func",
"(",
"a",
"*",
"IPRangeAllocator",
")",
"Remaining",
"(",
")",
"int64",
"{",
"a",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"a",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"return",
"a",
".",
"remaining",
"\n",
"}"
] | // Remaining returns the number of remaining IP addresses within the provided
// range that have not been already allocated. | [
"Remaining",
"returns",
"the",
"number",
"of",
"remaining",
"IP",
"addresses",
"within",
"the",
"provided",
"range",
"that",
"have",
"not",
"been",
"already",
"allocated",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/iprange/allocator.go#L163-L167 |
125,003 | apcera/util | iprange/allocator.go | findNextAvailbleIndex | func (a *IPRangeAllocator) findNextAvailbleIndex(idx int64) int64 {
// walk up from the index
for i := idx; i < a.size; i++ {
if !a.reserved[i] {
return i
}
}
// nothing above that one... lets try to walk down to find something
for i := idx - 1; i >= 0; i-- {
if !a.reserved[i] {
return i
}
}
// o... | go | func (a *IPRangeAllocator) findNextAvailbleIndex(idx int64) int64 {
// walk up from the index
for i := idx; i < a.size; i++ {
if !a.reserved[i] {
return i
}
}
// nothing above that one... lets try to walk down to find something
for i := idx - 1; i >= 0; i-- {
if !a.reserved[i] {
return i
}
}
// o... | [
"func",
"(",
"a",
"*",
"IPRangeAllocator",
")",
"findNextAvailbleIndex",
"(",
"idx",
"int64",
")",
"int64",
"{",
"// walk up from the index",
"for",
"i",
":=",
"idx",
";",
"i",
"<",
"a",
".",
"size",
";",
"i",
"++",
"{",
"if",
"!",
"a",
".",
"reserved"... | // findNextAvailableIndex finds the value of idx which is available and not in
// the reserved list. | [
"findNextAvailableIndex",
"finds",
"the",
"value",
"of",
"idx",
"which",
"is",
"available",
"and",
"not",
"in",
"the",
"reserved",
"list",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/iprange/allocator.go#L171-L188 |
125,004 | apcera/util | terminal/terminal_state_unix.go | Isatty | func Isatty(fd uintptr) bool {
var termios syscall.Termios
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd,
uintptr(syscallGetTermios), uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
return err == 0
} | go | func Isatty(fd uintptr) bool {
var termios syscall.Termios
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd,
uintptr(syscallGetTermios), uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
return err == 0
} | [
"func",
"Isatty",
"(",
"fd",
"uintptr",
")",
"bool",
"{",
"var",
"termios",
"syscall",
".",
"Termios",
"\n\n",
"_",
",",
"_",
",",
"err",
":=",
"syscall",
".",
"Syscall6",
"(",
"syscall",
".",
"SYS_IOCTL",
",",
"fd",
",",
"uintptr",
"(",
"syscallGetTer... | // isatty checks whether FD is a tty. Doesn't work on Windows. | [
"isatty",
"checks",
"whether",
"FD",
"is",
"a",
"tty",
".",
"Doesn",
"t",
"work",
"on",
"Windows",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/terminal/terminal_state_unix.go#L20-L27 |
125,005 | apcera/util | proc/parser.go | ReadInt64 | func ReadInt64(file string) (int64, error) {
f, err := os.Open(file)
if err != nil {
return 0, err
}
defer f.Close()
buf := make([]byte, 19)
n, err := f.Read(buf)
if err != nil {
return 0, err
}
p := strings.Split(string(buf[0:n]), "\n")
v, err := strconv.ParseInt(p[0], 10, 64)
if err != nil {
return... | go | func ReadInt64(file string) (int64, error) {
f, err := os.Open(file)
if err != nil {
return 0, err
}
defer f.Close()
buf := make([]byte, 19)
n, err := f.Read(buf)
if err != nil {
return 0, err
}
p := strings.Split(string(buf[0:n]), "\n")
v, err := strconv.ParseInt(p[0], 10, 64)
if err != nil {
return... | [
"func",
"ReadInt64",
"(",
"file",
"string",
")",
"(",
"int64",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"file",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n",
"defer",
"f",
... | // ReadInt64 reads one int64 number from the first line of a file. | [
"ReadInt64",
"reads",
"one",
"int64",
"number",
"from",
"the",
"first",
"line",
"of",
"a",
"file",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/proc/parser.go#L13-L33 |
125,006 | apcera/util | proc/parser.go | ParseSimpleProcFile | func ParseSimpleProcFile(
filename string,
lf func(index int, line string) error,
ef func(line, index int, elm string) error) error {
fd, err := os.Open(filename)
if err != nil {
return err
}
defer fd.Close()
contentsBytes, err := ioutil.ReadAll(fd)
if err != nil {
return err
}
// Setup base handlers ... | go | func ParseSimpleProcFile(
filename string,
lf func(index int, line string) error,
ef func(line, index int, elm string) error) error {
fd, err := os.Open(filename)
if err != nil {
return err
}
defer fd.Close()
contentsBytes, err := ioutil.ReadAll(fd)
if err != nil {
return err
}
// Setup base handlers ... | [
"func",
"ParseSimpleProcFile",
"(",
"filename",
"string",
",",
"lf",
"func",
"(",
"index",
"int",
",",
"line",
"string",
")",
"error",
",",
"ef",
"func",
"(",
"line",
",",
"index",
"int",
",",
"elm",
"string",
")",
"error",
")",
"error",
"{",
"fd",
"... | // Parses the given file into various elements. This function assumes basic
// white space semantics (' ' and '\t' for column splitting, and '\n' for
// row splitting. | [
"Parses",
"the",
"given",
"file",
"into",
"various",
"elements",
".",
"This",
"function",
"assumes",
"basic",
"white",
"space",
"semantics",
"(",
"and",
"\\",
"t",
"for",
"column",
"splitting",
"and",
"\\",
"n",
"for",
"row",
"splitting",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/proc/parser.go#L38-L77 |
125,007 | apcera/util | timeoutwg/timeoutwg.go | Add | func (twg *TimeoutWaitGroup) Add(delta int) {
twg.mutex.Lock()
defer twg.mutex.Unlock()
if twg.workers == 0 {
// waitgroups are reusable once workers is 0
twg.last = nil
} else if twg.workers > 0 && twg.last != nil {
// This mimics normal WG behavior. Cannot add after Wait() has been
// called, unless worke... | go | func (twg *TimeoutWaitGroup) Add(delta int) {
twg.mutex.Lock()
defer twg.mutex.Unlock()
if twg.workers == 0 {
// waitgroups are reusable once workers is 0
twg.last = nil
} else if twg.workers > 0 && twg.last != nil {
// This mimics normal WG behavior. Cannot add after Wait() has been
// called, unless worke... | [
"func",
"(",
"twg",
"*",
"TimeoutWaitGroup",
")",
"Add",
"(",
"delta",
"int",
")",
"{",
"twg",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"twg",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"if",
"twg",
".",
"workers",
"==",
"0",
"{",
... | // Add increments the wait group's count of active workers by delta. | [
"Add",
"increments",
"the",
"wait",
"group",
"s",
"count",
"of",
"active",
"workers",
"by",
"delta",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/timeoutwg/timeoutwg.go#L21-L33 |
125,008 | apcera/util | timeoutwg/timeoutwg.go | Done | func (twg *TimeoutWaitGroup) Done() {
twg.mutex.Lock()
defer twg.mutex.Unlock()
twg.workers--
if twg.workers < 0 {
panic("TimeoutWaitGroup: negative counter")
}
if twg.workers == 0 && twg.last != nil {
close(twg.last)
}
} | go | func (twg *TimeoutWaitGroup) Done() {
twg.mutex.Lock()
defer twg.mutex.Unlock()
twg.workers--
if twg.workers < 0 {
panic("TimeoutWaitGroup: negative counter")
}
if twg.workers == 0 && twg.last != nil {
close(twg.last)
}
} | [
"func",
"(",
"twg",
"*",
"TimeoutWaitGroup",
")",
"Done",
"(",
")",
"{",
"twg",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"twg",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"twg",
".",
"workers",
"--",
"\n",
"if",
"twg",
".",
"workers"... | // Done decrements the wait group count by one. | [
"Done",
"decrements",
"the",
"wait",
"group",
"count",
"by",
"one",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/timeoutwg/timeoutwg.go#L36-L46 |
125,009 | apcera/util | proc/proc.go | InterfaceStats | func InterfaceStats() (map[string]InterfaceStat, error) {
ret := make(map[string]InterfaceStat, 0)
var current InterfaceStat
lastline := -1
lastindex := -1
lf := func(index int, line string) error {
if lastline == index && lastindex == 16 {
ret[current.Device] = current
}
current = InterfaceStat{}
retu... | go | func InterfaceStats() (map[string]InterfaceStat, error) {
ret := make(map[string]InterfaceStat, 0)
var current InterfaceStat
lastline := -1
lastindex := -1
lf := func(index int, line string) error {
if lastline == index && lastindex == 16 {
ret[current.Device] = current
}
current = InterfaceStat{}
retu... | [
"func",
"InterfaceStats",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"InterfaceStat",
",",
"error",
")",
"{",
"ret",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"InterfaceStat",
",",
"0",
")",
"\n",
"var",
"current",
"InterfaceStat",
"\n",
"lastline",
... | // Returns the interface statistics as a map keyed off the interface name. | [
"Returns",
"the",
"interface",
"statistics",
"as",
"a",
"map",
"keyed",
"off",
"the",
"interface",
"name",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/proc/proc.go#L103-L164 |
125,010 | apcera/util | s3util/s3util.go | NewS3Uploader | func NewS3Uploader(bucket, permission string, quiet bool) (*S3Uploader, error) {
u := &url.URL{
Scheme: scheme,
Host: fmt.Sprintf("%s.%s", bucket, S3_URL),
}
permission = strings.ToLower(permission)
if err := validatePermission(permission); err != nil {
return nil, err
}
uploader := &S3Uploader{
s3url... | go | func NewS3Uploader(bucket, permission string, quiet bool) (*S3Uploader, error) {
u := &url.URL{
Scheme: scheme,
Host: fmt.Sprintf("%s.%s", bucket, S3_URL),
}
permission = strings.ToLower(permission)
if err := validatePermission(permission); err != nil {
return nil, err
}
uploader := &S3Uploader{
s3url... | [
"func",
"NewS3Uploader",
"(",
"bucket",
",",
"permission",
"string",
",",
"quiet",
"bool",
")",
"(",
"*",
"S3Uploader",
",",
"error",
")",
"{",
"u",
":=",
"&",
"url",
".",
"URL",
"{",
"Scheme",
":",
"scheme",
",",
"Host",
":",
"fmt",
".",
"Sprintf",
... | // NewS3Uploader configures a new S3 uploader from a uri. | [
"NewS3Uploader",
"configures",
"a",
"new",
"S3",
"uploader",
"from",
"a",
"uri",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/s3util/s3util.go#L46-L67 |
125,011 | apcera/util | s3util/s3util.go | UploadToS3 | func (s *S3Uploader) UploadToS3(fPath string, buf *bytes.Buffer) error {
fmt.Fprintf(s.out, "Preparing %q for upload to s3 bucket %q...", filepath.Base(fPath), s.s3url.String())
req, err := s.buildS3Request(filepath.Base(fPath), buf)
if err != nil {
fmt.Fprintln(s.out, " error")
return err
}
fmt.Fprintln(s.ou... | go | func (s *S3Uploader) UploadToS3(fPath string, buf *bytes.Buffer) error {
fmt.Fprintf(s.out, "Preparing %q for upload to s3 bucket %q...", filepath.Base(fPath), s.s3url.String())
req, err := s.buildS3Request(filepath.Base(fPath), buf)
if err != nil {
fmt.Fprintln(s.out, " error")
return err
}
fmt.Fprintln(s.ou... | [
"func",
"(",
"s",
"*",
"S3Uploader",
")",
"UploadToS3",
"(",
"fPath",
"string",
",",
"buf",
"*",
"bytes",
".",
"Buffer",
")",
"error",
"{",
"fmt",
".",
"Fprintf",
"(",
"s",
".",
"out",
",",
"\"",
"\"",
",",
"filepath",
".",
"Base",
"(",
"fPath",
... | // UploadToS3 prepares a buffer for upload to S3. | [
"UploadToS3",
"prepares",
"a",
"buffer",
"for",
"upload",
"to",
"S3",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/s3util/s3util.go#L90-L122 |
125,012 | apcera/util | s3util/s3util.go | buildS3Request | func (s *S3Uploader) buildS3Request(fileBase string, buffer *bytes.Buffer) (*http.Request, error) {
u := &url.URL{
Scheme: s.s3url.Scheme,
Host: s.s3url.Host,
Path: fileBase,
}
// This is a PUT request containing the data buffer.
req, err := http.NewRequest("PUT", u.String(), buffer)
if err != nil {
re... | go | func (s *S3Uploader) buildS3Request(fileBase string, buffer *bytes.Buffer) (*http.Request, error) {
u := &url.URL{
Scheme: s.s3url.Scheme,
Host: s.s3url.Host,
Path: fileBase,
}
// This is a PUT request containing the data buffer.
req, err := http.NewRequest("PUT", u.String(), buffer)
if err != nil {
re... | [
"func",
"(",
"s",
"*",
"S3Uploader",
")",
"buildS3Request",
"(",
"fileBase",
"string",
",",
"buffer",
"*",
"bytes",
".",
"Buffer",
")",
"(",
"*",
"http",
".",
"Request",
",",
"error",
")",
"{",
"u",
":=",
"&",
"url",
".",
"URL",
"{",
"Scheme",
":",... | // buildS3Request constructs an http request for the upload | [
"buildS3Request",
"constructs",
"an",
"http",
"request",
"for",
"the",
"upload"
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/s3util/s3util.go#L125-L167 |
125,013 | apcera/util | s3util/s3util.go | buildAuthHeader | func (s *S3Uploader) buildAuthHeader(md5, headerTime, fileName string) (string, error) {
access, err := getAuthCredentials()
if err != nil {
return "", err
}
// Docs: http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html
verStr := fmt.Sprintf("PUT\n%s\napplication/x-gzip\n%s\nx-amz-acl:%s\n/%s"... | go | func (s *S3Uploader) buildAuthHeader(md5, headerTime, fileName string) (string, error) {
access, err := getAuthCredentials()
if err != nil {
return "", err
}
// Docs: http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html
verStr := fmt.Sprintf("PUT\n%s\napplication/x-gzip\n%s\nx-amz-acl:%s\n/%s"... | [
"func",
"(",
"s",
"*",
"S3Uploader",
")",
"buildAuthHeader",
"(",
"md5",
",",
"headerTime",
",",
"fileName",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"access",
",",
"err",
":=",
"getAuthCredentials",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil... | // buildAuthHeader builds an authorization header for S3. | [
"buildAuthHeader",
"builds",
"an",
"authorization",
"header",
"for",
"S3",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/s3util/s3util.go#L170-L181 |
125,014 | apcera/util | procstat/procstat_linux.go | GetProcessStats | func GetProcessStats(pid int) (*ProcessStats, error) {
p := &ProcessStats{}
// Load and Parse /proc/{pid}/stat to get all the data we need
filename := fmt.Sprintf("/proc/%d/stat", pid)
b, err := ioutil.ReadFile(filename)
if err != nil {
return nil, fmt.Errorf("failed to read process stats: %v", err)
}
fields ... | go | func GetProcessStats(pid int) (*ProcessStats, error) {
p := &ProcessStats{}
// Load and Parse /proc/{pid}/stat to get all the data we need
filename := fmt.Sprintf("/proc/%d/stat", pid)
b, err := ioutil.ReadFile(filename)
if err != nil {
return nil, fmt.Errorf("failed to read process stats: %v", err)
}
fields ... | [
"func",
"GetProcessStats",
"(",
"pid",
"int",
")",
"(",
"*",
"ProcessStats",
",",
"error",
")",
"{",
"p",
":=",
"&",
"ProcessStats",
"{",
"}",
"\n\n",
"// Load and Parse /proc/{pid}/stat to get all the data we need",
"filename",
":=",
"fmt",
".",
"Sprintf",
"(",
... | // GetProcessStats will return the ProcessStats object associated with the given
// PID. If it fails to load the stats, then it will return an error. | [
"GetProcessStats",
"will",
"return",
"the",
"ProcessStats",
"object",
"associated",
"with",
"the",
"given",
"PID",
".",
"If",
"it",
"fails",
"to",
"load",
"the",
"stats",
"then",
"it",
"will",
"return",
"an",
"error",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/procstat/procstat_linux.go#L25-L59 |
125,015 | apcera/util | procstat/procstat_linux.go | sum | func sum(s ...string) (int64, error) {
var total int64
for _, v := range s {
i, err := strconv.ParseInt(v, 10, 64)
if err != nil {
return 0, err
}
total += i
}
return total, nil
} | go | func sum(s ...string) (int64, error) {
var total int64
for _, v := range s {
i, err := strconv.ParseInt(v, 10, 64)
if err != nil {
return 0, err
}
total += i
}
return total, nil
} | [
"func",
"sum",
"(",
"s",
"...",
"string",
")",
"(",
"int64",
",",
"error",
")",
"{",
"var",
"total",
"int64",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"s",
"{",
"i",
",",
"err",
":=",
"strconv",
".",
"ParseInt",
"(",
"v",
",",
"10",
",",
"6... | // sum will convert the list of strings into int64s and total them together. | [
"sum",
"will",
"convert",
"the",
"list",
"of",
"strings",
"into",
"int64s",
"and",
"total",
"them",
"together",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/procstat/procstat_linux.go#L62-L72 |
125,016 | apcera/util | hashutil/sha256util.go | IsSha256Valid | func IsSha256Valid(s string) bool {
if len(s) != 64 {
return false
}
b, err := hex.DecodeString(s)
if err != nil {
return false
}
if len(b) != 32 {
return false
}
return true
} | go | func IsSha256Valid(s string) bool {
if len(s) != 64 {
return false
}
b, err := hex.DecodeString(s)
if err != nil {
return false
}
if len(b) != 32 {
return false
}
return true
} | [
"func",
"IsSha256Valid",
"(",
"s",
"string",
")",
"bool",
"{",
"if",
"len",
"(",
"s",
")",
"!=",
"64",
"{",
"return",
"false",
"\n",
"}",
"\n",
"b",
",",
"err",
":=",
"hex",
".",
"DecodeString",
"(",
"s",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{... | // Simple function that allows verification that a string is in fact a valid
// SHA256 formated string. | [
"Simple",
"function",
"that",
"allows",
"verification",
"that",
"a",
"string",
"is",
"in",
"fact",
"a",
"valid",
"SHA256",
"formated",
"string",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/hashutil/sha256util.go#L13-L25 |
125,017 | apcera/util | hashutil/sha256util.go | NewSha256 | func NewSha256(r io.Reader) *Sha256Reader {
s := new(Sha256Reader)
s.hashReader = newHashReader(sha256.New(), r)
return s
} | go | func NewSha256(r io.Reader) *Sha256Reader {
s := new(Sha256Reader)
s.hashReader = newHashReader(sha256.New(), r)
return s
} | [
"func",
"NewSha256",
"(",
"r",
"io",
".",
"Reader",
")",
"*",
"Sha256Reader",
"{",
"s",
":=",
"new",
"(",
"Sha256Reader",
")",
"\n",
"s",
".",
"hashReader",
"=",
"newHashReader",
"(",
"sha256",
".",
"New",
"(",
")",
",",
"r",
")",
"\n",
"return",
"... | // Returns a new Sha256Reader. | [
"Returns",
"a",
"new",
"Sha256Reader",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/hashutil/sha256util.go#L34-L38 |
125,018 | apcera/util | hashutil/sha256util.go | Sha256 | func (s *Sha256Reader) Sha256() string {
return hex.EncodeToString(s.hash.Sum(nil))
} | go | func (s *Sha256Reader) Sha256() string {
return hex.EncodeToString(s.hash.Sum(nil))
} | [
"func",
"(",
"s",
"*",
"Sha256Reader",
")",
"Sha256",
"(",
")",
"string",
"{",
"return",
"hex",
".",
"EncodeToString",
"(",
"s",
".",
"hash",
".",
"Sum",
"(",
"nil",
")",
")",
"\n",
"}"
] | // Returns the SHA256 for all data that has been passed through this Reader
// already. This should ideally be called after the Reader is Closed, but
// otherwise its safe to call any time. | [
"Returns",
"the",
"SHA256",
"for",
"all",
"data",
"that",
"has",
"been",
"passed",
"through",
"this",
"Reader",
"already",
".",
"This",
"should",
"ideally",
"be",
"called",
"after",
"the",
"Reader",
"is",
"Closed",
"but",
"otherwise",
"its",
"safe",
"to",
... | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/hashutil/sha256util.go#L43-L45 |
125,019 | apcera/util | wsconn/websocket_connection.go | NewWebsocketConnection | func NewWebsocketConnection(ws Conn) net.Conn {
wsconn := &WebsocketConnection{
ws: ws,
readTimeout: 60 * time.Second,
writeTimeout: 10 * time.Second,
pingInterval: 10 * time.Second,
closedChan: make(chan bool),
textChan: make(chan []byte, 100),
}
wsconn.startPingInterval()
return wscon... | go | func NewWebsocketConnection(ws Conn) net.Conn {
wsconn := &WebsocketConnection{
ws: ws,
readTimeout: 60 * time.Second,
writeTimeout: 10 * time.Second,
pingInterval: 10 * time.Second,
closedChan: make(chan bool),
textChan: make(chan []byte, 100),
}
wsconn.startPingInterval()
return wscon... | [
"func",
"NewWebsocketConnection",
"(",
"ws",
"Conn",
")",
"net",
".",
"Conn",
"{",
"wsconn",
":=",
"&",
"WebsocketConnection",
"{",
"ws",
":",
"ws",
",",
"readTimeout",
":",
"60",
"*",
"time",
".",
"Second",
",",
"writeTimeout",
":",
"10",
"*",
"time",
... | // Returns a websocket connection wrapper to the net.Conn interface. | [
"Returns",
"a",
"websocket",
"connection",
"wrapper",
"to",
"the",
"net",
".",
"Conn",
"interface",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/wsconn/websocket_connection.go#L32-L43 |
125,020 | apcera/util | wsconn/websocket_connection.go | startPingInterval | func (conn *WebsocketConnection) startPingInterval() {
go func() {
for {
select {
case <-conn.closedChan:
return
case <-time.After(conn.pingInterval):
func() {
conn.writeMutex.Lock()
defer conn.writeMutex.Unlock()
conn.ws.WriteControl(websocket.PingMessage, []byte{}, time.Now().Add(co... | go | func (conn *WebsocketConnection) startPingInterval() {
go func() {
for {
select {
case <-conn.closedChan:
return
case <-time.After(conn.pingInterval):
func() {
conn.writeMutex.Lock()
defer conn.writeMutex.Unlock()
conn.ws.WriteControl(websocket.PingMessage, []byte{}, time.Now().Add(co... | [
"func",
"(",
"conn",
"*",
"WebsocketConnection",
")",
"startPingInterval",
"(",
")",
"{",
"go",
"func",
"(",
")",
"{",
"for",
"{",
"select",
"{",
"case",
"<-",
"conn",
".",
"closedChan",
":",
"return",
"\n",
"case",
"<-",
"time",
".",
"After",
"(",
"... | // Begins a goroutine to send a periodic ping to the other end | [
"Begins",
"a",
"goroutine",
"to",
"send",
"a",
"periodic",
"ping",
"to",
"the",
"other",
"end"
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/wsconn/websocket_connection.go#L59-L74 |
125,021 | apcera/util | wsconn/websocket_connection.go | waitForReader | func (conn *WebsocketConnection) waitForReader() error {
// no existing readers, wait for one
for {
opCode, reader, err := conn.ws.NextReader()
if err != nil {
return err
}
switch opCode {
case websocket.BinaryMessage:
// binary packet
conn.reader = reader
return nil
case websocket.TextMessa... | go | func (conn *WebsocketConnection) waitForReader() error {
// no existing readers, wait for one
for {
opCode, reader, err := conn.ws.NextReader()
if err != nil {
return err
}
switch opCode {
case websocket.BinaryMessage:
// binary packet
conn.reader = reader
return nil
case websocket.TextMessa... | [
"func",
"(",
"conn",
"*",
"WebsocketConnection",
")",
"waitForReader",
"(",
")",
"error",
"{",
"// no existing readers, wait for one",
"for",
"{",
"opCode",
",",
"reader",
",",
"err",
":=",
"conn",
".",
"ws",
".",
"NextReader",
"(",
")",
"\n",
"if",
"err",
... | // This method loops until a binary opcode comes in and returns its reader.
// While looping it will receive and process other opcodes, such as pings. | [
"This",
"method",
"loops",
"until",
"a",
"binary",
"opcode",
"comes",
"in",
"and",
"returns",
"its",
"reader",
".",
"While",
"looping",
"it",
"will",
"receive",
"and",
"process",
"other",
"opcodes",
"such",
"as",
"pings",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/wsconn/websocket_connection.go#L78-L116 |
125,022 | apcera/util | wsconn/websocket_connection.go | Read | func (conn *WebsocketConnection) Read(b []byte) (n int, err error) {
if conn.reader == nil {
err = conn.waitForReader()
if err != nil {
return
}
}
rn, rerr := conn.reader.Read(b)
switch rerr {
case io.EOF:
conn.reader = nil
default:
n, err = rn, rerr
}
return
} | go | func (conn *WebsocketConnection) Read(b []byte) (n int, err error) {
if conn.reader == nil {
err = conn.waitForReader()
if err != nil {
return
}
}
rn, rerr := conn.reader.Read(b)
switch rerr {
case io.EOF:
conn.reader = nil
default:
n, err = rn, rerr
}
return
} | [
"func",
"(",
"conn",
"*",
"WebsocketConnection",
")",
"Read",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"if",
"conn",
".",
"reader",
"==",
"nil",
"{",
"err",
"=",
"conn",
".",
"waitForReader",
"(",
")",
"\n"... | // Reads slice of bytes off of the websocket connection. | [
"Reads",
"slice",
"of",
"bytes",
"off",
"of",
"the",
"websocket",
"connection",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/wsconn/websocket_connection.go#L125-L141 |
125,023 | apcera/util | wsconn/websocket_connection.go | Write | func (conn *WebsocketConnection) Write(b []byte) (n int, err error) {
conn.writeMutex.Lock()
defer conn.writeMutex.Unlock()
// allocate a writer
var writer io.WriteCloser
writer, err = conn.ws.NextWriter(websocket.BinaryMessage)
if err != nil {
return
}
// write
n, err = writer.Write(b)
if err != nil {
... | go | func (conn *WebsocketConnection) Write(b []byte) (n int, err error) {
conn.writeMutex.Lock()
defer conn.writeMutex.Unlock()
// allocate a writer
var writer io.WriteCloser
writer, err = conn.ws.NextWriter(websocket.BinaryMessage)
if err != nil {
return
}
// write
n, err = writer.Write(b)
if err != nil {
... | [
"func",
"(",
"conn",
"*",
"WebsocketConnection",
")",
"Write",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"conn",
".",
"writeMutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"conn",
".",
"writeMutex",
".",
"Unlock... | // Writes the given bytes as a binary opcode segment onto the websocket. | [
"Writes",
"the",
"given",
"bytes",
"as",
"a",
"binary",
"opcode",
"segment",
"onto",
"the",
"websocket",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/wsconn/websocket_connection.go#L144-L164 |
125,024 | apcera/util | wsconn/websocket_connection.go | Close | func (conn *WebsocketConnection) Close() error {
defer close(conn.closedChan)
defer close(conn.textChan)
return conn.ws.Close()
} | go | func (conn *WebsocketConnection) Close() error {
defer close(conn.closedChan)
defer close(conn.textChan)
return conn.ws.Close()
} | [
"func",
"(",
"conn",
"*",
"WebsocketConnection",
")",
"Close",
"(",
")",
"error",
"{",
"defer",
"close",
"(",
"conn",
".",
"closedChan",
")",
"\n",
"defer",
"close",
"(",
"conn",
".",
"textChan",
")",
"\n",
"return",
"conn",
".",
"ws",
".",
"Close",
... | // Closes the connection and exits from the ping loop. | [
"Closes",
"the",
"connection",
"and",
"exits",
"from",
"the",
"ping",
"loop",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/wsconn/websocket_connection.go#L167-L171 |
125,025 | apcera/util | wsconn/websocket_connection.go | SetDeadline | func (conn *WebsocketConnection) SetDeadline(t time.Time) error {
if err := conn.ws.SetReadDeadline(t); err != nil {
return err
}
return conn.ws.SetWriteDeadline(t)
} | go | func (conn *WebsocketConnection) SetDeadline(t time.Time) error {
if err := conn.ws.SetReadDeadline(t); err != nil {
return err
}
return conn.ws.SetWriteDeadline(t)
} | [
"func",
"(",
"conn",
"*",
"WebsocketConnection",
")",
"SetDeadline",
"(",
"t",
"time",
".",
"Time",
")",
"error",
"{",
"if",
"err",
":=",
"conn",
".",
"ws",
".",
"SetReadDeadline",
"(",
"t",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
... | // SetDeadline the read and write deadlines associated with the connection. | [
"SetDeadline",
"the",
"read",
"and",
"write",
"deadlines",
"associated",
"with",
"the",
"connection",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/wsconn/websocket_connection.go#L184-L189 |
125,026 | apcera/util | wsconn/websocket_connection.go | SetReadDeadline | func (conn *WebsocketConnection) SetReadDeadline(t time.Time) error {
return conn.ws.SetReadDeadline(t)
} | go | func (conn *WebsocketConnection) SetReadDeadline(t time.Time) error {
return conn.ws.SetReadDeadline(t)
} | [
"func",
"(",
"conn",
"*",
"WebsocketConnection",
")",
"SetReadDeadline",
"(",
"t",
"time",
".",
"Time",
")",
"error",
"{",
"return",
"conn",
".",
"ws",
".",
"SetReadDeadline",
"(",
"t",
")",
"\n",
"}"
] | // SetReadDeadline sets the read deadline associated with the connection. | [
"SetReadDeadline",
"sets",
"the",
"read",
"deadline",
"associated",
"with",
"the",
"connection",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/wsconn/websocket_connection.go#L192-L194 |
125,027 | apcera/util | wsconn/websocket_connection.go | SetWriteDeadline | func (conn *WebsocketConnection) SetWriteDeadline(t time.Time) error {
return conn.ws.SetWriteDeadline(t)
} | go | func (conn *WebsocketConnection) SetWriteDeadline(t time.Time) error {
return conn.ws.SetWriteDeadline(t)
} | [
"func",
"(",
"conn",
"*",
"WebsocketConnection",
")",
"SetWriteDeadline",
"(",
"t",
"time",
".",
"Time",
")",
"error",
"{",
"return",
"conn",
".",
"ws",
".",
"SetWriteDeadline",
"(",
"t",
")",
"\n",
"}"
] | // SetWriteDeadline sets the write deadline assocated with the connection. | [
"SetWriteDeadline",
"sets",
"the",
"write",
"deadline",
"assocated",
"with",
"the",
"connection",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/wsconn/websocket_connection.go#L197-L199 |
125,028 | apcera/util | s3util/packaging_util.go | Zipper | func Zipper(zipPath string) (*bytes.Buffer, error) {
f, err := os.Open(zipPath)
if err != nil {
return nil, err
}
defer f.Close()
buffer := bytes.NewBuffer(nil)
w := zip.NewWriter(buffer)
fh := zip.FileHeader{}
fh.Name = filepath.Base(zipPath)
fh.SetMode(0755)
// Add some files to the archive.
var files ... | go | func Zipper(zipPath string) (*bytes.Buffer, error) {
f, err := os.Open(zipPath)
if err != nil {
return nil, err
}
defer f.Close()
buffer := bytes.NewBuffer(nil)
w := zip.NewWriter(buffer)
fh := zip.FileHeader{}
fh.Name = filepath.Base(zipPath)
fh.SetMode(0755)
// Add some files to the archive.
var files ... | [
"func",
"Zipper",
"(",
"zipPath",
"string",
")",
"(",
"*",
"bytes",
".",
"Buffer",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"zipPath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}... | // Zipper zips file contents at a path. Helper to prepare zipped data for upload
// to S3. | [
"Zipper",
"zips",
"file",
"contents",
"at",
"a",
"path",
".",
"Helper",
"to",
"prepare",
"zipped",
"data",
"for",
"upload",
"to",
"S3",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/s3util/packaging_util.go#L17-L62 |
125,029 | apcera/util | s3util/packaging_util.go | Gzipper | func Gzipper(gzipPath string) (*bytes.Buffer, error) {
f, err := os.Open(gzipPath)
if err != nil {
return nil, err
}
defer f.Close()
// Gzip the binary data and toss it in a buffer.
buffer := bytes.NewBuffer(nil)
gzipData := gzip.NewWriter(buffer)
gzipData.Header.Name = filepath.Base(gzipPath)
gzipData.Head... | go | func Gzipper(gzipPath string) (*bytes.Buffer, error) {
f, err := os.Open(gzipPath)
if err != nil {
return nil, err
}
defer f.Close()
// Gzip the binary data and toss it in a buffer.
buffer := bytes.NewBuffer(nil)
gzipData := gzip.NewWriter(buffer)
gzipData.Header.Name = filepath.Base(gzipPath)
gzipData.Head... | [
"func",
"Gzipper",
"(",
"gzipPath",
"string",
")",
"(",
"*",
"bytes",
".",
"Buffer",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"gzipPath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
... | // Gzipper gzips the file at the path. Helper to prepare gzipped data for upload
// to S3. | [
"Gzipper",
"gzips",
"the",
"file",
"at",
"the",
"path",
".",
"Helper",
"to",
"prepare",
"gzipped",
"data",
"for",
"upload",
"to",
"S3",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/s3util/packaging_util.go#L66-L85 |
125,030 | apcera/util | tarhelper/tar.go | NewTar | func NewTar(w io.Writer, targetDir string) *Tar {
return &Tar{
target: targetDir,
dest: w,
hardLinks: make(map[uint64]string),
IncludePermissions: true,
IncludeOwners: false,
OwnerMappingFunc: defaultMappingFunc,
GroupMappingFunc: defaultMappingFunc,
}
} | go | func NewTar(w io.Writer, targetDir string) *Tar {
return &Tar{
target: targetDir,
dest: w,
hardLinks: make(map[uint64]string),
IncludePermissions: true,
IncludeOwners: false,
OwnerMappingFunc: defaultMappingFunc,
GroupMappingFunc: defaultMappingFunc,
}
} | [
"func",
"NewTar",
"(",
"w",
"io",
".",
"Writer",
",",
"targetDir",
"string",
")",
"*",
"Tar",
"{",
"return",
"&",
"Tar",
"{",
"target",
":",
"targetDir",
",",
"dest",
":",
"w",
",",
"hardLinks",
":",
"make",
"(",
"map",
"[",
"uint64",
"]",
"string"... | // NewTar returns a Tar ready to write the contents of targetDir to w. | [
"NewTar",
"returns",
"a",
"Tar",
"ready",
"to",
"write",
"the",
"contents",
"of",
"targetDir",
"to",
"w",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/tarhelper/tar.go#L158-L168 |
125,031 | apcera/util | tarhelper/tar.go | IncludeRegexp | func (t *Tar) IncludeRegexp(re *regexp.Regexp, dirOnly bool) {
t.ignorePaths = append(t.ignorePaths, ignoreInfo{regexp: re, exclude: false, dirOnly: dirOnly})
} | go | func (t *Tar) IncludeRegexp(re *regexp.Regexp, dirOnly bool) {
t.ignorePaths = append(t.ignorePaths, ignoreInfo{regexp: re, exclude: false, dirOnly: dirOnly})
} | [
"func",
"(",
"t",
"*",
"Tar",
")",
"IncludeRegexp",
"(",
"re",
"*",
"regexp",
".",
"Regexp",
",",
"dirOnly",
"bool",
")",
"{",
"t",
".",
"ignorePaths",
"=",
"append",
"(",
"t",
".",
"ignorePaths",
",",
"ignoreInfo",
"{",
"regexp",
":",
"re",
",",
"... | // IncludeRegexp adds a Regexp into the list to consider when selectiong files
// to exclude. Files or directories matching the regexp will _not_ be excluded,
// even if they matched a previous Regexp. Files are only considered a match if
// they match the Regexp and isDir is false. | [
"IncludeRegexp",
"adds",
"a",
"Regexp",
"into",
"the",
"list",
"to",
"consider",
"when",
"selectiong",
"files",
"to",
"exclude",
".",
"Files",
"or",
"directories",
"matching",
"the",
"regexp",
"will",
"_not_",
"be",
"excluded",
"even",
"if",
"they",
"matched",... | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/tarhelper/tar.go#L264-L266 |
125,032 | apcera/util | tarhelper/tar.go | ExcludeRegexp | func (t *Tar) ExcludeRegexp(re *regexp.Regexp, dirOnly bool) {
t.ignorePaths = append(t.ignorePaths, ignoreInfo{regexp: re, exclude: true, dirOnly: dirOnly})
} | go | func (t *Tar) ExcludeRegexp(re *regexp.Regexp, dirOnly bool) {
t.ignorePaths = append(t.ignorePaths, ignoreInfo{regexp: re, exclude: true, dirOnly: dirOnly})
} | [
"func",
"(",
"t",
"*",
"Tar",
")",
"ExcludeRegexp",
"(",
"re",
"*",
"regexp",
".",
"Regexp",
",",
"dirOnly",
"bool",
")",
"{",
"t",
".",
"ignorePaths",
"=",
"append",
"(",
"t",
".",
"ignorePaths",
",",
"ignoreInfo",
"{",
"regexp",
":",
"re",
",",
"... | // ExcludeRegexp adds a Regexp into the list to consider when selectiong files
// to exclude. Files or directories matching the regexp will be excluded, even
// if they matched a previous Regexp from IncludeRegexp. Files are only
// considered a match if they match the Regexp and isDir is false. | [
"ExcludeRegexp",
"adds",
"a",
"Regexp",
"into",
"the",
"list",
"to",
"consider",
"when",
"selectiong",
"files",
"to",
"exclude",
".",
"Files",
"or",
"directories",
"matching",
"the",
"regexp",
"will",
"be",
"excluded",
"even",
"if",
"they",
"matched",
"a",
"... | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/tarhelper/tar.go#L272-L274 |
125,033 | apcera/util | tarhelper/tar.go | shouldBeExcluded | func (t *Tar) shouldBeExcluded(name string, isDir bool) bool {
name = filepath.ToSlash(filepath.Clean(name))
var exclude bool
for _, re := range t.ignorePaths {
if re.regexp.MatchString(name) || re.regexp.MatchString(filepath.Base(name)) {
if !re.dirOnly || (re.dirOnly && isDir) {
exclude = re.exclude
}
... | go | func (t *Tar) shouldBeExcluded(name string, isDir bool) bool {
name = filepath.ToSlash(filepath.Clean(name))
var exclude bool
for _, re := range t.ignorePaths {
if re.regexp.MatchString(name) || re.regexp.MatchString(filepath.Base(name)) {
if !re.dirOnly || (re.dirOnly && isDir) {
exclude = re.exclude
}
... | [
"func",
"(",
"t",
"*",
"Tar",
")",
"shouldBeExcluded",
"(",
"name",
"string",
",",
"isDir",
"bool",
")",
"bool",
"{",
"name",
"=",
"filepath",
".",
"ToSlash",
"(",
"filepath",
".",
"Clean",
"(",
"name",
")",
")",
"\n",
"var",
"exclude",
"bool",
"\n",... | // shouldBeExcluded determines if supplied name is contained in the slice of
// files to exclude. ignorePaths are considered in order so that files excluded
// by one criteria can be reincluded by a later one. | [
"shouldBeExcluded",
"determines",
"if",
"supplied",
"name",
"is",
"contained",
"in",
"the",
"slice",
"of",
"files",
"to",
"exclude",
".",
"ignorePaths",
"are",
"considered",
"in",
"order",
"so",
"that",
"files",
"excluded",
"by",
"one",
"criteria",
"can",
"be"... | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/tarhelper/tar.go#L558-L570 |
125,034 | apcera/util | tarhelper/tar.go | excludeRootPath | func (t *Tar) excludeRootPath(headerName string) bool {
if t.ExcludeRootPath && headerName == "./" {
return true
}
return false
} | go | func (t *Tar) excludeRootPath(headerName string) bool {
if t.ExcludeRootPath && headerName == "./" {
return true
}
return false
} | [
"func",
"(",
"t",
"*",
"Tar",
")",
"excludeRootPath",
"(",
"headerName",
"string",
")",
"bool",
"{",
"if",
"t",
".",
"ExcludeRootPath",
"&&",
"headerName",
"==",
"\"",
"\"",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
] | // excludeRootPath determines if the path is the root path and should be
// excluded. | [
"excludeRootPath",
"determines",
"if",
"the",
"path",
"is",
"the",
"root",
"path",
"and",
"should",
"be",
"excluded",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/tarhelper/tar.go#L574-L580 |
125,035 | apcera/util | tarhelper/untar.go | checkName | func checkName(name string) error {
if len(name) == 0 {
return fmt.Errorf("No name given for tar element.")
}
comp := strings.Split(name, string(os.PathSeparator))
if len(comp) > 0 && comp[0] == "" {
return fmt.Errorf("No absolute paths allowed.")
}
for i, c := range comp {
switch {
case c == "" && i != l... | go | func checkName(name string) error {
if len(name) == 0 {
return fmt.Errorf("No name given for tar element.")
}
comp := strings.Split(name, string(os.PathSeparator))
if len(comp) > 0 && comp[0] == "" {
return fmt.Errorf("No absolute paths allowed.")
}
for i, c := range comp {
switch {
case c == "" && i != l... | [
"func",
"checkName",
"(",
"name",
"string",
")",
"error",
"{",
"if",
"len",
"(",
"name",
")",
"==",
"0",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"comp",
":=",
"strings",
".",
"Split",
"(",
"name",
",",
"string"... | // Checks the security of the given name. Anything that looks
// fishy will be rejected. | [
"Checks",
"the",
"security",
"of",
"the",
"given",
"name",
".",
"Anything",
"that",
"looks",
"fishy",
"will",
"be",
"rejected",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/tarhelper/untar.go#L227-L246 |
125,036 | apcera/util | tarhelper/untar.go | checkLinkName | func checkLinkName(dest, src, targetBase string) error {
if len(dest) == 0 {
return fmt.Errorf("No name given for tar element.")
}
return nil
} | go | func checkLinkName(dest, src, targetBase string) error {
if len(dest) == 0 {
return fmt.Errorf("No name given for tar element.")
}
return nil
} | [
"func",
"checkLinkName",
"(",
"dest",
",",
"src",
",",
"targetBase",
"string",
")",
"error",
"{",
"if",
"len",
"(",
"dest",
")",
"==",
"0",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Checks the security of the given link name. Anything that looks fishy
// will be rejected. | [
"Checks",
"the",
"security",
"of",
"the",
"given",
"link",
"name",
".",
"Anything",
"that",
"looks",
"fishy",
"will",
"be",
"rejected",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/tarhelper/untar.go#L250-L255 |
125,037 | apcera/util | tarhelper/untar.go | checkEntryAgainstWhitelist | func (u *Untar) checkEntryAgainstWhitelist(header *tar.Header) bool {
if len(u.PathWhitelist) == 0 {
return true
}
name := "/" + filepath.Clean(header.Name)
for _, p := range u.PathWhitelist {
// Whitelist: "/foo" File: "/foo"
if p == name {
return true
}
if strings.HasSuffix(p, "/") {
// Whitel... | go | func (u *Untar) checkEntryAgainstWhitelist(header *tar.Header) bool {
if len(u.PathWhitelist) == 0 {
return true
}
name := "/" + filepath.Clean(header.Name)
for _, p := range u.PathWhitelist {
// Whitelist: "/foo" File: "/foo"
if p == name {
return true
}
if strings.HasSuffix(p, "/") {
// Whitel... | [
"func",
"(",
"u",
"*",
"Untar",
")",
"checkEntryAgainstWhitelist",
"(",
"header",
"*",
"tar",
".",
"Header",
")",
"bool",
"{",
"if",
"len",
"(",
"u",
".",
"PathWhitelist",
")",
"==",
"0",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"name",
":=",
"\"",
... | // checkEntryAgainstWhitelist will check if the specified file should be allowed
// to be extracted against the current PathWhitelist. If no PathWhitelist is
// allowed, then it will allow all files. | [
"checkEntryAgainstWhitelist",
"will",
"check",
"if",
"the",
"specified",
"file",
"should",
"be",
"allowed",
"to",
"be",
"extracted",
"against",
"the",
"current",
"PathWhitelist",
".",
"If",
"no",
"PathWhitelist",
"is",
"allowed",
"then",
"it",
"will",
"allow",
"... | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/tarhelper/untar.go#L650-L677 |
125,038 | apcera/util | hashutil/sha512util.go | NewSha512 | func NewSha512(r io.Reader) *Sha512Reader {
s := new(Sha512Reader)
s.hashReader = newHashReader(sha512.New(), r)
return s
} | go | func NewSha512(r io.Reader) *Sha512Reader {
s := new(Sha512Reader)
s.hashReader = newHashReader(sha512.New(), r)
return s
} | [
"func",
"NewSha512",
"(",
"r",
"io",
".",
"Reader",
")",
"*",
"Sha512Reader",
"{",
"s",
":=",
"new",
"(",
"Sha512Reader",
")",
"\n",
"s",
".",
"hashReader",
"=",
"newHashReader",
"(",
"sha512",
".",
"New",
"(",
")",
",",
"r",
")",
"\n",
"return",
"... | // Returns a new Sha512Reader. | [
"Returns",
"a",
"new",
"Sha512Reader",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/hashutil/sha512util.go#L34-L38 |
125,039 | apcera/util | hashutil/sha512util.go | Sha512 | func (s *Sha512Reader) Sha512() string {
return hex.EncodeToString(s.hash.Sum(nil))
} | go | func (s *Sha512Reader) Sha512() string {
return hex.EncodeToString(s.hash.Sum(nil))
} | [
"func",
"(",
"s",
"*",
"Sha512Reader",
")",
"Sha512",
"(",
")",
"string",
"{",
"return",
"hex",
".",
"EncodeToString",
"(",
"s",
".",
"hash",
".",
"Sum",
"(",
"nil",
")",
")",
"\n",
"}"
] | // Returns the SHA512 for all data that has been passed through this Reader
// already. This should ideally be called after the Reader is Closed, but
// otherwise its safe to call any time. | [
"Returns",
"the",
"SHA512",
"for",
"all",
"data",
"that",
"has",
"been",
"passed",
"through",
"this",
"Reader",
"already",
".",
"This",
"should",
"ideally",
"be",
"called",
"after",
"the",
"Reader",
"is",
"Closed",
"but",
"otherwise",
"its",
"safe",
"to",
... | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/hashutil/sha512util.go#L43-L45 |
125,040 | apcera/util | hashutil/md5util.go | NewMd5 | func NewMd5(r io.Reader) *Md5Reader {
m := &Md5Reader{}
m.hashReader = newHashReader(md5.New(), r)
return m
} | go | func NewMd5(r io.Reader) *Md5Reader {
m := &Md5Reader{}
m.hashReader = newHashReader(md5.New(), r)
return m
} | [
"func",
"NewMd5",
"(",
"r",
"io",
".",
"Reader",
")",
"*",
"Md5Reader",
"{",
"m",
":=",
"&",
"Md5Reader",
"{",
"}",
"\n",
"m",
".",
"hashReader",
"=",
"newHashReader",
"(",
"md5",
".",
"New",
"(",
")",
",",
"r",
")",
"\n",
"return",
"m",
"\n",
... | // Returns a new Md5Reader. | [
"Returns",
"a",
"new",
"Md5Reader",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/hashutil/md5util.go#L34-L38 |
125,041 | apcera/util | hashutil/md5util.go | Md5 | func (m *Md5Reader) Md5() string {
return hex.EncodeToString(m.hash.Sum(nil))
} | go | func (m *Md5Reader) Md5() string {
return hex.EncodeToString(m.hash.Sum(nil))
} | [
"func",
"(",
"m",
"*",
"Md5Reader",
")",
"Md5",
"(",
")",
"string",
"{",
"return",
"hex",
".",
"EncodeToString",
"(",
"m",
".",
"hash",
".",
"Sum",
"(",
"nil",
")",
")",
"\n",
"}"
] | // Returns the MD5 for all data that has been passed through this Reader
// already. This should ideally be called after the Reader is Closed, but
// otherwise its safe to call any time. | [
"Returns",
"the",
"MD5",
"for",
"all",
"data",
"that",
"has",
"been",
"passed",
"through",
"this",
"Reader",
"already",
".",
"This",
"should",
"ideally",
"be",
"called",
"after",
"the",
"Reader",
"is",
"Closed",
"but",
"otherwise",
"its",
"safe",
"to",
"ca... | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/hashutil/md5util.go#L43-L45 |
125,042 | apcera/util | tempfile/tempfile.go | New | func New(r io.Reader) (ReadSeekCloser, error) {
tf, err := ioutil.TempFile(os.TempDir(), "temporary-file")
if err != nil {
return nil, err
}
f := &unlinkOnCloseFile{tf}
successful := false
defer func() {
if !successful {
f.Close()
}
}()
if _, err := io.Copy(f, r); err != nil {
return nil, err
}
i... | go | func New(r io.Reader) (ReadSeekCloser, error) {
tf, err := ioutil.TempFile(os.TempDir(), "temporary-file")
if err != nil {
return nil, err
}
f := &unlinkOnCloseFile{tf}
successful := false
defer func() {
if !successful {
f.Close()
}
}()
if _, err := io.Copy(f, r); err != nil {
return nil, err
}
i... | [
"func",
"New",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"ReadSeekCloser",
",",
"error",
")",
"{",
"tf",
",",
"err",
":=",
"ioutil",
".",
"TempFile",
"(",
"os",
".",
"TempDir",
"(",
")",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",... | // New will take in a io.Reader and write its content to a new temporary
// file. The temporary file will be automatically removed when it closed. | [
"New",
"will",
"take",
"in",
"a",
"io",
".",
"Reader",
"and",
"write",
"its",
"content",
"to",
"a",
"new",
"temporary",
"file",
".",
"The",
"temporary",
"file",
"will",
"be",
"automatically",
"removed",
"when",
"it",
"closed",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/tempfile/tempfile.go#L32-L54 |
125,043 | apcera/util | spawn/spawn.go | loadConfig | func loadConfig(configFile string) ([][]string, error) {
f, err := os.Open(configFile)
if err != nil {
return nil, err
}
defer f.Close()
var config [][]string
if err := json.NewDecoder(f).Decode(&config); err != nil {
return nil, err
}
return config, nil
} | go | func loadConfig(configFile string) ([][]string, error) {
f, err := os.Open(configFile)
if err != nil {
return nil, err
}
defer f.Close()
var config [][]string
if err := json.NewDecoder(f).Decode(&config); err != nil {
return nil, err
}
return config, nil
} | [
"func",
"loadConfig",
"(",
"configFile",
"string",
")",
"(",
"[",
"]",
"[",
"]",
"string",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"configFile",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",... | // loadConfig handles loading specified configuration file and returning it. | [
"loadConfig",
"handles",
"loading",
"specified",
"configuration",
"file",
"and",
"returning",
"it",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/spawn/spawn.go#L130-L142 |
125,044 | apcera/util | events/stream.go | StreamEvents | func (e *EventClient) StreamEvents(w io.Writer, streamFQN string, timeout time.Duration) error {
timeoutTicker := time.NewTimer(timeout).C
handleEventStream := func(args []interface{}, kwargs map[string]interface{}) {
event := args[0].(map[string]interface{})
output := fmt.Sprintf("FQN: %q, Source: %s, Time: %b... | go | func (e *EventClient) StreamEvents(w io.Writer, streamFQN string, timeout time.Duration) error {
timeoutTicker := time.NewTimer(timeout).C
handleEventStream := func(args []interface{}, kwargs map[string]interface{}) {
event := args[0].(map[string]interface{})
output := fmt.Sprintf("FQN: %q, Source: %s, Time: %b... | [
"func",
"(",
"e",
"*",
"EventClient",
")",
"StreamEvents",
"(",
"w",
"io",
".",
"Writer",
",",
"streamFQN",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"error",
"{",
"timeoutTicker",
":=",
"time",
".",
"NewTimer",
"(",
"timeout",
")",
".",
... | // StreamEvents streams events from a given resource FQN to a specific writer.
// It blocks until the stream is disconnected, and will continue writing to
// the given writer. It will time if it has not received an event within the
// given timeout. | [
"StreamEvents",
"streams",
"events",
"from",
"a",
"given",
"resource",
"FQN",
"to",
"a",
"specific",
"writer",
".",
"It",
"blocks",
"until",
"the",
"stream",
"is",
"disconnected",
"and",
"will",
"continue",
"writing",
"to",
"the",
"given",
"writer",
".",
"It... | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/events/stream.go#L17-L50 |
125,045 | apcera/util | taskrenderer/renderer.go | RenderEvents | func (r *Renderer) RenderEvents(eventCh <-chan *TaskEvent) {
for event := range eventCh {
r.RenderEvent(event)
}
} | go | func (r *Renderer) RenderEvents(eventCh <-chan *TaskEvent) {
for event := range eventCh {
r.RenderEvent(event)
}
} | [
"func",
"(",
"r",
"*",
"Renderer",
")",
"RenderEvents",
"(",
"eventCh",
"<-",
"chan",
"*",
"TaskEvent",
")",
"{",
"for",
"event",
":=",
"range",
"eventCh",
"{",
"r",
".",
"RenderEvent",
"(",
"event",
")",
"\n",
"}",
"\n",
"}"
] | // RenderEvents reads every event sent on the given channel and renders it.
// The channel can be closed by the caller at any time to stop rendering. | [
"RenderEvents",
"reads",
"every",
"event",
"sent",
"on",
"the",
"given",
"channel",
"and",
"renders",
"it",
".",
"The",
"channel",
"can",
"be",
"closed",
"by",
"the",
"caller",
"at",
"any",
"time",
"to",
"stop",
"rendering",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/taskrenderer/renderer.go#L31-L35 |
125,046 | apcera/util | taskrenderer/renderer.go | RenderEvent | func (r *Renderer) RenderEvent(event *TaskEvent) string {
switch event.Type {
case "eos":
return ""
}
s := ""
if r.options.showTime {
s += fmt.Sprintf("(%s) ", time.Unix(0, event.Time).Format(time.UnixDate))
}
if event.Thread != "" {
s += fmt.Sprintf("[%s] -- ", event.Thread)
}
s += fmt.Sprintf("%s",... | go | func (r *Renderer) RenderEvent(event *TaskEvent) string {
switch event.Type {
case "eos":
return ""
}
s := ""
if r.options.showTime {
s += fmt.Sprintf("(%s) ", time.Unix(0, event.Time).Format(time.UnixDate))
}
if event.Thread != "" {
s += fmt.Sprintf("[%s] -- ", event.Thread)
}
s += fmt.Sprintf("%s",... | [
"func",
"(",
"r",
"*",
"Renderer",
")",
"RenderEvent",
"(",
"event",
"*",
"TaskEvent",
")",
"string",
"{",
"switch",
"event",
".",
"Type",
"{",
"case",
"\"",
"\"",
":",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"s",
":=",
"\"",
"\"",
"\n\n",
"if",
... | // renderEvent varies output depending on the information provided
// by the current taskEvent. | [
"renderEvent",
"varies",
"output",
"depending",
"on",
"the",
"information",
"provided",
"by",
"the",
"current",
"taskEvent",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/taskrenderer/renderer.go#L39-L73 |
125,047 | apcera/util | iprange/iprange.go | Contains | func (ipr *IPRange) Contains(ip net.IP) bool {
// if ip is less than start, return false
if bytes.Compare([]byte(ip), []byte(ipr.Start)) < 0 {
return false
}
// return true if ip is less than or equal to end
return bytes.Compare([]byte(ip), []byte(ipr.End)) <= 0
} | go | func (ipr *IPRange) Contains(ip net.IP) bool {
// if ip is less than start, return false
if bytes.Compare([]byte(ip), []byte(ipr.Start)) < 0 {
return false
}
// return true if ip is less than or equal to end
return bytes.Compare([]byte(ip), []byte(ipr.End)) <= 0
} | [
"func",
"(",
"ipr",
"*",
"IPRange",
")",
"Contains",
"(",
"ip",
"net",
".",
"IP",
")",
"bool",
"{",
"// if ip is less than start, return false",
"if",
"bytes",
".",
"Compare",
"(",
"[",
"]",
"byte",
"(",
"ip",
")",
",",
"[",
"]",
"byte",
"(",
"ipr",
... | // Contains returns whether or not the given IP address is within the specified
// IPRange. | [
"Contains",
"returns",
"whether",
"or",
"not",
"the",
"given",
"IP",
"address",
"is",
"within",
"the",
"specified",
"IPRange",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/iprange/iprange.go#L82-L89 |
125,048 | apcera/util | iprange/iprange.go | Overlaps | func (ipr *IPRange) Overlaps(o *IPRange) bool {
// if the start of o is less than our start, we need to make sure the end of o
// is less than our start
if bytes.Compare([]byte(o.Start), []byte(ipr.Start)) < 0 {
return bytes.Compare([]byte(o.End), []byte(ipr.Start)) >= 0
}
// if the start of o is greater than ou... | go | func (ipr *IPRange) Overlaps(o *IPRange) bool {
// if the start of o is less than our start, we need to make sure the end of o
// is less than our start
if bytes.Compare([]byte(o.Start), []byte(ipr.Start)) < 0 {
return bytes.Compare([]byte(o.End), []byte(ipr.Start)) >= 0
}
// if the start of o is greater than ou... | [
"func",
"(",
"ipr",
"*",
"IPRange",
")",
"Overlaps",
"(",
"o",
"*",
"IPRange",
")",
"bool",
"{",
"// if the start of o is less than our start, we need to make sure the end of o",
"// is less than our start",
"if",
"bytes",
".",
"Compare",
"(",
"[",
"]",
"byte",
"(",
... | // Overlaps checks whether another IPRange instance has an overlap in IPs with
// the current range. If will return true if there is any cross section between
// the two ranges. | [
"Overlaps",
"checks",
"whether",
"another",
"IPRange",
"instance",
"has",
"an",
"overlap",
"in",
"IPs",
"with",
"the",
"current",
"range",
".",
"If",
"will",
"return",
"true",
"if",
"there",
"is",
"any",
"cross",
"section",
"between",
"the",
"two",
"ranges",... | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/iprange/iprange.go#L94-L106 |
125,049 | apcera/util | iprange/iprange.go | spliceIP | func spliceIP(baseIP, partialIP string) string {
baseParts := strings.Split(baseIP, ".")
partialParts := strings.Split(partialIP, ".")
finalParts := append(baseParts[:(len(baseParts)-len(partialParts))], partialParts...)
return strings.Join(finalParts, ".")
} | go | func spliceIP(baseIP, partialIP string) string {
baseParts := strings.Split(baseIP, ".")
partialParts := strings.Split(partialIP, ".")
finalParts := append(baseParts[:(len(baseParts)-len(partialParts))], partialParts...)
return strings.Join(finalParts, ".")
} | [
"func",
"spliceIP",
"(",
"baseIP",
",",
"partialIP",
"string",
")",
"string",
"{",
"baseParts",
":=",
"strings",
".",
"Split",
"(",
"baseIP",
",",
"\"",
"\"",
")",
"\n",
"partialParts",
":=",
"strings",
".",
"Split",
"(",
"partialIP",
",",
"\"",
"\"",
... | // FIXME this only handles IPv4 at the moment | [
"FIXME",
"this",
"only",
"handles",
"IPv4",
"at",
"the",
"moment"
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/iprange/iprange.go#L109-L114 |
125,050 | apcera/util | uuid/uuid.go | Less | func (u UUIDSlice) Less(i, j int) bool {
return u[i] < u[j]
} | go | func (u UUIDSlice) Less(i, j int) bool {
return u[i] < u[j]
} | [
"func",
"(",
"u",
"UUIDSlice",
")",
"Less",
"(",
"i",
",",
"j",
"int",
")",
"bool",
"{",
"return",
"u",
"[",
"i",
"]",
"<",
"u",
"[",
"j",
"]",
"\n",
"}"
] | // Compares two the other UUID and returns true if this object is "less than"
// the other object. | [
"Compares",
"two",
"the",
"other",
"UUID",
"and",
"returns",
"true",
"if",
"this",
"object",
"is",
"less",
"than",
"the",
"other",
"object",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/uuid/uuid.go#L44-L46 |
125,051 | apcera/util | uuid/uuid.go | Swap | func (u UUIDSlice) Swap(i, j int) {
u[i], u[j] = u[j], u[i]
} | go | func (u UUIDSlice) Swap(i, j int) {
u[i], u[j] = u[j], u[i]
} | [
"func",
"(",
"u",
"UUIDSlice",
")",
"Swap",
"(",
"i",
",",
"j",
"int",
")",
"{",
"u",
"[",
"i",
"]",
",",
"u",
"[",
"j",
"]",
"=",
"u",
"[",
"j",
"]",
",",
"u",
"[",
"i",
"]",
"\n",
"}"
] | // Swaps the elements at index i and j in the given Slice. | [
"Swaps",
"the",
"elements",
"at",
"index",
"i",
"and",
"j",
"in",
"the",
"given",
"Slice",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/uuid/uuid.go#L49-L51 |
125,052 | apcera/util | uuid/uuid.go | setNodeName | func setNodeName() {
// Implementation specific optimization. Pre populate the counter with
// a random seed to reduce the risk of collision.
clockCorrect = uint16(math_rand.Int31() & 0xffff)
// Get a mac address from an interface on this machine.
interfaces, _ := net.Interfaces()
if interfaces != nil {
for _,... | go | func setNodeName() {
// Implementation specific optimization. Pre populate the counter with
// a random seed to reduce the risk of collision.
clockCorrect = uint16(math_rand.Int31() & 0xffff)
// Get a mac address from an interface on this machine.
interfaces, _ := net.Interfaces()
if interfaces != nil {
for _,... | [
"func",
"setNodeName",
"(",
")",
"{",
"// Implementation specific optimization. Pre populate the counter with",
"// a random seed to reduce the risk of collision.",
"clockCorrect",
"=",
"uint16",
"(",
"math_rand",
".",
"Int31",
"(",
")",
"&",
"0xffff",
")",
"\n\n",
"// Get a ... | // Sets the "node name" value that will be used for the life of this process.
//
// This is currently not completely safe as it will fall back to using random
// data if no mac address can be found, and if two machines fall into that
// state it is possible for them to generate colliding UUIDs. | [
"Sets",
"the",
"node",
"name",
"value",
"that",
"will",
"be",
"used",
"for",
"the",
"life",
"of",
"this",
"process",
".",
"This",
"is",
"currently",
"not",
"completely",
"safe",
"as",
"it",
"will",
"fall",
"back",
"to",
"using",
"random",
"data",
"if",
... | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/uuid/uuid.go#L72-L93 |
125,053 | apcera/util | uuid/uuid.go | Variant1 | func Variant1() (u UUID) {
// Format is as follows
// Time stamp (60 bits): aaabbbbcccccccc
// clock id (16 bits): dddd
// node id (48 bits): eeeeeeeeeeee
// Output is: cccccccc-bbbb-1aaa-dddd-Eeeeeeeeeeee
// where 1 is mandated, and E must have its MSB set.
setupOnce.Do(setNodeName)
// UUID uses time as nano... | go | func Variant1() (u UUID) {
// Format is as follows
// Time stamp (60 bits): aaabbbbcccccccc
// clock id (16 bits): dddd
// node id (48 bits): eeeeeeeeeeee
// Output is: cccccccc-bbbb-1aaa-dddd-Eeeeeeeeeeee
// where 1 is mandated, and E must have its MSB set.
setupOnce.Do(setNodeName)
// UUID uses time as nano... | [
"func",
"Variant1",
"(",
")",
"(",
"u",
"UUID",
")",
"{",
"// Format is as follows",
"// Time stamp (60 bits): aaabbbbcccccccc",
"// clock id (16 bits): dddd",
"// node id (48 bits): eeeeeeeeeeee",
"// Output is: cccccccc-bbbb-1aaa-dddd-Eeeeeeeeeeee",
"// where 1 is mandated, and E must ... | // Generates a "Variant 1" style UUID. This uses the machines MAC address, and
// the time since 15 October 1582 in nanoseconds, divided by 100.
//
// This form of UUID is useful when you do not care if you leak MAC info, can
// be sure that MAC addresses are not duplicated on your network, and can
// be sure that no m... | [
"Generates",
"a",
"Variant",
"1",
"style",
"UUID",
".",
"This",
"uses",
"the",
"machines",
"MAC",
"address",
"and",
"the",
"time",
"since",
"15",
"October",
"1582",
"in",
"nanoseconds",
"divided",
"by",
"100",
".",
"This",
"form",
"of",
"UUID",
"is",
"us... | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/uuid/uuid.go#L101-L143 |
125,054 | apcera/util | uuid/uuid.go | Variant3 | func Variant3(namespace UUID, name string) (u UUID) {
h := md5.New()
h.Write([]byte(namespace))
h.Write([]byte(name))
u = h.Sum(nil)[0:16]
u[6] = (u[6] & 0x0f) | 0x30
u[8] = (u[8] & 0x1f) | 0x80
return u
} | go | func Variant3(namespace UUID, name string) (u UUID) {
h := md5.New()
h.Write([]byte(namespace))
h.Write([]byte(name))
u = h.Sum(nil)[0:16]
u[6] = (u[6] & 0x0f) | 0x30
u[8] = (u[8] & 0x1f) | 0x80
return u
} | [
"func",
"Variant3",
"(",
"namespace",
"UUID",
",",
"name",
"string",
")",
"(",
"u",
"UUID",
")",
"{",
"h",
":=",
"md5",
".",
"New",
"(",
")",
"\n",
"h",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"namespace",
")",
")",
"\n",
"h",
".",
"Write",
... | // Generate a "Variant 3" style UUID. These UUIDs are not time based, instead
// using a namespace and a string to generate a hashed number. Variant 3
// is MD5 based and should only be used for legacy reasons. Use Variant 5 for
// all new projects. | [
"Generate",
"a",
"Variant",
"3",
"style",
"UUID",
".",
"These",
"UUIDs",
"are",
"not",
"time",
"based",
"instead",
"using",
"a",
"namespace",
"and",
"a",
"string",
"to",
"generate",
"a",
"hashed",
"number",
".",
"Variant",
"3",
"is",
"MD5",
"based",
"and... | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/uuid/uuid.go#L173-L181 |
125,055 | apcera/util | uuid/uuid.go | Variant4 | func Variant4() (u UUID) {
// Output is: rrrrrrrr-rrrr-4rrr-Rrrr-rrrrrrrrrrrr
// where 4 is mandated, and R must be one of 8, 9, A or B.
u = make([]byte, UUIDByteLen)
io.ReadFull(crypto_rand.Reader, u)
u[6] = (u[6] & 0x0f) + 0x40
u[8] = (u[8] & 0x1f) + 0x80
return u
} | go | func Variant4() (u UUID) {
// Output is: rrrrrrrr-rrrr-4rrr-Rrrr-rrrrrrrrrrrr
// where 4 is mandated, and R must be one of 8, 9, A or B.
u = make([]byte, UUIDByteLen)
io.ReadFull(crypto_rand.Reader, u)
u[6] = (u[6] & 0x0f) + 0x40
u[8] = (u[8] & 0x1f) + 0x80
return u
} | [
"func",
"Variant4",
"(",
")",
"(",
"u",
"UUID",
")",
"{",
"// Output is: rrrrrrrr-rrrr-4rrr-Rrrr-rrrrrrrrrrrr",
"// where 4 is mandated, and R must be one of 8, 9, A or B.",
"u",
"=",
"make",
"(",
"[",
"]",
"byte",
",",
"UUIDByteLen",
")",
"\n",
"io",
".",
"ReadFull",... | // Generates a "Variant 4" style UUID. These are nothing more than random
// data with the proper reserved bits set.
//
// A random UUID has not assurance that it is in fact unique. These are only
// usable if you can survive duplication, or have a central source to
// verify uniqueness. | [
"Generates",
"a",
"Variant",
"4",
"style",
"UUID",
".",
"These",
"are",
"nothing",
"more",
"than",
"random",
"data",
"with",
"the",
"proper",
"reserved",
"bits",
"set",
".",
"A",
"random",
"UUID",
"has",
"not",
"assurance",
"that",
"it",
"is",
"in",
"fac... | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/uuid/uuid.go#L189-L198 |
125,056 | apcera/util | uuid/uuid.go | Variant5 | func Variant5(namespace UUID, name string) (u UUID) {
h := sha1.New()
h.Write([]byte(namespace))
h.Write([]byte(name))
u = h.Sum(nil)[0:16]
u[6] = (u[6] & 0x0f) | 0x50
u[8] = (u[8] & 0x3f) | 0x80
return u
} | go | func Variant5(namespace UUID, name string) (u UUID) {
h := sha1.New()
h.Write([]byte(namespace))
h.Write([]byte(name))
u = h.Sum(nil)[0:16]
u[6] = (u[6] & 0x0f) | 0x50
u[8] = (u[8] & 0x3f) | 0x80
return u
} | [
"func",
"Variant5",
"(",
"namespace",
"UUID",
",",
"name",
"string",
")",
"(",
"u",
"UUID",
")",
"{",
"h",
":=",
"sha1",
".",
"New",
"(",
")",
"\n",
"h",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"namespace",
")",
")",
"\n",
"h",
".",
"Write",
... | // Generate a "Variant 5" style UUID. These are functionally the same as
// Variant 3, using sha1 rather than md5. Variant 5 UUIDs are recommended for
// all new designs where Variant 3 would have normally been used. It takes a
// given UUID as a name space and a string identifier, given the same name
// space and stri... | [
"Generate",
"a",
"Variant",
"5",
"style",
"UUID",
".",
"These",
"are",
"functionally",
"the",
"same",
"as",
"Variant",
"3",
"using",
"sha1",
"rather",
"than",
"md5",
".",
"Variant",
"5",
"UUIDs",
"are",
"recommended",
"for",
"all",
"new",
"designs",
"where... | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/uuid/uuid.go#L205-L213 |
125,057 | apcera/util | uuid/uuid.go | Compare | func (u UUID) Compare(o UUID) int {
return bytes.Compare(u, o)
} | go | func (u UUID) Compare(o UUID) int {
return bytes.Compare(u, o)
} | [
"func",
"(",
"u",
"UUID",
")",
"Compare",
"(",
"o",
"UUID",
")",
"int",
"{",
"return",
"bytes",
".",
"Compare",
"(",
"u",
",",
"o",
")",
"\n",
"}"
] | // Compares two UUID objects. | [
"Compares",
"two",
"UUID",
"objects",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/uuid/uuid.go#L222-L224 |
125,058 | apcera/util | uuid/uuid.go | Equal | func (u UUID) Equal(o UUID) bool {
return bytes.Equal(u, o)
} | go | func (u UUID) Equal(o UUID) bool {
return bytes.Equal(u, o)
} | [
"func",
"(",
"u",
"UUID",
")",
"Equal",
"(",
"o",
"UUID",
")",
"bool",
"{",
"return",
"bytes",
".",
"Equal",
"(",
"u",
",",
"o",
")",
"\n",
"}"
] | // Checks to see if two UUID objects are equal. | [
"Checks",
"to",
"see",
"if",
"two",
"UUID",
"objects",
"are",
"equal",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/uuid/uuid.go#L227-L229 |
125,059 | apcera/util | uuid/uuid.go | MarshalJSON | func (u UUID) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf("\"%s\"", u.String())), nil
} | go | func (u UUID) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf("\"%s\"", u.String())), nil
} | [
"func",
"(",
"u",
"UUID",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"[",
"]",
"byte",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"u",
".",
"String",
"(",
")",
")",
")",
",",
... | // Returns the string representation, quoted, as bytes, for JSON encoding | [
"Returns",
"the",
"string",
"representation",
"quoted",
"as",
"bytes",
"for",
"JSON",
"encoding"
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/uuid/uuid.go#L282-L284 |
125,060 | apcera/util | uuid/uuid.go | FromString | func FromString(s string) (u UUID, e error) {
if len(s) != UUIDStringLen {
return nil, &BadUUIDStringError{"length is not 36 bytes: " + s}
}
// Make enough space for the storage.
u = make([]byte, UUIDByteLen)
s_byte := []byte(s)
var i int
var err error
i, err = hex.Decode(u[0:4], s_byte[0:8])
if err != ni... | go | func FromString(s string) (u UUID, e error) {
if len(s) != UUIDStringLen {
return nil, &BadUUIDStringError{"length is not 36 bytes: " + s}
}
// Make enough space for the storage.
u = make([]byte, UUIDByteLen)
s_byte := []byte(s)
var i int
var err error
i, err = hex.Decode(u[0:4], s_byte[0:8])
if err != ni... | [
"func",
"FromString",
"(",
"s",
"string",
")",
"(",
"u",
"UUID",
",",
"e",
"error",
")",
"{",
"if",
"len",
"(",
"s",
")",
"!=",
"UUIDStringLen",
"{",
"return",
"nil",
",",
"&",
"BadUUIDStringError",
"{",
"\"",
"\"",
"+",
"s",
"}",
"\n",
"}",
"\n\... | // Converts a string representation of a UUID into a UUID object. | [
"Converts",
"a",
"string",
"representation",
"of",
"a",
"UUID",
"into",
"a",
"UUID",
"object",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/uuid/uuid.go#L301-L359 |
125,061 | apcera/util | uuid/uuid.go | FromBytes | func FromBytes(raw []byte) (u UUID, e error) {
if len(raw) != UUIDByteLen {
return nil, &NotAUUIDError{
fmt.Sprintf(
"Length of memory object should be %d, is %d",
UUIDByteLen, len(raw)), len(raw)}
}
if raw[8]&0xc0 != 0x80 {
return nil, &BadUUIDStringError{"Reserved bits used"}
}
return UUID(raw), n... | go | func FromBytes(raw []byte) (u UUID, e error) {
if len(raw) != UUIDByteLen {
return nil, &NotAUUIDError{
fmt.Sprintf(
"Length of memory object should be %d, is %d",
UUIDByteLen, len(raw)), len(raw)}
}
if raw[8]&0xc0 != 0x80 {
return nil, &BadUUIDStringError{"Reserved bits used"}
}
return UUID(raw), n... | [
"func",
"FromBytes",
"(",
"raw",
"[",
"]",
"byte",
")",
"(",
"u",
"UUID",
",",
"e",
"error",
")",
"{",
"if",
"len",
"(",
"raw",
")",
"!=",
"UUIDByteLen",
"{",
"return",
"nil",
",",
"&",
"NotAUUIDError",
"{",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\""... | // Constructs a UUID from a raw bytes object | [
"Constructs",
"a",
"UUID",
"from",
"a",
"raw",
"bytes",
"object"
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/uuid/uuid.go#L372-L383 |
125,062 | apcera/util | events/wamp_client.go | NewWAMPSessionClient | func NewWAMPSessionClient(wampServerURL, authToken, realm string) (*EventClient, error) {
u, err := url.Parse(wampServerURL)
if err != nil {
return nil, err
}
if u.Scheme == "https" {
u.Scheme = "wss"
} else {
u.Scheme = "ws"
}
targetURL := u.String()
if authToken != "" {
authorization, err := url.Par... | go | func NewWAMPSessionClient(wampServerURL, authToken, realm string) (*EventClient, error) {
u, err := url.Parse(wampServerURL)
if err != nil {
return nil, err
}
if u.Scheme == "https" {
u.Scheme = "wss"
} else {
u.Scheme = "ws"
}
targetURL := u.String()
if authToken != "" {
authorization, err := url.Par... | [
"func",
"NewWAMPSessionClient",
"(",
"wampServerURL",
",",
"authToken",
",",
"realm",
"string",
")",
"(",
"*",
"EventClient",
",",
"error",
")",
"{",
"u",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"wampServerURL",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // NewWAMPSessionClient returns a client handle associated with a session. It
// accepts an optional authorization token to supply as a query parameter on the
// initial request. | [
"NewWAMPSessionClient",
"returns",
"a",
"client",
"handle",
"associated",
"with",
"a",
"session",
".",
"It",
"accepts",
"an",
"optional",
"authorization",
"token",
"to",
"supply",
"as",
"a",
"query",
"parameter",
"on",
"the",
"initial",
"request",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/events/wamp_client.go#L19-L57 |
125,063 | apcera/util | hashutil/hashutil.go | newHashReader | func newHashReader(h hash.Hash, r io.Reader) *hashReader {
m := &hashReader{
source: r,
hash: h,
}
return m
} | go | func newHashReader(h hash.Hash, r io.Reader) *hashReader {
m := &hashReader{
source: r,
hash: h,
}
return m
} | [
"func",
"newHashReader",
"(",
"h",
"hash",
".",
"Hash",
",",
"r",
"io",
".",
"Reader",
")",
"*",
"hashReader",
"{",
"m",
":=",
"&",
"hashReader",
"{",
"source",
":",
"r",
",",
"hash",
":",
"h",
",",
"}",
"\n",
"return",
"m",
"\n",
"}"
] | // Returns a new hashReader. | [
"Returns",
"a",
"new",
"hashReader",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/hashutil/hashutil.go#L24-L30 |
125,064 | apcera/util | hashutil/hashutil.go | Read | func (m *hashReader) Read(p []byte) (n int, err error) {
n, err = m.source.Read(p)
if n > 0 {
// hash.Hash assures us that this can never return an error.
m.hash.Write(p[0:n])
m.length += int64(n)
}
return
} | go | func (m *hashReader) Read(p []byte) (n int, err error) {
n, err = m.source.Read(p)
if n > 0 {
// hash.Hash assures us that this can never return an error.
m.hash.Write(p[0:n])
m.length += int64(n)
}
return
} | [
"func",
"(",
"m",
"*",
"hashReader",
")",
"Read",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"n",
",",
"err",
"=",
"m",
".",
"source",
".",
"Read",
"(",
"p",
")",
"\n",
"if",
"n",
">",
"0",
"{",
"// h... | // Reads from the source, and returns the values upstream after adding the data
// to the hash. | [
"Reads",
"from",
"the",
"source",
"and",
"returns",
"the",
"values",
"upstream",
"after",
"adding",
"the",
"data",
"to",
"the",
"hash",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/hashutil/hashutil.go#L34-L42 |
125,065 | apcera/util | hashutil/hashutil.go | Close | func (m *hashReader) Close() error {
if m.source == nil {
return nil
}
if r, ok := m.source.(io.Closer); ok {
return r.Close()
}
return nil
} | go | func (m *hashReader) Close() error {
if m.source == nil {
return nil
}
if r, ok := m.source.(io.Closer); ok {
return r.Close()
}
return nil
} | [
"func",
"(",
"m",
"*",
"hashReader",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"m",
".",
"source",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"r",
",",
"ok",
":=",
"m",
".",
"source",
".",
"(",
"io",
".",
"Closer",
")",
";",
... | // Closes the source, if it implements io.Closer. | [
"Closes",
"the",
"source",
"if",
"it",
"implements",
"io",
".",
"Closer",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/hashutil/hashutil.go#L45-L53 |
125,066 | apcera/util | envmap/envmap.go | Keys | func (e *EnvMap) Keys() []string {
var keys []string
for k, _ := range e.Map() {
keys = append(keys, k)
}
return keys
} | go | func (e *EnvMap) Keys() []string {
var keys []string
for k, _ := range e.Map() {
keys = append(keys, k)
}
return keys
} | [
"func",
"(",
"e",
"*",
"EnvMap",
")",
"Keys",
"(",
")",
"[",
"]",
"string",
"{",
"var",
"keys",
"[",
"]",
"string",
"\n",
"for",
"k",
",",
"_",
":=",
"range",
"e",
".",
"Map",
"(",
")",
"{",
"keys",
"=",
"append",
"(",
"keys",
",",
"k",
")"... | // Keys returns an array of the keys of the environment map. | [
"Keys",
"returns",
"an",
"array",
"of",
"the",
"keys",
"of",
"the",
"environment",
"map",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/envmap/envmap.go#L126-L133 |
125,067 | apcera/util | deepmerge/merge.go | uglyDeepCopy | func uglyDeepCopy(v interface{}) (interface{}, error) {
// marshal
ugly := &uglyWrapper{Field: v}
b, err := json.Marshal(ugly)
if err != nil {
return nil, err
}
// demarshal
var ugly2 *uglyWrapper
err = json.Unmarshal(b, &ugly2)
if err != nil {
return nil, err
}
return ugly2.Field, nil
} | go | func uglyDeepCopy(v interface{}) (interface{}, error) {
// marshal
ugly := &uglyWrapper{Field: v}
b, err := json.Marshal(ugly)
if err != nil {
return nil, err
}
// demarshal
var ugly2 *uglyWrapper
err = json.Unmarshal(b, &ugly2)
if err != nil {
return nil, err
}
return ugly2.Field, nil
} | [
"func",
"uglyDeepCopy",
"(",
"v",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"// marshal",
"ugly",
":=",
"&",
"uglyWrapper",
"{",
"Field",
":",
"v",
"}",
"\n",
"b",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",... | // uglyDeepCopy is a truly ugly and hacky way to ensure a deep copy is done on
// an object, but it is what is necessary to ensure that the source object is
// fully cloned so that it can be assigned to the destination and ensure futher
// changes within the destination do not use a shared pointer and alter the
// sour... | [
"uglyDeepCopy",
"is",
"a",
"truly",
"ugly",
"and",
"hacky",
"way",
"to",
"ensure",
"a",
"deep",
"copy",
"is",
"done",
"on",
"an",
"object",
"but",
"it",
"is",
"what",
"is",
"necessary",
"to",
"ensure",
"that",
"the",
"source",
"object",
"is",
"fully",
... | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/deepmerge/merge.go#L83-L99 |
125,068 | apcera/util | docker/v1/registry.go | GetImage | func GetImage(name, registryURL string) (*Image, int, error) {
if name == "" {
return nil, -1, errors.New("image name is empty")
}
var ru *url.URL
var err error
if len(registryURL) != 0 {
ru, err = url.Parse(registryURL)
} else {
ru, err = url.Parse(DockerHubRegistryURL)
registryURL = DockerHubRegistryUR... | go | func GetImage(name, registryURL string) (*Image, int, error) {
if name == "" {
return nil, -1, errors.New("image name is empty")
}
var ru *url.URL
var err error
if len(registryURL) != 0 {
ru, err = url.Parse(registryURL)
} else {
ru, err = url.Parse(DockerHubRegistryURL)
registryURL = DockerHubRegistryUR... | [
"func",
"GetImage",
"(",
"name",
",",
"registryURL",
"string",
")",
"(",
"*",
"Image",
",",
"int",
",",
"error",
")",
"{",
"if",
"name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"-",
"1",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n... | // GetImage fetches Docker repository information from the specified Docker
// registry. If the registry is an empty string it defaults to the DockerHub.
// The integer return value is the status code of the HTTP response. | [
"GetImage",
"fetches",
"Docker",
"repository",
"information",
"from",
"the",
"specified",
"Docker",
"registry",
".",
"If",
"the",
"registry",
"is",
"an",
"empty",
"string",
"it",
"defaults",
"to",
"the",
"DockerHub",
".",
"The",
"integer",
"return",
"value",
"... | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/docker/v1/registry.go#L41-L125 |
125,069 | apcera/util | docker/v1/registry.go | Tags | func (i *Image) Tags() []string {
result := make([]string, 0)
for tag, _ := range i.tags {
result = append(result, tag)
}
return result
} | go | func (i *Image) Tags() []string {
result := make([]string, 0)
for tag, _ := range i.tags {
result = append(result, tag)
}
return result
} | [
"func",
"(",
"i",
"*",
"Image",
")",
"Tags",
"(",
")",
"[",
"]",
"string",
"{",
"result",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
"\n\n",
"for",
"tag",
",",
"_",
":=",
"range",
"i",
".",
"tags",
"{",
"result",
"=",
"append",
"("... | // Tags returns a list of tags available for image | [
"Tags",
"returns",
"a",
"list",
"of",
"tags",
"available",
"for",
"image"
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/docker/v1/registry.go#L128-L136 |
125,070 | apcera/util | docker/v1/registry.go | TagLayerID | func (i *Image) TagLayerID(tagName string) (string, error) {
layerID, ok := i.tags[tagName]
if !ok {
return "", fmt.Errorf("can't find tag '%s' for image '%s'", tagName, i.Name)
}
return layerID, nil
} | go | func (i *Image) TagLayerID(tagName string) (string, error) {
layerID, ok := i.tags[tagName]
if !ok {
return "", fmt.Errorf("can't find tag '%s' for image '%s'", tagName, i.Name)
}
return layerID, nil
} | [
"func",
"(",
"i",
"*",
"Image",
")",
"TagLayerID",
"(",
"tagName",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"layerID",
",",
"ok",
":=",
"i",
".",
"tags",
"[",
"tagName",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\"",
"\"",
",",
"... | // TagLayerID returns a layer ID for a given tag. | [
"TagLayerID",
"returns",
"a",
"layer",
"ID",
"for",
"a",
"given",
"tag",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/docker/v1/registry.go#L139-L146 |
125,071 | apcera/util | docker/v1/registry.go | Metadata | func (i *Image) Metadata(tagName string, v interface{}) error {
layerID, ok := i.tags[tagName]
if !ok {
return fmt.Errorf("can't find tag '%s' for image '%s'", tagName, i.Name)
}
err := i.parseResponse(fmt.Sprintf("v1/images/%s/json", layerID), &v)
if err != nil {
return err
}
return nil
} | go | func (i *Image) Metadata(tagName string, v interface{}) error {
layerID, ok := i.tags[tagName]
if !ok {
return fmt.Errorf("can't find tag '%s' for image '%s'", tagName, i.Name)
}
err := i.parseResponse(fmt.Sprintf("v1/images/%s/json", layerID), &v)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"i",
"*",
"Image",
")",
"Metadata",
"(",
"tagName",
"string",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"layerID",
",",
"ok",
":=",
"i",
".",
"tags",
"[",
"tagName",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"fmt",
".",
... | // Metadata unmarshals a Docker image metadata into provided 'v' interface. | [
"Metadata",
"unmarshals",
"a",
"Docker",
"image",
"metadata",
"into",
"provided",
"v",
"interface",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/docker/v1/registry.go#L149-L160 |
125,072 | apcera/util | docker/v1/registry.go | History | func (i *Image) History(tagName string) ([]string, error) {
layerID, ok := i.tags[tagName]
if !ok {
return nil, fmt.Errorf("can't find tag '%s' for image '%s'", tagName, i.Name)
}
var history []string
err := i.parseResponse(fmt.Sprintf("v1/images/%s/ancestry", layerID), &history)
if err != nil {
return nil, ... | go | func (i *Image) History(tagName string) ([]string, error) {
layerID, ok := i.tags[tagName]
if !ok {
return nil, fmt.Errorf("can't find tag '%s' for image '%s'", tagName, i.Name)
}
var history []string
err := i.parseResponse(fmt.Sprintf("v1/images/%s/ancestry", layerID), &history)
if err != nil {
return nil, ... | [
"func",
"(",
"i",
"*",
"Image",
")",
"History",
"(",
"tagName",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"layerID",
",",
"ok",
":=",
"i",
".",
"tags",
"[",
"tagName",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",... | // History returns an ordered list of layers that make up Docker. The order is reverse, it goes from
// the latest layer to the base layer. Client can iterate these layers and download them using LayerReader. | [
"History",
"returns",
"an",
"ordered",
"list",
"of",
"layers",
"that",
"make",
"up",
"Docker",
".",
"The",
"order",
"is",
"reverse",
"it",
"goes",
"from",
"the",
"latest",
"layer",
"to",
"the",
"base",
"layer",
".",
"Client",
"can",
"iterate",
"these",
"... | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/docker/v1/registry.go#L164-L176 |
125,073 | apcera/util | docker/v1/registry.go | LayerReader | func (i *Image) LayerReader(id string) (io.ReadCloser, error) {
resp, err := i.getResponse(fmt.Sprintf("v1/images/%s/layer", id))
if err != nil {
return nil, err
}
return resp.Body, nil
} | go | func (i *Image) LayerReader(id string) (io.ReadCloser, error) {
resp, err := i.getResponse(fmt.Sprintf("v1/images/%s/layer", id))
if err != nil {
return nil, err
}
return resp.Body, nil
} | [
"func",
"(",
"i",
"*",
"Image",
")",
"LayerReader",
"(",
"id",
"string",
")",
"(",
"io",
".",
"ReadCloser",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"i",
".",
"getResponse",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"id",
")",
... | // LayerReader returns io.ReadCloser that can be used to read Docker layer data. | [
"LayerReader",
"returns",
"io",
".",
"ReadCloser",
"that",
"can",
"be",
"used",
"to",
"read",
"Docker",
"layer",
"data",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/docker/v1/registry.go#L179-L185 |
125,074 | apcera/util | docker/v1/registry.go | LayerURLs | func (i *Image) LayerURLs(id string) []string {
var urls []string
for _, ep := range i.endpoints {
urls = append(urls, fmt.Sprintf("%s://%s/v1/images/%s/layer", i.scheme, ep, id))
}
return urls
} | go | func (i *Image) LayerURLs(id string) []string {
var urls []string
for _, ep := range i.endpoints {
urls = append(urls, fmt.Sprintf("%s://%s/v1/images/%s/layer", i.scheme, ep, id))
}
return urls
} | [
"func",
"(",
"i",
"*",
"Image",
")",
"LayerURLs",
"(",
"id",
"string",
")",
"[",
"]",
"string",
"{",
"var",
"urls",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"ep",
":=",
"range",
"i",
".",
"endpoints",
"{",
"urls",
"=",
"append",
"(",
"urls",
... | // LayerURLs returns several URLs for a specific layer. | [
"LayerURLs",
"returns",
"several",
"URLs",
"for",
"a",
"specific",
"layer",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/docker/v1/registry.go#L188-L194 |
125,075 | apcera/util | docker/v1/registry.go | AuthorizationHeader | func (i *Image) AuthorizationHeader() string {
if i.token == "" {
return ""
}
return fmt.Sprintf("Token %s", i.token)
} | go | func (i *Image) AuthorizationHeader() string {
if i.token == "" {
return ""
}
return fmt.Sprintf("Token %s", i.token)
} | [
"func",
"(",
"i",
"*",
"Image",
")",
"AuthorizationHeader",
"(",
")",
"string",
"{",
"if",
"i",
".",
"token",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
".",
"token",
... | // AuthorizationHeader exposes the authorization header created for the image
// for external layer downloads. | [
"AuthorizationHeader",
"exposes",
"the",
"authorization",
"header",
"created",
"for",
"the",
"image",
"for",
"external",
"layer",
"downloads",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/docker/v1/registry.go#L198-L203 |
125,076 | apcera/util | docker/v1/registry.go | fetchTags | func (i *Image) fetchTags() (map[string]string, error) {
// There is a weird quirk about Docker API: if tags are requested from index.docker.io,
// it returns a list of short layer IDs, so it's impossible to use them to download actual layers.
// However, when we hit the endpoint returned by image index API response... | go | func (i *Image) fetchTags() (map[string]string, error) {
// There is a weird quirk about Docker API: if tags are requested from index.docker.io,
// it returns a list of short layer IDs, so it's impossible to use them to download actual layers.
// However, when we hit the endpoint returned by image index API response... | [
"func",
"(",
"i",
"*",
"Image",
")",
"fetchTags",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"// There is a weird quirk about Docker API: if tags are requested from index.docker.io,",
"// it returns a list of short layer IDs, so it's impossibl... | // fetchTags fetches tags for the image and caches them in the Image struct,
// so that other methods can look them up efficiently. | [
"fetchTags",
"fetches",
"tags",
"for",
"the",
"image",
"and",
"caches",
"them",
"in",
"the",
"Image",
"struct",
"so",
"that",
"other",
"methods",
"can",
"look",
"them",
"up",
"efficiently",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/docker/v1/registry.go#L207-L217 |
125,077 | apcera/util | docker/v1/registry.go | getResponse | func (i *Image) getResponse(path string) (*http.Response, error) {
errors := make(map[string]error)
for _, ep := range i.endpoints {
resp, err := i.getResponseFromURL(fmt.Sprintf("%s://%s/%s", i.scheme, ep, path))
if err != nil {
errors[ep] = err
continue
}
return resp, nil
}
return nil, combineEnd... | go | func (i *Image) getResponse(path string) (*http.Response, error) {
errors := make(map[string]error)
for _, ep := range i.endpoints {
resp, err := i.getResponseFromURL(fmt.Sprintf("%s://%s/%s", i.scheme, ep, path))
if err != nil {
errors[ep] = err
continue
}
return resp, nil
}
return nil, combineEnd... | [
"func",
"(",
"i",
"*",
"Image",
")",
"getResponse",
"(",
"path",
"string",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"errors",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"error",
")",
"\n\n",
"for",
"_",
",",
"ep",
":=",
... | // getAPIResponse takes a path and tries to get Docker API response from each
// available Docker API endpoint. It returns raw HTTP response. | [
"getAPIResponse",
"takes",
"a",
"path",
"and",
"tries",
"to",
"get",
"Docker",
"API",
"response",
"from",
"each",
"available",
"Docker",
"API",
"endpoint",
".",
"It",
"returns",
"raw",
"HTTP",
"response",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/docker/v1/registry.go#L221-L235 |
125,078 | apcera/util | docker/v1/registry.go | parseResponse | func (i *Image) parseResponse(path string, result interface{}) error {
errors := make(map[string]error)
for _, ep := range i.endpoints {
err := i.parseResponseFromURL(fmt.Sprintf("%s://%s/%s", i.scheme, ep, path), result)
if err != nil {
errors[ep] = err
continue
}
return nil
}
return combineEndpoi... | go | func (i *Image) parseResponse(path string, result interface{}) error {
errors := make(map[string]error)
for _, ep := range i.endpoints {
err := i.parseResponseFromURL(fmt.Sprintf("%s://%s/%s", i.scheme, ep, path), result)
if err != nil {
errors[ep] = err
continue
}
return nil
}
return combineEndpoi... | [
"func",
"(",
"i",
"*",
"Image",
")",
"parseResponse",
"(",
"path",
"string",
",",
"result",
"interface",
"{",
"}",
")",
"error",
"{",
"errors",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"error",
")",
"\n\n",
"for",
"_",
",",
"ep",
":=",
"range"... | // parseJSONResponse takes a path and tries to get Docker API response from each
// available Docker API endpoint. It tries to parse response as JSON and saves
// the parsed version in the provided 'result' variable. | [
"parseJSONResponse",
"takes",
"a",
"path",
"and",
"tries",
"to",
"get",
"Docker",
"API",
"response",
"from",
"each",
"available",
"Docker",
"API",
"endpoint",
".",
"It",
"tries",
"to",
"parse",
"response",
"as",
"JSON",
"and",
"saves",
"the",
"parsed",
"vers... | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/docker/v1/registry.go#L240-L254 |
125,079 | apcera/util | docker/v1/registry.go | getResponseFromURL | func (i *Image) getResponseFromURL(u string) (*http.Response, error) {
req, err := http.NewRequest("GET", u, nil)
if err != nil {
return nil, err
}
req.Header.Set("Authorization", "Token "+i.token)
res, err := i.client.Do(req)
if err != nil {
return nil, err
}
if res.StatusCode != http.StatusOK {
defer ... | go | func (i *Image) getResponseFromURL(u string) (*http.Response, error) {
req, err := http.NewRequest("GET", u, nil)
if err != nil {
return nil, err
}
req.Header.Set("Authorization", "Token "+i.token)
res, err := i.client.Do(req)
if err != nil {
return nil, err
}
if res.StatusCode != http.StatusOK {
defer ... | [
"func",
"(",
"i",
"*",
"Image",
")",
"getResponseFromURL",
"(",
"u",
"string",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"http",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"u",
",",
"nil",
")",
"\n",
... | // getAPIResponseFromURL returns raw Docker API response at URL 'u'. | [
"getAPIResponseFromURL",
"returns",
"raw",
"Docker",
"API",
"response",
"at",
"URL",
"u",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/docker/v1/registry.go#L257-L284 |
125,080 | apcera/util | docker/v1/registry.go | parseResponseFromURL | func (i *Image) parseResponseFromURL(u string, result interface{}) error {
resp, err := i.getResponseFromURL(u)
if err != nil {
return err
}
defer resp.Body.Close()
dec := json.NewDecoder(resp.Body)
if err := dec.Decode(&result); err != nil {
return err
}
return nil
} | go | func (i *Image) parseResponseFromURL(u string, result interface{}) error {
resp, err := i.getResponseFromURL(u)
if err != nil {
return err
}
defer resp.Body.Close()
dec := json.NewDecoder(resp.Body)
if err := dec.Decode(&result); err != nil {
return err
}
return nil
} | [
"func",
"(",
"i",
"*",
"Image",
")",
"parseResponseFromURL",
"(",
"u",
"string",
",",
"result",
"interface",
"{",
"}",
")",
"error",
"{",
"resp",
",",
"err",
":=",
"i",
".",
"getResponseFromURL",
"(",
"u",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // parseResponseFromURL returns parsed JSON of a Docker API response at URL 'u'. | [
"parseResponseFromURL",
"returns",
"parsed",
"JSON",
"of",
"a",
"Docker",
"API",
"response",
"at",
"URL",
"u",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/docker/v1/registry.go#L287-L301 |
125,081 | apcera/util | docker/v1/registry.go | Cookie | func (i *Image) Cookie(u string) (string, error) {
if i.client.Jar == nil {
return "", nil
}
baseURL, err := url.Parse(u)
if err != nil {
return "", fmt.Errorf("Invalid URL: %s", err)
}
cookies := i.client.Jar.Cookies(baseURL)
if len(cookies) == 0 {
return "", nil
}
return cookies[0].String(), nil
} | go | func (i *Image) Cookie(u string) (string, error) {
if i.client.Jar == nil {
return "", nil
}
baseURL, err := url.Parse(u)
if err != nil {
return "", fmt.Errorf("Invalid URL: %s", err)
}
cookies := i.client.Jar.Cookies(baseURL)
if len(cookies) == 0 {
return "", nil
}
return cookies[0].String(), nil
} | [
"func",
"(",
"i",
"*",
"Image",
")",
"Cookie",
"(",
"u",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"i",
".",
"client",
".",
"Jar",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"nil",
"\n",
"}",
"\n\n",
"baseURL",
",",
"err",
... | // Cookie returns the string representation of the first
// cookie stored in stored client's cookie jar. | [
"Cookie",
"returns",
"the",
"string",
"representation",
"of",
"the",
"first",
"cookie",
"stored",
"in",
"stored",
"client",
"s",
"cookie",
"jar",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/docker/v1/registry.go#L305-L321 |
125,082 | apcera/util | docker/v1/registry.go | combineEndpointErrors | func combineEndpointErrors(allErrors map[string]error) error {
var parts []string
for ep, err := range allErrors {
parts = append(parts, fmt.Sprintf("%s: %s", ep, err))
}
return errors.New(strings.Join(parts, ", "))
} | go | func combineEndpointErrors(allErrors map[string]error) error {
var parts []string
for ep, err := range allErrors {
parts = append(parts, fmt.Sprintf("%s: %s", ep, err))
}
return errors.New(strings.Join(parts, ", "))
} | [
"func",
"combineEndpointErrors",
"(",
"allErrors",
"map",
"[",
"string",
"]",
"error",
")",
"error",
"{",
"var",
"parts",
"[",
"]",
"string",
"\n",
"for",
"ep",
",",
"err",
":=",
"range",
"allErrors",
"{",
"parts",
"=",
"append",
"(",
"parts",
",",
"fm... | // combineEndpointErrors takes a mapping of Docker API endpoints to errors encountered
// while talking to them and returns a single error that contains all endpoint URLs
// along with error for each URL. | [
"combineEndpointErrors",
"takes",
"a",
"mapping",
"of",
"Docker",
"API",
"endpoints",
"to",
"errors",
"encountered",
"while",
"talking",
"to",
"them",
"and",
"returns",
"a",
"single",
"error",
"that",
"contains",
"all",
"endpoint",
"URLs",
"along",
"with",
"erro... | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/docker/v1/registry.go#L326-L332 |
125,083 | apcera/util | docker/registry_url.go | ParseFullDockerRegistryURL | func ParseFullDockerRegistryURL(s string) (*DockerRegistryURL, error) {
s = handleSchemelessQuayRegistries(s)
registryURL := &DockerRegistryURL{
Scheme: "https",
}
u, err := url.Parse(s)
if err != nil {
return nil, err
}
if u.Scheme == "" || u.Host == "" {
return registryURL, fmt.Errorf("Registry URL mu... | go | func ParseFullDockerRegistryURL(s string) (*DockerRegistryURL, error) {
s = handleSchemelessQuayRegistries(s)
registryURL := &DockerRegistryURL{
Scheme: "https",
}
u, err := url.Parse(s)
if err != nil {
return nil, err
}
if u.Scheme == "" || u.Host == "" {
return registryURL, fmt.Errorf("Registry URL mu... | [
"func",
"ParseFullDockerRegistryURL",
"(",
"s",
"string",
")",
"(",
"*",
"DockerRegistryURL",
",",
"error",
")",
"{",
"s",
"=",
"handleSchemelessQuayRegistries",
"(",
"s",
")",
"\n\n",
"registryURL",
":=",
"&",
"DockerRegistryURL",
"{",
"Scheme",
":",
"\"",
"\... | // ParseFullDockerRegistryURL validates an input string URL to make sure
// that it conforms to the Docker V1 registry URL schema. | [
"ParseFullDockerRegistryURL",
"validates",
"an",
"input",
"string",
"URL",
"to",
"make",
"sure",
"that",
"it",
"conforms",
"to",
"the",
"Docker",
"V1",
"registry",
"URL",
"schema",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/docker/registry_url.go#L91-L123 |
125,084 | apcera/util | docker/registry_url.go | splitHostPort | func splitHostPort(hostport string) (string, string, error) {
if strings.Contains(hostport, ":") {
return net.SplitHostPort(hostport)
} else {
return hostport, "", nil
}
} | go | func splitHostPort(hostport string) (string, string, error) {
if strings.Contains(hostport, ":") {
return net.SplitHostPort(hostport)
} else {
return hostport, "", nil
}
} | [
"func",
"splitHostPort",
"(",
"hostport",
"string",
")",
"(",
"string",
",",
"string",
",",
"error",
")",
"{",
"if",
"strings",
".",
"Contains",
"(",
"hostport",
",",
"\"",
"\"",
")",
"{",
"return",
"net",
".",
"SplitHostPort",
"(",
"hostport",
")",
"\... | // splitHostPort wraps net.SplitHostPort, and can be called on a host
// whether or not it contains a port segment. | [
"splitHostPort",
"wraps",
"net",
".",
"SplitHostPort",
"and",
"can",
"be",
"called",
"on",
"a",
"host",
"whether",
"or",
"not",
"it",
"contains",
"a",
"port",
"segment",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/docker/registry_url.go#L138-L144 |
125,085 | apcera/util | docker/registry_url.go | cleanPath | func cleanPath(s string) (string, error) {
s = strings.Trim(s, "/")
if strings.HasPrefix(s, ":") {
return "", fmt.Errorf("Path cannot be made up of just a tag: %q", s)
}
return s, nil
} | go | func cleanPath(s string) (string, error) {
s = strings.Trim(s, "/")
if strings.HasPrefix(s, ":") {
return "", fmt.Errorf("Path cannot be made up of just a tag: %q", s)
}
return s, nil
} | [
"func",
"cleanPath",
"(",
"s",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"s",
"=",
"strings",
".",
"Trim",
"(",
"s",
",",
"\"",
"\"",
")",
"\n",
"if",
"strings",
".",
"HasPrefix",
"(",
"s",
",",
"\"",
"\"",
")",
"{",
"return",
"\"",... | // cleanPath removes leading and trailing forward slashes
// and makes sure that the path does not only contain a tag. | [
"cleanPath",
"removes",
"leading",
"and",
"trailing",
"forward",
"slashes",
"and",
"makes",
"sure",
"that",
"the",
"path",
"does",
"not",
"only",
"contain",
"a",
"tag",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/docker/registry_url.go#L171-L177 |
125,086 | apcera/util | docker/registry_url.go | parseTag | func parseTag(s string) (prefix, tag string, err error) {
splitString := strings.Split(s, ":")
if len(splitString) == 1 {
prefix = splitString[0]
} else if len(splitString) == 2 {
prefix, tag = splitString[0], splitString[1]
} else {
// Unlikely edge case but it doesn't hurt to test for it.
return "", "", f... | go | func parseTag(s string) (prefix, tag string, err error) {
splitString := strings.Split(s, ":")
if len(splitString) == 1 {
prefix = splitString[0]
} else if len(splitString) == 2 {
prefix, tag = splitString[0], splitString[1]
} else {
// Unlikely edge case but it doesn't hurt to test for it.
return "", "", f... | [
"func",
"parseTag",
"(",
"s",
"string",
")",
"(",
"prefix",
",",
"tag",
"string",
",",
"err",
"error",
")",
"{",
"splitString",
":=",
"strings",
".",
"Split",
"(",
"s",
",",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"splitString",
")",
"==",
"1",
... | // parseTag splits the Repository tag from the prefix. | [
"parseTag",
"splits",
"the",
"Repository",
"tag",
"from",
"the",
"prefix",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/docker/registry_url.go#L180-L196 |
125,087 | apcera/util | docker/registry_url.go | baseURL | func (u *DockerRegistryURL) baseURL(includeCredentials bool) string {
if u.Scheme == "" || u.Host == "" {
return ""
}
var result string
if u.Userinfo != nil && includeCredentials {
result = fmt.Sprintf("%s://%s@%s", u.Scheme, u.Userinfo, u.Host)
} else {
result = fmt.Sprintf("%s://%s", u.Scheme, u.Host)
}
... | go | func (u *DockerRegistryURL) baseURL(includeCredentials bool) string {
if u.Scheme == "" || u.Host == "" {
return ""
}
var result string
if u.Userinfo != nil && includeCredentials {
result = fmt.Sprintf("%s://%s@%s", u.Scheme, u.Userinfo, u.Host)
} else {
result = fmt.Sprintf("%s://%s", u.Scheme, u.Host)
}
... | [
"func",
"(",
"u",
"*",
"DockerRegistryURL",
")",
"baseURL",
"(",
"includeCredentials",
"bool",
")",
"string",
"{",
"if",
"u",
".",
"Scheme",
"==",
"\"",
"\"",
"||",
"u",
".",
"Host",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"... | // baseURL is wrapped by BaseURL and BaseURLNoCredentials.
// The boolean flag indicates whether credentials are included in the return string. | [
"baseURL",
"is",
"wrapped",
"by",
"BaseURL",
"and",
"BaseURLNoCredentials",
".",
"The",
"boolean",
"flag",
"indicates",
"whether",
"credentials",
"are",
"included",
"in",
"the",
"return",
"string",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/docker/registry_url.go#L200-L217 |
125,088 | apcera/util | docker/registry_url.go | HostPort | func (u *DockerRegistryURL) HostPort() string {
if u.Port == "" {
return u.Host
}
return net.JoinHostPort(u.Host, u.Port)
} | go | func (u *DockerRegistryURL) HostPort() string {
if u.Port == "" {
return u.Host
}
return net.JoinHostPort(u.Host, u.Port)
} | [
"func",
"(",
"u",
"*",
"DockerRegistryURL",
")",
"HostPort",
"(",
")",
"string",
"{",
"if",
"u",
".",
"Port",
"==",
"\"",
"\"",
"{",
"return",
"u",
".",
"Host",
"\n",
"}",
"\n",
"return",
"net",
".",
"JoinHostPort",
"(",
"u",
".",
"Host",
",",
"u... | // HostPort returns the HostPort of the registry URL. If there is no port, then
// it returns just the host. | [
"HostPort",
"returns",
"the",
"HostPort",
"of",
"the",
"registry",
"URL",
".",
"If",
"there",
"is",
"no",
"port",
"then",
"it",
"returns",
"just",
"the",
"host",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/docker/registry_url.go#L221-L227 |
125,089 | apcera/util | docker/registry_url.go | AddLibraryNamespace | func (u *DockerRegistryURL) AddLibraryNamespace() {
// If the image name does not contain '/', it is intended to be an official
// image; so we add the `library` namespace to the URL.
if !strings.Contains(u.ImageName, "/") {
u.ImageName = fmt.Sprintf("library/%s", u.ImageName)
}
} | go | func (u *DockerRegistryURL) AddLibraryNamespace() {
// If the image name does not contain '/', it is intended to be an official
// image; so we add the `library` namespace to the URL.
if !strings.Contains(u.ImageName, "/") {
u.ImageName = fmt.Sprintf("library/%s", u.ImageName)
}
} | [
"func",
"(",
"u",
"*",
"DockerRegistryURL",
")",
"AddLibraryNamespace",
"(",
")",
"{",
"// If the image name does not contain '/', it is intended to be an official",
"// image; so we add the `library` namespace to the URL.",
"if",
"!",
"strings",
".",
"Contains",
"(",
"u",
".",... | // AddLibraryNamespace explicitly appends the `library` namespace used for
// official images. | [
"AddLibraryNamespace",
"explicitly",
"appends",
"the",
"library",
"namespace",
"used",
"for",
"official",
"images",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/docker/registry_url.go#L231-L237 |
125,090 | apcera/util | docker/registry_url.go | baseString | func (u *DockerRegistryURL) baseString(includeCredentials bool) string {
var base string
if includeCredentials {
base = u.BaseURL()
} else {
base = u.BaseURLNoCredentials()
}
s := u.Path()
if s == "" {
return base
} else {
return fmt.Sprintf("%s/%s", base, s)
}
} | go | func (u *DockerRegistryURL) baseString(includeCredentials bool) string {
var base string
if includeCredentials {
base = u.BaseURL()
} else {
base = u.BaseURLNoCredentials()
}
s := u.Path()
if s == "" {
return base
} else {
return fmt.Sprintf("%s/%s", base, s)
}
} | [
"func",
"(",
"u",
"*",
"DockerRegistryURL",
")",
"baseString",
"(",
"includeCredentials",
"bool",
")",
"string",
"{",
"var",
"base",
"string",
"\n",
"if",
"includeCredentials",
"{",
"base",
"=",
"u",
".",
"BaseURL",
"(",
")",
"\n",
"}",
"else",
"{",
"bas... | // baseString is wrapped by String and StringNoCredentials.
// It exposes a flag to indicate whether to include credentials in the BaseURL. | [
"baseString",
"is",
"wrapped",
"by",
"String",
"and",
"StringNoCredentials",
".",
"It",
"exposes",
"a",
"flag",
"to",
"indicate",
"whether",
"to",
"include",
"credentials",
"in",
"the",
"BaseURL",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/docker/registry_url.go#L261-L275 |
125,091 | apcera/util | docker/registry_url.go | MarshalJSON | func (u *DockerRegistryURL) MarshalJSON() ([]byte, error) {
// Using the alias type allows it to have all the same fields as the
// DockerRegistryURL but avoids a loop when marshalling since it will not
// have the same MarshalJSON method.
type Alias DockerRegistryURL
ui := ""
if u != nil && u.Userinfo != nil {
... | go | func (u *DockerRegistryURL) MarshalJSON() ([]byte, error) {
// Using the alias type allows it to have all the same fields as the
// DockerRegistryURL but avoids a loop when marshalling since it will not
// have the same MarshalJSON method.
type Alias DockerRegistryURL
ui := ""
if u != nil && u.Userinfo != nil {
... | [
"func",
"(",
"u",
"*",
"DockerRegistryURL",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"// Using the alias type allows it to have all the same fields as the",
"// DockerRegistryURL but avoids a loop when marshalling since it will not",
"// have... | // MarshalJSON implements marshalling which will maintain the url.Userinfo
// details which are normally lost due to lack of exported fields. | [
"MarshalJSON",
"implements",
"marshalling",
"which",
"will",
"maintain",
"the",
"url",
".",
"Userinfo",
"details",
"which",
"are",
"normally",
"lost",
"due",
"to",
"lack",
"of",
"exported",
"fields",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/docker/registry_url.go#L294-L310 |
125,092 | apcera/util | docker/registry_url.go | UnmarshalJSON | func (u *DockerRegistryURL) UnmarshalJSON(data []byte) error {
// Using the alias type allows it to have all the same fields as the
// DockerRegistryURL but avoids a loop when marshalling since it will not
// have the same UnmarshalJSON method.
type Alias DockerRegistryURL
aux := &struct {
Userinfo string `json:... | go | func (u *DockerRegistryURL) UnmarshalJSON(data []byte) error {
// Using the alias type allows it to have all the same fields as the
// DockerRegistryURL but avoids a loop when marshalling since it will not
// have the same UnmarshalJSON method.
type Alias DockerRegistryURL
aux := &struct {
Userinfo string `json:... | [
"func",
"(",
"u",
"*",
"DockerRegistryURL",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"// Using the alias type allows it to have all the same fields as the",
"// DockerRegistryURL but avoids a loop when marshalling since it will not",
"// have the same... | // UnmarshalJSON implements unmarshalling which will maintain the url.Userinfo
// details which are normally lost due to lack of exported fields. | [
"UnmarshalJSON",
"implements",
"unmarshalling",
"which",
"will",
"maintain",
"the",
"url",
".",
"Userinfo",
"details",
"which",
"are",
"normally",
"lost",
"due",
"to",
"lack",
"of",
"exported",
"fields",
"."
] | 7a50bc84ee48450f6838847f84fde2d806f8a33a | https://github.com/apcera/util/blob/7a50bc84ee48450f6838847f84fde2d806f8a33a/docker/registry_url.go#L314-L337 |
125,093 | Jumpscale/go-raml | raml/parser.go | ParseFile | func ParseFile(filePath string, root Root) error {
workDir, fileName := filepath.Split(filePath)
_, err := ParseReadFile(workDir, fileName, root)
return err
} | go | func ParseFile(filePath string, root Root) error {
workDir, fileName := filepath.Split(filePath)
_, err := ParseReadFile(workDir, fileName, root)
return err
} | [
"func",
"ParseFile",
"(",
"filePath",
"string",
",",
"root",
"Root",
")",
"error",
"{",
"workDir",
",",
"fileName",
":=",
"filepath",
".",
"Split",
"(",
"filePath",
")",
"\n",
"_",
",",
"err",
":=",
"ParseReadFile",
"(",
"workDir",
",",
"fileName",
",",
... | // ParseFile parses an RAML file.
// Returns a raml.APIDefinition value or an error if
// something went wrong. | [
"ParseFile",
"parses",
"an",
"RAML",
"file",
".",
"Returns",
"a",
"raml",
".",
"APIDefinition",
"value",
"or",
"an",
"error",
"if",
"something",
"went",
"wrong",
"."
] | f151e1e143c47282b294fe70c5e56f113988ed10 | https://github.com/Jumpscale/go-raml/blob/f151e1e143c47282b294fe70c5e56f113988ed10/raml/parser.go#L67-L71 |
125,094 | Jumpscale/go-raml | raml/parser.go | ParseReadFile | func ParseReadFile(workDir, fileName string, root Root) ([]byte, error) {
if strings.HasSuffix(fmt.Sprint(reflect.TypeOf(root)), "APIDefinition") { // when we parse for APIDefinition, we reset ramlFileDir
ramlFileDir = workDir
}
// Read original file contents into a byte array
mainFileBytes, err := readFileOrURL... | go | func ParseReadFile(workDir, fileName string, root Root) ([]byte, error) {
if strings.HasSuffix(fmt.Sprint(reflect.TypeOf(root)), "APIDefinition") { // when we parse for APIDefinition, we reset ramlFileDir
ramlFileDir = workDir
}
// Read original file contents into a byte array
mainFileBytes, err := readFileOrURL... | [
"func",
"ParseReadFile",
"(",
"workDir",
",",
"fileName",
"string",
",",
"root",
"Root",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"strings",
".",
"HasSuffix",
"(",
"fmt",
".",
"Sprint",
"(",
"reflect",
".",
"TypeOf",
"(",
"root",
")"... | // ParseReadFile parse an .raml file.
// It returns API definition and the concatenated .raml file. | [
"ParseReadFile",
"parse",
"an",
".",
"raml",
"file",
".",
"It",
"returns",
"API",
"definition",
"and",
"the",
"concatenated",
".",
"raml",
"file",
"."
] | f151e1e143c47282b294fe70c5e56f113988ed10 | https://github.com/Jumpscale/go-raml/blob/f151e1e143c47282b294fe70c5e56f113988ed10/raml/parser.go#L75-L147 |
125,095 | Jumpscale/go-raml | raml/parser.go | readFileContents | func readFileContents(workingDirectory string, fileName string) ([]byte, error) {
filePath := filepath.Join(workingDirectory, fileName)
if fileName == "" {
return nil, fmt.Errorf("File name cannot be nil: %s", filePath)
}
// Read the file
fileContentsArray, err := ioutil.ReadFile(filePath)
if err != nil {
... | go | func readFileContents(workingDirectory string, fileName string) ([]byte, error) {
filePath := filepath.Join(workingDirectory, fileName)
if fileName == "" {
return nil, fmt.Errorf("File name cannot be nil: %s", filePath)
}
// Read the file
fileContentsArray, err := ioutil.ReadFile(filePath)
if err != nil {
... | [
"func",
"readFileContents",
"(",
"workingDirectory",
"string",
",",
"fileName",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"filePath",
":=",
"filepath",
".",
"Join",
"(",
"workingDirectory",
",",
"fileName",
")",
"\n\n",
"if",
"fileName",
... | // Reads the contents of a file, returns a bytes buffer | [
"Reads",
"the",
"contents",
"of",
"a",
"file",
"returns",
"a",
"bytes",
"buffer"
] | f151e1e143c47282b294fe70c5e56f113988ed10 | https://github.com/Jumpscale/go-raml/blob/f151e1e143c47282b294fe70c5e56f113988ed10/raml/parser.go#L168-L185 |
125,096 | Jumpscale/go-raml | raml/parser.go | isURL | func isURL(path string) bool {
if strings.HasPrefix(path, "http://") || strings.HasPrefix(path, "https://") {
if _, err := url.Parse(path); err == nil {
return true
}
}
return false
} | go | func isURL(path string) bool {
if strings.HasPrefix(path, "http://") || strings.HasPrefix(path, "https://") {
if _, err := url.Parse(path); err == nil {
return true
}
}
return false
} | [
"func",
"isURL",
"(",
"path",
"string",
")",
"bool",
"{",
"if",
"strings",
".",
"HasPrefix",
"(",
"path",
",",
"\"",
"\"",
")",
"||",
"strings",
".",
"HasPrefix",
"(",
"path",
",",
"\"",
"\"",
")",
"{",
"if",
"_",
",",
"err",
":=",
"url",
".",
... | // returns true if the path is an HTTP URL | [
"returns",
"true",
"if",
"the",
"path",
"is",
"an",
"HTTP",
"URL"
] | f151e1e143c47282b294fe70c5e56f113988ed10 | https://github.com/Jumpscale/go-raml/blob/f151e1e143c47282b294fe70c5e56f113988ed10/raml/parser.go#L188-L195 |
125,097 | Jumpscale/go-raml | raml/parser.go | preProcess | func preProcess(originalContents io.Reader, workingDirectory string) ([]byte, error) {
// NOTE: Since YAML doesn't support !include directives, and since go-yaml
// does NOT play nice with !include tags, this has to be done like this.
// I am considering modifying go-yaml to add custom handlers for specific
// tag... | go | func preProcess(originalContents io.Reader, workingDirectory string) ([]byte, error) {
// NOTE: Since YAML doesn't support !include directives, and since go-yaml
// does NOT play nice with !include tags, this has to be done like this.
// I am considering modifying go-yaml to add custom handlers for specific
// tag... | [
"func",
"preProcess",
"(",
"originalContents",
"io",
".",
"Reader",
",",
"workingDirectory",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"// NOTE: Since YAML doesn't support !include directives, and since go-yaml",
"// does NOT play nice with !include tags, ... | // preProcess acts as a preprocessor for a RAML document in YAML format,
// including files referenced via !include. It returns a pre-processed document. | [
"preProcess",
"acts",
"as",
"a",
"preprocessor",
"for",
"a",
"RAML",
"document",
"in",
"YAML",
"format",
"including",
"files",
"referenced",
"via",
"!include",
".",
"It",
"returns",
"a",
"pre",
"-",
"processed",
"document",
"."
] | f151e1e143c47282b294fe70c5e56f113988ed10 | https://github.com/Jumpscale/go-raml/blob/f151e1e143c47282b294fe70c5e56f113988ed10/raml/parser.go#L199-L291 |
125,098 | Jumpscale/go-raml | raml/utils.go | appendStrNotExist | func appendStrNotExist(str string, arr []string) []string {
// check if a `str` exist in `arr`
isStrInArr := func(str string, arr []string) bool {
for _, s := range arr {
if str == s {
return true
}
}
return false
}
if !isStrInArr(str, arr) {
arr = append(arr, str)
}
return arr
} | go | func appendStrNotExist(str string, arr []string) []string {
// check if a `str` exist in `arr`
isStrInArr := func(str string, arr []string) bool {
for _, s := range arr {
if str == s {
return true
}
}
return false
}
if !isStrInArr(str, arr) {
arr = append(arr, str)
}
return arr
} | [
"func",
"appendStrNotExist",
"(",
"str",
"string",
",",
"arr",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"// check if a `str` exist in `arr`",
"isStrInArr",
":=",
"func",
"(",
"str",
"string",
",",
"arr",
"[",
"]",
"string",
")",
"bool",
"{",
"for"... | // append `str` to `arr` if `str` not exist in `arr` | [
"append",
"str",
"to",
"arr",
"if",
"str",
"not",
"exist",
"in",
"arr"
] | f151e1e143c47282b294fe70c5e56f113988ed10 | https://github.com/Jumpscale/go-raml/blob/f151e1e143c47282b294fe70c5e56f113988ed10/raml/utils.go#L4-L19 |
125,099 | Jumpscale/go-raml | codegen/tarantool/resources.go | Handler | func (m *method) Handler() string {
var name string
if len(m.DisplayName) > 0 {
name = commons.DisplayNameToFuncName(m.DisplayName)
} else {
name = commons.NormalizeIdentifier(commons.NormalizeURI(m.Endpoint)) + m.Verb()
}
return casee.ToSnakeCase(name + "Handler")
} | go | func (m *method) Handler() string {
var name string
if len(m.DisplayName) > 0 {
name = commons.DisplayNameToFuncName(m.DisplayName)
} else {
name = commons.NormalizeIdentifier(commons.NormalizeURI(m.Endpoint)) + m.Verb()
}
return casee.ToSnakeCase(name + "Handler")
} | [
"func",
"(",
"m",
"*",
"method",
")",
"Handler",
"(",
")",
"string",
"{",
"var",
"name",
"string",
"\n",
"if",
"len",
"(",
"m",
".",
"DisplayName",
")",
">",
"0",
"{",
"name",
"=",
"commons",
".",
"DisplayNameToFuncName",
"(",
"m",
".",
"DisplayName"... | // Handler returns the name of the function that handles requests for this method | [
"Handler",
"returns",
"the",
"name",
"of",
"the",
"function",
"that",
"handles",
"requests",
"for",
"this",
"method"
] | f151e1e143c47282b294fe70c5e56f113988ed10 | https://github.com/Jumpscale/go-raml/blob/f151e1e143c47282b294fe70c5e56f113988ed10/codegen/tarantool/resources.go#L33-L41 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.